From a7bfd94876b87df547bddd15d206102d8a7f37a1 Mon Sep 17 00:00:00 2001 From: ppillot Date: Sat, 14 Oct 2023 17:12:59 -0400 Subject: [PATCH] update ngl --- CHANGELOG.md | 9 +- README.md | 3 +- dist/declarations/ngl.d.ts | 1 - dist/ngl.esm.js | 7 +- dist/ngl.esm.js.map | 2 +- dist/ngl.js | 169 ++++++++++++++++++------------------- dist/ngl.js.map | 2 +- dist/ngl.umd.js | 55 ++++++------ dist/ngl.umd.js.map | 2 +- package-lock.json | 4 +- package.json | 2 +- 11 files changed, 126 insertions(+), 130 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffbdb987..94036a27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log All notable changes to this project will be documented in this file, following the suggestions of [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to [Semantic Versioning](http://semver.org/). +## [v2.2.0] +- Summary of changes from v2.1.1 +### Added + - Pymol mouse bindings: add focus scroll #992 +### Changed + - Remove support for Internet Explorer #993 + ## [v2.1.1] - Summary of changes from v2.0.0 ### Changed @@ -32,7 +39,7 @@ All notable changes to this project will be documented in this file, following t ### Added - color management - Export many more types (representations, params) -- support coloring atoms or bonds by external data +- support coloring atoms or bonds by external data ### Changed - default surface type is 'av' diff --git a/README.md b/README.md index ce1c86c7..7270b0df 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ See it in action: Integration with python and R: -* [NGLView](https://github.com/nglviewer/nglview): Jupyter Notebook Widget +* [NGLView](https://github.com/nglviewer/nglview): Jupyter Notebook Widget * [NGLViewR](https://github.com/nvelden/NGLVieweR/) R htmlwidget (and an example [Shiny Application](https://niels-van-der-velden.shinyapps.io/shinyNGLVieweR/)) Documentation: @@ -65,7 +65,6 @@ This project would not be possible without many fine open-source projects. Espec * [Font Awesome](http://fontawesome.io) - for icons * [JS Signals](http://millermedeiros.github.com/js-signals) * [tether.js](http://github.hubspot.com/tether/) -* [Lightweight promise polyfill](https://github.com/taylorhakes/promise-polyfill) * [pako - zlib port](https://github.com/nodeca/pako) * [Open Source PyMOL](http://sourceforge.net/projects/pymol/) - screen aligned cylinder shader * [VTK](http://www.vtk.org/) Quadric shader code from the PointSprite Plugin - quadric surface center calculation diff --git a/dist/declarations/ngl.d.ts b/dist/declarations/ngl.d.ts index 6d85ada6..e798cf53 100644 --- a/dist/declarations/ngl.d.ts +++ b/dist/declarations/ngl.d.ts @@ -3,7 +3,6 @@ * @private * @author Alexander Rose */ -import './polyfills'; /** * The NGL module. These members are available in the `NGL` namespace when using the {@link https://github.com/umdjs/umd|UMD} build in the `ngl.js` file. * @module NGL diff --git a/dist/ngl.esm.js b/dist/ngl.esm.js index 5685b4cb..dd36752e 100644 --- a/dist/ngl.esm.js +++ b/dist/ngl.esm.js @@ -1,6 +1,4 @@ -import t from"promise-polyfill";import{Vector2 as e,Vector3 as r,Matrix4 as i,Quaternion as o,Color as n,ShaderChunk as a,Points as s,Box3 as c,LinearEncoding as u,PerspectiveCamera as h,OrthographicCamera as l,StereoCamera as p,Scene as d,Group as f,Fog as m,SpotLight as g,AmbientLight as y,WebGLRenderer as v,WebGLRenderTarget as b,NearestFilter as x,RGBAFormat as _,UnsignedByteType as w,LinearFilter as A,Uniform as S,ShaderMaterial as C,AdditiveBlending as P,Mesh as I,PlaneGeometry as O,BufferGeometry as k,BufferAttribute as M,LineSegments as T,sRGBEncoding as B,FloatType as D,Geometry as E,Matrix3 as F,UniformsUtils as R,UniformsLib as $,NoBlending as L,FrontSide as N,BackSide as z,DoubleSide as j,IcosahedronBufferGeometry as V,DataTexture as G,NormalBlending as U,Euler as H,CanvasTexture as W,CylinderBufferGeometry as q,ConeBufferGeometry as X,BoxBufferGeometry as Y,OctahedronBufferGeometry as K,TetrahedronBufferGeometry as Z,TorusBufferGeometry as Q,Face3 as J}from"three";export{Box3,Color,Euler,Matrix3,Matrix4,Plane,Quaternion,Vector2,Vector3}from"three";import*as tt from"chroma-js";import*as et from"signals";import{Signal as rt}from"signals";export{Signal}from"signals";import{sprintf as it}from"sprintf-js";var ot,nt,at,st,ct;function ut(t){if("undefined"!=typeof window){var e=new RegExp(t+"=([^&#=]*)").exec(window.location.search);return e?decodeURIComponent(e[1]):void 0}}function ht(t,e){return void 0!==t?t:e}function lt(t,e){var r=Object.assign({},t);for(var i in e){void 0===t[i]&&(r[i]=e[i])}return r}function pt(t,e){for(var r in e){var i=e[r];void 0!==i&&(t[r]=i)}return t}function dt(t,e){e=ht(e,[]);for(var r=0;re?(a&&(clearTimeout(a),a=null),s=u,n=t.apply(i,o),a||(i=o=null)):a||!1===r.trailing||(a=setTimeout(c,h)),n}}function bt(t,e){return te?1:0}function xt(t,e,r){void 0===r&&(r=bt);for(var i=0,o=t.length-1;i<=o;){var n=i+o>>1,a=r(e,t[n]);if(a>0)i=n+1;else{if(!(a<0))return n;o=n-1}}return-i-1}function _t(t,e,r){var i=function(t,e){var r=t.length-1;if(t[r]>1;t[o]>=e?r=o-1:i=o+1}return r+1}(t,e),o=function(t,e){if(t[0]>e)return-1;for(var r=0,i=t.length-1;r<=i;){var o=r+i>>1;t[o]>e?i=o-1:r=o+1}return r-1}(t,r);return-1===i||-1===o||i>o?0:o-i+1}function wt(t){return t.sort().filter((function(t,e,r){return 0===e||t!==r[e-1]}))}function At(t){var e=28672;if(t.length>e){for(var r=[],i=0;i65535?Uint32Array:Uint16Array)(t)}function Pt(t){return t.buffer&&t.buffer instanceof ArrayBuffer?t.buffer:t}function It(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function Ot(t){return It(t,r)}function kt(t){return It(t,i)}function Mt(t){return It(t,o)}function Tt(t){return e=t,r=Float32Array,e instanceof r?e:new r(e);var e,r}function Bt(t){return ht(t,"").toString().toLowerCase()}"undefined"!=typeof window&&function(){window.console=window.console||{};for(var t,e,r=window.console,i={},o=function(){},n="memory".split(","),a="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");t=n.pop();)r[t]||(r[t]=i);for(;e=a.pop();)r[e]||(r[e]=o)}(),"undefined"==typeof window||void 0===window.HTMLCanvasElement||window.HTMLCanvasElement.prototype.toBlob||Object.defineProperty(window.HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,r){for(var i=window.atob(this.toDataURL(e,r).split(",")[1]),o=i.length,n=o>>2,a=new Uint8Array(o),s=new Uint32Array(a.buffer,0,n),c=0,u=0;c0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&t>-9007199254740992&&t<9007199254740992&&Math.floor(t)===t}),Number.isNaN||(Number.isNaN=function(t){return t!=t}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var e=arguments;if(null==t)throw new TypeError("Cannot convert first argument to object");for(var r,i=Object(t),o=!1,n=1;n1?arguments[1]:void 0,s=a?Number(a):0;Number.isNaN(s)&&(s=0);var c=Math.min(Math.max(s,0),i);if(n+c>i)return!1;for(var u=-1;++ur.length)&&(e=r.length),e-=t.length;var i=r.indexOf(t,e);return-1!==i&&i===e}),String.prototype.repeat||(String.prototype.repeat=function(t){if(null===this)throw new TypeError("can't convert "+this+" to object");var e=""+this;if(t=+t,Number.isNaN(t)&&(t=0),t<0)throw new RangeError("repeat count must be non-negative");if(t===1/0)throw new RangeError("repeat count must be less than infinity");if(t=Math.floor(t),0===e.length||0===t)return"";if(e.length*t>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.includes||(Array.prototype.includes=function(t){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),r=parseInt(e.length,10)||0;if(0===r)return!1;var i,o,n=parseInt(arguments[1],10)||0;for(n>=0?i=n:(i=r+n)<0&&(i=0);i0?1:-1)*Math.floor(Math.abs(e)):e}(t);return Math.min(Math.max(e,0),at)},function(t){var e=this,r=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var i,o=arguments.length>1?arguments[1]:void 0;if(void 0!==o){if(!nt(o))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(i=arguments[2])}for(var n,a=st(r.length),s=nt(e)?Object(new e(a)):new Array(a),c=0;c>=4,$t[r]=Rt[19===r?3&t|8:t]);return $t.join("")}function Nt(t,e,r){return Math.max(e,Math.min(r,t))}function zt(t,e,r){return t+(e-t)*r}function jt(t,e,r,i,o,n){var a=(r-t)*n,s=(i-e)*n,c=o*o;return(2*e-2*r+a+s)*(o*c)+(-3*e+3*r-2*a-s)*c+a*o+e}function Vt(t,e,r){var i;return i=function(t,e,r){return(t-e)/(r-e)}(r,t,e),(r=Nt(i,0,1))*r*(3-2*r)}var Gt="sRGB";var Ut={scale:"uniform",mode:"hcl",domain:[0,1],value:16777215,reverse:!1},Ht=new n;function Wt(t,e,r){var i=r.value;return r.value=function(t,e){var r=i.bind(this,t,e)();return"linear"==Gt?(Ht.set(r),Ht.convertSRGBToLinear(),Ht.getHex()):r},r}var qt,Xt=function(t){void 0===t&&(t={}),this.parameters=lt(t,Ut),"string"==typeof this.parameters.value&&(this.parameters.value=Ht.set(this.parameters.value).getHex()),this.parameters.structure&&(this.atomProxy=this.parameters.structure.getAtomProxy())};Xt.prototype.getScale=function(t){void 0===t&&(t={});var e=lt(t,this.parameters);return"rainbow"===e.scale?e.scale=["red","orange","yellow","green","blue"]:"rwb"===e.scale&&(e.scale=["red","white","blue"]),e.reverse&&(e.domain=e.domain.slice().reverse()),tt.scale(e.scale).mode(e.mode).domain(e.domain).out("num")},Xt.prototype.colorToArray=function(t,e,r){return void 0===e&&(e=[]),void 0===r&&(r=0),e[r]=(t>>16&255)/255,e[r+1]=(t>>8&255)/255,e[r+2]=(255&t)/255,e},Xt.prototype.atomColorToArray=function(t,e,r){return this.colorToArray(this.atomColor?this.atomColor(t):0,e,r)},Xt.prototype.bondColor=function(t,e){return this.atomProxy&&this.atomColor?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):0},Xt.prototype.bondColorToArray=function(t,e,r,i){return this.colorToArray(this.bondColor(t,e),r,i)},Xt.prototype.volumeColorToArray=function(t,e,r){return this.colorToArray(this.volumeColor?this.volumeColor(t):0,e,r)},Xt.prototype.positionColorToArray=function(t,e,r){return this.colorToArray(this.positionColor?this.positionColor(t):0,e,r)},function(t){t[t.PROTEIN=1]="PROTEIN",t[t.NUCLEIC=2]="NUCLEIC",t[t.RNA=3]="RNA",t[t.DNA=4]="DNA",t[t.POLYMER=5]="POLYMER",t[t.WATER=6]="WATER",t[t.HELIX=7]="HELIX",t[t.SHEET=8]="SHEET",t[t.TURN=9]="TURN",t[t.BACKBONE=10]="BACKBONE",t[t.SIDECHAIN=11]="SIDECHAIN",t[t.ALL=12]="ALL",t[t.HETERO=13]="HETERO",t[t.ION=14]="ION",t[t.SACCHARIDE=15]="SACCHARIDE",t[t.SUGAR=15]="SUGAR",t[t.BONDED=16]="BONDED",t[t.RING=17]="RING",t[t.AROMATICRING=18]="AROMATICRING",t[t.METAL=19]="METAL",t[t.POLARH=20]="POLARH",t[t.NONE=21]="NONE"}(qt||(qt={}));var Yt=["*","","ALL"],Kt=["NONE"],Zt=[qt.BACKBONE,qt.SIDECHAIN,qt.BONDED,qt.RING,qt.AROMATICRING,qt.METAL,qt.POLARH],Qt=[qt.POLYMER,qt.WATER],Jt=["ALA","GLY","SER"],te=["CYS","SER","THR"],ee=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],re=["PHE","TRP","TYR","HIS"],ie=["ASN","GLN"],oe=["ASP","GLU"],ne=["ARG","HIS","LYS"],ae=["ARG","ASP","GLU","HIS","LYS"],se=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],ce=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],ue=["HIS","PHE","PRO","TRP","TYR"],he=["ALA","GLY","ILE","LEU","VAL"];function le(t,e){if(void 0===e.atomname&&void 0===e.element&&void 0===e.altloc&&void 0===e.atomindex&&void 0===e.keyword&&void 0===e.inscode&&void 0===e.resname&&void 0===e.sstruc&&void 0===e.resno&&void 0===e.chainname&&void 0===e.model)return-1;if(void 0!==e.keyword){if(e.keyword===qt.BACKBONE&&!t.isBackbone())return!1;if(e.keyword===qt.SIDECHAIN&&!t.isSidechain())return!1;if(e.keyword===qt.BONDED&&!t.isBonded())return!1;if(e.keyword===qt.RING&&!t.isRing())return!1;if(e.keyword===qt.AROMATICRING&&!t.isAromatic())return!1;if(e.keyword===qt.HETERO&&!t.isHetero())return!1;if(e.keyword===qt.PROTEIN&&!t.isProtein())return!1;if(e.keyword===qt.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===qt.RNA&&!t.isRna())return!1;if(e.keyword===qt.DNA&&!t.isDna())return!1;if(e.keyword===qt.POLYMER&&!t.isPolymer())return!1;if(e.keyword===qt.WATER&&!t.isWater())return!1;if(e.keyword===qt.HELIX&&!t.isHelix())return!1;if(e.keyword===qt.SHEET&&!t.isSheet())return!1;if(e.keyword===qt.TURN&&!t.isTurn())return!1;if(e.keyword===qt.ION&&!t.isIon())return!1;if(e.keyword===qt.SACCHARIDE&&!t.isSaccharide())return!1;if(e.keyword===qt.METAL&&!t.isMetal())return!1;if(e.keyword===qt.POLARH&&!t.isPolarHydrogen())return!1}if(void 0!==e.atomname&&e.atomname!==t.atomname)return!1;if(void 0!==e.element&&e.element!==t.element)return!1;if(void 0!==e.altloc&&e.altloc!==t.altloc)return!1;if(void 0!==e.atomindex&&xt(e.atomindex,t.index)<0)return!1;if(void 0!==e.resname)if(Array.isArray(e.resname)){if(!e.resname.includes(t.resname))return!1}else if(e.resname!==t.resname)return!1;if(void 0!==e.sstruc&&e.sstruc!==t.sstruc)return!1;if(void 0!==e.resno)if(Array.isArray(e.resno)&&2===e.resno.length){if(e.resno[0]>t.resno||e.resno[1]t.resno||e.resno[1]0?t:null}function ye(t,e){void 0===e&&(e=!1);var r=t;return e&&(r=ge(t,(function(t){return void 0!==t.keyword&&!Zt.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))}))),me(r,le)}function ve(t,e){void 0===e&&(e=!1);var r=t;return e&&(r=ge(t,(function(t){return!(void 0===t.keyword||!Zt.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))}))),me(r,pe)}function be(t,e){void 0===e&&(e=!1);var r=t;return e&&(r=ge(t,(function(t){return void 0!==t.keyword&&!Qt.includes(t.keyword)||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode))))))}))),me(r,de)}function xe(t,e){void 0===e&&(e=!1);var r=t;return e&&(r=ge(t,(function(t){return void 0!==t.keyword||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode)))))))}))),me(r,fe)}var _e=function(t){this.signals={stringChanged:new rt},this.setString(t)},we={type:{configurable:!0}};we.type.get=function(){return"selection"},_e.prototype.setString=function(t,e){if(void 0===t&&(t=this.string||""),t!==this.string){try{this.selection=function(t){var e={operator:void 0,rules:[]};if(!t)return e;var r,i,o=e,n=[];"("===(t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());for(var a=t.split(/\s+/),s=function(t){r={operator:t,rules:[]},void 0===o?(o=r,e=r):(o.rules.push(r),n.push(o),o=r)},c=function(t){i=o,void 0===(o=n.pop())&&(s(t),u(i))},u=function(t){o.rules.push(t)},h=!1,l=0;l0)if("NOT"===d)h=1;else if(1===h)h=2;else{if(2!==h)throw new Error("something went wrong with 'not'");h=!1,c()}if("AND"!==d)if("OR"!==d)if("NOT"!==p.toUpperCase()){if(+d!=+d){var f=qt[d];if(void 0!==f){u({keyword:f});continue}}if("HYDROGEN"!==d)if("SMALL"!==d)if("NUCLEOPHILIC"!==d)if("HYDROPHOBIC"!==d)if("AROMATIC"!==d)if("AMIDE"!==d)if("ACIDIC"!==d)if("BASIC"!==d)if("CHARGED"!==d)if("POLAR"!==d)if("NONPOLAR"!==d)if("CYCLIC"!==d)if("ALIPHATIC"!==d)if("SIDECHAINATTACHED"!==d)if("APOLARH"!==d)if("LIGAND"!==d)if(-1===Yt.indexOf(d))if("@"!==p.charAt(0))if("#"!==p.charAt(0))if("_"!==p.charAt(0))if("["!==p[0]||"]"!==p[p.length-1])if(p.length>=1&&p.length<=4&&"^"!==p[0]&&":"!==p[0]&&"."!==p[0]&&"%"!==p[0]&&"/"!==p[0]&&isNaN(parseInt(p)))u({resname:d});else{var m={operator:"AND",rules:[]},g=p.split("/");if(g.length>1&&g[1]){if(isNaN(parseInt(g[1])))throw new Error("model must be an integer");m.rules.push({model:parseInt(g[1])})}var y=g[0].split("%");y.length>1&&m.rules.push({altloc:y[1]});var v=y[0].split(".");if(v.length>1&&v[1]){if(v[1].length>4)throw new Error("atomname must be one to four characters");m.rules.push({atomname:v[1].substring(0,4).toUpperCase()})}var b=v[0].split(":");b.length>1&&b[1]&&m.rules.push({chainname:b[1]});var x=b[0].split("^");if(x.length>1&&m.rules.push({inscode:x[1]}),x[0]){var _=void 0,w=void 0;"-"===x[0][0]&&(x[0]=x[0].substr(1),_=!0),x[0].includes("--")&&(x[0]=x[0].replace("--","-"),w=!0);var A=x[0].split("-");if(1===A.length){var S=parseInt(A[0]);if(isNaN(S))throw new Error("resi must be an integer");_&&(S*=-1),m.rules.push({resno:S})}else{if(2!==A.length)throw new Error("resi range must contain one '-'");var C=A.map((function(t){return parseInt(t)}));_&&(C[0]*=-1),w&&(C[1]*=-1),m.rules.push({resno:[C[0],C[1]]})}}if(1===m.rules.length)u(m.rules[0]);else{if(!(m.rules.length>1))throw new Error("empty selection chunk");u(m)}}else{var P=d.substr(1,p.length-2).split(","),I=P.length>1?P:P[0];u({resname:I})}else u({element:d.substr(1)});else console.error("# for element selection deprecated, use _"),u({element:d.substr(1)});else{var O=p.substr(1).split(",").map((function(t){return parseInt(t)}));O.sort((function(t,e){return t-e})),u({atomindex:O})}else u({keyword:qt.ALL});else u({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:qt.HETERO},{negate:!0,operator:void 0,rules:[{keyword:qt.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:qt.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:qt.WATER},{keyword:qt.ION}]}]}]});else u({operator:"AND",negate:!1,rules:[{element:"H"},{negate:!0,operator:void 0,rules:[{keyword:qt.POLARH}]}]});else u({operator:"OR",rules:[{keyword:qt.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:qt.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:qt.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"HO3'"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"HO5'"},{atomname:"C5'"},{atomname:"C5*"},{atomname:"H5'"},{atomname:"H5''"}]}]}]});else u({resname:he});else u({resname:ue});else u({resname:ce});else u({resname:se});else u({resname:ae});else u({resname:ne});else u({resname:oe});else u({resname:ie});else u({resname:re});else u({resname:ee});else u({resname:te});else u({resname:Jt});else u({operator:"OR",rules:[{element:"H"},{element:"D"}]})}else h=1,s(),o.negate=!0;else"AND"===o.operator?c("OR"):o.operator="OR";else if("OR"===o.operator){var k=o.rules.pop();s("AND"),u(k)}else o.operator="AND"}else c(),o.negate&&c();else h=!1,s()}return void 0===e.operator&&1===e.rules.length&&e.rules[0].hasOwnProperty("operator")&&(e=e.rules[0]),e}(t)}catch(t){this.selection={error:t.message}}var r=this.selection;this.string=t,this.test=ye(r),this.residueTest=ve(r),this.chainTest=be(r),this.modelTest=xe(r),this.atomOnlyTest=ye(r,!0),this.residueOnlyTest=ve(r,!0),this.chainOnlyTest=be(r,!0),this.modelOnlyTest=xe(r,!0),e||this.signals.stringChanged.dispatch(this.string)}},_e.prototype.isAllSelection=function(){return Yt.includes(this.string.toUpperCase())},_e.prototype.isNoneSelection=function(){return Kt.includes(this.string.toUpperCase())},Object.defineProperties(_e.prototype,we);var Ae=function(t){function e(e){var r=this;t.call(this,e),this.colormakerList=[],this.selectionList=[],(e.dataList||[]).forEach((function(t){var e=t[0],i=t[1],o=t[2];void 0===o&&(o={}),Ze.hasScheme(e)?Object.assign(o,{scheme:e,structure:r.parameters.structure}):Object.assign(o,{scheme:"uniform",value:new n(e).getHex()}),r.colormakerList.push(Ze.getScheme(o)),r.selectionList.push(new _e(i))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){for(var e=0,r=this.selectionList.length;ei).lines},cr.prototype.chunkCount=function(){return Math.floor(this.data.length/this.chunkSize)+1},cr.prototype.asText=function(){return this.isBinary()?At(this.data):this.data},cr.prototype.chunkToLines=function(t,e,r){var i=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(i),partialLine:""};var o=[],n=this.isBinary()?At(t):t,a=n.lastIndexOf(i);if(-1===a)e+=n;else{var s=e+n.substr(0,a);o=o.concat(s.split(i)),e=a===n.length-i.length?"":n.substr(a+i.length)}return r&&""!==e&&o.push(e),{lines:o,partialLine:e}},cr.prototype.nextChunk=function(){var t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)},cr.prototype.nextChunkOfLines=function(){var t=this.nextChunk();if(void 0!==t){var e=this.__pointer>this.data.length,r=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=r.partialLine,r.lines}},cr.prototype.eachChunk=function(t){for(var e=this.chunkSize,r=this.data.length,i=this.chunkCount(),o=0;o1?(u.pop()||"").toLowerCase():"",l=e.match(/^(.+):\/\/(.+)$/);l&&(o=l[1].toLowerCase(),e=l[2]||"");var p=e.substring(0,e.lastIndexOf("/")+1);if(i.includes(h)){r=h;var d=e.length-h.length-1;h=(e.substr(0,d).split(".").pop()||"").toLowerCase();var f=c.length-h.length-1;c=c.substr(0,f)}else r=!1;return{path:e,name:s,ext:h,base:c,dir:p,compressed:r,protocol:o,query:a,src:t}}function gr(t){var e=mr(t),r=Qe.get(e.protocol);return r&&!(e=mr(r.getUrl(e.src))).ext&&r.getExt&&(e.ext=r.getExt(t)),e}function yr(t,e){void 0===e&&(e={});var r,i=Object.assign(gr(t),e);return tr.names.includes(i.ext)?r=new pr(i.src,i):Ye.includes(i.ext)&&(r=new fr(i.src,i)),r?r.load():Promise.reject(new Error("autoLoad: ext '"+i.ext+"' unknown"))}var vr=function(){};vr.prototype.getBlob=function(){return new Blob([this.getData()],{type:this.mimeType})},vr.prototype.download=function(t,e){t=ht(t,this.defaultName),e=ht(e,this.defaultExt),yt(this.getBlob(),t+"."+e)};var br=function(t){function e(e,r){t.call(this),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";var i=Object.assign({},r);this.renumberSerial=ht(i.renumberSerial,!0),this.remarks=function(t){return Array.isArray(t)?t:[t]}(ht(i.remarks,[])),this.structure=e,this._records=[]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._writeRecords=function(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()},e.prototype._writeTitle=function(){this._records.push(it("TITLE %-74s",this.structure.name))},e.prototype._writeRemarks=function(){var t=this;this.remarks.forEach((function(e){t._records.push(it("REMARK %-73s",e))})),this.structure.trajectory&&(this._records.push(it("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(it("REMARK %-73s","Frame "+this.structure.trajectory.frame)))},e.prototype._writeAtoms=function(){var t=this,e=1,r=1,i=" ",o=" ",n=this.structure.modelStore.count>1;this.structure.eachModel((function(a){n&&t._records.push(it("MODEL %4d%-66s",r++,"")),a.eachAtom((function(r){var n=r.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",a=t.renumberSerial?e:r.serial,s=r.atomname;(1===s.length||s.length<4&&1===r.element.length&&s[0]===r.element)&&(s=" "+s),r.formalCharge?(i=Math.abs(r.formalCharge).toPrecision(1),o=r.formalCharge>0?"+":"-"):(i=" ",o=" "),t._records.push(it(n,a,s,r.resname,ht(r.chainname," "),r.resno,r.x,r.y,r.z,ht(r.occupancy,1),ht(r.bfactor,0),"",ht(r.element,""),i,o)),e+=1}),t.structure.getSelection()),n&&t._records.push(it("%-80s","ENDMDL"))})),this._records.push(it("%-80s","END"))},e.prototype.getString=function(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()},e.prototype.getData=function(){return this._writeRecords(),this._records.join("\n")},e}(vr),xr=function(t){function e(e){t.call(this),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=e,this._records=[]}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={idString:{configurable:!0},titleString:{configurable:!0},countsString:{configurable:!0},chargeLines:{configurable:!0}};return r.idString.get=function(){return this.structure.id},r.titleString.get=function(){return" "+this.structure.title},r.countsString.get=function(){return it("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)},r.chargeLines.get=function(){var t=[];this.structure.eachAtom((function(e){null!=e.formalCharge&&0!==e.formalCharge&&t.push([e.index,e.formalCharge])}));for(var e=[],r=0;r>>0:0,o=t.byteLength-i,n=i;t instanceof ArrayBuffer||(t.byteLength!==t.buffer.byteLength&&(n=t.byteOffset+i),t=t.buffer),this._lastWrittenByte=r?o:0,this.buffer=t,this.length=o,this.byteLength=o,this.byteOffset=n,this._data=new DataView(this.buffer,n,o)};wr.prototype.available=function(t){return void 0===t&&(t=1),this.offset+t<=this.length},wr.prototype.isLittleEndian=function(){return this.littleEndian},wr.prototype.setLittleEndian=function(){return this.littleEndian=!0,this},wr.prototype.isBigEndian=function(){return!this.littleEndian},wr.prototype.setBigEndian=function(){return this.littleEndian=!1,this},wr.prototype.skip=function(t){return void 0===t&&(t=1),this.offset+=t,this},wr.prototype.seek=function(t){return this.offset=t,this},wr.prototype.mark=function(){return this._mark=this.offset,this},wr.prototype.reset=function(){return this.offset=this._mark,this},wr.prototype.pushMark=function(){return this._marks.push(this.offset),this},wr.prototype.popMark=function(){var t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this},wr.prototype.rewind=function(){return this.offset=0,this},wr.prototype.ensureAvailable=function(t){if(void 0===t&&(t=1),!this.available(t)){var e=2*(this.offset+t),r=new Uint8Array(e);r.set(new Uint8Array(this.buffer)),this.buffer=r.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this},wr.prototype.readBoolean=function(){return 0!==this.readUint8()},wr.prototype.readInt8=function(){return this._data.getInt8(this.offset++)},wr.prototype.readUint8=function(){return this._data.getUint8(this.offset++)},wr.prototype.readByte=function(){return this.readUint8()},wr.prototype.readBytes=function(t){void 0===t&&(t=1);for(var e=new Uint8Array(t),r=0;rthis._lastWrittenByte&&(this._lastWrittenByte=this.offset)};var Ar=function(t){function e(e){t.call(this),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getData=function(){var t=this.surface.index.length/3,e=new wr(2*t+3*t*4*4+80+4);e.skip(80),e.writeUint32(t);for(var i=new r,o=new r,n=new r,a=new r,s=0;sthis.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=t,this.frames=0),t},er.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),er.add("shader/chunk/interior_fragment.glsl","if( gl_FrontFacing == false ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}"),er.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),er.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),er.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"),er.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),er.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),er.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),er.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");var Pr=/^(?!\/\/)\s*#include\s+(\S+)/gim,Ir={};function Or(t,e){void 0===e&&(e={});var r=t+"|";for(var i in e)r+=i+":"+e[i];if(!Ir[r]){var o=function(t){if(void 0===t)return"";var e=[];for(var r in t){var i=t[r];i&&e.push("#define "+r+" "+i)}return e.join("\n")+"\n"}(e),n=er.get("shader/"+t);if(!n)throw new Error("empty shader, '"+t+"'");n=n.replace(Pr,(function(t,e){var r="shader/chunk/"+e+".glsl",i=er.get(r)||a[e];if(!i)throw new Error("empty chunk, '"+e+"'");return i})),Ir[r]=o+n}return Ir[r]}if("undefined"!=typeof WebGLRenderingContext){var kr=WebGLRenderingContext.prototype,Mr=kr.getShaderParameter;kr.getShaderParameter=function(){return!He||Mr.apply(this,arguments)};var Tr=kr.getShaderInfoLog;kr.getShaderInfoLog=function(){return He?Tr.apply(this,arguments):""};var Br=kr.getProgramParameter;kr.getProgramParameter=function(t,e){return!He&&e===kr.LINK_STATUS||Br.apply(this,arguments)};var Dr=kr.getProgramInfoLog;kr.getProgramInfoLog=function(){return He?Dr.apply(this,arguments):""}}var Er=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];Er.forEach((function(t){t.forEach((function(t){t[0]*=.0625,t[1]*=.0625}))}));var Fr=function(t,e,r,i){this.canvas=document.createElement("canvas"),this._viewer=r,this._factor=ht(i.factor,2),this._antialias=ht(i.antialias,!1),this._onProgress=i.onProgress,this._onFinish=i.onFinish,this._antialias&&(this._factor*=2),this._n=this._factor*this._factor,this._width=this._viewer.width,this._height=this._viewer.height,this._antialias?(this.canvas.width=this._width*this._factor/2,this.canvas.height=this._height*this._factor/2):(this.canvas.width=this._width*this._factor,this.canvas.height=this._height*this._factor),this._ctx=this.canvas.getContext("2d"),this._viewerSampleLevel=r.sampleLevel,this._viewer.setSampling(-1)};Fr.prototype._renderTile=function(t){var e=this._viewer,r=this._width,i=this._height,o=this._factor,n=t%o*r,a=Math.floor(t/o)*i;if(e.camera.setViewOffset(r*o,i*o,n,a,r,i),e.render(),this._antialias){var s=Math.round((n+r)/2)-Math.round(n/2),c=Math.round((a+i)/2)-Math.round(a/2);this._ctx.drawImage(e.renderer.domElement,Math.round(n/2),Math.round(a/2),s,c)}else this._ctx.drawImage(e.renderer.domElement,Math.floor(n),Math.floor(a),Math.ceil(r),Math.ceil(i));"function"==typeof this._onProgress&&this._onProgress(t+1,this._n,!1)},Fr.prototype._finalize=function(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,"function"==typeof this._onFinish&&this._onFinish(this._n+1,this._n,!1)},Fr.prototype.render=function(){for(var t=0;t<=this._n;++t)t===this._n?this._finalize():this._renderTile(t)},Fr.prototype.renderAsync=function(){for(var t=this,e=0,r=this._n,i=function(){e===r?t._finalize():t._renderTile(e),e+=1},o=0;o<=r;++o)setTimeout(i,0)};var Rr=2*Math.PI,$r=180/Math.PI;function Lr(t,e,r,i,o){void 0===r&&(r=1),void 0===i&&(i=0);var n=o?o.length:t.length/r,a=0,s=0;if(o)for(var c=0;ce&&(e=t[r]);return e}function Yr(t){for(var e=1/0,r=0,i=t.length;r=0;a--){for(n=h-1;n>=0;n--)if(l[c=4*(a*h+n)]!==e||l[c+1]!==r||l[c+2]!==i||l[c+3]!==o){s=!0;break}if(s)break}var f=a;for(s=!1,n=h-1;n>=0;n--){for(a=u-1;a>=0;a--)if(l[c=4*(a*h+n)]!==e||l[c+1]!==r||l[c+2]!==i||l[c+3]!==o){s=!0;break}if(s)break}var m=n,g=document.createElement("canvas");return g.width=m-d,g.height=f-p,g.getContext("2d").drawImage(t,d,p,g.width,g.height,0,0,g.width,g.height),g}(t,a?0:255*e.r,a?0:255*e.g,a?0:255*e.b,a?0:255)}return t}function d(t,r,i){"function"==typeof e.onProgress&&e.onProgress(t,r,i)}return new Promise((function(e,r){var i=new Fr(s,c,t,{factor:o,antialias:n,onProgress:d,onFinish:function(o,n){p(i.canvas).toBlob((function(i){s.setClearAlpha(u),l(!0),t.requestRender(),d(n,n,!0),i?e(i):r("error creating image")}),"image/png")}});s.setClearAlpha(a?0:1),l(),i.renderAsync()}))}var ti=new r,ei=new i,ri=new i;var ii=new e,oi=new i,ni=new i;function ai(t,e){oi.getInverse(e.projectionMatrix),ni.copy(e.projectionMatrix).transpose(),t.traverse((function(t){var e=t.material;if(e){var r=e.uniforms;r&&(r.projectionMatrixInverse&&r.projectionMatrixInverse.value.copy(oi),r.projectionMatrixTranspose&&r.projectionMatrixTranspose.value.copy(ni))}}))}function si(t,e,r){var i=t.createShader(r);if(i)return t.shaderSource(i,e),t.compileShader(i),t.getShaderParameter(i,t.COMPILE_STATUS)?i:(console.log("error compiling shader "+i+": "+t.getShaderInfoLog(i)),t.deleteShader(i),null);console.log("error creating WebGL shader "+r)}function ci(t,e){var r=t.getExtension(e);return r||console.log("extension '"+e+"' not available"),r}var ui=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function hi(t){var e=document.createElement("canvas");e.width=16,e.height=16,e.style.width="16px",e.style.height="16px";var r=e.getContext("webgl")||e.getContext("experimental-webgl");if(!r)return console.log("error creating webgl context for "+t),!1;if(!(r instanceof WebGLRenderingContext))return console.log("Got unexpected type for WebGL rendering context"),!1;ci(r,"OES_texture_float"),ci(r,"OES_texture_half_float"),ci(r,"WEBGL_color_buffer_float");var i=si(r,"\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}",r.VERTEX_SHADER),o=si(r,"\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}",r.FRAGMENT_SHADER);if(!i||!o)return!1;var n=function(t,e,r,i){var o=t.createProgram();if(o)return e.forEach((function(e){return t.attachShader(o,e)})),r&&r.forEach((function(e,r){t.bindAttribLocation(o,i?i[r]:r,e)})),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.log("error linking program: "+t.getProgramInfoLog(o)),t.deleteProgram(o),null);console.log("error creating WebGL program")}(r,[i,o]);if(!n)return console.log("error creating WebGL program"),!1;r.useProgram(n);var a=r.getAttribLocation(n,"a_position"),s=r.getUniformLocation(n,"u_color");if(!s)return console.log("error getting 'u_color' uniform location"),!1;var c=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,ui,r.STATIC_DRAW),r.enableVertexAttribArray(a),r.vertexAttribPointer(a,2,r.FLOAT,!1,0,0);var u=r.createTexture(),h=new Uint8Array([255,255,255,255]);r.bindTexture(r.TEXTURE_2D,u),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,h);var l=r.createTexture();r.bindTexture(r.TEXTURE_2D,l),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,t,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST);var p=r.createFramebuffer();if(r.bindFramebuffer(r.FRAMEBUFFER,p),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,l,0),r.checkFramebufferStatus(r.FRAMEBUFFER)!==r.FRAMEBUFFER_COMPLETE)return console.log("error creating framebuffer for "+t),!1;r.bindTexture(r.TEXTURE_2D,u),r.uniform4fv(s,[0,10,20,1]),r.drawArrays(r.TRIANGLES,0,6),r.bindTexture(r.TEXTURE_2D,l),r.bindFramebuffer(r.FRAMEBUFFER,null),r.clearColor(1,0,0,1),r.clear(r.COLOR_BUFFER_BIT),r.uniform4fv(s,[0,.1,.05,1]),r.drawArrays(r.TRIANGLES,0,6);var d=new Uint8Array(4);if(r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,d),0!==d[0]||d[1]<248||d[2]<248||d[3]<254)return console.log("not able to actually render to "+t+" texture"),!1;if(t===r.FLOAT){r.bindFramebuffer(r.FRAMEBUFFER,p);var f=new Float32Array(4);r.readPixels(0,0,1,1,r.RGBA,r.FLOAT,f);var m=r.getError();if(m)return console.log("error reading pixels as float: '"+function(t,e){switch(e){case t.NO_ERROR:return"no error";case t.INVALID_ENUM:return"invalid enum";case t.INVALID_VALUE:return"invalid value";case t.INVALID_OPERATION:return"invalid operation";case t.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case t.OUT_OF_MEMORY:return"out of memory";case t.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}(r,m)+"'"),!1}return!0}var li=new Float32Array(100),pi=new Uint8Array(100),di=[12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20],fi=new i;function mi(t,e,r,i,o){var n=o.uniforms,a=[];if(n&&(n.objectId&&(n.objectId.value=$e?this.id:this.id/255,a.push("objectId")),(n.modelViewMatrixInverse||n.modelViewMatrixInverseTranspose||n.modelViewProjectionMatrix||n.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,this.matrixWorld),n.modelViewMatrixInverse&&(n.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),a.push("modelViewMatrixInverse")),n.modelViewMatrixInverseTranspose&&(n.modelViewMatrixInverse?n.modelViewMatrixInverseTranspose.value.copy(n.modelViewMatrixInverse.value).transpose():n.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),a.push("modelViewMatrixInverseTranspose")),n.modelViewProjectionMatrix&&(n.modelViewProjectionMatrix.value.multiplyMatrices(r.projectionMatrix,this.modelViewMatrix),a.push("modelViewProjectionMatrix")),n.modelViewProjectionMatrixInverse&&(n.modelViewProjectionMatrix?(fi.copy(n.modelViewProjectionMatrix.value),n.modelViewProjectionMatrixInverse.value.getInverse(fi)):(fi.multiplyMatrices(r.projectionMatrix,this.modelViewMatrix),n.modelViewProjectionMatrixInverse.value.getInverse(fi)),a.push("modelViewProjectionMatrixInverse")),a.length)){var s=t.properties.get(o);if(s.program){var c=t.getContext(),u=s.program;c.useProgram(u.program);var h=u.getUniforms();a.forEach((function(t){h.setValue(c,t,n[t].value)}))}}}var gi=function(t){if(this.boundingBox=new c,this.boundingBoxSize=new r,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new r,this.signals={ticked:new rt,rendered:new rt},"string"==typeof t){var e=document.getElementById(t);this.container=null===e?document.createElement("div"):e}else t instanceof HTMLElement?this.container=t:this.container=document.createElement("div");if(this.container===document.body)this.width=window.innerWidth||1,this.height=window.innerHeight||1;else{var i=this.container.getBoundingClientRect();this.width=i.width||1,this.height=i.height||1,this.container.style.overflow="hidden"}this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.container.appendChild(this.wrapper),this._initParams(),this._initStats(),this._initCamera(),this._initScene(),!1!==this._initRenderer()?(this._initHelper(),this.setBackground(),this.setFog(),this.animate=this.animate.bind(this)):je.error("Viewer: could not initialize renderer")},yi={cameraDistance:{configurable:!0}};gi.prototype._initParams=function(){this.parameters={fogColor:new n(0),fogNear:50,fogFar:100,backgroundColor:new n(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new n(14540253),lightIntensity:1,ambientColor:new n(14540253),ambientIntensity:.2,sampleLevel:0,rendererEncoding:u}},gi.prototype._initCamera=function(){var t=new r(0,0,0),e=this.width,i=this.height;this.perspectiveCamera=new h(this.parameters.cameraFov,e/i),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(t),this.orthographicCamera=new l(e/-2,e/2,i/2,i/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(t),this.stereoCamera=new p,this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;var o=this.parameters.cameraType;if("orthographic"===o)this.camera=this.orthographicCamera;else{if("perspective"!==o&&"stereo"!==o)throw new Error("Unknown cameraType '"+o+"'");this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()},gi.prototype._initStats=function(){this.stats=new Cr},gi.prototype._initScene=function(){this.scene||(this.scene=new d,this.scene.name="scene"),this.rotationGroup=new f,this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new f,this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new f,this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new f,this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new f,this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new f,this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new m(this.parameters.fogColor.getHex()),this.spotLight=new g(this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.spotLight),this.ambientLight=new y(this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)},gi.prototype._initRenderer=function(){var t=window.devicePixelRatio,e=this.width,r=this.height;try{this.renderer=new v({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(t){return this.wrapper.innerHTML='

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

',!1}this.renderer.setPixelRatio(t),this.renderer.setSize(e,r),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,this.renderer.outputEncoding=this.parameters.rendererEncoding;var i=this.renderer.getContext();this.renderer.capabilities.isWebGL2?(ze(!0),Le(this.renderer.extensions.get("EXT_color_buffer_float")),this.supportsHalfFloat=!0):(ze(this.renderer.extensions.get("EXT_frag_depth")),this.renderer.extensions.get("OES_element_index_uint"),Le(this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&hi(i.FLOAT)),this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&hi(36193)),this.wrapper.appendChild(this.renderer.domElement);var o=e*t,n=r*t;He&&console.log(JSON.stringify({Browser:De,OES_texture_float:!!this.renderer.extensions.get("OES_texture_float"),OES_texture_half_float:!!this.renderer.extensions.get("OES_texture_half_float"),WEBGL_color_buffer_float:!!this.renderer.extensions.get("WEBGL_color_buffer_float"),"testTextureSupport Float":hi(i.FLOAT),"testTextureSupport HalfFloat":hi(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:$e},null,2)),this.pickingTarget=new b(o,n,{minFilter:x,magFilter:x,stencilBuffer:!1,format:_,type:$e?D:w}),this.pickingTarget.texture.generateMipmaps=!1,this.pickingTarget.texture.encoding=this.parameters.rendererEncoding,this.renderer.setRenderTarget(this.pickingTarget),this.renderer.clear(),this.renderer.setRenderTarget(null),this.sampleTarget=new b(o,n,{minFilter:A,magFilter:A,format:_}),this.sampleTarget.texture.encoding=this.parameters.rendererEncoding,this.holdTarget=new b(o,n,{minFilter:x,magFilter:x,format:_,type:w}),this.holdTarget.texture.encoding=this.parameters.rendererEncoding,this.compositeUniforms={tForeground:new S(this.sampleTarget.texture),scale:new S(1)},this.compositeMaterial=new C({uniforms:this.compositeUniforms,vertexShader:Or("Quad.vert"),fragmentShader:Or("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:P,depthTest:!1,depthWrite:!1}),this.compositeCamera=new l(-1,1,1,-1,0,1),this.compositeScene=new d,this.compositeScene.name="compositeScene",this.compositeScene.add(new I(new O(2,2),this.compositeMaterial))},gi.prototype._initHelper=function(){var t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),e=new Float32Array(24),r=new k;r.setIndex(new M(t,1)),r.setAttribute("position",new M(e,3));var i=new C({uniforms:{uColor:{value:new n("skyblue")}},vertexShader:Or("BasicLine.vert"),fragmentShader:Or("BasicLine.frag")});this.boundingBoxMesh=new T(r,i),this.helperGroup.add(this.boundingBoxMesh)},gi.prototype.updateHelper=function(){var t=this.boundingBoxMesh.geometry.attributes.position,e=t.array,r=this.boundingBox,i=r.min,o=r.max;e[0]=o.x,e[1]=o.y,e[2]=o.z,e[3]=i.x,e[4]=o.y,e[5]=o.z,e[6]=i.x,e[7]=i.y,e[8]=o.z,e[9]=o.x,e[10]=i.y,e[11]=o.z,e[12]=o.x,e[13]=o.y,e[14]=i.z,e[15]=i.x,e[16]=o.y,e[17]=i.z,e[18]=i.x,e[19]=i.y,e[20]=i.z,e[21]=o.x,e[22]=i.y,e[23]=i.z,t.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()},yi.cameraDistance.get=function(){return Math.abs(this.camera.position.z)},yi.cameraDistance.set=function(t){this.camera.position.z=-t},gi.prototype.add=function(t,e){var r=this;e?e.forEach((function(e){return r.addBuffer(t,e)})):this.addBuffer(t),t.group.name="meshGroup",t.wireframeGroup.name="wireframeGroup",t.parameters.background?(this.backgroundGroup.add(t.group),this.backgroundGroup.add(t.wireframeGroup)):(this.modelGroup.add(t.group),this.modelGroup.add(t.wireframeGroup)),t.pickable&&this.pickingGroup.add(t.pickingGroup),He&&this.updateHelper()},gi.prototype.addBuffer=function(t,e){function r(i){i instanceof f?i.children.forEach(r):(i.userData.buffer=t,i.userData.instance=e,i.onBeforeRender=mi)}var i=t.getMesh();e&&i.applyMatrix4(e.matrix),r(i),t.group.add(i);var o=t.getWireframeMesh();if(e&&(o.matrix.copy(i.matrix),o.position.copy(i.position),o.quaternion.copy(i.quaternion),o.scale.copy(i.scale)),r(o),t.wireframeGroup.add(o),t.pickable){var n=t.getPickingMesh();e&&(n.matrix.copy(i.matrix),n.position.copy(i.position),n.quaternion.copy(i.quaternion),n.scale.copy(i.scale)),r(n),t.pickingGroup.add(n)}e?this._updateBoundingBox(t.geometry,t.matrix,e.matrix):this._updateBoundingBox(t.geometry,t.matrix)},gi.prototype.remove=function(t){this.translationGroup.children.forEach((function(e){e.remove(t.group),e.remove(t.wireframeGroup)})),t.pickable&&this.pickingGroup.remove(t.pickingGroup),this.updateBoundingBox(),He&&this.updateHelper()},gi.prototype._updateBoundingBox=function(t,e,r){var i=this.boundingBox;function o(t,e,r){null==t.boundingBox&&t.computeBoundingBox();var o=t.boundingBox.clone();e&&o.applyMatrix4(e),r&&o.applyMatrix4(r),o.min.equals(o.max)&&o.expandByScalar(5),i.union(o)}function n(t){var e,r;void 0!==t.geometry&&(t.userData.buffer&&(e=t.userData.buffer.matrix),t.userData.instance&&(r=t.userData.instance.matrix),o(t.geometry,e,r))}t?o(t,e,r):(i.makeEmpty(),this.modelGroup.traverse(n),this.backgroundGroup.traverse(n)),i.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()},gi.prototype.updateBoundingBox=function(){this._updateBoundingBox(),He&&this.updateHelper()},gi.prototype.getPickingPixels=function(){var t=this.width,e=this.height,r=t*e*4,i=$e?new Float32Array(r):new Uint8Array(r);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,t,e,i),i},gi.prototype.getImage=function(t){var e=this;return new Promise((function(r){if(t){var i=e,o=i.width,n=i.height,a=o*n*4,s=e.getPickingPixels();if($e){for(var c=new Uint8Array(a),u=0;u500&&!this.isStill&&this.sampleLevel<3&&-1!==this.sampleLevel){var t=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=t,He&&je.log("rendered still frame")}this.frameRequest=window.requestAnimationFrame(this.animate)},gi.prototype.pick=function(t,e){if("stereo"===this.parameters.cameraType)return{pid:0,instance:void 0,picker:void 0};t*=window.devicePixelRatio,e*=window.devicePixelRatio,t=Math.max(t-2,0),e=Math.max(e-2,0);var r,i,o=0,n=$e?li:pi;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,t,e,5,5,n);for(var a=0;a22&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame((function(){t.render(),t.stats.update()})))},gi.prototype.updateZoom=function(){var t=Ft(this.perspectiveCamera.fov),e=2*Math.tan(t/2)*this.cameraDistance;this.orthographicCamera.zoom=this.height/e},gi.prototype.absoluteToRelative=function(t){return 50*(1-t/this.bRadius)},gi.prototype.relativeToAbsolute=function(t){return this.bRadius*(1-t/50)},gi.prototype.__updateClipping=function(){var t=this.parameters;this.bRadius=Math.max(10,.5*this.boundingBoxLength),isFinite(this.bRadius)||(this.bRadius=50),this.camera.getWorldPosition(this.distVector),this.cDist=this.distVector.length(),this.cDist||(this.cameraDistance=Math.abs(t.cameraZ),this.cDist=Math.abs(t.cameraZ));var e=this.scene.fog;if(e.color.set(t.fogColor),"camera"===t.clipMode)this.camera.near=t.clipNear,this.camera.far=t.clipFar,e.near=t.fogNear,e.far=t.fogFar;else if("absolute"===t.clipScale)this.camera.near=this.cDist-t.clipNear,this.camera.far=this.cDist+t.clipFar,e.near=this.cDist-t.fogNear,e.far=this.cDist+t.fogFar;else{var r=(50-t.clipNear)/50,i=-(50-t.clipFar)/50;this.camera.near=this.cDist-this.bRadius*r,this.camera.far=this.cDist+this.bRadius*i;var o=(50-t.fogNear)/50,n=-(50-t.fogFar)/50;e.near=this.cDist-this.bRadius*o,e.far=this.cDist+this.bRadius*n}"camera"!==t.clipMode&&("PerspectiveCamera"===this.camera.type?(this.camera.near=Math.max(.1,t.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),e.near=Math.max(.1,e.near),e.far=Math.max(1,e.far)):"OrthographicCamera"===this.camera.type&&t.clipDist>0&&(this.camera.near=Math.max(t.clipDist,this.camera.near)))},gi.prototype.__updateCamera=function(){var t=this.camera;t.updateMatrix(),t.updateMatrixWorld(!0),t.updateProjectionMatrix(),function(t,r,i,o,n){var a=new e;i.getSize(a);var s=a.height,c=i.getPixelRatio(),u="OrthographicCamera"===r.type;ii.set(a.width,a.height),oi.getInverse(r.projectionMatrix),ni.copy(r.projectionMatrix).transpose(),t.traverse((function(t){var e=t.material;if(e){var r=e.uniforms;if(r){if(e.clipNear){var i=(50-e.clipNear)/50,a=o-n*i;r.clipNear.value=a}r.canvasHeight&&(r.canvasHeight.value=s),r.resolution&&r.resolution.value.copy(ii),r.pixelRatio&&(r.pixelRatio.value=c),r.projectionMatrixInverse&&r.projectionMatrixInverse.value.copy(oi),r.projectionMatrixTranspose&&r.projectionMatrixTranspose.value.copy(ni),r.ortho&&(r.ortho.value=u)}}}))}(this.scene,t,this.renderer,this.cDist,this.bRadius),function(t,e){t.traverseVisible((function(t){if(t instanceof s&&t.userData.buffer.parameters.sortParticles){var r=t.geometry.attributes,i=r.position.count;if(0!==i){var o,n,a,c,u,h,l;ei.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),ri.multiplyMatrices(e.projectionMatrix,ei),t.userData.sortData?(o=t.userData.sortData,a=o.__zArray,n=o.__sortArray,c=o.__cmpFn):(a=new Float32Array(i),n=new Uint32Array(i),o={__zArray:a,__sortArray:n,__cmpFn:c=function(t,e){var r=a[t],i=a[e];return r>i?1:re?1:t=u&&e(t[n],o)>0;)t[n+1]=t[n],--n;t[n+1]=o}if(-1===c)break;h=s[c--],u=s[c--]}else{for(a=h,l(u+h>>1,n=u+1),e(t[u],t[h])>0&&l(u,h),e(t[n],t[h])>0&&l(n,h),e(t[u],t[n])>0&&l(u,n),o=t[n];;){do{n++}while(e(t[n],o)<0);do{a--}while(e(t[a],o)>0);if(a=a-u?(s[++c]=n,s[++c]=h,h=a-1):(s[++c]=u,s[++c]=a-1,u=n)}}(n,c),r){var f=r[d],m=f.array,g=f.itemSize;o[d]||(o[d]=new Float32Array(g*i)),l=o[d],o[d]=m;for(var y=0;y0&&"stereo"!==this.parameters.cameraType?this.__renderSuperSample(e,r):this.__renderModelGroup(e,r)},gi.prototype.render=function(t,e){if(void 0===t&&(t=!1),this.rendering)je.warn("'tried to call 'render' from within 'render'");else{this.rendering=!0;try{this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),"stereo"===this.parameters.cameraType?this.__renderStereo(t,e):this.__render(t,this.camera,e),this.lastRenderedPicking=t}finally{this.rendering=!1,this.renderPending=!1}this.signals.rendered.dispatch()}},gi.prototype.clear=function(){je.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()},gi.prototype.dispose=function(){this.renderer.dispose(),window.cancelAnimationFrame(this.frameRequest)},Object.defineProperties(gi.prototype,yi);var vi=1,bi=2,xi=3;function _i(t){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;return Math.sqrt(e*e+r*r)}var wi=function(t,r){void 0===r&&(r={}),this.domElement=t,this.signals={moved:new rt,scrolled:new rt,dragged:new rt,dropped:new rt,clicked:new rt,hovered:new rt,doubleClicked:new rt},this.position=new e,this.prevPosition=new e,this.down=new e,this.canvasPosition=new e,this.prevClickCP=new e,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=0,this.buttons=0,this.pressed=!1,this.altKey=!1,this.ctrlKey=!1,this.metaKey=!1,this.shiftKey=!1,this.domElement.style.touchAction="none",this.hoverTimeout=ht(r.hoverTimeout,50),this.handleScroll=ht(r.handleScroll,!0),this.doubleClickSpeed=ht(r.doubleClickSpeed,500),this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();var i={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,i),document.addEventListener("wheel",this._onMousewheel,i),document.addEventListener("MozMousePixelScroll",this._onMousewheel,i),document.addEventListener("mousemove",this._onMousemove,i),document.addEventListener("mousedown",this._onMousedown,i),document.addEventListener("mouseup",this._onMouseup,i),document.addEventListener("contextmenu",this._onContextmenu,i),document.addEventListener("touchstart",this._onTouchstart,i),document.addEventListener("touchend",this._onTouchend,i),document.addEventListener("touchmove",this._onTouchmove,i)},Ai={key:{configurable:!0}};Ai.key.get=function(){var t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t},wi.prototype.setParameters=function(t){void 0===t&&(t={}),this.hoverTimeout=ht(t.hoverTimeout,this.hoverTimeout)},wi.prototype._listen=function(){var t=window.performance.now(),e=this.canvasPosition;this.doubleClickPending&&t-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),t-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(e.x,e.y))),this.frameRequest=window.requestAnimationFrame(this._listen)},wi.prototype._onMousewheel=function(t){var e=this;if(t.target===this.domElement&&this.handleScroll){t.preventDefault(),this._setKeys(t);var r=0;"deltaY"in t&&"deltaMode"in t&&void 0!==t.deltaY&&void 0!==t.deltaMode?r=t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?.025*-t.deltaY:t.deltaMode===WheelEvent.DOM_DELTA_LINE?-t.deltaY*(2.5/3):2.5*-t.deltaY:"deltaY"in t&&!("detail"in t)?r=.025*-t.deltaY:void 0!==t.wheelDelta?r=.025*-t.wheelDelta:void 0!==t.wheelDeltaY?r=.025*-t.wheelDeltaY:void 0!==t.detail&&(r=-t.detail/3),this.signals.scrolled.dispatch(r),setTimeout((function(){e.scrolled=!0}),this.hoverTimeout)}},wi.prototype._onMousemove=function(t){t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(t),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.clientX,t.clientY),this._setCanvasPosition(t);var e=this.prevPosition.x-this.position.x,r=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,r),this.pressed&&this.signals.dragged.dispatch(e,r)},wi.prototype._onMousedown=function(t){t.target===this.domElement&&(t.preventDefault(),this._setKeys(t),this.moving=!1,this.hovering=!1,this.down.set(t.clientX,t.clientY),this.position.set(t.clientX,t.clientY),this.which=t.which,this.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(o/2);else{this.which=3,this.buttons=2;var n=this.prevPosition.x-this.position.x,a=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(n,a),this.pressed&&this.signals.dragged.dispatch(n,a)}}},wi.prototype._distance=function(){return this.position.distanceTo(this.down)},wi.prototype._setCanvasPosition=function(t){var e,r,i=this.domElement.getBoundingClientRect();"clientX"in t&&"clientY"in t?(e=t.clientX-i.left,r=t.clientY-i.top):(e=t.offsetX,r=t.offsetY),this.canvasPosition.set(e,i.height-r)},wi.prototype._setKeys=function(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey},wi.prototype.dispose=function(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove),window.cancelAnimationFrame(this.frameRequest)},Object.defineProperties(wi.prototype,Ai);var Si=new i,Ci=new i,Pi=new i,Ii=new i,Oi=new i,ki=new r,Mi=new o,Ti=new o,Bi=new i,Di=new r,Ei=new r,Fi=function(t,e){void 0===e&&(e={}),this.stage=t,this.rotateSpeed=ht(e.rotateSpeed,2),this.zoomSpeed=ht(e.zoomSpeed,1.2),this.panSpeed=ht(e.panSpeed,1),this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls},Ri={component:{configurable:!0},atom:{configurable:!0}};Ri.component.get=function(){return this.stage.transformComponent},Ri.atom.get=function(){return this.stage.transformAtom},Fi.prototype._setPanVector=function(t,e,r){void 0===r&&(r=0);var i=this.controls.getCanvasScaleFactor(r);Di.set(t,e,0),Di.multiplyScalar(this.panSpeed*i)},Fi.prototype._getRotateXY=function(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]},Fi.prototype._getCameraRotation=function(t){return t.extractRotation(this.viewer.camera.matrixWorld),t.multiply(Ci.makeRotationY(Math.PI)),t},Fi.prototype._transformPanVector=function(){this.component&&(Bi.extractRotation(this.component.transform),Bi.premultiply(this.viewer.rotationGroup.matrix),Bi.getInverse(Bi),Bi.multiply(this._getCameraRotation(Ii)),Di.applyMatrix4(Bi))},Fi.prototype.zoom=function(t){this.controls.zoom(this.zoomSpeed*t*.02)},Fi.prototype.pan=function(t,e){this._setPanVector(t,e),Bi.getInverse(this.viewer.rotationGroup.matrix),Bi.multiply(this._getCameraRotation(Ii)),Di.applyMatrix4(Bi),this.controls.translate(Di)},Fi.prototype.panComponent=function(t,e){this.component&&(this._setPanVector(t,e),this._transformPanVector(),this.component.position.add(Di),this.component.updateMatrix())},Fi.prototype.panAtom=function(t,e){this.atom&&this.component&&(this.atom.positionToVector3(Ei),Ei.add(this.viewer.translationGroup.position),Ei.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(t,e,Ei.z),this._transformPanVector(),this.atom.positionAdd(Di),this.component.updateRepresentations({position:!0}))},Fi.prototype.rotate=function(t,e){var r=this._getRotateXY(t,e),i=r[0],o=r[1];this._getCameraRotation(Ii),ki.set(1,0,0),ki.applyMatrix4(Ii),Mi.setFromAxisAngle(ki,o),ki.set(0,1,0),ki.applyMatrix4(Ii),Ti.setFromAxisAngle(ki,i),Mi.multiply(Ti),Ii.makeRotationFromQuaternion(Mi),this.controls.applyMatrix(Ii)},Fi.prototype.zRotate=function(t,e){var r=this.rotateSpeed*((-t+e)/-2)*.01;Pi.makeRotationZ(r),this.controls.applyMatrix(Pi)},Fi.prototype.rotateComponent=function(t,e){if(this.component){var r=this._getRotateXY(t,e),i=r[0],o=r[1];this._getCameraRotation(Oi),Ii.extractRotation(this.component.transform),Ii.premultiply(this.viewer.rotationGroup.matrix),Ii.getInverse(Ii),Ii.premultiply(Oi),ki.set(1,0,0),ki.applyMatrix4(Ii),Si.makeRotationAxis(ki,o),ki.set(0,1,0),ki.applyMatrix4(Ii),Ci.makeRotationAxis(ki,i),Si.multiply(Ci),Mi.setFromRotationMatrix(Si),this.component.quaternion.premultiply(Mi),this.component.quaternion.normalize(),this.component.updateMatrix()}},Object.defineProperties(Fi.prototype,Ri);var $i=new r;var Li=function(t,e){this.stage=e,this.pid=t.pid,this.picker=t.picker,this.instance=t.instance,this.stage=e,this.controls=e.viewerControls,this.mouse=e.mouseObserver},Ni={type:{configurable:!0},altKey:{configurable:!0},ctrlKey:{configurable:!0},metaKey:{configurable:!0},shiftKey:{configurable:!0},canvasPosition:{configurable:!0},component:{configurable:!0},object:{configurable:!0},position:{configurable:!0},closestBondAtom:{configurable:!0},closeAtom:{configurable:!0},arrow:{configurable:!0},atom:{configurable:!0},axes:{configurable:!0},bond:{configurable:!0},box:{configurable:!0},cone:{configurable:!0},clash:{configurable:!0},contact:{configurable:!0},cylinder:{configurable:!0},distance:{configurable:!0},ellipsoid:{configurable:!0},octahedron:{configurable:!0},point:{configurable:!0},mesh:{configurable:!0},slice:{configurable:!0},sphere:{configurable:!0},tetrahedron:{configurable:!0},torus:{configurable:!0},surface:{configurable:!0},unitcell:{configurable:!0},unknown:{configurable:!0},volume:{configurable:!0},wideline:{configurable:!0}};Ni.type.get=function(){return this.picker.type},Ni.altKey.get=function(){return this.mouse.altKey},Ni.ctrlKey.get=function(){return this.mouse.ctrlKey},Ni.metaKey.get=function(){return this.mouse.metaKey},Ni.shiftKey.get=function(){return this.mouse.shiftKey},Ni.canvasPosition.get=function(){return this.mouse.canvasPosition},Ni.component.get=function(){return this.stage.getComponentsByObject(this.picker.data).list[0]},Ni.object.get=function(){return this.picker.getObject(this.pid)},Ni.position.get=function(){return this.picker.getPosition(this.pid,this.instance,this.component)},Ni.closestBondAtom.get=function(){if("bond"===this.type&&this.bond){var t=this.bond,e=this.controls,r=this.canvasPosition,i=t.atom1.positionToVector3(),o=t.atom2.positionToVector3();i.applyMatrix4(this.component.matrix),o.applyMatrix4(this.component.matrix);var n,a,s,c=e.getPositionOnCanvas(i),u=e.getPositionOnCanvas(o);return a=c,s=u,(n=r).distanceTo(a)=i.length))return new Li(r,this.stage);console.error("pid >= picker.array.length")}};var ji=new o,Vi=new r,Gi=new r,Ui=new r,Hi=new r,Wi=new i,qi=new r,Xi=new i,Yi=function(t){this.stage=t,this.signals={changed:new et.Signal},this.viewer=t.viewer},Ki={position:{configurable:!0},rotation:{configurable:!0}};Ki.position.get=function(){return this.viewer.translationGroup.position},Ki.rotation.get=function(){return this.viewer.rotationGroup.quaternion},Yi.prototype.changed=function(){this.viewer.requestRender(),this.signals.changed.dispatch()},Yi.prototype.getPositionOnCanvas=function(t,r){var i=It(r,e),o=this.viewer;return Ui.copy(t).add(o.translationGroup.position).applyMatrix4(o.rotationGroup.matrix).project(o.camera),i.set((Ui.x+1)*o.width/2,(Ui.y+1)*o.height/2)},Yi.prototype.getCanvasScaleFactor=function(t){void 0===t&&(t=0);var e=this.viewer.camera;if(e instanceof l)return 1/e.zoom;t=Math.abs(t),t+=this.getCameraDistance();var r=Ft(e.fov);return 2*t*Math.tan(r/2)/this.viewer.height},Yi.prototype.getOrientation=function(t){var e=kt(t);e.copy(this.viewer.rotationGroup.matrix);var r=this.getCameraDistance();return e.scale(Hi.set(r,r,r)),e.setPosition(this.viewer.translationGroup.position),e},Yi.prototype.orient=function(t){kt(t).decompose(Vi,ji,Gi);var e=this.viewer;e.rotationGroup.setRotationFromQuaternion(ji),e.translationGroup.position.copy(Vi),e.cameraDistance=Gi.z,e.updateZoom(),this.changed()},Yi.prototype.translate=function(t){this.viewer.translationGroup.position.add(Ot(t)),this.changed()},Yi.prototype.center=function(t){this.viewer.translationGroup.position.copy(Ot(t)).negate(),this.changed()},Yi.prototype.zoom=function(t){this.distance(this.getCameraDistance()*(1-t))},Yi.prototype.getCameraDistance=function(){return this.viewer.cameraDistance},Yi.prototype.distance=function(t){this.viewer.cameraDistance=Math.max(Math.abs(t),.2),this.viewer.updateZoom(),this.changed()},Yi.prototype.spin=function(t,e){Wi.getInverse(this.viewer.rotationGroup.matrix),qi.copy(Ot(t)).applyMatrix4(Wi),this.viewer.rotationGroup.rotateOnAxis(qi,e),this.changed()},Yi.prototype.rotate=function(t){this.viewer.rotationGroup.setRotationFromQuaternion(Mt(t)),this.changed()},Yi.prototype.align=function(t){Xi.getInverse(kt(t)),this.viewer.rotationGroup.setRotationFromMatrix(Xi),this.changed()},Yi.prototype.applyMatrix=function(t){this.viewer.rotationGroup.applyMatrix4(kt(t)),this.changed()},Object.defineProperties(Yi.prototype,Ki);var Zi=function(t,e){for(var r,i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=ht(t,1e3),this.controls=e,this.startTime=window.performance.now(),(r=this)._init.apply(r,i)},Qi={done:{configurable:!0},paused:{configurable:!0}};Qi.done.get=function(){return 1===this.alpha},Qi.paused.get=function(){return this._paused},Zi.prototype.tick=function(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=Vt(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach((function(t){return t()})),this.done},Zi.prototype.pause=function(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0},Zi.prototype.resume=function(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)},Zi.prototype.toggle=function(){this._paused?this.resume():this.pause()},Zi.prototype.then=function(t){var e=this;return(this.done?Promise.resolve():new Promise((function(t){return e._resolveList.push(t)}))).then(t)},Object.defineProperties(Zi.prototype,Qi);var Ji=function(t){function e(e,r){for(var i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];t.apply(this,[ht(e,1/0),r].concat(i))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){Array.isArray(t)?this.axis=(new r).fromArray(t):this.axis=ht(t,new r(0,1,0)),this.angle=ht(e,.01)},e.prototype._tick=function(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)},e}(Zi),to=function(t){function e(e,r){for(var i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];t.apply(this,[ht(e,1/0),r].concat(i)),this.angleSum=0,this.direction=1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,i){Array.isArray(t)?this.axis=(new r).fromArray(t):this.axis=ht(t,new r(0,1,0)),this.angleStep=ht(e,.01),this.angleEnd=ht(i,.2)},e.prototype._tick=function(t){if(this.axis&&this.angleStep&&this.angleEnd){var e=Vt(0,1,Math.abs(this.angleSum)/this.angleEnd),r=this.angleStep*this.direction*(1.1-e);this.controls.spin(this.axis,r*t.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}},e}(Zi),eo=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.moveFrom=Ot(ht(t,new r)),this.moveTo=Ot(ht(e,new r))},e.prototype._tick=function(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()},e}(Zi),ro=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.zoomFrom=t,this.zoomTo=e},e.prototype._tick=function(){this.controls.distance(zt(this.zoomFrom,this.zoomTo,this.alpha))},e}(Zi),io=function(t){function e(){t.apply(this,arguments),this._currentRotation=new o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.rotateFrom=Mt(t),this.rotateTo=Mt(e),this._currentRotation=new o},e.prototype._tick=function(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)},e}(Zi),oo=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,r){this.valueFrom=t,this.valueTo=e,this.callback=r},e.prototype._tick=function(){this.callback(zt(this.valueFrom,this.valueTo,this.alpha))},e}(Zi),no=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t){this.callback=t},e.prototype._tick=function(){1===this.alpha&&this.callback()},e}(Zi),ao=function(t){void 0===t&&(t=[]),this._resolveList=[],this._list=t},so={done:{configurable:!0}};so.done.get=function(){return this._list.every((function(t){return t.done}))},ao.prototype.then=function(t){var e,r=this;return e=this.done?Promise.resolve():new Promise((function(t){r._resolveList.push(t),r._list.forEach((function(t){t.then((function(){r._resolveList.forEach((function(t){t()})),r._resolveList.length=0}))}))})),e.then(t)},Object.defineProperties(ao.prototype,so);var co=function(t){this.stage=t,this.animationList=[],this.finishedList=[],this.viewer=t.viewer,this.controls=t.viewerControls},uo={paused:{configurable:!0}};uo.paused.get=function(){return this.animationList.every((function(t){return t.paused}))},co.prototype.add=function(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t},co.prototype.remove=function(t){var e=this.animationList,r=e.indexOf(t);r>-1&&e.splice(r,1)},co.prototype.run=function(t){for(var e=this.finishedList,r=this.animationList,i=r.length,o=0;o0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(t||!1)}else this.lazyProps.build=!0},lo.prototype.make=function(t,e){var r=this;He&&je.time("Representation.make "+this.type);var i=function(){t?(r.update(t),r.viewer.requestRender(),r.tasks.decrement(),e&&e()):(r.clear(),r.create(),r.manualAttach||r.disposed||(He&&je.time("Representation.attach "+r.type),r.attach((function(){He&&je.timeEnd("Representation.attach "+r.type),r.tasks.decrement(),e&&e()})))),He&&je.timeEnd("Representation.make "+r.type)};this.toBePrepared?this.prepare(i):i()},lo.prototype.attach=function(t){this.setVisibility(this.visible),t()},lo.prototype.setVisibility=function(t,e){if(this.visible=t,this.visible&&this.opacity){var r=this.lazyProps,i=r.bufferParams,o=r.what;if(r.build)return r.build=!1,this.build(),this;(Object.keys(i).length||Object.keys(o).length)&&(r.bufferParams={},r.what={},this.updateParameters(i,o))}return this.bufferList.forEach((function(e){e.setVisibility(t)})),e||this.viewer.requestRender(),this},lo.prototype.setParameters=function(t,e,r){void 0===e&&(e={}),void 0===r&&(r=!1);var i=t||{},o=this.parameters,n={};for(var a in this.opacity||void 0===i.opacity||(this.lazyProps.build?(this.lazyProps.build=!1,r=!0):(Object.assign(n,this.lazyProps.bufferParams),Object.assign(e,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(i.color,i),i)if(void 0!==i[a]&&void 0!==o[a]&&(o[a].int&&(i[a]=parseInt(i[a])),o[a].float&&(i[a]=parseFloat(i[a])),i[a]!==this[a]||i[a].equals&&!i[a].equals(this[a]))){if(this[a]&&this[a].copy&&i[a].copy?this[a].copy(i[a]):this[a]&&this[a].set?this[a].set(i[a]):this[a]=i[a],o[a].buffer)if(!0===o[a].buffer)n[a]=i[a];else n[o[a].buffer]=i[a];o[a].update&&(e[o[a].update]=!0),!o[a].rebuild||"impostor"===o[a].rebuild&&Ne&&!this.disableImpostor||(r=!0)}return r?this.build():this.updateParameters(n,e),this},lo.prototype.updateParameters=function(t,e){if(void 0===t&&(t={}),this.lazy&&(!this.visible||!this.opacity)&&!1===t.hasOwnProperty("opacity"))return Object.assign(this.lazyProps.bufferParams,t),void Object.assign(this.lazyProps.what,e);this.bufferList.forEach((function(e){e.setParameters(t)})),Object.keys(e).length&&this.update(e),this.viewer.requestRender()},lo.prototype.getParameters=function(){var t=this,e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach((function(r){null!==t.parameters[r]&&(e[r]=t[r])})),e},lo.prototype.clear=function(){var t=this;this.bufferList.forEach((function(e){t.viewer.remove(e),e.dispose()})),this.bufferList.length=0,this.viewer.requestRender()},lo.prototype.dispose=function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()};var po=function(t){var e=this;this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=t,this.blobUrl=window.URL.createObjectURL(Ke.get(t)),this.worker=new Worker(this.blobUrl),Ke.activeWorkerCount+=1,this.worker.onmessage=function(r){e.pending-=1;var i=r.data.__postId;He&&je.timeEnd("Worker.postMessage "+t+" #"+i);var o=e.onmessageDict[i];o&&o.call(e.worker,r),delete e.onmessageDict[i],delete e.onerrorDict[i]},this.worker.onerror=function(r){if(e.pending-=1,r.data){var i=r.data.__postId,o=e.onerrorDict[i];o?o.call(e.worker,r):je.error("Worker.onerror",i,t,r),delete e.onmessageDict[i],delete e.onerrorDict[i]}else je.error("Worker.onerror",t,r)}};po.prototype.post=function(t,e,r,i){void 0===t&&(t={}),this.onmessageDict[this.postCount]=r,this.onerrorDict[this.postCount]=i,t.__name=this.name,t.__postId=this.postCount,t.__debug=He,He&&je.time("Worker.postMessage "+this.name+" #"+this.postCount);try{this.worker.postMessage(t,e)}catch(e){je.error("worker.post:",e),this.worker.postMessage(t)}return this.pending+=1,this.postCount+=1,this},po.prototype.terminate=function(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),Ke.activeWorkerCount-=1):je.log("no worker to terminate")};var fo=function(t,e){void 0===e&&(e=2),this.pool=[],this.count=0,this.maxCount=Math.min(8,e),this.name=t};function mo(t){for(var e=t.length,i=e/3,o=0,n=0,a=0,s=0;so&&(o=u),h>n&&(n=h),l>a&&(a=l)}return[_o([e,r,i]),_o([o,n,a])]}function vo(t,e){for(var r=0,i=e.length;r0){var s=1/Math.sqrt(a);t[e]=i*s,t[e+1]=o*s,t[e+2]=n*s}}}function _o(t){return new Float32Array(t||3)}function wo(t,e,r){var i=e[0],o=e[1],n=e[2],a=r[0],s=r[1],c=r[2];t[0]=o*c-n*s,t[1]=n*a-i*c,t[2]=i*s-o*a}function Ao(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function So(t,e,r){t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2]}function Co(t,e,r){t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2]}function Po(t,e,r){void 0===r&&(r=0),t[0]=e[r],t[1]=e[r+1],t[2]=e[r+2]}function Io(t,e,r){void 0===r&&(r=0),e[r]=t[0],e[r+1]=t[1],e[r+2]=t[2]}function Oo(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function ko(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])}function Mo(t,e,r){To(t,e,1/r)}function To(t,e,r){t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r}function Bo(t,e){var r=Oo(e);0==r?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):To(t,e,1/Math.sqrt(r))}function Do(t,e,r){t[0]=e[0]-r,t[1]=e[1]-r,t[2]=e[2]-r}function Eo(t,e,r){t[0]=e[0]+r,t[1]=e[1]+r,t[2]=e[2]+r}function Fo(t,e){t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2])}function Ro(t,e){t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2])}function $o(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}function Lo(t,e){void 0===e&&(e=9);for(var i=Math.floor(e/2),o=t.position1.length/3,n=3*(i*o),a=1/e,s=zr(t.position1,t.position2),c=new Float32Array(n),u=new Float32Array(n),h=new r,l=0;l0){var O=3*f;n[O]=t.position2[3*l-3],n[O+1]=t.position2[3*l-2],n[O+1]=t.position2[3*l-1]}var k=new Float32Array(o),M=new Float32Array(n),T=Nr(k,M),B=new Float32Array(a),D={position:T,position1:k,position2:M,color:B,color2:B};return s&&(D.radius=new Float32Array(s)),c&&t.picking&&(t.picking.array=new Float32Array(c),D.picking=t.picking),u&&(D.primitiveId=new Float32Array(u)),D}fo.prototype.post=function(t,e,r,i){void 0===t&&(t={});var o=this.getNextWorker();return o?o.post(t,e,r,i):console.error("unable to get worker from pool"),this},fo.prototype.terminate=function(){this.pool.forEach((function(t){t.terminate()}))},fo.prototype.getNextWorker=function(){for(var t,e=1/0,r=0;r=this.count){t=new po(this.name),this.pool.push(t),this.count+=1;break}var i=this.pool[r];if(0===i.pending){t=i;break}i.pending>this.exp),this.boundY=1+(r.max.y-this.minY>>this.exp),this.boundZ=1+(r.max.z-this.minZ>>this.exp);for(var i=this.boundX*this.boundY*this.boundZ,o=void 0!==t.count?t.count:t.x.length,n=t.x,a=t.y,s=t.z,u=0,h=new Uint32Array(i),l=new Int32Array(o),p=0;p>this.exp,f=a[p]-this.minY>>this.exp,m=s[p]-this.minZ>>this.exp,g=(d*this.boundY+f)*this.boundZ+m;1===(h[g]+=1)&&(u+=1),l[p]=g}for(var y=new Uint16Array(u),v=0,b=0;v0&&(h[v]=b+1,y[b]=x,b+=1)}for(var _=new Uint32Array(u),w=1;w0){var I=P-1;S[_[I]+A[I]]=C,A[I]+=1}}this.grid=h,this.bucketCount=y,this.bucketOffset=_,this.bucketArray=S,this.xArray=n,this.yArray=a,this.zArray=s};rn.prototype.within=function(t,e,r,i){var o=[];return this.eachWithin(t,e,r,i,(function(t){return o.push(t)})),o},rn.prototype.eachWithin=function(t,e,r,i,o){for(var n=i*i,a=Math.max(0,t-i-this.minX>>this.exp),s=Math.max(0,e-i-this.minY>>this.exp),c=Math.max(0,r-i-this.minZ>>this.exp),u=Math.min(this.boundX,1+(t+i-this.minX>>this.exp)),h=Math.min(this.boundY,1+(e+i-this.minY>>this.exp)),l=Math.min(this.boundZ,1+(r+i-this.minZ>>this.exp)),p=a;p0)for(var y=g-1,v=this.bucketOffset[y],b=v+this.bucketCount[y],x=v;xn?a.set(this[i].subarray(0,n)):a.set(this[i]),this[i]=a}},on.prototype.growIfFull=function(){if(this.count>=this.length){var t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}},on.prototype.copyFrom=function(t,e,r,i){for(var o=0,n=this._fields.length;o0;)c-=1;s<=c&&(s===a?a=c:c===a&&(a=s),(u=s)!==(h=c)&&(r.copyFrom(e,0,u,1),e.copyWithin(u,h,1),e.copyFrom(r,h,0,1)),s+=1,c-=1)}while(s<=c);i(o,c),i(s,n)}var u,h}(0,this.count-1),je.timeEnd("Store.sort")},on.prototype.clear=function(){this.count=0},on.prototype.dispose=function(){for(var t=0,e=this._fields.length;t>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}var cn=function(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()};function un(t){for(var e=t.edgeCount,r=t.nodeCount,i=t.nodeArray1,o=t.nodeArray2,n=new Uint8Array(r),a=new Int32Array(r),s=0;s0){var i=t.types,o=t.groups,n=t.centers,a=t.atomSets;i.push(e.type),o.push(e.group),n.x.push(e.x/r),n.y.push(e.y/r),n.z.push(e.z/r),a.push(e.atomSet)}}cn.prototype.get=function(t){return 0!=(this._words[t>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,a=e>>>5,s=n+1;s>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>r,this},cn.prototype._isRangeValue=function(t,e,r){if(!(e>>5,a=e>>>5,s=n+1;s>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<1||1!==e.number&&(i.index=e.index,n[a++].subVectors(e,t))})),1===a&&i.eachBondedAtom((function(e){a>1||1!==e.number&&e.index!==t.index&&n[a++].subVectors(e,t)})),2===a){var s=n[0].cross(n[1]);return Math.abs(Math.PI/2-s.angleTo(o))}}function Hn(t,e){var r=t.structure,i=r.atomCount,o=new Int8Array(i),n=new Int8Array(i),a=new Int8Array(i),s=new Int8Array(i);return r.eachAtom((function(t){var r=t.index,i=function(t,e){var r=t.bondToElementCount(1),i=t.formalCharge||0,o="always"===e.assignCharge||"auto"===e.assignCharge&&0===i,n="always"===e.assignH||"auto"===e.assignH&&0===r,a=t.bondCount,s=function(t){var e=0;return t.eachBond((function(t){return e+=t.bondOrder})),e}(t),c=function(t){var e=t.structure.getBondProxy(),r=t.number,i=8===r||7===r;if(i&&4===t.bondCount)return!1;var o=!1;return t.eachBond((function(r){if(r.bondOrder>1)o=!0;else if(i){var n=r.getOtherAtom(t);n.eachBond((function(t){if(t.bondOrder>1){var e=n.number;if((15===e||16===e)&&8===t.getOtherAtom(n).number)return;o=!0}}),e)}})),o}(t),u=s-a>0,h=0,l=8;switch(t.number){case 1:o&&(0===a?(i=1,l=0):1===a&&(i=0,l=1));break;case 6:o&&(i=0),n&&(h=Math.max(0,4-s-Math.abs(i))),l=jn(a+h+Math.max(0,-i));break;case 7:if(o)if(n)if(c&&s<4)i=a-r==1&&s-r==2?1:0;else{var p=!1;t.eachBondedAtom((function(t){(16===t.number||t.isMetal())&&(p=!0)})),i=p?0:1}else i=s-3;n&&(h=Math.max(0,3-s+i)),l=jn(c&&!u?a+h-i:a+h+1-i);break;case 8:o&&(n||(i=s-2),1===s&&t.eachBondedAtom((function(e){e.eachBond((function(r){var o=r.getOtherAtom(e);o.index!==t.index&&8===o.number&&2===r.bondOrder&&(i=-1)}))}))),n&&(h=Math.max(0,2-s+i)),l=jn(c&&!u?a+h-i+1:a+h-i+2);break;case 16:o&&(n||(i=s<=3&&!t.bondToElementCount(8)?s-2:0)),n&&s<2&&(h=Math.max(0,2-s+i)),s<=3&&(l=jn(a+h-i+2));break;case 9:case 17:case 35:case 53:case 85:o&&(i=s-1);break;case 3:case 11:case 19:case 37:case 55:case 87:o&&(i=1-s);break;case 4:case 12:case 20:case 38:case 56:case 88:o&&(i=2-s);break;default:console.warn("Requested charge, protonation for an unhandled element",t.element)}return[i,h,h+r,l]}(t,e),c=i[0],u=i[1],h=i[2],l=i[3];o[r]=c,n[r]=u,a[r]=h,s[r]=l})),{charge:o,implicitH:n,totalH:a,idealGeometry:s}}function Wn(t){if(t["@valenceModel"])return t["@valenceModel"];var e=Hn(t,{assignCharge:"auto",assignH:"auto"});return t["@valenceModel"]=e,e}function qn(t){return 15===t.number&&t.bondToElementCount(8)===t.bondCount}var Xn=["ARG","HIS","LYS"],Yn=["GLU","ASP"];function Kn(t,e,i){void 0===i&&(i={});for(var o=ht(i.maxIonicDist,na.maxIonicDist),n=ht(i.maxPiStackingDist,na.maxPiStackingDist),a=ht(i.maxPiStackingOffset,na.maxPiStackingOffset),s=ht(i.maxPiStackingAngle,na.maxPiStackingAngle),c=ht(i.maxCationPiDist,na.maxCationPiDist),u=ht(i.maxCationPiOffset,na.maxCationPiOffset),h=ht(i.masterModelIndex,na.masterModelIndex),l=Math.max(o+2,n,c),p=n*n,d=c*c,f=e.features,m=e.spatialHash,g=e.contactStore,y=e.featureSet,v=f.types,b=f.centers,x=f.atomSets,_=b.x,w=b.y,A=b.z,S=v.length,C=t.atomStore.x,P=t.atomStore.y,I=t.atomStore.z,O=t.getAtomProxy(),k=t.getAtomProxy(),M=new r,T=new r,B=new r,D=new r,E=new r,F=new r,R=new r,$=function(t,e){M.set(C[t[0]],P[t[0]],I[t[0]]),T.set(C[t[1]],P[t[1]],I[t[1]]),B.set(C[t[2]],P[t[2]],I[t[2]]),D.subVectors(M,T),E.subVectors(M,B),e.crossVectors(D,E)},L=function(t,e,r){return M.set(_[t],w[t],A[t]),T.set(_[e],w[e],A[e]),M.sub(T).projectOnPlane(r).add(T).distanceTo(T)},N=function(t,e,r){y.setBits(t,e),g.addContact(t,e,r)},z=function(t){m.eachWithin(_[t],w[t],A[t],l,(function(e,r){if(!(e<=t||(O.index=x[t][0],k.index=x[e][0],sa(O,k,h)))){var i=v[t],n=v[e];if(function(t,e){return 2===t&&1===e||1===t&&2===e}(i,n))(function(t,e,r){for(var i=t.length,o=e.length,n=0;n=180-s||c<=s+90&&c>=90-s)&&N(t,e,3)}}else if(function(t,e){return 3===t&&1===e||1===t&&3===e}(i,n)&&r<=d){var l=3===i?[t,e]:[e,t],f=l[0],m=l[1];$(x[f],F),L(m,f,F)<=u&&N(f,m,2)}}}))},j=0;j0&&(i[t.index]||(ln(o,t),pn(e,o)))})))}))}(t,e),function(t,e){var r=Wn(t.data).charge,i={};t.eachResidue((function(t){if(Yn.includes(t.resname)){var o=hn(2);t.eachAtom((function(t){8===t.number&&t.isSidechain()&&ln(o,t)})),pn(e,o)}else if(Dn.includes(t.resname)){var n=hn(2);t.eachAtom((function(t){qn(t)&&(n.group=6,t.eachBondedAtom((function(t){8===t.number&&ln(n,t)})),pn(e,n))}))}else kn.includes(t.resname)||Dn.includes(t.resname)||(t.eachAtom((function(t){var r=!1,o=hn(2);!function(t){return 16===t.number&&3===t.bondToElementCount(8)}(t)?qn(t)?(o.group=6,r=!0):function(t){return 16===t.number&&4===t.bondToElementCount(8)}(t)?(o.group=5,r=!0):function(t){var e=0;return 6===t.number&&2===t.bondToElementCount(8)&&1===t.bondToElementCount(6)&&t.eachBondedAtom((function(t){8===t.number&&t.bondCount-t.bondToElementCount(1)==1&&++e})),2===e}(t)&&(o.group=10,r=!0):(o.group=4,r=!0),r&&(t.eachBondedAtom((function(t){8===t.number&&(i[t.index]=!0,ln(o,t))})),pn(e,o))})),t.eachAtom((function(t){var o=hn(2);r[t.index]<0&&(i[t.index]||(ln(o,t),pn(e,o)))})))}))}(t,e),function(t,e){var r=t.getAtomProxy();t.eachResidue((function(t){var i=t.getAromaticRings();if(i){var o=t.atomOffset;i.forEach((function(t){var i=hn(3);t.forEach((function(t){r.index=t+o,ln(i,r)})),pn(e,i)}))}}))}(t,e),function(t,e){var r=Wn(t.data),i=r.charge,o=r.implicitH,n=r.idealGeometry;t.eachAtom((function(t){var r=hn(5),a=t.number;if(8===a)ln(r,t),pn(e,r);else if(7===a){if(Zn(t))ln(r,t),pn(e,r);else if(i[t.index]<1){var s=t.bondCount+o[t.index],c=n[t.index];(4===c&&s<4||3===c&&s<3||2===c&&s<2)&&(ln(r,t),pn(e,r))}}else 16===a&&("CYS"!==t.resname&&"MET"!==t.resname&&-1!==t.formalCharge||(ln(r,t),pn(e,r)))}))}(t,e),function(t,e){var r=Wn(t.data).totalH;t.eachAtom((function(t){var i=hn(4),o=t.number;(Zn(t)||r[t.index]>0&&(7===o||8===o||16===o))&&(ln(i,t),pn(e,i))}))}(t,e),function(t,e){var r=Wn(t.data).totalH;t.eachAtom((function(t){if(6===t.number&&r[t.index]>0&&(t.bondToElementCount(7)>0||t.bondToElementCount(8)>0||function(t){if(!t.isAromatic())return!1;var e=t.residueType.getRings();if(!e)return!1;var r=!1;return e.rings.forEach((function(e){r||e.some((function(e){return t.index-t.residueAtomOffset===e}))&&(r=e.some((function(e){var r=t.residueType.atomTypeIdList[e],i=t.atomMap.get(r).number;return 7===i||8===i})))})),r}(t))){var i=hn(9);ln(i,t),pn(e,i)}}))}(t,e),function(t,e){t.eachAtom((function(t){var r=!1,i=!1,o=kn.includes(t.resname),n=Dn.includes(t.resname);if(o||n?o?8===t.number?(["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(t.resname)&&t.isSidechain()||t.isBackbone())&&(r=!0,i=!0):16===t.number&&"CYS"===t.resname?(r=!0,i=!0):7===t.number&&"HIS"===t.resname&&t.isSidechain()&&(r=!0):n&&(8===t.number&&t.isBackbone()?(r=!0,i=!0):["N3","N4","N7"].includes(t.atomname)?r=!0:["O2","O4","O6"].includes(t.atomname)&&(r=!0,i=!0)):t.isHalogen()||8===t.number||16===t.number?(r=!0,i=!0):7===t.number&&(r=!0),r){var a=hn(11);ln(a,t),pn(e,a)}if(i){var s=hn(10);ln(s,t),pn(e,s)}}))}(t,e),function(t,e){t.eachAtom((function(t){if(t.isTransitionMetal()||30===t.number||48===t.number){var r=hn(12);ln(r,t),pn(e,r)}else if(Qn.includes(t.number)){var i=hn(13);ln(i,t),pn(e,i)}}))}(t,e),function(t,e){t.eachAtom((function(t){var r=hn(8),i=!1;6===t.number?(i=!0,t.eachBondedAtom((function(t){var e=t.number;6!==e&&1!==e&&(i=!1)}))):9===t.number&&(i=!0),i&&(ln(r,t),pn(e,r))}))}(t,e),function(t,e){t.eachAtom((function(t){if(ta.includes(t.number)){var r=!1;if(t.eachBondedAtom((function(t){ea.includes(t.number)&&(r=!0)})),r){var i=hn(7);ln(i,t),pn(e,i)}}}))}(t,e),function(t,e){t.eachAtom((function(t){if(Jn.includes(t.number)&&1===t.bondToElementCount(6)){var r=hn(6);ln(r,t),pn(e,r)}}))}(t,e),He&&je.timeEnd("calculateFeatures"),e}function ua(t,e){void 0===e&&(e=na);var i=function(t){var e=t.types,r=t.centers;return{features:t,spatialHash:new rn(r),contactStore:new an,featureSet:new cn(e.length,!1)}}(ca(t));He&&je.time("calculateContacts"),Kn(t,i,e),function(t,e,r){void 0===r&&(r={});for(var i=ht(r.maxHbondDist,na.maxHbondDist),o=ht(r.maxHbondSulfurDist,na.maxHbondSulfurDist),n=Ft(ht(r.maxHbondAccAngle,na.maxHbondAccAngle)),a=Ft(ht(r.maxHbondDonAngle,na.maxHbondDonAngle)),s=Ft(ht(r.maxHbondAccPlaneAngle,na.maxHbondAccPlaneAngle)),c=Ft(ht(r.maxHbondDonPlaneAngle,na.maxHbondDonPlaneAngle)),u=ht(r.masterModelIndex,na.masterModelIndex),h=Math.max(i,o),l=i*i,p=e.features,d=e.spatialHash,f=e.contactStore,m=e.featureSet,g=p.types,y=p.centers,v=p.atomSets,b=y.x,x=y.y,_=y.z,w=g.length,A=Wn(t.data).idealGeometry,S=t.getAtomProxy(),C=t.getAtomProxy(),P=function(t){d.eachWithin(b[t],x[t],_[t],h,(function(e,r){if(!(e<=t)){var i=g[t],o=g[e],h=function(t,e){return 9===t&&5===e||5===t&&9===e}(i,o);if(h||function(t,e){return 5===t&&4===e||4===t&&5===e}(i,o)){var p=5===o?[t,e]:[e,t],d=p[0],y=p[1];if(S.index=v[d][0],C.index=v[y][0],C.index!==S.index&&!sa(S,C,u)&&!(16!==S.number&&16!==C.number&&r>l||S.connectedTo(C))){var b=Gn(S,C),x=Vn.get(A[S.index])||Ft(120);if(!b.some((function(t){return Math.abs(x-t)>a}))){if(3===A[S.index]){var _=Un(S,C);if(void 0!==_&&_>c)return}var w=Gn(C,S),P=Vn.get(A[C.index])||Ft(120);if(!w.some((function(t){return P-t>n}))){if(3===A[C.index]){var I=Un(C,S);if(void 0!==I&&I>s)return}m.setBits(d,y);var O,k,M=h?8:function(t,e){return t.isWater()&&e.isWater()}(O=S,k=C)?9:function(t,e){return t.isBackbone()&&e.isBackbone()}(O,k)?10:4;f.addContact(d,y,M)}}}}}}))},I=0;Io)){var m=Gn(d,l);0!==m.length&&(m.some((function(t){return ia-t>o}))||(u.setBits(t,e),c.addContact(t,e,5)))}}}))},x=0;xr&&!oa(y,b,n)&&!oa(v,b,n)&&!o.includes(e)&&!c.includes(e)&&x.distanceToSquared(b)>1&&_.distanceToSquared(b)>1&&(s.clear(t),He&&je.log("removing",y.qualifiedName(),v.qualifiedName(),"because",b.qualifiedName()))}))})),He&&je.timeEnd("refineLineOfSight")}(t,o,e),function(t,e){var r=e.contactSet,i=e.contactStore,o=e.features,n=i.type,a=i.index1,s=i.index2,c=o.atomSets,u=t.getAtomProxy(),h=t.getAtomProxy(),l={},p=function(t,e,i){var o=l[i]||[1/0,-1],n=o[0],a=o[1];t=d){D=v,k=!0;break}if(k)break}if(k)break}for(k=!1,y=n;y=d){B=y,k=!0;break}if(k)break}if(k)break}for(k=!1,m=o;m=d){T=m,k=!0;break}if(k)break}if(k)break}for(k=!1,v=h;v>=s;--v){for(y=u;y>=n;--y){for(m=c;m>=o;--m)if(t[l=e*r*v+e*y+m]>=d){$=v,k=!0;break}if(k)break}if(k)break}for(k=!1,y=u;y>=n;--y){for(v=$;v>=s;--v){for(m=c;m>=o;--m)if(t[l=e*r*v+e*y+m]>=d){R=y,k=!0;break}if(k)break}if(k)break}for(k=!1,m=c;m>=o;--m){for(y=R;y>=n;--y){for(v=$;v>=s;--v)if(t[l=e*r*v+e*y+m]>=d){E=m,k=!0;break}if(k)break}if(k)break}f?(o=Math.max(0,T-1),n=Math.max(0,B-1),s=Math.max(0,D-1),c=Math.min(e-1,E+1),u=Math.min(r-1,R+1),h=Math.min(i-1,$+1)):(o=Math.max(1,T-1),n=Math.max(1,B-1),s=Math.max(1,D-1),c=Math.min(e-2,E+1),u=Math.min(r-2,R+1),h=Math.min(i-2,$+1))}var L=15;for(v=s;v0?-1:1,n||(n=new Float32Array(3*b)));var I=3*b;if(a&&a.length===I||(a=new Int32Array(I)),s=0,c=0,void 0!==x){var O=x[0].map(Math.round),k=x[1].map(Math.round);u=e*Math.ceil(Math.abs(O[0])/e),h=r*Math.ceil(Math.abs(O[1])/r),l=i*Math.ceil(Math.abs(O[2])/i),R(O[0],O[1],O[2],k[0],k[1],k[2])}else u=h=l=0,R();return A.length=3*s,f||(S.length=3*s),C.length=c,o&&(P.length=s),{position:new Float32Array(A),normal:f?void 0:new Float32Array(S),index:Ct(C,A.length/3),atomindex:o?new Int32Array(P):void 0,contour:m}}}nr.add("arrow",va),nr.add("box",Oa),nr.add("cone",Aa),nr.add("cylinder",ya),nr.add("ellipsoid",Pa),nr.add("octahedron",Ia),nr.add("sphere",Ta),nr.add("tetrahedron",Da),nr.add("torus",Ea),nr.add("point",La),nr.add("wideline",Na),Object.assign(Va,{__deps:[za,ja,Ct]});var Ga=function(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)};function Ua(t,e){for(var r=0,i=0,o=e.rows,n=e.cols,a=0,s=0,c=0,u=e.data,h=t.data;r(e=Math.abs(e))?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}Ga.prototype.copyTo=function(t){t.data.set(this.data)};function Za(t,e,r,i){var o=0,n=0,a=t.rows,s=t.cols,c=a,u=s;c>16)?B:-B,t[c*e+h]=T;for(l=0;l<2;l++)for(u=0;ur){var i=e;e=r,r=i}var o=t[e];return void 0===o?(t[e]=[r],!0):!o.includes(r)&&(o.push(r),!0)}var r=this.geometry,i=r.index;if(this.parameters.wireframe)if(i){var o,n=i.array,a=n.length;if(r.drawRange.count!==1/0&&(a=r.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*a)o=this.wireframeIndex;else o=Ct(2*a,r.attributes.position.count);var s=0;t.length=0;for(var c=0;c2*d?this.wireframeIndex:Ct(2*d,d);for(var f=0,m=0;fthis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new M(this.wireframeIndex,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0));else{var t=this.wireframeGeometry.getIndex();if(!t)return void je.error("Index is null");t.set(this.wireframeIndex),t.needsUpdate=this.wireframeIndexCount>0,t.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}},xs.prototype.getRenderOrder=function(){var t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t},xs.prototype._getMesh=function(t){this.material||this.makeMaterial();var e,r=this.geometry,i=this[t];return(e=this.isLine?new T(r,i):this.isPoint?new s(r,i):new I(r,i)).frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e},xs.prototype.getMesh=function(){return this._getMesh("material")},xs.prototype.getWireframeMesh=function(){var t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),(t=new T(this.wireframeGeometry,this.wireframeMaterial)).frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},xs.prototype.getPickingMesh=function(){return this._getMesh("pickingMaterial")},xs.prototype.getShader=function(t,e){return Or(t,this.getDefines(e))},xs.prototype.getVertexShader=function(t){return this.getShader(this.vertexShader,t)},xs.prototype.getFragmentShader=function(t){return this.getShader(this.fragmentShader,t)},xs.prototype.getDefines=function(t){var e={};return this.parameters.clipNear&&(e.NEAR_CLIP=1),this.parameters.clipRadius&&(e.RADIUS_CLIP=1),"picking"===t?e.PICKING=1:(("background"===t||this.parameters.background)&&(e.NOLIGHT=1),this.parameters.flatShaded&&(e.FLAT_SHADED=1),this.parameters.opaqueBack&&(e.OPAQUE_BACK=1),this.parameters.diffuseInterior&&(e.DIFFUSE_INTERIOR=1),this.parameters.useInteriorColor&&(e.USE_INTERIOR_COLOR=1)),e},xs.prototype.getParameters=function(){return this.parameters},xs.prototype.addUniforms=function(t){this.uniforms=R.merge([this.uniforms,t]),this.pickingUniforms=R.merge([this.pickingUniforms,t])},xs.prototype.addAttributes=function(t){for(var e in t){var r=void 0,i=t[e],o=this.attributeSize*gs[i.type];i.value?(o!==i.value.length&&je.error("attribute value has wrong length",e),r=i.value):r=St("float32",o),this.geometry.setAttribute(e,new M(r,gs[i.type]).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0))}},xs.prototype.updateRenderOrder=function(){var t=this.getRenderOrder();function e(e){e.renderOrder=t}this.group.children.forEach(e),this.pickingGroup&&this.pickingGroup.children.forEach(e)},xs.prototype.updateShader=function(){var t=this.material,e=this.wireframeMaterial,r=this.pickingMaterial;t.vertexShader=this.getVertexShader(),t.fragmentShader=this.getFragmentShader(),t.needsUpdate=!0,e.vertexShader=this.getShader("Line.vert"),e.fragmentShader=this.getShader("Line.frag"),e.needsUpdate=!0,r.vertexShader=this.getVertexShader("picking"),r.fragmentShader=this.getFragmentShader("picking"),r.needsUpdate=!0},xs.prototype.setParameters=function(t){var e=t,r=this.parameterTypes,i=this.parameters,o={},n={},a=!1,s=!1;for(var c in e){var u=e[c];void 0!==u&&(i[c]=u,void 0!==r[c]&&(r[c].property&&(!0!==r[c].property?o[r[c].property]=u:o[c]=u),r[c].uniform&&(!0!==r[c].uniform?n[r[c].uniform]=u:n[c]=u),r[c].updateShader&&(a=!0),r[c].updateVisibility&&(s=!0),this.dynamic&&"wireframe"===c&&!0===u&&this.updateWireframeIndex(),"forceTransparent"===c&&(o.transparent=this.transparent),"matrix"===c&&(this.matrix=u)))}this.setProperties(o),this.setUniforms(n),a&&this.updateShader(),s&&this.setVisibility(this.visible)},xs.prototype.setAttributes=function(t){var e=this.geometry,r=e.attributes;for(var i in t)if("picking"!==i){var o=t[i],n=o.length;if("index"===i){var a=e.getIndex();if(!a){je.error("Index is null");continue}e.setDrawRange(0,1/0),n>a.array.length?e.setIndex(new M(o,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(a.set(o),a.count=n,a.needsUpdate=n>0,a.updateRange.count=n,e.setDrawRange(0,n)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{var s=r[i];n>s.array.length?e.setAttribute(i,new M(o,s.itemSize).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(r[i].set(o),r[i].needsUpdate=n>0,r[i].updateRange.count=n)}}},xs.prototype.setUniforms=function(t){if(t){var e=this.material.uniforms,r=this.wireframeMaterial.uniforms,i=this.pickingMaterial.uniforms;for(var o in t)"opacity"===o&&this.setProperties({transparent:this.transparent}),void 0!==e[o]&&(e[o].value.isVector3?e[o].value.copy(t[o]):e[o].value.set?e[o].value.set(t[o]):e[o].value=t[o]),void 0!==r[o]&&(r[o].value.isVector3?r[o].value.copy(t[o]):r[o].value.set?r[o].value.set(t[o]):r[o].value=t[o]),void 0!==i[o]&&(i[o].value.isVector3?i[o].value.copy(t[o]):i[o].value.set?i[o].value.set(t[o]):i[o].value=t[o])}},xs.prototype.setProperties=function(t){if(t){var e=this.material,r=this.wireframeMaterial,i=this.pickingMaterial;for(var o in t){var n=o,a=t[n];"transparent"===n?this.updateRenderOrder():"side"===n&&(a=ms(a)),e[n]=a,r[n]=a,i[n]=a}e.needsUpdate=!0,r.needsUpdate=!0,i.needsUpdate=!0}},xs.prototype.setVisibility=function(t){this.visible=t,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))},xs.prototype.dispose=function(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()},xs.prototype.toJSON=function(){var t={};for(var e in this)"group"!==e&&"wireframeGroup"!==e&&"pickingGroup"!=e&&"picking"!==e&&(t[e]=this[e]);return t},Object.defineProperties(xs.prototype,_s);var ws=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,e,r),this.vertexShader="Mesh.vert",this.fragmentShader="Mesh.frag",this.addAttributes({normal:{type:"v3",value:e.normal}}),void 0===e.normal&&this.geometry.computeVertexNormals()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(xs),As=function(t){function e(){t.apply(this,arguments),this.isSurface=!0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(ws);function Ss(t){t.visible=!0}function Cs(t){t.visible=!1}var Ps=function(t){this.group=new f,this.wireframeGroup=new f,this.pickingGroup=new f,this.frontMeshes=[],this.backMeshes=[],this.size=t.size,this.side=t.parameters.side,this.visible=t.visible,this.geometry=t.geometry,this.picking=t.picking,this.group=new f,this.wireframeGroup=new f,this.pickingGroup=new f,this.matrix=t.matrix;var e=t,r=new t.constructor({position:new Float32Array(0)});e.makeMaterial(),r.makeMaterial(),r.picking=t.picking,r.geometry=t.geometry,r.wireframeGeometry=t.wireframeGeometry,r.setParameters(t.getParameters()),r.updateShader(),e.setParameters({side:"front"}),r.setParameters({side:"back",opacity:r.parameters.opacity}),this.buffer=t,this.frontBuffer=e,this.backBuffer=r},Is={matrix:{configurable:!0},pickable:{configurable:!0},parameters:{configurable:!0}};Is.matrix.set=function(t){xs.prototype.setMatrix.call(this,t)},Is.matrix.get=function(){return this.group.matrix.clone()},Is.pickable.get=function(){return!!this.picking&&!this.parameters.disablePicking},Is.parameters.get=function(){return this.buffer.parameters},Ps.prototype.getParameters=function(){var t=Object.assign({},this.buffer.parameters);return t.side=this.side,t},Ps.prototype.getMesh=function(t){var e,r;return t?(r=this.backBuffer.getPickingMesh(),e=this.frontBuffer.getPickingMesh()):(r=this.backBuffer.getMesh(),e=this.frontBuffer.getMesh()),this.frontMeshes.push(e),this.backMeshes.push(r),this.setParameters({side:this.side}),(new f).add(r,e)},Ps.prototype.getWireframeMesh=function(){return this.buffer.getWireframeMesh()},Ps.prototype.getPickingMesh=function(){return this.getMesh(!0)},Ps.prototype.setAttributes=function(t){this.buffer.setAttributes(t)},Ps.prototype.setParameters=function(t){"front"===(t=Object.assign({},t)).side?(this.frontMeshes.forEach(Ss),this.backMeshes.forEach(Cs)):"back"===t.side?(this.frontMeshes.forEach(Cs),this.backMeshes.forEach(Ss)):"double"===t.side&&(this.frontMeshes.forEach(Ss),this.backMeshes.forEach(Ss)),void 0!==t.side&&(this.side=t.side),delete t.side,void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,this.frontBuffer.setParameters(t),void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),delete t.wireframe,this.backBuffer.setParameters(t)},Ps.prototype.setVisibility=function(t){this.visible=t,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))},Ps.prototype.dispose=function(){this.frontBuffer.dispose(),this.backBuffer.dispose()},Ps.prototype.toJSON=function(){var t={};for(var e in this)["side","size","visible","matrix","parameters"].includes(e)&&(t[e]=this[e]);return t},Object.defineProperties(Ps.prototype,Is),er.add("shader/Line.vert","uniform float clipNear;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),er.add("shader/Line.frag","uniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");var Os=function(t){function e(){t.apply(this,arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(xs),ks=function(t){function e(e,o,n){t.call(this,e,o,n),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},isolevelScroll:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),e instanceof ds?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new r,this.__boxCenter=new r,this.box=new c,this.__box=new c,this._position=new r,this.inverseMatrix=new i,this.setBox=function(){this._position.copy(o.translationGroup.position).negate(),this._position.applyMatrix4(this.inverseMatrix),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(n)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.colorScheme=ht(r.colorScheme,"uniform"),r.colorValue=ht(r.colorValue,14540253),this.isolevelType=ht(r.isolevelType,"sigma"),this.isolevel=ht(r.isolevel,2),this.negateIsolevel=ht(r.negateIsolevel,!1),this.isolevelScroll=ht(r.isolevelScroll,!1),this.smooth=ht(r.smooth,0),this.background=ht(r.background,!1),this.opaqueBack=ht(r.opaqueBack,!0),this.boxSize=ht(r.boxSize,0),this.colorVolume=ht(r.colorVolume,void 0),this.contour=ht(r.contour,!1),this.useWorker=ht(r.useWorker,!0),this.wrap=ht(r.wrap,!1),t.prototype.init.call(this,r),this.inverseMatrix.getInverse(this.matrix),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach((function(t){e.viewer.add(t)})),this.setVisibility(this.visible),t()},e.prototype.prepare=function(t){var e,r=this;if(this.volume)if(e="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(e*=-1),!this.surface||this.__isolevel!==e||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=e,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);var i=function(e){r.surface=e,t()};this.useWorker?this.volume.getSurfaceWorker(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else t();else t()},e.prototype.create=function(){var t,e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};if(this.contour)t=new Os(e,this.getBufferParams({wireframe:!1}));else{Object.assign(e,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});var r=new As(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new Ps(r)}this.bufferList.push(t)},e.prototype.update=function(t){if(0!==this.bufferList.length){var e={};(t=t||{}).position&&(e.position=this.surface.getPosition()),t.color&&(e.color=this.surface.getColor(this.getColorParams())),t.index&&(e.index=this.surface.getIndex()),t.normal&&(e.normal=this.surface.getNormal()),this.bufferList.forEach((function(t){t.setAttributes(e)}))}},e.prototype.setParameters=function(e,r,i){return e&&void 0!==e.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===e.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===e.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=e.isolevelType),e&&e.boxCenter&&(this.boxCenter.copy(e.boxCenter),delete e.boxCenter),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),t.prototype.setParameters.call(this,e,r,i),e.matrix&&this.inverseMatrix.getInverse(e.matrix),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&void 0!==e.colorVolume&&r&&(r.color=!0),this.surface&&(void 0!==e.isolevel||void 0!==e.negateIsolevel||void 0!==e.smooth||void 0!==e.wrap||void 0!==e.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.volume=this.colorVolume,e},e.prototype.dispose=function(){this.viewer.signals.ticked.remove(this.setBox,this),t.prototype.dispose.call(this)},e}(lo),Ms=function(){};Ms.zoomScroll=function(t,e){t.trackballControls.zoom(e)},Ms.clipNearScroll=function(t,e){var r=t.getParameters();t.setParameters({clipNear:r.clipNear+e/10})},Ms.focusScroll=function(t,e){var r=t.getFocus(),i=Math.sign(e)*function(t,e,r){if(t>e)return t;var i=t/e;return((2*r-e)*i+(2*e-3*r))*i*i+r}((100-r)/10,5,.2);t.setFocus(r+i)},Ms.zoomFocusScroll=function(t,e){t.trackballControls.zoom(e);var r=t.viewer.camera.position.z;t.setFocus(100-Math.abs(r/8))},Ms.isolevelScroll=function(t,e){var r=Math.sign(e)/10;t.eachRepresentation((function(t,e){if(t.repr instanceof ks){var i=t.getParameters();i.isolevelScroll&&t.setParameters({isolevel:i.isolevel+r})}}))},Ms.panDrag=function(t,e,r){t.trackballControls.pan(e,r)},Ms.rotateDrag=function(t,e,r){t.trackballControls.rotate(e,r)},Ms.zRotateDrag=function(t,e,r){t.trackballControls.zRotate(e,r)},Ms.zoomDrag=function(t,e,r){t.trackballControls.zoom((e+r)/-2)},Ms.zoomFocusDrag=function(t,e,r){t.trackballControls.zoom((e+r)/-2);var i=t.viewer.camera.position.z;t.setFocus(100-Math.abs(i/8))},Ms.panComponentDrag=function(t,e,r){t.trackballControls.panComponent(e,r)},Ms.panAtomDrag=function(t,e,r){t.trackballControls.panAtom(e,r)},Ms.rotateComponentDrag=function(t,e,r){t.trackballControls.rotateComponent(e,r)},Ms.movePick=function(t,e){e&&t.animationControls.move(e.position.clone())},Ms.tooltipPick=function(t,e){var r=t.tooltip;if(t.getParameters().tooltip&&e){var i=e.mouse.position;r.innerText=e.getLabel(),r.style.bottom=window.innerHeight-i.y+3+"px",r.style.left=i.x+3+"px",r.style.display="block"}else r.style.display="none"};var Ts={default:[["scroll",Ms.zoomScroll],["scroll-shift",Ms.focusScroll],["scroll-ctrl",Ms.isolevelScroll],["scroll-shift-ctrl",Ms.zoomFocusScroll],["drag-left",Ms.rotateDrag],["drag-right",Ms.panDrag],["drag-ctrl-left",Ms.panDrag],["drag-ctrl-right",Ms.zRotateDrag],["drag-shift-left",Ms.zoomDrag],["drag-middle",Ms.zoomFocusDrag],["drag-ctrl-shift-right",Ms.panComponentDrag],["drag-ctrl-shift-left",Ms.rotateComponentDrag],["clickPick-right",Ms.measurePick=function(t,e){if(e&&(e.atom||e.bond)){var r=e.atom||e.closestBondAtom;e.component.measurePick(r)}else t.measureClear()}],["clickPick-ctrl-left",Ms.measurePick],["clickPick-middle",Ms.movePick],["clickPick-left",Ms.movePick],["hoverPick",Ms.tooltipPick]],pymol:[["drag-left",Ms.rotateDrag],["drag-middle",Ms.panDrag],["drag-right",Ms.zoomDrag],["drag-shift-right",Ms.focusScroll],["clickPick-ctrl+shift-middle",Ms.movePick],["hoverPick",Ms.tooltipPick]],coot:[["scroll",Ms.isolevelScroll],["drag-left",Ms.rotateDrag],["drag-middle",Ms.panDrag],["drag-ctrl-left",Ms.panDrag],["drag-right",Ms.zoomFocusDrag],["drag-ctrl-right",Ms.focusScroll],["clickPick-middle",Ms.movePick],["hoverPick",Ms.tooltipPick]],astexviewer:[["drag-left",Ms.rotateDrag],["drag-ctrl-left",Ms.panDrag],["drag-shift-left",Ms.zoomDrag],["scroll",Ms.focusScroll],["clickPick-middle",Ms.movePick],["hoverPick",Ms.tooltipPick]]};function Bs(t){var e=t.split(/[-+]/),r="";e.includes("scroll")&&(r="scroll"),e.includes("drag")&&(r="drag"),e.includes("click")&&(r="click"),e.includes("doubleClick")&&(r="doubleClick"),e.includes("hover")&&(r="hover"),e.includes("clickPick")&&(r="clickPick"),e.includes("hoverPick")&&(r="hoverPick");var i=0;e.includes("alt")&&(i+=1),e.includes("ctrl")&&(i+=2),e.includes("meta")&&(i+=4),e.includes("shift")&&(i+=8);var o=0;return e.includes("left")&&(o+=1),e.includes("right")&&(o+=2),e.includes("middle")&&(o+=4),[r,i,o]}var Ds=function(t,e){void 0===e&&(e={}),this.stage=t,this.actionList=[],this.mouse=t.mouseObserver,this.disabled=e.disabled||!1,this.preset(e.preset||"default")};Ds.prototype.run=function(t){for(var e=this,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];if(!this.disabled){var o=this.mouse.key||0,n=this.mouse.buttons||0;this.actionList.forEach((function(i){i.type===t&&i.key===o&&i.button===n&&i.callback.apply(i,[e.stage].concat(r))}))}},Ds.prototype.add=function(t,e){var r=Bs(t),i=r[0],o=r[1],n=r[2];this.actionList.push({type:i,key:o,button:n,callback:e})},Ds.prototype.remove=function(t,e){var r=t.includes("*"),i=Bs(t),o=i[0],n=i[1],a=i[2],s=this.actionList.filter((function(t){return!((t.type===o||r&&""===o)&&(t.key===n||r&&0===n)&&(t.button===a||r&&0===a)&&(t.callback===e||void 0===e))}));this.actionList=s},Ds.prototype.preset=function(t){var e=this;this.clear(),(Ts[t]||[]).forEach((function(t){return e.add(t[0],t[1])}))},Ds.prototype.clear=function(){this.actionList.length=0};var Es=function(){};Es.autoView=function(t){t.autoView(1e3)},Es.toggleAnimations=function(t){t.animationControls.toggle()},Es.toggleRock=function(t){t.toggleRock()};var Fs={default:[["i",Es.toggleSpin=function(t){t.toggleSpin()}],["k",Es.toggleRock],["p",Es.toggleAnimations],["a",Es.toggleAntialiasing=function(t){var e=t.getParameters();t.setParameters({sampleLevel:-1===e.sampleLevel?0:-1})}],["r",Es.autoView]]},Rs=function(t,e){void 0===e&&(e={}),this.stage=t,this.actionList=[],this.disabled=e.disabled||!1,this.preset(e.preset||"default")};Rs.prototype.run=function(t){var e=this;this.disabled||this.actionList.forEach((function(r){r.key===t&&r.callback(e.stage)}))},Rs.prototype.add=function(t,e){this.actionList.push({key:t,callback:e})},Rs.prototype.remove=function(t,e){var r=this.actionList.filter((function(r){return!(r.key===t&&(r.callback===e||void 0===e))}));this.actionList=r},Rs.prototype.preset=function(t){var e=this;this.clear(),(Fs[t]||[]).forEach((function(t){return e.add(t[0],t[1])}))},Rs.prototype.clear=function(){this.actionList.length=0};var $s=function(t){this.stage=t,this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)};$s.prototype._onClick=function(t,e){var r=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(r),this.controls.run("clickPick",r)},$s.prototype._onHover=function(t,e){var r=this.stage.pickingControls.pick(t,e);r&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=r.component,this.stage.transformAtom=r.atom),this.stage.signals.hovered.dispatch(r),this.controls.run("hoverPick",r)},$s.prototype.dispose=function(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Ls=function(t){this.stage=t,this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)};Ls.prototype._onMove=function(){this.stage.tooltip.style.display="none"},Ls.prototype._onScroll=function(t){this.controls.run("scroll",t)},Ls.prototype._onDrag=function(t,e){this.controls.run("drag",t,e)},Ls.prototype._onClick=function(t,e){this.controls.run("click",t,e)},Ls.prototype._onDblclick=function(t,e){this.controls.run("doubleClick",t,e)},Ls.prototype._onHover=function(t,e){this.controls.run("hover",t,e)},Ls.prototype.dispose=function(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Ns=function(t){this.stage=t,this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)};Ns.prototype._onTick=function(t){this.animationControls.run(t)},Ns.prototype.dispose=function(){this.viewer.signals.ticked.remove(this._onTick,this)};var zs=!!Ee&&{passive:!0},js=function(t){this.stage=t,this.stage=t,this.controls=t.keyControls,this.domElement=t.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,zs),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)};js.prototype._onKeydown=function(){},js.prototype._onKeyup=function(){},js.prototype._onKeypress=function(t){var e;e="key"in KeyboardEvent.prototype?t.key:String.fromCharCode(t.which||t.keyCode),this.controls.run(e)},js.prototype._focusDomElement=function(){this.domElement.focus()},js.prototype.dispose=function(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,zs),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)};var Vs=function(t,i,o,n){void 0===n&&(n={}),this.component=t,this.position=i,this.offsetX=ht(n.offsetX,0),this.offsetY=ht(n.offsetY,0),this.visible=ht(n.visible,!0),this.stage=t.stage,this.viewer=t.stage.viewer,this._viewerPosition=new r,this._updateViewerPosition(),this._canvasPosition=new e,this._cameraPosition=new r,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",left:"-10000px"}),this.viewer.wrapper.appendChild(this.element),this.setContent(o),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)};Vs.prototype.setContent=function(t){var e=this.element.style.display;if("none"===e&&(this.element.style.left="-10000px",this.element.style.display="block"),t instanceof HTMLElement)this.element.appendChild(t);else{var r=document.createElement("div");r.innerText=t,Object.assign(r.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(r)}this._clientRect=this.element.getBoundingClientRect(),"none"===e&&(this.element.style.display=e)},Vs.prototype.setVisibility=function(t){this.visible=t,this.updateVisibility()},Vs.prototype.getVisibility=function(){return this.visible&&this.component.parameters.visible},Vs.prototype.updateVisibility=function(){this.element.style.display=this.getVisibility()?"block":"none"},Vs.prototype._updateViewerPosition=function(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)},Vs.prototype._update=function(){if(this.getVisibility()){var t=this.element.style,e=this._canvasPosition,r=this._viewerPosition,i=this._clientRect;if(this._cameraPosition.copy(r).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)t.display="none";else{t.display="block";var o=this._cameraPosition.length(),n=this.viewer.scene.fog;t.opacity=(1-Vt(n.near,n.far,o)).toString(),t.zIndex=Math.round(100*(n.far-o)).toString(),this.stage.viewerControls.getPositionOnCanvas(r,e),t.bottom=this.offsetX+e.y+i.height/2+"px",t.left=this.offsetY+e.x-i.width/2+"px"}}},Vs.prototype.dispose=function(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)};var Gs=new i,Us=new r,Hs=new o,Ws=function(t){this.component=t,this.signals={changed:new et.Signal},this.stage=t.stage,this.viewer=t.stage.viewer},qs={position:{configurable:!0},rotation:{configurable:!0}};qs.position.get=function(){return this.component.position},qs.rotation.get=function(){return this.component.quaternion},Ws.prototype.changed=function(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()},Ws.prototype.spin=function(t,e){Gs.getInverse(this.viewer.rotationGroup.matrix),Us.copy(Ot(t)).applyMatrix4(Gs),Gs.extractRotation(this.component.transform),Gs.premultiply(this.viewer.rotationGroup.matrix),Gs.getInverse(Gs),Us.copy(Ot(t)),Us.applyMatrix4(Gs),Gs.makeRotationAxis(Us,e),Hs.setFromRotationMatrix(Gs),this.component.quaternion.premultiply(Hs),this.changed()},Object.defineProperties(Ws.prototype,qs);var Xs={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"},Ys=function(t){void 0===t&&(t={}),this.max=10,this.type=ht(t.type,"size"),this.scale=ht(t.scale,1),this.size=ht(t.size,1),this.data=ht(t.data,{})};Ys.prototype.atomRadius=function(t){var e;switch(this.type){case"vdw":e=t.vdw;break;case"covalent":e=t.covalent;break;case"bfactor":e=t.bfactor||1;break;case"sstruc":var r=t.sstruc;e="h"===r||"g"===r||"i"===r||"e"===r||"b"===r?.25:Ln.includes(t.atomname)?.4:.1;break;case"data":e=ht(this.data[t.index],1);break;case"explicit":null===(e=t.radius)&&(e=this.size);break;default:e=this.size}return Math.min(e*this.scale,this.max)},Ys.types=Xs;var Ks=new r(-1,-1,-1),Zs=new i,Qs=function(t){var e=t.rows,i=e/3,o=new Ga(e,3),n=new Ga(3,3),a=new Ga(1,3),s=new Ga(3,3),c=new Ga(3,3),u=qa(t);Xa(t,u),Ua(o,t),Ha(n,o,o),Za(n,a,s,c);var h=new r(u[0],u[1],u[2]),l=new r(s.data[0],s.data[3],s.data[6]),p=new r(s.data[1],s.data[4],s.data[7]),d=new r(s.data[2],s.data[5],s.data[8]),f=l.clone().multiplyScalar(Math.sqrt(a.data[0]/i)),m=p.clone().multiplyScalar(Math.sqrt(a.data[1]/i)),g=d.clone().multiplyScalar(Math.sqrt(a.data[2]/i));this.begA=h.clone().sub(f),this.endA=h.clone().add(f),this.begB=h.clone().sub(m),this.endB=h.clone().add(m),this.begC=h.clone().sub(g),this.endC=h.clone().add(g),this.center=h,this.vecA=f,this.vecB=m,this.vecC=g,this.normVecA=l,this.normVecB=p,this.normVecC=d};Qs.prototype.getBasisMatrix=function(t){void 0===t&&(t=new i);var e=t;return e.makeBasis(this.normVecB,this.normVecA,this.normVecC),e.determinant()<0&&e.scale(Ks),e},Qs.prototype.getRotationQuaternion=function(t){void 0===t&&(t=new o);var e=t;return e.setFromRotationMatrix(this.getBasisMatrix(Zs)),e.inverse()},Qs.prototype.getProjectedScaleForAtoms=function(t){var e=-1/0,i=-1/0,o=-1/0,n=-1/0,a=-1/0,s=-1/0,c=new r,u=new r,h=this.center,l=this.normVecA,p=this.normVecB,d=this.normVecC;return t.eachAtom((function(t){go(c.copy(t),l,h);var r=u.subVectors(c,h).normalize().dot(l),f=c.distanceTo(h);r>0?f>e&&(e=f):f>i&&(i=f),go(c.copy(t),p,h);var m=u.subVectors(c,h).normalize().dot(p),g=c.distanceTo(h);m>0?g>o&&(o=g):g>n&&(n=g),go(c.copy(t),d,h);var y=u.subVectors(c,h).normalize().dot(d),v=c.distanceTo(h);y>0?v>a&&(a=v):v>s&&(s=v)})),{d1a:e,d2a:o,d3a:a,d1b:-i,d2b:-n,d3b:-s}};var Js=function(t,e,r,i){this.volume=t,this.setFilter(e,r,i)},tc={header:{configurable:!0},matrix:{configurable:!0},normalMatrix:{configurable:!0},inverseMatrix:{configurable:!0},center:{configurable:!0},boundingBox:{configurable:!0},min:{configurable:!0},max:{configurable:!0},mean:{configurable:!0},rms:{configurable:!0}};tc.header.get=function(){return this.volume.header},tc.matrix.get=function(){return this.volume.matrix},tc.normalMatrix.get=function(){return this.volume.normalMatrix},tc.inverseMatrix.get=function(){return this.volume.inverseMatrix},tc.center.get=function(){return this.volume.center},tc.boundingBox.get=function(){return this.volume.boundingBox},tc.min.get=function(){return this.volume.min},tc.max.get=function(){return this.volume.max},tc.mean.get=function(){return this.volume.mean},tc.rms.get=function(){return this.volume.rms},Js.prototype._getFilterHash=function(t,e,r){return JSON.stringify([t,e,r])},Js.prototype.setFilter=function(t,e,r){isNaN(t)&&this.header&&(t=this.header.DMEAN+2*this.header.ARMS),t=void 0===t||isNaN(t)?-1/0:t,e=ht(e,1/0),r=ht(r,!1);var i=this.volume.data,o=this.volume.position,n=this.volume.atomindex,a=this._getFilterHash(t,e,r);if(a!==this._filterHash){if(t===-1/0&&e===1/0)this.data=i,this.position=o,this.atomindex=n;else{var s=i.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*s),this._positionBuffer=new ArrayBuffer(3*s*4),n&&(this._atomindexBuffer=new ArrayBuffer(4*s)));var c,u=new Float32Array(this._dataBuffer),h=new Float32Array(this._positionBuffer);n&&(c=new Uint32Array(this._atomindexBuffer));for(var l=0,p=0;p=t&&f<=e||r&&(fe)){var m=3*l;u[l]=f,h[m+0]=o[d+0],h[m+1]=o[d+1],h[m+2]=o[d+2],n&&c&&(c[l]=n[p]),l+=1}}this.data=new Float32Array(this._dataBuffer,0,l),this.position=new Float32Array(this._positionBuffer,0,3*l),n&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,l))}this._filterHash=a}},Object.defineProperties(Js.prototype,tc),Js.prototype.getValueForSigma=ds.prototype.getValueForSigma,Js.prototype.getSigmaForValue=ds.prototype.getSigmaForValue,Js.prototype.getDataAtomindex=ds.prototype.getDataAtomindex,Js.prototype.getDataPosition=ds.prototype.getDataPosition,Js.prototype.getDataColor=ds.prototype.getDataColor,Js.prototype.getDataPicking=ds.prototype.getDataPicking,Js.prototype.getDataSize=ds.prototype.getDataSize;var ec=function(t,e){var r=un({nodeArray1:t.atomIndex1,nodeArray2:t.atomIndex2,edgeCount:t.count,nodeCount:e});this.countArray=r.countArray,this.offsetArray=r.offsetArray,this.indexArray=r.indexArray},rc=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={_defaultFields:{configurable:!0}};return r._defaultFields.get=function(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]},e.prototype.addBond=function(t,e,r){this.growIfFull();var i=this.count,o=t.index,n=e.index;o0&&(s[k]=x.angleTo(_));var T=Math.cos(m.angleTo(g));h[k]=180/Math.PI*Math.acos(T);var B=m.length(),D=g.length();c[k]=Math.sqrt(D*B)/Math.max(2,2*(1-T)),u[k]=Math.abs(d.dot(x)),y.copy(m).multiplyScalar(c[k]/B),v.copy(g).multiplyScalar(c[k]/D),y.subVectors(P,y),v.subVectors(I,v),y.toArray(n,M+3),v.toArray(n,M+6),w.subVectors(C,A),w.toArray(l,M),_.copy(x),A.copy(y)}y.fromArray(n,3),v.fromArray(n,6),x.subVectors(y,v).normalize(),C.index=t.getAtomIndexByType(0,S),A.copy(C),b.copy(C),go(b,x,y),b.toArray(n,0),w.subVectors(A,y),w.toArray(l,0),y.fromArray(n,3*i-6),v.fromArray(n,3*i-9),x.subVectors(y,v).normalize(),C.index=t.getAtomIndexByType(i-1,S),A.copy(C),b.copy(C),go(b,x,y),b.toArray(n,3*i-3);for(var E=i-3;Ee||h.bending[$]>t)&&(R=!0)),R){if($-g<4){g=$,R=!1;continue}D.index=T.traceAtomIndex,I=h.axis.subarray(3*g+3,3*$),O=h.center.subarray(3*g,3*$+3),p=mo(I).normalize(),d=mo(O),k.fromArray(O),go(k,p,d),M.fromArray(O,O.length-3),go(M,p,d),p.subVectors(M,k),p.toArray(v,y),d.toArray(b,y),k.toArray(x,y),M.toArray(_,y),f.atomColorToArray(D,w,y),A.push(D.index),S.push(m.atomRadius(D)),C.push(u+g),P.push(u+$+1-g),y+=3,g=$,R=!1}var L=new Float32Array(A);return{axis:new Float32Array(v),center:new Float32Array(b),begin:new Float32Array(x),end:new Float32Array(_),color:new Float32Array(w),picking:new ba(L,s),size:new Float32Array(S),residueOffset:C,residueCount:P}};var uc=function(t){this.scoreFunction=t,this.content=[],this.scoreFunction=t};uc.prototype.push=function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},uc.prototype.pop=function(){var t=this.content[0],e=this.content.pop();return e&&this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},uc.prototype.peek=function(){return this.content[0]},uc.prototype.remove=function(t){for(var e=this.content.length,r=0;r0;){var r=Math.floor((t+1)/2)-1,i=this.content[r];if(!(this.scoreFunction(e)e?(o&&(clearTimeout(o),o=null),a=l,n=t.apply(r,s),o||(r=s=null)):o||!1===i.trailing||(o=setTimeout(c,h)),n}}function mt(t,e){return te?1:0}function pt(t,e,i=mt){let r=0,s=t.length-1;for(;r<=s;){const n=r+s>>1,o=i(e,t[n]);if(o>0)r=n+1;else{if(!(o<0))return n;s=n-1}}return-r-1}function ft(t,e,i){const r=function(t,e){let i=t.length-1;if(t[i]>1;t[s]>=e?i=s-1:r=s+1}return i+1}(t,e),s=function(t,e){if(t[0]>e)return-1;let i=0,r=t.length-1;for(;i<=r;){const s=i+r>>1;t[s]>e?r=s-1:i=s+1}return i-1}(t,i);return-1===r||-1===s||r>s?0:s-r+1}function gt(t){return t.sort().filter((function(t,e,i){return 0===e||t!==i[e-1]}))}function yt(t){const e=28672;if(t.length>e){const i=[];for(let r=0;r65535?Uint32Array:Uint16Array)(t)}function vt(t){return t.buffer&&t.buffer instanceof ArrayBuffer?t.buffer:t}function wt(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function At(t){return wt(t,e)}function _t(t){return wt(t,i)}function St(t){return wt(t,r)}function Ct(t){return e=t,i=Float32Array,e instanceof i?e:new i(e);var e,i}function Pt(t){return st(t,"").toString().toLowerCase()}class It{constructor(t){this.name=t,this._dict={}}add(t,e){this._dict[Pt(t)]=e}get(t){return this._dict[Pt(t)]}get names(){return Object.keys(this._dict)}}function kt(t){return.01745*t}const Mt="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Tt=new Array(36);function Bt(){let t,e=0;for(let i=0;i<36;i++)8===i||13===i||18===i||23===i?Tt[i]="-":14===i?Tt[i]="4":(e<=2&&(e=33554432+16777216*Math.random()|0),t=15&e,e>>=4,Tt[i]=Mt[19===i?3&t|8:t]);return Tt.join("")}function Dt(t,e,i){return Math.max(e,Math.min(i,t))}function $t(t,e,i){return t+(e-t)*i}function Ot(t,e,i,r,s,n){const o=(i-t)*n,a=(r-e)*n,c=s*s;return(2*e-2*i+o+a)*(s*c)+(-3*e+3*i-2*o-a)*c+o*s+e}function Rt(t,e,i){var r;return r=function(t,e,i){return(t-e)/(i-e)}(i,t,e),(i=Dt(r,0,1))*i*(3-2*i)}var Et="sRGB";const Ft={scale:"uniform",mode:"hcl",domain:[0,1],value:16777215,reverse:!1},Lt=new s;function Nt(t,e,i){const r=i.value;return i.value=function(t,e){let i=r.bind(this,t,e)();return"linear"==Et?(Lt.set(i),Lt.convertSRGBToLinear(),Lt.getHex()):i},i}class zt{constructor(t={}){this.parameters=nt(t,Ft),"string"==typeof this.parameters.value&&(this.parameters.value=Lt.set(this.parameters.value).getHex()),this.parameters.structure&&(this.atomProxy=this.parameters.structure.getAtomProxy())}getScale(t={}){const e=nt(t,this.parameters);return"rainbow"===e.scale?e.scale=["red","orange","yellow","green","blue"]:"rwb"===e.scale&&(e.scale=["red","white","blue"]),e.reverse&&(e.domain=e.domain.slice().reverse()),J.scale(e.scale).mode(e.mode).domain(e.domain).out("num")}colorToArray(t,e=[],i=0){return e[i]=(t>>16&255)/255,e[i+1]=(t>>8&255)/255,e[i+2]=(255&t)/255,e}atomColorToArray(t,e,i){return this.colorToArray(this.atomColor?this.atomColor(t):0,e,i)}bondColor(t,e){return this.atomProxy&&this.atomColor?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):0}bondColorToArray(t,e,i,r){return this.colorToArray(this.bondColor(t,e),i,r)}volumeColorToArray(t,e,i){return this.colorToArray(this.volumeColor?this.volumeColor(t):0,e,i)}positionColorToArray(t,e,i){return this.colorToArray(this.positionColor?this.positionColor(t):0,e,i)}}var Vt;!function(t){t[t.PROTEIN=1]="PROTEIN",t[t.NUCLEIC=2]="NUCLEIC",t[t.RNA=3]="RNA",t[t.DNA=4]="DNA",t[t.POLYMER=5]="POLYMER",t[t.WATER=6]="WATER",t[t.HELIX=7]="HELIX",t[t.SHEET=8]="SHEET",t[t.TURN=9]="TURN",t[t.BACKBONE=10]="BACKBONE",t[t.SIDECHAIN=11]="SIDECHAIN",t[t.ALL=12]="ALL",t[t.HETERO=13]="HETERO",t[t.ION=14]="ION",t[t.SACCHARIDE=15]="SACCHARIDE",t[t.SUGAR=15]="SUGAR",t[t.BONDED=16]="BONDED",t[t.RING=17]="RING",t[t.AROMATICRING=18]="AROMATICRING",t[t.METAL=19]="METAL",t[t.POLARH=20]="POLARH",t[t.NONE=21]="NONE"}(Vt||(Vt={}));const Gt=["*","","ALL"],Ut=["NONE"],jt=[Vt.BACKBONE,Vt.SIDECHAIN,Vt.BONDED,Vt.RING,Vt.AROMATICRING,Vt.METAL,Vt.POLARH],Ht=[Vt.POLYMER,Vt.WATER],Wt=["ALA","GLY","SER"],qt=["CYS","SER","THR"],Xt=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Yt=["PHE","TRP","TYR","HIS"],Kt=["ASN","GLN"],Zt=["ASP","GLU"],Qt=["ARG","HIS","LYS"],Jt=["ARG","ASP","GLU","HIS","LYS"],te=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],ee=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],ie=["HIS","PHE","PRO","TRP","TYR"],re=["ALA","GLY","ILE","LEU","VAL"];function se(t,e){if(void 0===e.atomname&&void 0===e.element&&void 0===e.altloc&&void 0===e.atomindex&&void 0===e.keyword&&void 0===e.inscode&&void 0===e.resname&&void 0===e.sstruc&&void 0===e.resno&&void 0===e.chainname&&void 0===e.model)return-1;if(void 0!==e.keyword){if(e.keyword===Vt.BACKBONE&&!t.isBackbone())return!1;if(e.keyword===Vt.SIDECHAIN&&!t.isSidechain())return!1;if(e.keyword===Vt.BONDED&&!t.isBonded())return!1;if(e.keyword===Vt.RING&&!t.isRing())return!1;if(e.keyword===Vt.AROMATICRING&&!t.isAromatic())return!1;if(e.keyword===Vt.HETERO&&!t.isHetero())return!1;if(e.keyword===Vt.PROTEIN&&!t.isProtein())return!1;if(e.keyword===Vt.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===Vt.RNA&&!t.isRna())return!1;if(e.keyword===Vt.DNA&&!t.isDna())return!1;if(e.keyword===Vt.POLYMER&&!t.isPolymer())return!1;if(e.keyword===Vt.WATER&&!t.isWater())return!1;if(e.keyword===Vt.HELIX&&!t.isHelix())return!1;if(e.keyword===Vt.SHEET&&!t.isSheet())return!1;if(e.keyword===Vt.TURN&&!t.isTurn())return!1;if(e.keyword===Vt.ION&&!t.isIon())return!1;if(e.keyword===Vt.SACCHARIDE&&!t.isSaccharide())return!1;if(e.keyword===Vt.METAL&&!t.isMetal())return!1;if(e.keyword===Vt.POLARH&&!t.isPolarHydrogen())return!1}if(void 0!==e.atomname&&e.atomname!==t.atomname)return!1;if(void 0!==e.element&&e.element!==t.element)return!1;if(void 0!==e.altloc&&e.altloc!==t.altloc)return!1;if(void 0!==e.atomindex&&pt(e.atomindex,t.index)<0)return!1;if(void 0!==e.resname)if(Array.isArray(e.resname)){if(!e.resname.includes(t.resname))return!1}else if(e.resname!==t.resname)return!1;if(void 0!==e.sstruc&&e.sstruc!==t.sstruc)return!1;if(void 0!==e.resno)if(Array.isArray(e.resno)&&2===e.resno.length){if(e.resno[0]>t.resno||e.resno[1]t.resno||e.resno[1]0?t:null}function he(t,e=!1){let i=t;return e&&(i=le(t,(function(t){return void 0!==t.keyword&&!jt.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))}))),ce(i,se)}function de(t,e=!1){let i=t;return e&&(i=le(t,(function(t){return!(void 0===t.keyword||!jt.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))}))),ce(i,ne)}function ue(t,e=!1){let i=t;return e&&(i=le(t,(function(t){return void 0!==t.keyword&&!Ht.includes(t.keyword)||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode))))))}))),ce(i,oe)}function me(t,e=!1){let i=t;return e&&(i=le(t,(function(t){return void 0!==t.keyword||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode)))))))}))),ce(i,ae)}class pe{constructor(t){this.signals={stringChanged:new et},this.setString(t)}get type(){return"selection"}setString(t,e){if(void 0===t&&(t=this.string||""),t===this.string)return;try{this.selection=function(t){let e={operator:void 0,rules:[]};if(!t)return e;let i,r,s=e;const n=[];"("===(t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());const o=t.split(/\s+/),a=t=>{i={operator:t,rules:[]},void 0===s?(s=i,e=i):(s.rules.push(i),n.push(s),s=i)},c=function(t){r=s,s=n.pop(),void 0===s&&(a(t),l(r))},l=function(t){s.rules.push(t)};let h=!1;for(let t=0;t0)if("NOT"===i)h=1;else if(1===h)h=2;else{if(2!==h)throw new Error("something went wrong with 'not'");h=!1,c()}if("AND"===i){if("OR"===s.operator){const t=s.rules.pop();a("AND"),l(t)}else s.operator="AND";continue}if("OR"===i){"AND"===s.operator?c("OR"):s.operator="OR";continue}if("NOT"===e.toUpperCase()){h=1,a(),s.negate=!0;continue}if(+i!=+i){const t=Vt[i];if(void 0!==t){l({keyword:t});continue}}if("HYDROGEN"===i){l({operator:"OR",rules:[{element:"H"},{element:"D"}]});continue}if("SMALL"===i){l({resname:Wt});continue}if("NUCLEOPHILIC"===i){l({resname:qt});continue}if("HYDROPHOBIC"===i){l({resname:Xt});continue}if("AROMATIC"===i){l({resname:Yt});continue}if("AMIDE"===i){l({resname:Kt});continue}if("ACIDIC"===i){l({resname:Zt});continue}if("BASIC"===i){l({resname:Qt});continue}if("CHARGED"===i){l({resname:Jt});continue}if("POLAR"===i){l({resname:te});continue}if("NONPOLAR"===i){l({resname:ee});continue}if("CYCLIC"===i){l({resname:ie});continue}if("ALIPHATIC"===i){l({resname:re});continue}if("SIDECHAINATTACHED"===i){l({operator:"OR",rules:[{keyword:Vt.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:Vt.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:Vt.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"HO3'"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"HO5'"},{atomname:"C5'"},{atomname:"C5*"},{atomname:"H5'"},{atomname:"H5''"}]}]}]});continue}if("APOLARH"===i){l({operator:"AND",negate:!1,rules:[{element:"H"},{negate:!0,operator:void 0,rules:[{keyword:Vt.POLARH}]}]});continue}if("LIGAND"===i){l({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:Vt.HETERO},{negate:!0,operator:void 0,rules:[{keyword:Vt.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:Vt.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:Vt.WATER},{keyword:Vt.ION}]}]}]});continue}if(-1!==Gt.indexOf(i)){l({keyword:Vt.ALL});continue}if("@"===e.charAt(0)){const t=e.substr(1).split(",").map((t=>parseInt(t)));t.sort((function(t,e){return t-e})),l({atomindex:t});continue}if("#"===e.charAt(0)){console.error("# for element selection deprecated, use _"),l({element:i.substr(1)});continue}if("_"===e.charAt(0)){l({element:i.substr(1)});continue}if("["===e[0]&&"]"===e[e.length-1]){const t=i.substr(1,e.length-2).split(","),r=t.length>1?t:t[0];l({resname:r});continue}if(e.length>=1&&e.length<=4&&"^"!==e[0]&&":"!==e[0]&&"."!==e[0]&&"%"!==e[0]&&"/"!==e[0]&&isNaN(parseInt(e))){l({resname:i});continue}const r={operator:"AND",rules:[]},n=e.split("/");if(n.length>1&&n[1]){if(isNaN(parseInt(n[1])))throw new Error("model must be an integer");r.rules.push({model:parseInt(n[1])})}const d=n[0].split("%");d.length>1&&r.rules.push({altloc:d[1]});const u=d[0].split(".");if(u.length>1&&u[1]){if(u[1].length>4)throw new Error("atomname must be one to four characters");r.rules.push({atomname:u[1].substring(0,4).toUpperCase()})}const m=u[0].split(":");m.length>1&&m[1]&&r.rules.push({chainname:m[1]});const p=m[0].split("^");if(p.length>1&&r.rules.push({inscode:p[1]}),p[0]){let t,e;"-"===p[0][0]&&(p[0]=p[0].substr(1),t=!0),p[0].includes("--")&&(p[0]=p[0].replace("--","-"),e=!0);let i=p[0].split("-");if(1===i.length){let e=parseInt(i[0]);if(isNaN(e))throw new Error("resi must be an integer");t&&(e*=-1),r.rules.push({resno:e})}else{if(2!==i.length)throw new Error("resi range must contain one '-'");{const s=i.map((t=>parseInt(t)));t&&(s[0]*=-1),e&&(s[1]*=-1),r.rules.push({resno:[s[0],s[1]]})}}}if(1===r.rules.length)l(r.rules[0]);else{if(!(r.rules.length>1))throw new Error("empty selection chunk");l(r)}}return void 0===e.operator&&1===e.rules.length&&e.rules[0].hasOwnProperty("operator")&&(e=e.rules[0]),e}(t)}catch(t){this.selection={error:t.message}}const i=this.selection;this.string=t,this.test=he(i),this.residueTest=de(i),this.chainTest=ue(i),this.modelTest=me(i),this.atomOnlyTest=he(i,!0),this.residueOnlyTest=de(i,!0),this.chainOnlyTest=ue(i,!0),this.modelOnlyTest=me(i,!0),e||this.signals.stringChanged.dispatch(this.string)}isAllSelection(){return Gt.includes(this.string.toUpperCase())}isNoneSelection(){return Ut.includes(this.string.toUpperCase())}}class fe extends zt{constructor(t){super(t),this.colormakerList=[],this.selectionList=[];(t.dataList||[]).forEach((t=>{const[e,i,r={}]=t;Fe.hasScheme(e)?Object.assign(r,{scheme:e,structure:this.parameters.structure}):Object.assign(r,{scheme:"uniform",value:new s(e).getHex()}),this.colormakerList.push(Fe.getScheme(r)),this.selectionList.push(new pe(i))}))}atomColor(t){for(let e=0,i=this.selectionList.length;e{}),t)}catch(t){}const Se="undefined"!=typeof window&&void 0!==window.orientation;let Ce=!1;function Pe(t){Ce=t}let Ie=!1;function ke(t){Ie=t}const Me={log:Function.prototype.bind.call(console.log,console),info:Function.prototype.bind.call(console.info,console),warn:Function.prototype.bind.call(console.warn,console),error:Function.prototype.bind.call(console.error,console),time:Function.prototype.bind.call(console.time,console),timeEnd:Function.prototype.bind.call(console.timeEnd,console)};let Te={color:"green",labelColor:8421504,labelAttachment:"bottom-center",labelSize:.7,labelZOffset:.5,labelYOffset:.1,labelBorder:!0,labelBorderColor:13882323,labelBorderWidth:.25,lineOpacity:.8,linewidth:5,opacity:.6,labelUnit:"angstrom",arcVisible:!0,planeVisible:!1};function Be(t={}){Object.assign(Te,t)}let De=!!($e=rt("debug"))&&("string"!=typeof $e||/^1|true|t|yes|y$/i.test($e));var $e;function Oe(t){De=t}const Re=["ngl","js"],Ee=new class{constructor(){this.activeWorkerCount=0,this._funcDict={},this._depsDict={},this._blobDict={}}add(t,e,i){this._funcDict[t]=e,this._depsDict[t]=i}get(t){return this._blobDict[t]||(this._blobDict[t]=we(this._funcDict[t],this._depsDict[t])),this._blobDict[t]}},Fe=new class{constructor(){this.schemes={},this.userSchemes={}}getScheme(t){const e=((t||{}).scheme||"").toLowerCase();let i;return i=e in this.schemes?this.schemes[e]:e in this.userSchemes?this.userSchemes[e]:zt,new i(t)}getSchemes(){const t={};return Object.keys(this.schemes).forEach((function(e){t[e]=e})),Object.keys(this.userSchemes).forEach((function(e){t[e]=e.split("|")[1]})),t}getScales(){return ge}getModes(){return ye}add(t,e){t=t.toLowerCase(),this.schemes[t]=e}addScheme(t,e){return t instanceof zt||(t=this._createScheme(t)),this._addUserScheme(t,e)}_addUserScheme(t,e){e=e||"";const i=`${Bt()}|${e}`.toLowerCase();return this.userSchemes[i]=t,i}removeScheme(t){t=t.toLowerCase(),delete this.userSchemes[t]}_createScheme(t){const e=function(e){zt.call(this,e),t.call(this,e)};return(e.prototype=zt.prototype).constructor=zt,e}addSelectionScheme(t,e){return this._addUserScheme(class extends fe{constructor(e){super(Object.assign({dataList:t},e))}},e)}hasScheme(t){return(t=t.toLowerCase())in this.schemes||t in this.userSchemes}},Le=new It("datasource"),Ne=new It("representatation"),ze=new class extends It{constructor(){super("parser")}__hasObjName(t,e){const i=this.get(t);return i&&i.prototype.__objName===e}isTrajectory(t){return this.__hasObjName(t,"frames")}isStructure(t){return this.__hasObjName(t,"structure")}isVolume(t){return this.__hasObjName(t,"volume")}isSurface(t){return this.__hasObjName(t,"surface")}isBinary(t){const e=this.get(t);return e&&e.prototype.isBinary}isXml(t){const e=this.get(t);return e&&e.prototype.isXml}isJson(t){const e=this.get(t);return e&&e.prototype.isJson}getTrajectoryExtensions(){return this.names.filter((t=>this.isTrajectory(t)))}getStructureExtensions(){return this.names.filter((t=>this.isStructure(t)))}getVolumeExtensions(){return this.names.filter((t=>this.isVolume(t)))}getSurfaceExtensions(){return this.names.filter((t=>this.isSurface(t)))}},Ve=new It("shader"),Ge=new It("decompressor"),Ue=new It("component"),je=new It("buffer"),He=new It("picker");let We,qe;function Xe(t){We=t}function Ye(t){qe=t}class Ke{constructor(t,e={}){this.chunkSize=10485760,this.newline="\n",this.__pointer=0,this.__partialLine="",this.compressed=st(e.compressed,!1),this.binary=st(e.binary,!1),this.json=st(e.json,!1),this.xml=st(e.xml,!1),this.src=t}isBinary(){return this.binary||this.compressed}read(){return this._read().then((t=>{const e=this.compressed?Ge.get(this.compressed):void 0;return this.compressed&&e?this.data=e(t):((this.binary||this.compressed)&&t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.data=t),this.data}))}_chunk(t,e){return e=Math.min(this.data.length,e),0===t&&this.data.length===e?this.data:this.isBinary()?this.data.subarray(t,e):this.data.substring(t,e)}chunk(t){const e=t+this.chunkSize;return this._chunk(t,e)}peekLines(t){const e=this.data,i=e.length,r=this.isBinary()?this.newline.charCodeAt(0):this.newline;let s,n=0;for(s=0;si).lines}chunkCount(){return Math.floor(this.data.length/this.chunkSize)+1}asText(){return this.isBinary()?yt(this.data):this.data}chunkToLines(t,e,i){const r=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(r),partialLine:""};let s=[];const n=this.isBinary()?yt(t):t,o=n.lastIndexOf(r);if(-1===o)e+=n;else{const t=e+n.substr(0,o);s=s.concat(t.split(r)),e=o===n.length-r.length?"":n.substr(o+r.length)}return i&&""!==e&&s.push(e),{lines:s,partialLine:e}}nextChunk(){const t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)}nextChunkOfLines(){const t=this.nextChunk();if(void 0===t)return;const e=this.__pointer>this.data.length,i=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=i.partialLine,i.lines}eachChunk(t){const e=this.chunkSize,i=this.data.length,r=this.chunkCount();for(let s=0;s{const s=i===r+1,n=this.chunkToLines(e,this.__partialLine,s);this.__partialLine=n.partialLine,t(n.lines,i,r)}))}dispose(){delete this.src}}class Ze extends Ke{_read(){return new Promise(((t,e)=>{const i=this.src,r=new FileReader;r.onload=e=>{e.target&&t(e.target.result)},r.onerror=t=>e(t),this.binary||this.compressed?r.readAsArrayBuffer(i):r.readAsText(i)}))}}class Qe extends Ke{_read(){return new Promise(((t,e)=>{const i=this.src,r=new XMLHttpRequest;r.open("GET",i,!0),r.addEventListener("load",(()=>{if(200===r.status||304===r.status||0===r.status)try{t(r.response)}catch(t){e(t)}else e(r.statusText)}),!1),r.addEventListener("error",(t=>e("network error")),!1),this.isBinary()?r.responseType="arraybuffer":this.json?r.responseType="json":this.xml?r.responseType="document":r.responseType="text",r.send()}))}}class Je{constructor(t,e={}){this.parameters=nt(e,{ext:"",compressed:!1,binary:ze.isBinary(e.ext||""),name:"",dir:"",path:"",protocol:""});const i={compressed:this.parameters.compressed,binary:this.parameters.binary,json:ze.isJson(this.parameters.ext),xml:ze.isXml(this.parameters.ext)};"undefined"!=typeof File&&t instanceof File||"undefined"!=typeof Blob&&t instanceof Blob?this.streamer=new Ze(t,i):this.streamer=new Qe(t,i)}}class ti extends Je{constructor(t,e={}){super(t,e),this.parserParams={voxelSize:e.voxelSize,firstModelOnly:e.firstModelOnly,asTrajectory:e.asTrajectory,cAlphaOnly:e.cAlphaOnly,delimiter:e.delimiter,comment:e.comment,columnNames:e.columnNames,name:this.parameters.name,path:this.parameters.path}}load(){return new(ze.get(this.parameters.ext))(this.streamer,this.parserParams).parse()}}class ei{constructor(t,e,i){this.name=e,this.path=i,this.signals={elementAdded:new et,elementRemoved:new et,nameChanged:new et},this.type="Script",this.dir=i.substring(0,i.lastIndexOf("/")+1);try{this.fn=new Function("stage","__name","__path","__dir",t)}catch(t){Me.error("Script compilation failed",t),this.fn=function(){}}}run(t){return new Promise(((e,i)=>{try{this.fn.apply(null,[t,this.name,this.path,this.dir]),e()}catch(t){Me.error("Script.fn",t),i(t)}}))}}class ii extends Je{load(){return this.streamer.read().then((()=>new ei(this.streamer.asText(),this.parameters.name,this.parameters.path)))}}function ri(t){const e=Ge.names;let i,r,s="";i=t instanceof File?t.name:t instanceof Blob?"":t;const n=i.lastIndexOf("?"),o=-1!==n?i.substring(n):"";i=i.substring(0,-1===n?i.length:n);const a=i.replace(/^.*[\\/]/,"");let c=a.substring(0,a.lastIndexOf("."));const l=a.split(".");let h=l.length>1?(l.pop()||"").toLowerCase():"";const d=i.match(/^(.+):\/\/(.+)$/);d&&(s=d[1].toLowerCase(),i=d[2]||"");const u=i.substring(0,i.lastIndexOf("/")+1);if(e.includes(h)){r=h;const t=i.length-h.length-1;h=(i.substr(0,t).split(".").pop()||"").toLowerCase();const e=c.length-h.length-1;c=c.substr(0,e)}else r=!1;return{path:i,name:a,ext:h,base:c,dir:u,compressed:r,protocol:s,query:o,src:t}}function si(t){let e=ri(t);const i=Le.get(e.protocol);return i&&(e=ri(i.getUrl(e.src)),!e.ext&&i.getExt&&(e.ext=i.getExt(t))),e}function ni(t,e={}){const i=Object.assign(si(t),e);let r;return ze.names.includes(i.ext)?r=new ti(i.src,i):Re.includes(i.ext)&&(r=new ii(i.src,i)),r?r.load():Promise.reject(new Error(`autoLoad: ext '${i.ext}' unknown`))}class oi{getBlob(){return new Blob([this.getData()],{type:this.mimeType})}download(t,e){t=st(t,this.defaultName),e=st(e,this.defaultExt),dt(this.getBlob(),`${t}.${e}`)}}class ai extends oi{constructor(t,e){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";const i=Object.assign({},e);this.renumberSerial=st(i.renumberSerial,!0),this.remarks=function(t){return Array.isArray(t)?t:[t]}(st(i.remarks,[])),this.structure=t,this._records=[]}_writeRecords(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()}_writeTitle(){this._records.push(it("TITLE %-74s",this.structure.name))}_writeRemarks(){this.remarks.forEach((t=>{this._records.push(it("REMARK %-73s",t))})),this.structure.trajectory&&(this._records.push(it("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(it("REMARK %-73s",`Frame ${this.structure.trajectory.frame}`)))}_writeAtoms(){let t=1,e=1,i=" ",r=" ";const s=this.structure.modelStore.count>1;this.structure.eachModel((n=>{s&&this._records.push(it("MODEL %4d%-66s",e++,"")),n.eachAtom((e=>{const s=e.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",n=this.renumberSerial?t:e.serial;let o=e.atomname;(1===o.length||o.length<4&&1===e.element.length&&o[0]===e.element)&&(o=" "+o),e.formalCharge?(i=Math.abs(e.formalCharge).toPrecision(1),r=e.formalCharge>0?"+":"-"):(i=" ",r=" "),this._records.push(it(s,n,o,e.resname,st(e.chainname," "),e.resno,e.x,e.y,e.z,st(e.occupancy,1),st(e.bfactor,0),"",st(e.element,""),i,r)),t+=1}),this.structure.getSelection()),s&&this._records.push(it("%-80s","ENDMDL"))})),this._records.push(it("%-80s","END"))}getString(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()}getData(){return this._writeRecords(),this._records.join("\n")}}class ci extends oi{constructor(t){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=t,this._records=[]}get idString(){return this.structure.id}get titleString(){return" "+this.structure.title}get countsString(){return it("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)}get chargeLines(){const t=[];this.structure.eachAtom((e=>{null!=e.formalCharge&&0!==e.formalCharge&&t.push([e.index,e.formalCharge])}));const e=[];for(let i=0;i{this._records.push(this.formatAtom(t))})),this.structure.eachBond((t=>{this._records.push(this.formatBond(t))})),this.chargeLines.forEach((t=>{this._records.push(t)})),this._records.push("M END")}_writeFooter(){this._records.push("$$$$")}getData(){return this._writeRecords(),this._records.join("\n")}}const li=[];class hi{constructor(t,e={}){this._mark=0,this._marks=[],this.offset=0,this.littleEndian=!0;let i=!1;void 0===t&&(t=8192),"number"==typeof t?t=new ArrayBuffer(t):i=!0;const r=e.offset?e.offset>>>0:0;let s=t.byteLength-r,n=r;t instanceof ArrayBuffer||(t.byteLength!==t.buffer.byteLength&&(n=t.byteOffset+r),t=t.buffer),this._lastWrittenByte=i?s:0,this.buffer=t,this.length=s,this.byteLength=s,this.byteOffset=n,this._data=new DataView(this.buffer,n,s)}available(t){return void 0===t&&(t=1),this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t){return void 0===t&&(t=1),this.offset+=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t){if(void 0===t&&(t=1),!this.available(t)){const e=2*(this.offset+t),i=new Uint8Array(e);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t){void 0===t&&(t=1);for(var e=new Uint8Array(t),i=0;ithis._lastWrittenByte&&(this._lastWrittenByte=this.offset)}}class di extends oi{constructor(t){super(),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=t}getData(){const t=this.surface.index.length/3,i=new hi(2*t+3*t*4*4+80+4);i.skip(80),i.writeUint32(t);const r=new e,s=new e,n=new e,o=new e;for(let e=0;e{0===this.count&&(this.signals.countChanged.remove(i,this),t.call(e))};this.signals.countChanged.add(i,this)}}dispose(){this.clear(),this.signals.countChanged.dispose()}}Ve.add("shader/BasicLine.vert","void main(){\n#include begin_vertex\n#include project_vertex\n}"),Ve.add("shader/BasicLine.frag","uniform vec3 uColor;\n#include common\n#include fog_pars_fragment\nvoid main(){\ngl_FragColor = vec4( uColor, 1.0 );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}"),Ve.add("shader/Quad.vert","varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"),Ve.add("shader/Quad.frag","varying vec2 vUv;\nuniform sampler2D tForeground;\nuniform float scale;\nvoid main() {\nvec4 foreground = texture2D( tForeground, vUv );\ngl_FragColor = foreground * scale;\n}");class mi{constructor(){this.signals={updated:new tt.Signal},this.maxDuration=-1/0,this.minDuration=1/0,this.avgDuration=14,this.lastDuration=1/0,this.prevFpsTime=0,this.lastFps=1/0,this.lastFrames=1,this.frames=0,this.count=0,this.begin()}update(){this.startTime=this.end(),this.currentTime=this.startTime,this.signals.updated.dispatch()}begin(){this.startTime=window.performance.now(),this.lastFrames=this.frames}end(){const t=window.performance.now();return this.count+=1,this.frames+=1,this.lastDuration=t-this.startTime,this.minDuration=Math.min(this.minDuration,this.lastDuration),this.maxDuration=Math.max(this.maxDuration,this.lastDuration),this.avgDuration-=this.avgDuration/30,this.avgDuration+=this.lastDuration/30,t>this.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=t,this.frames=0),t}}Ve.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),Ve.add("shader/chunk/interior_fragment.glsl","if( gl_FrontFacing == false ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}"),Ve.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),Ve.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),Ve.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"),Ve.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),Ve.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),Ve.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),Ve.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");const pi=/^(?!\/\/)\s*#include\s+(\S+)/gim,fi={};function gi(t,e={}){let i=t+"|";for(const t in e)i+=t+":"+e[t];if(!fi[i]){const r=function(t){if(void 0===t)return"";const e=[];for(const i in t){const r=t[i];r&&e.push(`#define ${i} ${r}`)}return e.join("\n")+"\n"}(e);let s=Ve.get(`shader/${t}`);if(!s)throw new Error(`empty shader, '${t}'`);s=s.replace(pi,(function(t,e){const i=`shader/chunk/${e}.glsl`,r=Ve.get(i)||n[e];if(!r)throw new Error(`empty chunk, '${e}'`);return r})),fi[i]=r+s}return fi[i]}if("undefined"!=typeof WebGLRenderingContext){const t=WebGLRenderingContext.prototype,e=t.getShaderParameter;t.getShaderParameter=function(){return!De||e.apply(this,arguments)};const i=t.getShaderInfoLog;t.getShaderInfoLog=function(){return De?i.apply(this,arguments):""};const r=t.getProgramParameter;t.getProgramParameter=function(e,i){return!De&&i===t.LINK_STATUS||r.apply(this,arguments)};const s=t.getProgramInfoLog;t.getProgramInfoLog=function(){return De?s.apply(this,arguments):""}}const yi=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];yi.forEach((t=>{t.forEach((t=>{t[0]*=.0625,t[1]*=.0625}))}));class bi{constructor(t,e,i,r){this.canvas=document.createElement("canvas"),this._viewer=i,this._factor=st(r.factor,2),this._antialias=st(r.antialias,!1),this._onProgress=r.onProgress,this._onFinish=r.onFinish,this._antialias&&(this._factor*=2),this._n=this._factor*this._factor,this._width=this._viewer.width,this._height=this._viewer.height,this._antialias?(this.canvas.width=this._width*this._factor/2,this.canvas.height=this._height*this._factor/2):(this.canvas.width=this._width*this._factor,this.canvas.height=this._height*this._factor),this._ctx=this.canvas.getContext("2d"),this._viewerSampleLevel=i.sampleLevel,this._viewer.setSampling(-1)}_renderTile(t){const e=this._viewer,i=this._width,r=this._height,s=this._factor,n=t%s*i,o=Math.floor(t/s)*r;if(e.camera.setViewOffset(i*s,r*s,n,o,i,r),e.render(),this._antialias){const t=Math.round((n+i)/2)-Math.round(n/2),s=Math.round((o+r)/2)-Math.round(o/2);this._ctx.drawImage(e.renderer.domElement,Math.round(n/2),Math.round(o/2),t,s)}else this._ctx.drawImage(e.renderer.domElement,Math.floor(n),Math.floor(o),Math.ceil(i),Math.ceil(r));"function"==typeof this._onProgress&&this._onProgress(t+1,this._n,!1)}_finalize(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,"function"==typeof this._onFinish&&this._onFinish(this._n+1,this._n,!1)}render(){for(let t=0;t<=this._n;++t)t===this._n?this._finalize():this._renderTile(t)}renderAsync(){let t=0;const e=this._n,i=()=>{t===e?this._finalize():this._renderTile(t),t+=1};for(let t=0;t<=e;++t)setTimeout(i,0)}}const xi=2*Math.PI,vi=180/Math.PI;function wi(t,e,i=1,r=0,s){const n=s?s.length:t.length/i;let o=0,a=0;if(s)for(let c=0;ce&&(e=t[i]);return e}function Di(t){let e=1/0;for(let i=0,r=t.length;i=0;l--){for(c=o-1;c>=0;c--)if(d=4*(l*o+c),a[d]!==e||a[d+1]!==i||a[d+2]!==r||a[d+3]!==s){h=!0;break}if(h)break}const p=l;for(h=!1,c=o-1;c>=0;c--){for(l=n-1;l>=0;l--)if(d=4*(l*o+c),a[d]!==e||a[d+1]!==i||a[d+2]!==r||a[d+3]!==s){h=!0;break}if(h)break}const f=c,g=document.createElement("canvas");return g.width=f-m,g.height=p-u,g.getContext("2d").drawImage(t,m,u,g.width,g.height,0,0,g.width,g.height),g}(t,n?0:255*e.r,n?0:255*e.g,n?0:255*e.b,n?0:255)}return t}function u(t,i,r){"function"==typeof e.onProgress&&e.onProgress(t,i,r)}return new Promise((function(e,i){const l=new bi(o,a,t,{factor:r,antialias:s,onProgress:u,onFinish:function(r,s){d(l.canvas).toBlob((function(r){o.setClearAlpha(c),h(!0),t.requestRender(),u(s,s,!0),r?e(r):i("error creating image")}),"image/png")}});o.setClearAlpha(n?0:1),h(),l.renderAsync()}))}const Fi=new e,Li=new i,Ni=new i;const zi=new t,Vi=new i,Gi=new i;function Ui(t,e){Vi.getInverse(e.projectionMatrix),Gi.copy(e.projectionMatrix).transpose(),t.traverse((function(t){const e=t.material;if(!e)return;const i=e.uniforms;i&&(i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(Vi),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(Gi))}))}function ji(t,e,i){const r=t.createShader(i);if(!r)return void console.log(`error creating WebGL shader ${i}`);t.shaderSource(r,e),t.compileShader(r);return t.getShaderParameter(r,t.COMPILE_STATUS)?r:(console.log(`error compiling shader ${r}: ${t.getShaderInfoLog(r)}`),t.deleteShader(r),null)}function Hi(t,e){const i=t.getExtension(e);return i||console.log(`extension '${e}' not available`),i}const Wi=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function qi(t){const e=document.createElement("canvas");e.width=16,e.height=16,e.style.width="16px",e.style.height="16px";const i=e.getContext("webgl")||e.getContext("experimental-webgl");if(!i)return console.log(`error creating webgl context for ${t}`),!1;if(!(i instanceof WebGLRenderingContext))return console.log("Got unexpected type for WebGL rendering context"),!1;Hi(i,"OES_texture_float"),Hi(i,"OES_texture_half_float"),Hi(i,"WEBGL_color_buffer_float");const r=ji(i,"\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}",i.VERTEX_SHADER),s=ji(i,"\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}",i.FRAGMENT_SHADER);if(!r||!s)return!1;const n=function(t,e,i,r){const s=t.createProgram();return s?(e.forEach((e=>t.attachShader(s,e))),i&&i.forEach(((e,i)=>{t.bindAttribLocation(s,r?r[i]:i,e)})),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS)?s:(console.log(`error linking program: ${t.getProgramInfoLog(s)}`),t.deleteProgram(s),null)):void console.log("error creating WebGL program")}(i,[r,s]);if(!n)return console.log("error creating WebGL program"),!1;i.useProgram(n);const o=i.getAttribLocation(n,"a_position"),a=i.getUniformLocation(n,"u_color");if(!a)return console.log("error getting 'u_color' uniform location"),!1;const c=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,Wi,i.STATIC_DRAW),i.enableVertexAttribArray(o),i.vertexAttribPointer(o,2,i.FLOAT,!1,0,0);const l=i.createTexture(),h=new Uint8Array([255,255,255,255]);i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,h);const d=i.createTexture();i.bindTexture(i.TEXTURE_2D,d),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,t,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST);const u=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,u),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,d,0);if(i.checkFramebufferStatus(i.FRAMEBUFFER)!==i.FRAMEBUFFER_COMPLETE)return console.log(`error creating framebuffer for ${t}`),!1;i.bindTexture(i.TEXTURE_2D,l),i.uniform4fv(a,[0,10,20,1]),i.drawArrays(i.TRIANGLES,0,6),i.bindTexture(i.TEXTURE_2D,d),i.bindFramebuffer(i.FRAMEBUFFER,null),i.clearColor(1,0,0,1),i.clear(i.COLOR_BUFFER_BIT),i.uniform4fv(a,[0,.1,.05,1]),i.drawArrays(i.TRIANGLES,0,6);const m=new Uint8Array(4);if(i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,m),0!==m[0]||m[1]<248||m[2]<248||m[3]<254)return console.log(`not able to actually render to ${t} texture`),!1;if(t===i.FLOAT){i.bindFramebuffer(i.FRAMEBUFFER,u);const t=new Float32Array(4);i.readPixels(0,0,1,1,i.RGBA,i.FLOAT,t);const e=i.getError();if(e)return console.log(`error reading pixels as float: '${function(t,e){switch(e){case t.NO_ERROR:return"no error";case t.INVALID_ENUM:return"invalid enum";case t.INVALID_VALUE:return"invalid value";case t.INVALID_OPERATION:return"invalid operation";case t.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case t.OUT_OF_MEMORY:return"out of memory";case t.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}(i,e)}'`),!1}return!0}const Xi=new Float32Array(100),Yi=new Uint8Array(100),Ki=[12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20],Zi=new i;function Qi(t,e,i,r,s){const n=s.uniforms,o=[];if(n&&(n.objectId&&(n.objectId.value=Ce?this.id:this.id/255,o.push("objectId")),(n.modelViewMatrixInverse||n.modelViewMatrixInverseTranspose||n.modelViewProjectionMatrix||n.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,this.matrixWorld),n.modelViewMatrixInverse&&(n.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),o.push("modelViewMatrixInverse")),n.modelViewMatrixInverseTranspose&&(n.modelViewMatrixInverse?n.modelViewMatrixInverseTranspose.value.copy(n.modelViewMatrixInverse.value).transpose():n.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),o.push("modelViewMatrixInverseTranspose")),n.modelViewProjectionMatrix&&(n.modelViewProjectionMatrix.value.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),n.modelViewProjectionMatrixInverse&&(n.modelViewProjectionMatrix?(Zi.copy(n.modelViewProjectionMatrix.value),n.modelViewProjectionMatrixInverse.value.getInverse(Zi)):(Zi.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),n.modelViewProjectionMatrixInverse.value.getInverse(Zi)),o.push("modelViewProjectionMatrixInverse")),o.length)){const e=t.properties.get(s);if(e.program){const i=t.getContext(),r=e.program;i.useProgram(r.program);const s=r.getUniforms();o.forEach((function(t){s.setValue(i,t,n[t].value)}))}}}class Ji{constructor(t){if(this.boundingBox=new a,this.boundingBoxSize=new e,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new e,this.signals={ticked:new et,rendered:new et},"string"==typeof t){const e=document.getElementById(t);this.container=null===e?document.createElement("div"):e}else t instanceof HTMLElement?this.container=t:this.container=document.createElement("div");if(this.container===document.body)this.width=window.innerWidth||1,this.height=window.innerHeight||1;else{const t=this.container.getBoundingClientRect();this.width=t.width||1,this.height=t.height||1,this.container.style.overflow="hidden"}this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.container.appendChild(this.wrapper),this._initParams(),this._initStats(),this._initCamera(),this._initScene(),!1!==this._initRenderer()?(this._initHelper(),this.setBackground(),this.setFog(),this.animate=this.animate.bind(this)):Me.error("Viewer: could not initialize renderer")}_initParams(){this.parameters={fogColor:new s(0),fogNear:50,fogFar:100,backgroundColor:new s(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new s(14540253),lightIntensity:1,ambientColor:new s(14540253),ambientIntensity:.2,sampleLevel:0,rendererEncoding:c}}_initCamera(){const t=new e(0,0,0),{width:i,height:r}=this;this.perspectiveCamera=new l(this.parameters.cameraFov,i/r),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(t),this.orthographicCamera=new h(i/-2,i/2,r/2,r/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(t),this.stereoCamera=new d,this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;const s=this.parameters.cameraType;if("orthographic"===s)this.camera=this.orthographicCamera;else{if("perspective"!==s&&"stereo"!==s)throw new Error(`Unknown cameraType '${s}'`);this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()}_initStats(){this.stats=new mi}_initScene(){this.scene||(this.scene=new u,this.scene.name="scene"),this.rotationGroup=new m,this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new m,this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new m,this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new m,this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new m,this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new m,this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new p(this.parameters.fogColor.getHex()),this.spotLight=new f(this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.spotLight),this.ambientLight=new g(this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)}_initRenderer(){const t=window.devicePixelRatio,{width:e,height:i}=this;try{this.renderer=new y({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(t){return this.wrapper.innerHTML='

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

',!1}this.renderer.setPixelRatio(t),this.renderer.setSize(e,i),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,this.renderer.outputEncoding=this.parameters.rendererEncoding;const r=this.renderer.getContext();this.renderer.capabilities.isWebGL2?(ke(!0),Pe(this.renderer.extensions.get("EXT_color_buffer_float")),this.supportsHalfFloat=!0):(ke(this.renderer.extensions.get("EXT_frag_depth")),this.renderer.extensions.get("OES_element_index_uint"),Pe(this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&qi(r.FLOAT)),this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&qi(36193)),this.wrapper.appendChild(this.renderer.domElement);const s=e*t,n=i*t;De&&console.log(JSON.stringify({Browser:Ae,OES_texture_float:!!this.renderer.extensions.get("OES_texture_float"),OES_texture_half_float:!!this.renderer.extensions.get("OES_texture_half_float"),WEBGL_color_buffer_float:!!this.renderer.extensions.get("WEBGL_color_buffer_float"),"testTextureSupport Float":qi(r.FLOAT),"testTextureSupport HalfFloat":qi(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:Ce},null,2)),this.pickingTarget=new b(s,n,{minFilter:x,magFilter:x,stencilBuffer:!1,format:v,type:Ce?D:w}),this.pickingTarget.texture.generateMipmaps=!1,this.pickingTarget.texture.encoding=this.parameters.rendererEncoding,this.renderer.setRenderTarget(this.pickingTarget),this.renderer.clear(),this.renderer.setRenderTarget(null),this.sampleTarget=new b(s,n,{minFilter:A,magFilter:A,format:v}),this.sampleTarget.texture.encoding=this.parameters.rendererEncoding,this.holdTarget=new b(s,n,{minFilter:x,magFilter:x,format:v,type:w}),this.holdTarget.texture.encoding=this.parameters.rendererEncoding,this.compositeUniforms={tForeground:new _(this.sampleTarget.texture),scale:new _(1)},this.compositeMaterial=new S({uniforms:this.compositeUniforms,vertexShader:gi("Quad.vert"),fragmentShader:gi("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:C,depthTest:!1,depthWrite:!1}),this.compositeCamera=new h(-1,1,1,-1,0,1),this.compositeScene=new u,this.compositeScene.name="compositeScene",this.compositeScene.add(new P(new I(2,2),this.compositeMaterial))}_initHelper(){const t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),e=new Float32Array(24),i=new k;i.setIndex(new M(t,1)),i.setAttribute("position",new M(e,3));const r=new S({uniforms:{uColor:{value:new s("skyblue")}},vertexShader:gi("BasicLine.vert"),fragmentShader:gi("BasicLine.frag")});this.boundingBoxMesh=new T(i,r),this.helperGroup.add(this.boundingBoxMesh)}updateHelper(){const t=this.boundingBoxMesh.geometry.attributes.position,e=t.array,{min:i,max:r}=this.boundingBox;e[0]=r.x,e[1]=r.y,e[2]=r.z,e[3]=i.x,e[4]=r.y,e[5]=r.z,e[6]=i.x,e[7]=i.y,e[8]=r.z,e[9]=r.x,e[10]=i.y,e[11]=r.z,e[12]=r.x,e[13]=r.y,e[14]=i.z,e[15]=i.x,e[16]=r.y,e[17]=i.z,e[18]=i.x,e[19]=i.y,e[20]=i.z,e[21]=r.x,e[22]=i.y,e[23]=i.z,t.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()}get cameraDistance(){return Math.abs(this.camera.position.z)}set cameraDistance(t){this.camera.position.z=-t}add(t,e){e?e.forEach((e=>this.addBuffer(t,e))):this.addBuffer(t),t.group.name="meshGroup",t.wireframeGroup.name="wireframeGroup",t.parameters.background?(this.backgroundGroup.add(t.group),this.backgroundGroup.add(t.wireframeGroup)):(this.modelGroup.add(t.group),this.modelGroup.add(t.wireframeGroup)),t.pickable&&this.pickingGroup.add(t.pickingGroup),De&&this.updateHelper()}addBuffer(t,e){function i(r){r instanceof m?r.children.forEach(i):(r.userData.buffer=t,r.userData.instance=e,r.onBeforeRender=Qi)}const r=t.getMesh();e&&r.applyMatrix4(e.matrix),i(r),t.group.add(r);const s=t.getWireframeMesh();if(e&&(s.matrix.copy(r.matrix),s.position.copy(r.position),s.quaternion.copy(r.quaternion),s.scale.copy(r.scale)),i(s),t.wireframeGroup.add(s),t.pickable){const s=t.getPickingMesh();e&&(s.matrix.copy(r.matrix),s.position.copy(r.position),s.quaternion.copy(r.quaternion),s.scale.copy(r.scale)),i(s),t.pickingGroup.add(s)}e?this._updateBoundingBox(t.geometry,t.matrix,e.matrix):this._updateBoundingBox(t.geometry,t.matrix)}remove(t){this.translationGroup.children.forEach((function(e){e.remove(t.group),e.remove(t.wireframeGroup)})),t.pickable&&this.pickingGroup.remove(t.pickingGroup),this.updateBoundingBox(),De&&this.updateHelper()}_updateBoundingBox(t,e,i){const r=this.boundingBox;function s(t,e,i){null==t.boundingBox&&t.computeBoundingBox();const s=t.boundingBox.clone();e&&s.applyMatrix4(e),i&&s.applyMatrix4(i),s.min.equals(s.max)&&s.expandByScalar(5),r.union(s)}function n(t){if(void 0!==t.geometry){let e,i;t.userData.buffer&&(e=t.userData.buffer.matrix),t.userData.instance&&(i=t.userData.instance.matrix),s(t.geometry,e,i)}}t?s(t,e,i):(r.makeEmpty(),this.modelGroup.traverse(n),this.backgroundGroup.traverse(n)),r.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()}updateBoundingBox(){this._updateBoundingBox(),De&&this.updateHelper()}getPickingPixels(){const{width:t,height:e}=this,i=t*e*4,r=Ce?new Float32Array(i):new Uint8Array(i);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,t,e,r),r}getImage(t){return new Promise((e=>{if(t){const{width:t,height:i}=this,r=t*i*4;let s=this.getPickingPixels();if(Ce){const t=new Uint8Array(r);for(let e=0;e500&&!this.isStill&&this.sampleLevel<3&&-1!==this.sampleLevel){const t=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=t,De&&Me.log("rendered still frame")}this.frameRequest=window.requestAnimationFrame(this.animate)}pick(t,e){if("stereo"===this.parameters.cameraType)return{pid:0,instance:void 0,picker:void 0};t*=window.devicePixelRatio,e*=window.devicePixelRatio,t=Math.max(t-2,0),e=Math.max(e-2,0);let i,r,s=0;const n=Ce?Xi:Yi;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,t,e,5,5,n);for(let t=0;t22&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame((()=>{this.render(),this.stats.update()})))}updateZoom(){const t=kt(this.perspectiveCamera.fov),e=2*Math.tan(t/2)*this.cameraDistance;this.orthographicCamera.zoom=this.height/e}absoluteToRelative(t){return 50*(1-t/this.bRadius)}relativeToAbsolute(t){return this.bRadius*(1-t/50)}__updateClipping(){const t=this.parameters;this.bRadius=Math.max(10,.5*this.boundingBoxLength),isFinite(this.bRadius)||(this.bRadius=50),this.camera.getWorldPosition(this.distVector),this.cDist=this.distVector.length(),this.cDist||(this.cameraDistance=Math.abs(t.cameraZ),this.cDist=Math.abs(t.cameraZ));const e=this.scene.fog;if(e.color.set(t.fogColor),"camera"===t.clipMode)this.camera.near=t.clipNear,this.camera.far=t.clipFar,e.near=t.fogNear,e.far=t.fogFar;else if("absolute"===t.clipScale)this.camera.near=this.cDist-t.clipNear,this.camera.far=this.cDist+t.clipFar,e.near=this.cDist-t.fogNear,e.far=this.cDist+t.fogFar;else{const i=(50-t.clipNear)/50,r=-(50-t.clipFar)/50;this.camera.near=this.cDist-this.bRadius*i,this.camera.far=this.cDist+this.bRadius*r;const s=(50-t.fogNear)/50,n=-(50-t.fogFar)/50;e.near=this.cDist-this.bRadius*s,e.far=this.cDist+this.bRadius*n}"camera"!==t.clipMode&&("PerspectiveCamera"===this.camera.type?(this.camera.near=Math.max(.1,t.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),e.near=Math.max(.1,e.near),e.far=Math.max(1,e.far)):"OrthographicCamera"===this.camera.type&&t.clipDist>0&&(this.camera.near=Math.max(t.clipDist,this.camera.near)))}__updateCamera(){const e=this.camera;e.updateMatrix(),e.updateMatrixWorld(!0),e.updateProjectionMatrix(),function(e,i,r,s,n){let o=new t;r.getSize(o);const a=o.height,c=r.getPixelRatio(),l="OrthographicCamera"===i.type;zi.set(o.width,o.height),Vi.getInverse(i.projectionMatrix),Gi.copy(i.projectionMatrix).transpose(),e.traverse((function(t){const e=t.material;if(!e)return;const i=e.uniforms;if(i){if(e.clipNear){const t=(50-e.clipNear)/50,r=s-n*t;i.clipNear.value=r}i.canvasHeight&&(i.canvasHeight.value=a),i.resolution&&i.resolution.value.copy(zi),i.pixelRatio&&(i.pixelRatio.value=c),i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(Vi),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(Gi),i.ortho&&(i.ortho.value=l)}}))}(this.scene,e,this.renderer,this.cDist,this.bRadius),function(t,e){t.traverseVisible((function(t){if(!(t instanceof o&&t.userData.buffer.parameters.sortParticles))return;const i=t.geometry.attributes,r=i.position.count;if(0===r)return;let s,n,a,c,l,h,d,u;Li.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),Ni.multiplyMatrices(e.projectionMatrix,Li),t.userData.sortData?(s=t.userData.sortData,a=s.__zArray,n=s.__sortArray,c=s.__cmpFn):(a=new Float32Array(r),n=new Uint32Array(r),c=function(t,e){const i=a[t],r=a[e];return i>r?1:ie?1:t=l&&e(t[o],n)>0;)t[o+1]=t[o],--o;t[o+1]=n}if(-1===c)break;h=s[c--],l=s[c--]}else{for(o=l+1,a=h,d(l+h>>1,o),e(t[l],t[h])>0&&d(l,h),e(t[o],t[h])>0&&d(o,h),e(t[l],t[o])>0&&d(l,o),n=t[o];;){do{o++}while(e(t[o],n)<0);do{a--}while(e(t[a],n)>0);if(a=a-l?(s[++c]=o,s[++c]=h,h=a-1):(s[++c]=l,s[++c]=a-1,l=o)}}(n,c);for(let t in i){const e=i[t],o=e.array,a=e.itemSize;s[t]||(s[t]=new Float32Array(a*r)),u=s[t],s[t]=o;for(let t=0;t0&&"stereo"!==this.parameters.cameraType?this.__renderSuperSample(e,i):this.__renderModelGroup(e,i)}render(t=!1,e){if(this.rendering)Me.warn("'tried to call 'render' from within 'render'");else{this.rendering=!0;try{this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),"stereo"===this.parameters.cameraType?this.__renderStereo(t,e):this.__render(t,this.camera,e),this.lastRenderedPicking=t}finally{this.rendering=!1,this.renderPending=!1}this.signals.rendered.dispatch()}}clear(){Me.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()}dispose(){this.renderer.dispose(),window.cancelAnimationFrame(this.frameRequest)}}const tr=1,er=2,ir=3;function rr(t){const e=t.touches[0].pageX-t.touches[1].pageX,i=t.touches[0].pageY-t.touches[1].pageY;return Math.sqrt(e*e+i*i)}class sr{constructor(e,i={}){this.domElement=e,this.signals={moved:new et,scrolled:new et,dragged:new et,dropped:new et,clicked:new et,hovered:new et,doubleClicked:new et},this.position=new t,this.prevPosition=new t,this.down=new t,this.canvasPosition=new t,this.prevClickCP=new t,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=0,this.buttons=0,this.pressed=!1,this.altKey=!1,this.ctrlKey=!1,this.metaKey=!1,this.shiftKey=!1,this.domElement.style.touchAction="none",this.hoverTimeout=st(i.hoverTimeout,50),this.handleScroll=st(i.handleScroll,!0),this.doubleClickSpeed=st(i.doubleClickSpeed,500),this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();const r={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,r),document.addEventListener("wheel",this._onMousewheel,r),document.addEventListener("MozMousePixelScroll",this._onMousewheel,r),document.addEventListener("mousemove",this._onMousemove,r),document.addEventListener("mousedown",this._onMousedown,r),document.addEventListener("mouseup",this._onMouseup,r),document.addEventListener("contextmenu",this._onContextmenu,r),document.addEventListener("touchstart",this._onTouchstart,r),document.addEventListener("touchend",this._onTouchend,r),document.addEventListener("touchmove",this._onTouchmove,r)}get key(){let t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t}setParameters(t={}){this.hoverTimeout=st(t.hoverTimeout,this.hoverTimeout)}_listen(){const t=window.performance.now(),e=this.canvasPosition;this.doubleClickPending&&t-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),t-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(e.x,e.y))),this.frameRequest=window.requestAnimationFrame(this._listen)}_onMousewheel(t){if(t.target!==this.domElement||!this.handleScroll)return;t.preventDefault(),this._setKeys(t);let e=0;"deltaY"in t&&"deltaMode"in t&&void 0!==t.deltaY&&void 0!==t.deltaMode?e=t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?.025*-t.deltaY:t.deltaMode===WheelEvent.DOM_DELTA_LINE?-t.deltaY*(2.5/3):2.5*-t.deltaY:"deltaY"in t&&!("detail"in t)?e=.025*-t.deltaY:void 0!==t.wheelDelta?e=.025*-t.wheelDelta:void 0!==t.wheelDeltaY?e=.025*-t.wheelDeltaY:void 0!==t.detail&&(e=-t.detail/3),this.signals.scrolled.dispatch(e),setTimeout((()=>{this.scrolled=!0}),this.hoverTimeout)}_onMousemove(t){t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(t),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.clientX,t.clientY),this._setCanvasPosition(t);const e=this.prevPosition.x-this.position.x,i=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,i),this.pressed&&this.signals.dragged.dispatch(e,i)}_onMousedown(t){t.target===this.domElement&&(t.preventDefault(),this._setKeys(t),this.moving=!1,this.hovering=!1,this.down.set(t.clientX,t.clientY),this.position.set(t.clientX,t.clientY),this.which=t.which,this.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){const e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(i/2);else{this.which=3,this.buttons=2;const t=this.prevPosition.x-this.position.x,e=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(t,e),this.pressed&&this.signals.dragged.dispatch(t,e)}}}}_distance(){return this.position.distanceTo(this.down)}_setCanvasPosition(t){const e=this.domElement.getBoundingClientRect();let i,r;"clientX"in t&&"clientY"in t?(i=t.clientX-e.left,r=t.clientY-e.top):(i=t.offsetX,r=t.offsetY),this.canvasPosition.set(i,e.height-r)}_setKeys(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey}dispose(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove),window.cancelAnimationFrame(this.frameRequest)}}const nr=new i,or=new i,ar=new i,cr=new i,lr=new i,hr=new e,dr=new r,ur=new r,mr=new i,pr=new e,fr=new e;class gr{constructor(t,e={}){this.stage=t,this.rotateSpeed=st(e.rotateSpeed,2),this.zoomSpeed=st(e.zoomSpeed,1.2),this.panSpeed=st(e.panSpeed,1),this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls}get component(){return this.stage.transformComponent}get atom(){return this.stage.transformAtom}_setPanVector(t,e,i=0){const r=this.controls.getCanvasScaleFactor(i);pr.set(t,e,0),pr.multiplyScalar(this.panSpeed*r)}_getRotateXY(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]}_getCameraRotation(t){return t.extractRotation(this.viewer.camera.matrixWorld),t.multiply(or.makeRotationY(Math.PI)),t}_transformPanVector(){this.component&&(mr.extractRotation(this.component.transform),mr.premultiply(this.viewer.rotationGroup.matrix),mr.getInverse(mr),mr.multiply(this._getCameraRotation(cr)),pr.applyMatrix4(mr))}zoom(t){this.controls.zoom(this.zoomSpeed*t*.02)}pan(t,e){this._setPanVector(t,e),mr.getInverse(this.viewer.rotationGroup.matrix),mr.multiply(this._getCameraRotation(cr)),pr.applyMatrix4(mr),this.controls.translate(pr)}panComponent(t,e){this.component&&(this._setPanVector(t,e),this._transformPanVector(),this.component.position.add(pr),this.component.updateMatrix())}panAtom(t,e){this.atom&&this.component&&(this.atom.positionToVector3(fr),fr.add(this.viewer.translationGroup.position),fr.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(t,e,fr.z),this._transformPanVector(),this.atom.positionAdd(pr),this.component.updateRepresentations({position:!0}))}rotate(t,e){const[i,r]=this._getRotateXY(t,e);this._getCameraRotation(cr),hr.set(1,0,0),hr.applyMatrix4(cr),dr.setFromAxisAngle(hr,r),hr.set(0,1,0),hr.applyMatrix4(cr),ur.setFromAxisAngle(hr,i),dr.multiply(ur),cr.makeRotationFromQuaternion(dr),this.controls.applyMatrix(cr)}zRotate(t,e){const i=this.rotateSpeed*((-t+e)/-2)*.01;ar.makeRotationZ(i),this.controls.applyMatrix(ar)}rotateComponent(t,e){if(!this.component)return;const[i,r]=this._getRotateXY(t,e);this._getCameraRotation(lr),cr.extractRotation(this.component.transform),cr.premultiply(this.viewer.rotationGroup.matrix),cr.getInverse(cr),cr.premultiply(lr),hr.set(1,0,0),hr.applyMatrix4(cr),nr.makeRotationAxis(hr,r),hr.set(0,1,0),hr.applyMatrix4(cr),or.makeRotationAxis(hr,i),nr.multiply(or),dr.setFromRotationMatrix(nr),this.component.quaternion.premultiply(dr),this.component.quaternion.normalize(),this.component.updateMatrix()}}const yr=new e;class br{constructor(t,e){this.stage=e,this.pid=t.pid,this.picker=t.picker,this.instance=t.instance,this.stage=e,this.controls=e.viewerControls,this.mouse=e.mouseObserver}get type(){return this.picker.type}get altKey(){return this.mouse.altKey}get ctrlKey(){return this.mouse.ctrlKey}get metaKey(){return this.mouse.metaKey}get shiftKey(){return this.mouse.shiftKey}get canvasPosition(){return this.mouse.canvasPosition}get component(){return this.stage.getComponentsByObject(this.picker.data).list[0]}get object(){return this.picker.getObject(this.pid)}get position(){return this.picker.getPosition(this.pid,this.instance,this.component)}get closestBondAtom(){if("bond"!==this.type||!this.bond)return;const t=this.bond,e=this.controls,i=this.canvasPosition,r=t.atom1.positionToVector3(),s=t.atom2.positionToVector3();r.applyMatrix4(this.component.matrix),s.applyMatrix4(this.component.matrix);const n=e.getPositionOnCanvas(r),o=e.getPositionOnCanvas(s);return c=n,l=o,(a=i).distanceTo(c)=t.length))return new br(i,this.stage);console.error("pid >= picker.array.length")}}}const vr=new r,wr=new e,Ar=new e,_r=new e,Sr=new e,Cr=new i,Pr=new e,Ir=new i;class kr{constructor(t){this.stage=t,this.signals={changed:new tt.Signal},this.viewer=t.viewer}get position(){return this.viewer.translationGroup.position}get rotation(){return this.viewer.rotationGroup.quaternion}changed(){this.viewer.requestRender(),this.signals.changed.dispatch()}getPositionOnCanvas(e,i){const r=wt(i,t);const s=this.viewer;return _r.copy(e).add(s.translationGroup.position).applyMatrix4(s.rotationGroup.matrix).project(s.camera),r.set((_r.x+1)*s.width/2,(_r.y+1)*s.height/2)}getCanvasScaleFactor(t=0){const e=this.viewer.camera;if(e instanceof h)return 1/e.zoom;{t=Math.abs(t),t+=this.getCameraDistance();const i=kt(e.fov);return 2*t*Math.tan(i/2)/this.viewer.height}}getOrientation(t){const e=_t(t);e.copy(this.viewer.rotationGroup.matrix);const i=this.getCameraDistance();return e.scale(Sr.set(i,i,i)),e.setPosition(this.viewer.translationGroup.position),e}orient(t){_t(t).decompose(wr,vr,Ar);const e=this.viewer;e.rotationGroup.setRotationFromQuaternion(vr),e.translationGroup.position.copy(wr),e.cameraDistance=Ar.z,e.updateZoom(),this.changed()}translate(t){this.viewer.translationGroup.position.add(At(t)),this.changed()}center(t){this.viewer.translationGroup.position.copy(At(t)).negate(),this.changed()}zoom(t){this.distance(this.getCameraDistance()*(1-t))}getCameraDistance(){return this.viewer.cameraDistance}distance(t){this.viewer.cameraDistance=Math.max(Math.abs(t),.2),this.viewer.updateZoom(),this.changed()}spin(t,e){Cr.getInverse(this.viewer.rotationGroup.matrix),Pr.copy(At(t)).applyMatrix4(Cr),this.viewer.rotationGroup.rotateOnAxis(Pr,e),this.changed()}rotate(t){this.viewer.rotationGroup.setRotationFromQuaternion(St(t)),this.changed()}align(t){Ir.getInverse(_t(t)),this.viewer.rotationGroup.setRotationFromMatrix(Ir),this.changed()}applyMatrix(t){this.viewer.rotationGroup.applyMatrix4(_t(t)),this.changed()}}class Mr{constructor(t,e,...i){this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=st(t,1e3),this.controls=e,this.startTime=window.performance.now(),this._init(...i)}get done(){return 1===this.alpha}get paused(){return this._paused}tick(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=Rt(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach((t=>t())),this.done}pause(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0}resume(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)}toggle(){this._paused?this.resume():this.pause()}then(t){let e;return e=this.done?Promise.resolve():new Promise((t=>this._resolveList.push(t))),e.then(t)}}class Tr extends Mr{constructor(t,e,...i){super(st(t,1/0),e,...i)}_init(t,i){Array.isArray(t)?this.axis=(new e).fromArray(t):this.axis=st(t,new e(0,1,0)),this.angle=st(i,.01)}_tick(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)}}class Br extends Mr{constructor(t,e,...i){super(st(t,1/0),e,...i),this.angleSum=0,this.direction=1}_init(t,i,r){Array.isArray(t)?this.axis=(new e).fromArray(t):this.axis=st(t,new e(0,1,0)),this.angleStep=st(i,.01),this.angleEnd=st(r,.2)}_tick(t){if(!this.axis||!this.angleStep||!this.angleEnd)return;const e=Rt(0,1,Math.abs(this.angleSum)/this.angleEnd),i=this.angleStep*this.direction*(1.1-e);this.controls.spin(this.axis,i*t.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}}class Dr extends Mr{_init(t,i){this.moveFrom=At(st(t,new e)),this.moveTo=At(st(i,new e))}_tick(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()}}class $r extends Mr{_init(t,e){this.zoomFrom=t,this.zoomTo=e}_tick(){this.controls.distance($t(this.zoomFrom,this.zoomTo,this.alpha))}}class Or extends Mr{constructor(){super(...arguments),this._currentRotation=new r}_init(t,e){this.rotateFrom=St(t),this.rotateTo=St(e),this._currentRotation=new r}_tick(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)}}class Rr extends Mr{_init(t,e,i){this.valueFrom=t,this.valueTo=e,this.callback=i}_tick(){this.callback($t(this.valueFrom,this.valueTo,this.alpha))}}class Er extends Mr{_init(t){this.callback=t}_tick(){1===this.alpha&&this.callback()}}class Fr{constructor(t=[]){this._resolveList=[],this._list=t}get done(){return this._list.every((t=>t.done))}then(t){let e;return e=this.done?Promise.resolve():new Promise((t=>{this._resolveList.push(t),this._list.forEach((t=>{t.then((()=>{this._resolveList.forEach((t=>{t()})),this._resolveList.length=0}))}))})),e.then(t)}}class Lr{constructor(t){this.stage=t,this.animationList=[],this.finishedList=[],this.viewer=t.viewer,this.controls=t.viewerControls}get paused(){return this.animationList.every((t=>t.paused))}add(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t}remove(t){const e=this.animationList,i=e.indexOf(t);i>-1&&e.splice(i,1)}run(t){const e=this.finishedList,i=this.animationList,r=i.length;for(let s=0;st.pause()))}resume(){this.animationList.forEach((t=>t.resume()))}toggle(){this.paused?this.resume():this.pause()}clear(){this.animationList.length=0}dispose(){this.clear()}}class Nr{constructor(t,e){if(this.fn=t,this.queue=[],this.pending=!1,this.next=this.next.bind(this),e){for(let t=0,i=e.length;tthis.run(t)))):this.pending=!1}push(t){this.queue.push(t),this.pending||this.next()}kill(){this.queue.length=0}length(){return this.queue.length}}class zr{constructor(t,e,i){this.type="",this.parameters={lazy:{type:"boolean"},clipNear:{type:"range",step:1,max:100,min:0,buffer:!0},clipRadius:{type:"number",precision:1,max:1e3,min:0,buffer:!0},clipCenter:{type:"vector3",precision:1,buffer:!0},flatShaded:{type:"boolean",buffer:!0},opacity:{type:"range",step:.01,max:1,min:0,buffer:!0},depthWrite:{type:"boolean",buffer:!0},side:{type:"select",buffer:!0,options:{front:"front",back:"back",double:"double"}},wireframe:{type:"boolean",buffer:!0},colorData:{type:"hidden",update:"color"},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:Fe.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:Fe.getModes()},roughness:{type:"range",step:.01,max:1,min:0,buffer:!0},metalness:{type:"range",step:.01,max:1,min:0,buffer:!0},diffuse:{type:"color",buffer:!0},diffuseInterior:{type:"boolean",buffer:!0},useInteriorColor:{type:"boolean",buffer:!0},interiorColor:{type:"color",buffer:!0},interiorDarkening:{type:"range",step:.01,max:1,min:0,buffer:!0},matrix:{type:"hidden",buffer:!0},disablePicking:{type:"boolean",rebuild:!0}},this.viewer=e,this.tasks=new ui,this.queue=new Nr(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=Fe.getSchemes()),this.toBePrepared=!1}init(t){const r=t||{};this.clipNear=st(r.clipNear,0),this.clipRadius=st(r.clipRadius,0),this.clipCenter=st(r.clipCenter,new e),this.flatShaded=st(r.flatShaded,!1),this.side=st(r.side,"double"),this.opacity=st(r.opacity,1),this.depthWrite=st(r.depthWrite,!0),this.wireframe=st(r.wireframe,!1),this.setColor(r.color,r),this.colorData=st(r.colorData,void 0),this.colorScheme=st(r.colorScheme,"uniform"),this.colorScale=st(r.colorScale,""),this.colorReverse=st(r.colorReverse,!1),this.colorValue=st(r.colorValue,9474192),this.colorDomain=st(r.colorDomain,void 0),this.colorMode=st(r.colorMode,"hcl"),this.visible=st(r.visible,!0),this.quality=st(r.quality,void 0),this.roughness=st(r.roughness,.4),this.metalness=st(r.metalness,0),this.diffuse=st(r.diffuse,16777215),this.diffuseInterior=st(r.diffuseInterior,!1),this.useInteriorColor=st(r.useInteriorColor,!1),this.interiorColor=st(r.interiorColor,2236962),this.interiorDarkening=st(r.interiorDarkening,0),this.lazy=st(r.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=st(r.matrix,new i),this.disablePicking=st(r.disablePicking,!1);const s=this.parameters;!0===s.sphereDetail&&(s.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===s.radialSegments&&(s.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===s.openEnded&&(s.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===s.disableImpostor&&(s.disableImpostor={type:"boolean",rebuild:!0}),"low"===r.quality?(s.sphereDetail&&(this.sphereDetail=0),s.radialSegments&&(this.radialSegments=5)):"medium"===r.quality?(s.sphereDetail&&(this.sphereDetail=1),s.radialSegments&&(this.radialSegments=10)):"high"===r.quality?(s.sphereDetail&&(this.sphereDetail=2),s.radialSegments&&(this.radialSegments=20)):(s.sphereDetail&&(this.sphereDetail=st(r.sphereDetail,1)),s.radialSegments&&(this.radialSegments=st(r.radialSegments,10))),s.openEnded&&(this.openEnded=st(r.openEnded,!0)),s.disableImpostor&&(this.disableImpostor=st(r.disableImpostor,!1))}getColorParams(t){return Object.assign({data:this.colorData,scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode,colorSpace:this.colorSpace},t)}getBufferParams(t={}){return Object.assign({clipNear:this.clipNear,clipRadius:this.clipRadius,clipCenter:this.clipCenter,flatShaded:this.flatShaded,opacity:this.opacity,depthWrite:this.depthWrite,side:this.side,wireframe:this.wireframe,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,diffuseInterior:this.diffuseInterior,useInteriorColor:this.useInteriorColor,interiorColor:this.interiorColor,interiorDarkening:this.interiorDarkening,matrix:this.matrix,disablePicking:this.disablePicking},t)}setColor(t,e){const i=Object.keys(Fe.getSchemes());if("string"==typeof t&&i.includes(t.toLowerCase()))e?e.colorScheme=t:this.setParameters({colorScheme:t});else if(void 0!==t){let i=new s(t).getHex();e?(e.colorScheme="uniform",e.colorValue=i):this.setParameters({colorScheme:"uniform",colorValue:i})}return this}prepare(t){}create(){}update(t){this.build()}build(t){if(!this.lazy||this.visible&&this.opacity){if(!this.toBePrepared)return this.tasks.increment(),void this.make();this.queue.length()>0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(t||!1)}else this.lazyProps.build=!0}make(t,e){De&&Me.time("Representation.make "+this.type);const i=()=>{t?(this.update(t),this.viewer.requestRender(),this.tasks.decrement(),e&&e()):(this.clear(),this.create(),this.manualAttach||this.disposed||(De&&Me.time("Representation.attach "+this.type),this.attach((()=>{De&&Me.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),e&&e()})))),De&&Me.timeEnd("Representation.make "+this.type)};this.toBePrepared?this.prepare(i):i()}attach(t){this.setVisibility(this.visible),t()}setVisibility(t,e){if(this.visible=t,this.visible&&this.opacity){const t=this.lazyProps,e=t.bufferParams,i=t.what;if(t.build)return t.build=!1,this.build(),this;(Object.keys(e).length||Object.keys(i).length)&&(t.bufferParams={},t.what={},this.updateParameters(e,i))}return this.bufferList.forEach((function(e){e.setVisibility(t)})),e||this.viewer.requestRender(),this}setParameters(t,e={},i=!1){const r=t||{},s=this.parameters,n={};this.opacity||void 0===r.opacity||(this.lazyProps.build?(this.lazyProps.build=!1,i=!0):(Object.assign(n,this.lazyProps.bufferParams),Object.assign(e,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(r.color,r);for(let t in r)if(void 0!==r[t]&&null!=s[t]&&(s[t].int&&(r[t]=parseInt(r[t])),s[t].float&&(r[t]=parseFloat(r[t])),r[t]!==this[t]||r[t].equals&&!r[t].equals(this[t]))){if(this[t]&&this[t].copy&&r[t].copy?this[t].copy(r[t]):this[t]&&this[t].set?this[t].set(r[t]):this[t]=r[t],s[t].buffer)if(!0===s[t].buffer)n[t]=r[t];else{n[s[t].buffer]=r[t]}s[t].update&&(e[s[t].update]=!0),!s[t].rebuild||"impostor"===s[t].rebuild&&Ie&&!this.disableImpostor||(i=!0)}return i?this.build():this.updateParameters(n,e),this}updateParameters(t={},e){if(this.lazy&&(!this.visible||!this.opacity)&&!1===t.hasOwnProperty("opacity"))return Object.assign(this.lazyProps.bufferParams,t),void Object.assign(this.lazyProps.what,e);this.bufferList.forEach((function(e){e.setParameters(t)})),Object.keys(e).length&&this.update(e),this.viewer.requestRender()}getParameters(){const t={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach((e=>{null!==this.parameters[e]&&(t[e]=this[e])})),t}clear(){this.bufferList.forEach((t=>{this.viewer.remove(t),t.dispose()})),this.bufferList.length=0,this.viewer.requestRender()}dispose(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()}}class Vr{constructor(t){this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=t,this.blobUrl=window.URL.createObjectURL(Ee.get(t)),this.worker=new Worker(this.blobUrl),Ee.activeWorkerCount+=1,this.worker.onmessage=e=>{this.pending-=1;const i=e.data.__postId;De&&Me.timeEnd("Worker.postMessage "+t+" #"+i);const r=this.onmessageDict[i];r&&r.call(this.worker,e),delete this.onmessageDict[i],delete this.onerrorDict[i]},this.worker.onerror=e=>{if(this.pending-=1,e.data){const i=e.data.__postId,r=this.onerrorDict[i];r?r.call(this.worker,e):Me.error("Worker.onerror",i,t,e),delete this.onmessageDict[i],delete this.onerrorDict[i]}else Me.error("Worker.onerror",t,e)}}post(t={},e,i,r){this.onmessageDict[this.postCount]=i,this.onerrorDict[this.postCount]=r,t.__name=this.name,t.__postId=this.postCount,t.__debug=De,De&&Me.time(`Worker.postMessage ${this.name} #${this.postCount}`);try{this.worker.postMessage(t,e)}catch(e){Me.error("worker.post:",e),this.worker.postMessage(t)}return this.pending+=1,this.postCount+=1,this}terminate(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),Ee.activeWorkerCount-=1):Me.log("no worker to terminate")}}class Gr{constructor(t,e=2){this.pool=[],this.count=0,this.maxCount=Math.min(8,e),this.name=t}post(t={},e,i,r){const s=this.getNextWorker();return s?s.post(t,e,i,r):console.error("unable to get worker from pool"),this}terminate(){this.pool.forEach((function(t){t.terminate()}))}getNextWorker(){let t,e=1/0;for(let i=0;i=this.count){t=new Vr(this.name),this.pool.push(t),this.count+=1;break}const r=this.pool[i];if(0===r.pending){t=r;break}r.pendings&&(s=c),l>n&&(n=l),h>o&&(o=h)}return[Yr([e,i,r]),Yr([s,n,o])]}function Wr(t,e){for(let i=0,r=e.length;i0){const o=1/Math.sqrt(n);t[e]=i*o,t[e+1]=r*o,t[e+2]=s*o}}}function Yr(t){return new Float32Array(t||3)}function Kr(t,e,i){const r=e[0],s=e[1],n=e[2],o=i[0],a=i[1],c=i[2];t[0]=s*c-n*a,t[1]=n*o-r*c,t[2]=r*a-s*o}function Zr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Qr(t,e,i){t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2]}function Jr(t,e,i){t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2]}function ts(t,e,i=0){t[0]=e[i],t[1]=e[i+1],t[2]=e[i+2]}function es(t,e,i=0){e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2]}function is(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function rs(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])}function ss(t,e,i){ns(t,e,1/i)}function ns(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}function os(t,e){const i=is(e);0==i?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):ns(t,e,1/Math.sqrt(i))}function as(t,e,i){t[0]=e[0]-i,t[1]=e[1]-i,t[2]=e[2]-i}function cs(t,e,i){t[0]=e[0]+i,t[1]=e[1]+i,t[2]=e[2]+i}function ls(t,e){t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2])}function hs(t,e){t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2])}function ds(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}function us(t,e){const i=t[0],r=t[1],s=t[2],n=e[0],o=e[1],a=e[2],c=r*a-s*o,l=s*n-i*a,h=i*o-r*n,d=Math.sqrt(c*c+l*l+h*h),u=i*n+r*o+s*a;return Math.atan2(d,u)}function ms(t,i=9){const r=Math.floor(i/2),s=t.position1.length/3,n=3*(r*s),o=1/i,a=_i(t.position1,t.position2),c=new Float32Array(n),l=new Float32Array(n),h=new e;for(let e=0;e0){const e=3*p;n[e]=t.position2[3*d-3],n[e+1]=t.position2[3*d-2],n[e+1]=t.position2[3*d-1]}const y=new Float32Array(s),b=new Float32Array(n),x=Ai(y,b),v=new Float32Array(o),w={position:x,position1:y,position2:b,color:v,color2:v};return a&&(w.radius=new Float32Array(a)),c&&t.picking&&(t.picking.array=new Float32Array(c),w.picking=t.picking),l&&(w.primitiveId=new Float32Array(l)),w}Gr.prototype.constructor=Gr,Hr.__deps=[Yr],ss.__deps=[ns],os.__deps=[ns,is];const gs=new e;class ys{static get Picker(){return He.get(this.type)}static get Buffer(){return je.get(this.type)}static getShapeKey(t){return this.type+t[0].toUpperCase()+t.substr(1)}static expandBoundingBox(t,e){}static valueToShape(t,e,i){const r=t._primitiveData[this.getShapeKey(e)];switch(this.fields[e]){case"v3":case"c":n=r,void 0!==(s=i).toArray?s=s.toArray():void 0!==s.x?s=[s.x,s.y,s.z]:void 0!==s.r&&(s=[s.r,s.g,s.b]),n.push.apply(n,s);break;default:r.push(i)}var s,n}static objectToShape(t,e){Object.keys(this.fields).forEach((i=>{this.valueToShape(t,i,e[i])})),this.valueToShape(t,"name",e.name),this.expandBoundingBox(t.boundingBox,e)}static valueFromShape(t,i,r){const n=t._primitiveData[this.getShapeKey(r)];switch(this.fields[r]){case"v3":return(new e).fromArray(n,3*i);case"c":return(new s).fromArray(n,3*i);default:return n[i]}}static objectFromShape(t,e){let i=this.valueFromShape(t,e,"name");void 0===i&&(i=`${this.type}: ${e} (${t.name})`);const r={shape:t,name:i};return Object.keys(this.fields).forEach((i=>{r[i]=this.valueFromShape(t,e,i)})),r}static arrayFromShape(t,e){const i=t._primitiveData[this.getShapeKey(e)];return"s"===this.fields[e]?i:new Float32Array(i)}static dataFromShape(t){const e={};return this.Picker&&(e.picking=new this.Picker(t)),Object.keys(this.fields).forEach((i=>{e[i]=this.arrayFromShape(t,i)})),e}static bufferFromShape(t,e){return new this.Buffer(this.dataFromShape(t),e)}}ys.type="",ys.fields={};class bs extends ys{static positionFromShape(t,e){return this.valueFromShape(t,e,"position")}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position))}}bs.type="sphere",bs.fields={position:"v3",color:"c",radius:"f"};class xs extends ys{static positionFromShape(t,e){return this.valueFromShape(t,e,"position")}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position))}}xs.type="box",xs.fields={position:"v3",color:"c",size:"f",heightAxis:"v3",depthAxis:"v3"};class vs extends xs{}vs.type="octahedron";class ws extends xs{}ws.type="tetrahedron";class As extends ys{static positionFromShape(t,e){const i=this.valueFromShape(t,e,"position1"),r=this.valueFromShape(t,e,"position2");return i.add(r).multiplyScalar(.5)}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position1)),t.expandByPoint(gs.fromArray(e.position2))}static bufferFromShape(t,e={}){let i=this.dataFromShape(t);return"cylinder"===this.type&&e.dashedCylinder&&(i=ps(i)),new this.Buffer(i,e)}}As.type="cylinder",As.fields={position1:"v3",position2:"v3",color:"c",radius:"f"};class _s extends As{}_s.type="arrow";class Ss extends As{}Ss.type="cone";class Cs extends bs{}Cs.type="ellipsoid",Cs.fields={position:"v3",color:"c",radius:"f",majorAxis:"v3",minorAxis:"v3"};class Ps extends Cs{}Ps.type="torus";class Is extends ys{static positionFromShape(t,e){return this.valueFromShape(t,e,"position")}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position))}}Is.type="text",Is.fields={position:"v3",color:"c",size:"f",text:"s"};class ks extends ys{static positionFromShape(t,e){return this.valueFromShape(t,e,"position")}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position))}}ks.type="point",ks.fields={position:"v3",color:"c"};class Ms extends ys{static positionFromShape(t,e){const i=this.valueFromShape(t,e,"position1"),r=this.valueFromShape(t,e,"position2");return i.add(r).multiplyScalar(.5)}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position1)),t.expandByPoint(gs.fromArray(e.position2))}}Ms.type="wideline",Ms.fields={position1:"v3",position2:"v3",color:"c"};class Ts{constructor(t,e){this.exp=3;const i=e||function(t){const{x:e,y:i,z:r}=t,s=new a,n=e.length,{min:o,max:c}=s;for(let t=0;t>this.exp),this.boundY=1+(i.max.y-this.minY>>this.exp),this.boundZ=1+(i.max.z-this.minZ>>this.exp);const r=this.boundX*this.boundY*this.boundZ,s=void 0!==t.count?t.count:t.x.length,n=t.x,o=t.y,c=t.z;let l=0;const h=new Uint32Array(r),d=new Int32Array(s);for(let t=0;t>this.exp,i=o[t]-this.minY>>this.exp,r=c[t]-this.minZ>>this.exp,s=(e*this.boundY+i)*this.boundZ+r;1===(h[s]+=1)&&(l+=1),d[t]=s}const u=new Uint16Array(l);for(let t=0,e=0;t0&&(h[t]=e+1,u[e]=i,e+=1)}const m=new Uint32Array(l);for(let t=1;t0){const i=e-1;f[m[i]+p[i]]=t,p[i]+=1}}this.grid=h,this.bucketCount=u,this.bucketOffset=m,this.bucketArray=f,this.xArray=n,this.yArray=o,this.zArray=c}within(t,e,i,r){const s=[];return this.eachWithin(t,e,i,r,(t=>s.push(t))),s}eachWithin(t,e,i,r,s){const n=r*r,o=Math.max(0,t-r-this.minX>>this.exp),a=Math.max(0,e-r-this.minY>>this.exp),c=Math.max(0,i-r-this.minZ>>this.exp),l=Math.min(this.boundX,1+(t+r-this.minX>>this.exp)),h=Math.min(this.boundY,1+(e+r-this.minY>>this.exp)),d=Math.min(this.boundZ,1+(i+r-this.minZ>>this.exp));for(let r=o;r0){const r=l-1,o=this.bucketOffset[r],a=o+this.bucketCount[r];for(let r=o;rr?s.set(this[e].subarray(0,r)):s.set(this[e]),this[e]=s}}growIfFull(){if(this.count>=this.length){const t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}}copyFrom(t,e,i,r){for(let s=0,n=this._fields.length;s0;)h-=1;l<=h&&(l===c?c=h:h===c&&(c=l),(o=l)!==(a=h)&&(i.copyFrom(e,0,o,1),e.copyWithin(o,a,1),e.copyFrom(i,a,0,1)),l+=1,h-=1)}while(l<=h);r(s,h),r(l,n)}var o,a}(0,this.count-1),Me.timeEnd("Store.sort")}clear(){this.count=0}dispose(){for(let t=0,e=this._fields.length;t>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}class Os{constructor(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()}get(t){return 0!=(this._words[t>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,o=e>>>5;for(let t=n+1;t>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>i,this}_isRangeValue(t,e,i){if(e>>5,o=e>>>5;for(let t=n+1;t>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<0){const{types:r,groups:s,centers:n,atomSets:o}=t;r.push(e.type),s.push(e.group),n.x.push(e.x/i),n.y.push(e.y/i),n.z.push(e.z/i),o.push(e.atomSet)}}const Ns=0,zs=["D-BETA-PEPTIDE, C-GAMMA LINKING","D-GAMMA-PEPTIDE, C-DELTA LINKING","D-PEPTIDE COOH CARBOXY TERMINUS","D-PEPTIDE NH3 AMINO TERMINUS","D-PEPTIDE LINKING","L-BETA-PEPTIDE, C-GAMMA LINKING","L-GAMMA-PEPTIDE, C-DELTA LINKING","L-PEPTIDE COOH CARBOXY TERMINUS","L-PEPTIDE NH3 AMINO TERMINUS","L-PEPTIDE LINKING","PEPTIDE LINKING","PEPTIDE-LIKE"],Vs=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],Gs=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],Us=["D-SACCHARIDE","D-SACCHARIDE 1,4 AND 1,4 LINKING","D-SACCHARIDE 1,4 AND 1,6 LINKING","L-SACCHARIDE","L-SACCHARIDE 1,4 AND 1,4 LINKING","L-SACCHARIDE 1,4 AND 1,6 LINKING","SACCHARIDE"],js=["NON-POLYMER"].concat(["OTHER"],Us),Hs=["h","g","i"],Ws=["e","b"],qs=["s","t","l",""],Xs={H:1,D:1,T:1,HE:2,LI:3,BE:4,B:5,C:6,N:7,O:8,F:9,NE:10,NA:11,MG:12,AL:13,SI:14,P:15,S:16,CL:17,AR:18,K:19,CA:20,SC:21,TI:22,V:23,CR:24,MN:25,FE:26,CO:27,NI:28,CU:29,ZN:30,GA:31,GE:32,AS:33,SE:34,BR:35,KR:36,RB:37,SR:38,Y:39,ZR:40,NB:41,MO:42,TC:43,RU:44,RH:45,PD:46,AG:47,CD:48,IN:49,SN:50,SB:51,TE:52,I:53,XE:54,CS:55,BA:56,LA:57,CE:58,PR:59,ND:60,PM:61,SM:62,EU:63,GD:64,TB:65,DY:66,HO:67,ER:68,TM:69,YB:70,LU:71,HF:72,TA:73,W:74,RE:75,OS:76,IR:77,PT:78,AU:79,HG:80,TL:81,PB:82,BI:83,PO:84,AT:85,RN:86,FR:87,RA:88,AC:89,TH:90,PA:91,U:92,NP:93,PU:94,AM:95,CM:96,BK:97,CF:98,ES:99,FM:100,MD:101,NO:102,LR:103,RF:104,DB:105,SG:106,BH:107,HS:108,MT:109,DS:110,RG:111,CN:112,NH:113,FL:114,MC:115,LV:116,TS:117,OG:118},Ys={1:1.1,2:1.4,3:1.81,4:1.53,5:1.92,6:1.7,7:1.55,8:1.52,9:1.47,10:1.54,11:2.27,12:1.73,13:1.84,14:2.1,15:1.8,16:1.8,17:1.75,18:1.88,19:2.75,20:2.31,21:2.3,22:2.15,23:2.05,24:2.05,25:2.05,26:2.05,27:2,28:2,29:2,30:2.1,31:1.87,32:2.11,33:1.85,34:1.9,35:1.83,36:2.02,37:3.03,38:2.49,39:2.4,40:2.3,41:2.15,42:2.1,43:2.05,44:2.05,45:2,46:2.05,47:2.1,48:2.2,49:2.2,50:1.93,51:2.17,52:2.06,53:1.98,54:2.16,55:3.43,56:2.68,57:2.5,58:2.48,59:2.47,60:2.45,61:2.43,62:2.42,63:2.4,64:2.38,65:2.37,66:2.35,67:2.33,68:2.32,69:2.3,70:2.28,71:2.27,72:2.25,73:2.2,74:2.1,75:2.05,76:2,77:2,78:2.05,79:2.1,80:2.05,81:1.96,82:2.02,83:2.07,84:1.97,85:2.02,86:2.2,87:3.48,88:2.83,89:2,90:2.4,91:2,92:2.3,93:2,94:2,95:2,96:2,97:2,98:2,99:2,100:2,101:2,102:2,103:2,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:2,114:2,115:2,116:2,117:2,118:2},Ks={1:.31,2:.28,3:1.28,4:.96,5:.84,6:.76,7:.71,8:.66,9:.57,10:.58,11:1.66,12:1.41,13:1.21,14:1.11,15:1.07,16:1.05,17:1.02,18:1.06,19:2.03,20:1.76,21:1.7,22:1.6,23:1.53,24:1.39,25:1.39,26:1.32,27:1.26,28:1.24,29:1.32,30:1.22,31:1.22,32:1.2,33:1.19,34:1.2,35:1.2,36:1.16,37:2.2,38:1.95,39:1.9,40:1.75,41:1.64,42:1.54,43:1.47,44:1.46,45:1.42,46:1.39,47:1.45,48:1.44,49:1.42,50:1.39,51:1.39,52:1.38,53:1.39,54:1.4,55:2.44,56:2.15,57:2.07,58:2.04,59:2.03,60:2.01,61:1.99,62:1.98,63:1.98,64:1.96,65:1.94,66:1.92,67:1.92,68:1.89,69:1.9,70:1.87,71:1.87,72:1.75,73:1.7,74:1.62,75:1.51,76:1.44,77:1.41,78:1.36,79:1.36,80:1.32,81:1.45,82:1.46,83:1.48,84:1.4,85:1.5,86:1.5,87:2.6,88:2.21,89:2.15,90:2.06,91:2,92:1.96,93:1.9,94:1.87,95:1.8,96:1.69,97:1.6,98:1.6,99:1.6,100:1.6,101:1.6,102:1.6,103:1.6,104:1.6,105:1.6,106:1.6,107:1.6,108:1.6,109:1.6,110:1.6,111:1.6,112:1.6,113:1.6,114:1.6,115:1.6,116:1.6,117:1.6,118:1.6},Zs={1:[1],2:[0],3:[1],4:[2],5:[3],6:[4],7:[3],8:[2],9:[1],10:[0],11:[1],12:[2],13:[6],14:[6],15:[3,5,7],16:[2,4,6],17:[1],18:[0],19:[1],20:[2],31:[3],32:[4],33:[3,5],34:[2,4,6],35:[1],36:[0],37:[1],38:[2],49:[3],50:[4],51:[3,5],52:[2],53:[1,2,5],54:[0,2],55:[1],56:[2],81:[3],82:[4],83:[3],84:[2],85:[1],86:[0],87:[1],88:[2]},Qs={1:1,2:2,3:1,4:2,5:3,6:4,7:5,8:6,9:7,10:8,11:1,12:2,13:3,14:4,15:5,16:6,17:7,18:8,19:1,20:2,21:3,22:4,23:5,24:6,25:7,26:8,27:9,28:10,29:11,30:2,31:3,32:4,33:5,34:6,35:7,36:8,37:1,38:2,39:3,40:4,41:5,42:6,43:7,44:8,45:9,46:10,47:11,48:2,49:3,50:4,51:5,52:6,53:7,54:8,55:1,56:2,57:3,58:4,59:3,60:4,61:5,62:6,63:7,64:8,65:9,66:10,67:11,68:12,69:13,70:14,71:15,72:4,73:5,74:6,75:7,76:8,77:9,78:10,79:11,80:2,81:3,82:4,83:5,84:6,85:7,86:8,87:1,88:2,89:3,90:4,91:3,92:4,93:5,94:6,95:7,96:8,97:9,98:10,99:11,100:12,101:13,102:14,103:15,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:3,114:4,115:5,116:6,117:7,118:8},Js={ALA:[.17,.5,.33],ARG:[.81,1.81,1],ASN:[.42,.85,.43],ASP:[1.23,3.64,2.41],ASH:[-.07,.43,.5],CYS:[-.24,-.02,.22],GLN:[.58,.77,.19],GLU:[2.02,3.63,1.61],GLH:[-.01,.11,.12],GLY:[.01,1.15,1.14],HIS:[.17,.11,-.06],ILE:[-.31,-1.12,-.81],LEU:[-.56,-1.25,-.69],LYS:[.99,2.8,1.81],MET:[-.23,-.67,-.44],PHE:[-1.13,-1.71,-.58],PRO:[.45,.14,-.31],SER:[.13,.46,.33],THR:[.14,.25,.11],TRP:[-1.85,-2.09,-.24],TYR:[-.94,-.71,.23],VAL:[.07,-.46,-.53]},tn=[0,0,0],en={HIS:"H",ARG:"R",LYS:"K",ILE:"I",PHE:"F",LEU:"L",TRP:"W",ALA:"A",MET:"M",PRO:"P",CYS:"C",ASN:"N",VAL:"V",GLY:"G",SER:"S",GLN:"Q",TYR:"Y",ASP:"D",GLU:"E",THR:"T",SEC:"U",PYL:"O"},rn=Object.keys(en),sn=["A","C","T","G","U","I"],nn=["DA","DC","DT","DG","DU","DI"],on=["A","G","I","DA","DG","DI"],an=sn.concat(nn),cn=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4","SPC"],ln=["118","119","1AL","1CU","2FK","2HP","2OF","3CO","3MT","3NI","3OF","3P8","4MO","4PU","543","6MO","ACT","AG","AL","ALF","AM","ATH","AU","AU3","AUC","AZI","BA","BCT","BEF","BF4","BO4","BR","BS3","BSY","CA","CAC","CD","CD1","CD3","CD5","CE","CHT","CL","CO","CO3","CO5","CON","CR","CS","CSB","CU","CU1","CU3","CUA","CUZ","CYN","DME","DMI","DSC","DTI","DY","E4N","EDR","EMC","ER3","EU","EU3","F","FE","FE2","FPO","GA","GD3","GEP","HAI","HG","HGC","IN","IOD","IR","IR3","IRI","IUM","K","KO4","LA","LCO","LCP","LI","LU","MAC","MG","MH2","MH3","MLI","MLT","MMC","MN","MN3","MN5","MN6","MO1","MO2","MO3","MO4","MO5","MO6","MOO","MOS","MOW","MW1","MW2","MW3","NA","NA2","NA5","NA6","NAO","NAW","NCO","NET","NH4","NI","NI1","NI2","NI3","NO2","NO3","NRU","O4M","OAA","OC1","OC2","OC3","OC4","OC5","OC6","OC7","OC8","OCL","OCM","OCN","OCO","OF1","OF2","OF3","OH","OS","OS4","OXL","PB","PBM","PD","PDV","PER","PI","PO3","PO4","PR","PT","PT4","PTN","RB","RH3","RHD","RU","SB","SCN","SE4","SEK","SM","SMO","SO3","SO4","SR","T1A","TB","TBA","TCN","TEA","TH","THE","TL","TMA","TRA","UNX","V","VN3","VO4","W","WO5","Y1","YB","YB2","YH","YT3","ZCM","ZN","ZN2","ZN3","ZNO","ZO3","OHX"],hn=["045","0AT","0BD","0MK","0NZ","0TS","0V4","0XY","0YT","10M","147","149","14T","15L","16G","18T","18Y","1AR","1BW","1GL","1GN","1JB","1LL","1NA","1S3","26M","26Q","26R","26V","26W","26Y","27C","289","291","293","2DG","2F8","2FG","2FL","2FP","2GL","2M4","2M5","32O","34V","3CM","3DO","3DY","3FM","3LR","3MF","3MG","3SA","3ZW","46D","46M","46Z","48Z","4CQ","4GC","4NN","50A","5DI","5GF","5MM","5RP","5SA","5SP","64K","6PG","6SA","7JZ","7SA","A1Q","A2G","AAB","AAL","AAO","ABC","ABD","ABE","ABF","ABL","ACG","ACI","ACR","ACX","ADA","ADG","ADR","AF1","AFD","AFL","AFO","AFP","AFR","AGC","AGH","AGL","AHR","AIG","ALL","ALX","AMU","AOG","AOS","ARA","ARB","ARE","ARI","ASG","ASO","AXP","AXR","B0D","B16","B2G","B4G","B6D","B8D","B9D","BBK","BCD","BDG","BDP","BDR","BEM","BFP","BGC","BGL","BGP","BGS","BHG","BMA","BMX","BNG","BNX","BOG","BRI","BXF","BXP","BXX","BXY","C3X","C4X","C5X","CAP","CBI","CBK","CBS","CDR","CEG","CGF","CHO","CR1","CR6","CRA","CT3","CTO","CTR","CTT","D6G","DAF","DAG","DDA","DDB","DDL","DEL","DFR","DFX","DG0","DGC","DGD","DGM","DGS","DIG","DLF","DLG","DMU","DNO","DOM","DP5","DQQ","DQR","DR2","DR3","DR4","DRI","DSR","DT6","DVC","E4P","E5G","EAG","EBG","EBQ","EGA","EJT","EPG","ERE","ERI","F1P","F1X","F6P","FBP","FCA","FCB","FCT","FDP","FDQ","FFC","FIX","FMO","FRU","FSI","FU4","FUB","FUC","FUD","FUL","FXP","G16","G1P","G2F","G3I","G4D","G4S","G6D","G6P","G6S","GAC","GAD","GAL","GC1","GC4","GCD","GCN","GCO","GCS","GCT","GCU","GCV","GCW","GCX","GE1","GFG","GFP","GIV","GL0","GL2","GL5","GL6","GL7","GL9","GLA","GLB","GLC","GLD","GLF","GLG","GLO","GLP","GLS","GLT","GLW","GMH","GN1","GNX","GP1","GP4","GPH","GPM","GQ1","GQ2","GQ4","GS1","GS4","GSA","GSD","GTE","GTH","GTK","GTR","GTZ","GU0","GU1","GU2","GU3","GU4","GU5","GU6","GU8","GU9","GUF","GUP","GUZ","GYP","GYV","H2P","HDL","HMS","HS2","HSD","HSG","HSH","HSJ","HSQ","HSR","HSU","HSX","HSY","HSZ","IAB","IDG","IDR","IDS","IDT","IDU","IDX","IDY","IMK","IN1","IPT","ISL","KBG","KD2","KDA","KDM","KDO","KFN","KO1","KO2","KTU","L6S","LAG","LAI","LAK","LAO","LAT","LB2","LBT","LCN","LDY","LGC","LGU","LM2","LMT","LMU","LOG","LOX","LPK","LSM","LTM","LVZ","LXB","LXZ","M1F","M3M","M6P","M8C","MA1","MA2","MA3","MAB","MAG","MAL","MAN","MAT","MAV","MAW","MBG","MCU","MDA","MDM","MDP","MFA","MFB","MFU","MG5","MGA","MGL","MLB","MMA","MMN","MN0","MRP","MTT","MUG","MVP","MXY","N1L","N9S","NAA","NAG","NBG","NDG","NED","NG1","NG6","NGA","NGB","NGC","NGE","NGF","NGL","NGS","NGY","NHF","NM6","NM9","NTF","NTO","NTP","NXD","NYT","OPG","OPM","ORP","OX2","P3M","P53","P6P","PA5","PNA","PNG","PNW","PRP","PSJ","PSV","PTQ","QDK","QPS","QV4","R1P","R1X","R2B","R5P","RAA","RAE","RAF","RAM","RAO","RAT","RB5","RBL","RCD","RDP","REL","RER","RF5","RG1","RGG","RHA","RIB","RIP","RNS","RNT","ROB","ROR","RPA","RST","RUB","RUU","RZM","S6P","S7P","SA0","SCR","SDD","SF6","SF9","SG4","SG5","SG6","SG7","SGA","SGC","SGD","SGN","SGS","SHB","SHG","SI3","SIO","SOE","SOL","SSG","SUC","SUP","SUS","T6P","T6T","TAG","TCB","TDG","TGK","TGY","TH1","TIA","TM5","TM6","TM9","TMR","TMX","TOA","TOC","TRE","TYV","UCD","UDC","VG1","X0X","X1X","X2F","X4S","X5S","X6X","XBP","XDN","XDP","XIF","XIM","XLF","XLS","XMM","XUL","XXR","XYP","XYS","YO5","Z3Q","Z6J","Z9M","ZDC","ZDM"],dn=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","OT1","OT2","H","H1","H2","H3","HA","HN","BB"],un=["P","OP1","OP2","HOP2","HOP3","O2'","O3'","O4'","O5'","C1'","C2'","C3'","C4'","C5'","H1'","H2'","H2''","HO2'","H3'","H4'","H5'","H5''","HO3'","HO5'","O2*","O3*","O4*","O5*","C1*","C2*","C3*","C4*","C5*"],mn={1:{trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT","OT1","OT2"],backboneStart:"N",backboneEnd:"C"},2:{trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},3:{trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},4:{trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},5:{trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},6:{trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]}};mn[Ns]={};const pn={HD:"H",HS:"H",A:"C",NA:"N",NS:"N",OA:"O",OS:"O",SA:"S",G0:"C",G1:"C",G2:"C",G3:"C",CG0:"C",CG1:"C",CG2:"C",CG3:"C",W:"O"};function fn(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;default:return 8}}const gn=new Map([[2,kt(180)],[3,kt(120)],[4,kt(109.4721)],[6,kt(90)]]);function yn(t,i){let r=[];const s=new e,n=new e;return s.subVectors(i,t),t.eachBondedAtom((e=>{1!==e.number&&(n.subVectors(e,t),r.push(s.angleTo(n)))})),r}function bn(t,i){const r=t.clone(),s=new e;s.subVectors(i,t);const n=[new e,new e];let o=0;if(t.eachBondedAtom((e=>{o>1||1!==e.number&&(r.index=e.index,n[o++].subVectors(e,t))})),1===o&&r.eachBondedAtom((e=>{o>1||1!==e.number&&e.index!==t.index&&n[o++].subVectors(e,t)})),2!==o)return;const a=n[0].cross(n[1]);return Math.abs(Math.PI/2-a.angleTo(s))}function xn(t,e){const i=t.structure,r=i.atomCount,s=new Int8Array(r),n=new Int8Array(r),o=new Int8Array(r),a=new Int8Array(r);return i.eachAtom((t=>{const i=t.index,[r,c,l,h]=function(t,e){const i=t.bondToElementCount(1);let r=t.formalCharge||0;const s="always"===e.assignCharge||"auto"===e.assignCharge&&0===r,n="always"===e.assignH||"auto"===e.assignH&&0===i,o=t.bondCount,a=function(t){let e=0;return t.eachBond((t=>e+=t.bondOrder)),e}(t),c=function(t){const e=t.structure.getBondProxy(),i=t.number,r=8===i||7===i;if(r&&4===t.bondCount)return!1;let s=!1;return t.eachBond((i=>{if(i.bondOrder>1)s=!0;else if(r){const r=i.getOtherAtom(t);r.eachBond((t=>{if(t.bondOrder>1){const e=r.number;if((15===e||16===e)&&8===t.getOtherAtom(r).number)return;s=!0}}),e)}})),s}(t),l=a-o>0;let h=0,d=8;switch(t.number){case 1:s&&(0===o?(r=1,d=0):1===o&&(r=0,d=1));break;case 6:s&&(r=0),n&&(h=Math.max(0,4-a-Math.abs(r))),d=fn(o+h+Math.max(0,-r));break;case 7:if(s)if(n)if(c&&a<4)r=o-i==1&&a-i==2?1:0;else{let e=!1;t.eachBondedAtom((t=>{(16===t.number||t.isMetal())&&(e=!0)})),r=e?0:1}else r=a-3;n&&(h=Math.max(0,3-a+r)),d=fn(c&&!l?o+h-r:o+h+1-r);break;case 8:s&&(n||(r=a-2),1===a&&t.eachBondedAtom((e=>{e.eachBond((i=>{const s=i.getOtherAtom(e);s.index!==t.index&&8===s.number&&2===i.bondOrder&&(r=-1)}))}))),n&&(h=Math.max(0,2-a+r)),d=fn(c&&!l?o+h-r+1:o+h-r+2);break;case 16:s&&(n||(r=a<=3&&!t.bondToElementCount(8)?a-2:0)),n&&a<2&&(h=Math.max(0,2-a+r)),a<=3&&(d=fn(o+h-r+2));break;case 9:case 17:case 35:case 53:case 85:s&&(r=a-1);break;case 3:case 11:case 19:case 37:case 55:case 87:s&&(r=1-a);break;case 4:case 12:case 20:case 38:case 56:case 88:s&&(r=2-a);break;default:console.warn("Requested charge, protonation for an unhandled element",t.element)}return[r,h,h+i,d]}(t,e);s[i]=r,n[i]=c,o[i]=l,a[i]=h})),{charge:s,implicitH:n,totalH:o,idealGeometry:a}}function vn(t){if(t["@valenceModel"])return t["@valenceModel"];const e=xn(t,{assignCharge:"auto",assignH:"auto"});return t["@valenceModel"]=e,e}function wn(t){return 15===t.number&&t.bondToElementCount(8)===t.bondCount}const An=["ARG","HIS","LYS"],_n=["GLU","ASP"];function Sn(t,e){return 2===t&&1===e||1===t&&2===e}function Cn(t,e){return 3===t&&3===e}function Pn(t,e){return 3===t&&1===e||1===t&&3===e}function In(t){return"HIS"===t.resname&&7==t.number&&t.isRing()}function kn(t,e){return 5===t&&4===e||4===t&&5===e}function Mn(t,e){return 9===t&&5===e||5===t&&9===e}const Tn=[3,11,19,37,55,12,20,38,56,13,31,49,81,21,50,82,83,51,80];function Bn(t,e){return 12===t?11===e||12===e:13===t?10===e:void 0}const Dn=[17,35,53,85];const $n=[7,8,16],On=[6,7,15,16];const Rn=kt(180),En=kt(120);function Fn(t,e,i){return!Nn(t,e,i)&&(t.modelIndex!==e.modelIndex||t.altloc&&e.altloc&&t.altloc!==e.altloc)}const Ln={maxHydrophobicDist:4,maxHbondDist:3.5,maxHbondSulfurDist:4.1,maxHbondAccAngle:45,maxHbondDonAngle:45,maxHbondAccPlaneAngle:90,maxHbondDonPlaneAngle:30,maxPiStackingDist:5.5,maxPiStackingOffset:2,maxPiStackingAngle:30,maxCationPiDist:6,maxCationPiOffset:2,maxIonicDist:5,maxHalogenBondDist:4,maxHalogenBondAngle:30,maxMetalDist:3,refineSaltBridges:!0,masterModelIndex:-1,lineOfSightDistFactor:1};function Nn(t,e,i){return t.modelIndex===i&&e.modelIndex!==i||e.modelIndex===i&&t.modelIndex!==i}function zn(t,e,i){return!Nn(t,e,i)&&(t.modelIndex!==e.modelIndex||t.residueIndex===e.residueIndex||t.altloc&&e.altloc&&t.altloc!==e.altloc)}function Vn(t){const e={types:[],groups:[],centers:{x:[],y:[],z:[]},atomSets:[]};return De&&Me.time("calculateFeatures"),function(t,e){const{charge:i}=vn(t.data),r={};t.eachResidue((t=>{if(An.includes(t.resname)){const i=Es(1);t.eachAtom((t=>{7===t.number&&t.isSidechain()&&Fs(i,t)})),Ls(e,i)}else rn.includes(t.resname)||t.isNucleic()||(t.eachAtom((t=>{let i=!1;const s=Es(1);!function(t){let e=0;return 6===t.number&&3===t.bondCount&&3===t.bondToElementCount(7)&&t.eachBondedAtom((t=>{t.bondCount-t.bondToElementCount(1)==1&&++e})),2===e}(t)?function(t){let e=0;return 6===t.number&&3===t.bondCount&&2===t.bondToElementCount(7)&&1===t.bondToElementCount(6)&&t.eachBondedAtom((t=>{t.bondCount-t.bondToElementCount(1)==1&&++e})),2===e}(t)&&(s.group=9,i=!0):(s.group=8,i=!0),i&&(t.eachBondedAtom((t=>{7===t.number&&(r[t.index]=!0,Fs(s,t))})),Ls(e,s))})),t.eachAtom((t=>{const s=Es(1);i[t.index]>0&&(r[t.index]||(Fs(s,t),Ls(e,s)))})))}))}(t,e),function(t,e){const{charge:i}=vn(t.data),r={};t.eachResidue((t=>{if(_n.includes(t.resname)){const i=Es(2);t.eachAtom((t=>{8===t.number&&t.isSidechain()&&Fs(i,t)})),Ls(e,i)}else if(an.includes(t.resname)){const i=Es(2);t.eachAtom((t=>{wn(t)&&(i.group=6,t.eachBondedAtom((t=>{8===t.number&&Fs(i,t)})),Ls(e,i))}))}else rn.includes(t.resname)||an.includes(t.resname)||(t.eachAtom((t=>{let i=!1;const s=Es(2);!function(t){return 16===t.number&&3===t.bondToElementCount(8)}(t)?wn(t)?(s.group=6,i=!0):function(t){return 16===t.number&&4===t.bondToElementCount(8)}(t)?(s.group=5,i=!0):function(t){let e=0;return 6===t.number&&2===t.bondToElementCount(8)&&1===t.bondToElementCount(6)&&t.eachBondedAtom((t=>{8===t.number&&t.bondCount-t.bondToElementCount(1)==1&&++e})),2===e}(t)&&(s.group=10,i=!0):(s.group=4,i=!0),i&&(t.eachBondedAtom((t=>{8===t.number&&(r[t.index]=!0,Fs(s,t))})),Ls(e,s))})),t.eachAtom((t=>{const s=Es(2);i[t.index]<0&&(r[t.index]||(Fs(s,t),Ls(e,s)))})))}))}(t,e),function(t,e){const i=t.getAtomProxy();t.eachResidue((t=>{const r=t.getAromaticRings();if(r){const s=t.atomOffset;r.forEach((t=>{const r=Es(3);t.forEach((t=>{i.index=t+s,Fs(r,i)})),Ls(e,r)}))}}))}(t,e),function(t,e){const{charge:i,implicitH:r,idealGeometry:s}=vn(t.data);t.eachAtom((t=>{const n=Es(5),o=t.number;if(8===o)Fs(n,t),Ls(e,n);else if(7===o){if(In(t))Fs(n,t),Ls(e,n);else if(i[t.index]<1){const i=t.bondCount+r[t.index],o=s[t.index];(4===o&&i<4||3===o&&i<3||2===o&&i<2)&&(Fs(n,t),Ls(e,n))}}else 16===o&&("CYS"!==t.resname&&"MET"!==t.resname&&-1!==t.formalCharge||(Fs(n,t),Ls(e,n)))}))}(t,e),function(t,e){const{totalH:i}=vn(t.data);t.eachAtom((t=>{const r=Es(4),s=t.number;(In(t)||i[t.index]>0&&(7===s||8===s||16===s))&&(Fs(r,t),Ls(e,r))}))}(t,e),function(t,e){const{totalH:i}=vn(t.data);t.eachAtom((t=>{if(6===t.number&&i[t.index]>0&&(t.bondToElementCount(7)>0||t.bondToElementCount(8)>0||function(t){if(!t.isAromatic())return!1;const e=t.residueType.getRings();if(!e)return!1;let i=!1;return e.rings.forEach((e=>{i||e.some((e=>t.index-t.residueAtomOffset===e))&&(i=e.some((e=>{const i=t.residueType.atomTypeIdList[e],r=t.atomMap.get(i).number;return 7===r||8===r})))})),i}(t))){const i=Es(9);Fs(i,t),Ls(e,i)}}))}(t,e),function(t,e){t.eachAtom((t=>{let i=!1,r=!1;const s=rn.includes(t.resname),n=an.includes(t.resname);if(s||n?s?8===t.number?(["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(t.resname)&&t.isSidechain()||t.isBackbone())&&(i=!0,r=!0):16===t.number&&"CYS"===t.resname?(i=!0,r=!0):7===t.number&&"HIS"===t.resname&&t.isSidechain()&&(i=!0):n&&(8===t.number&&t.isBackbone()?(i=!0,r=!0):["N3","N4","N7"].includes(t.atomname)?i=!0:["O2","O4","O6"].includes(t.atomname)&&(i=!0,r=!0)):t.isHalogen()||8===t.number||16===t.number?(i=!0,r=!0):7===t.number&&(i=!0),i){const i=Es(11);Fs(i,t),Ls(e,i)}if(r){const i=Es(10);Fs(i,t),Ls(e,i)}}))}(t,e),function(t,e){t.eachAtom((t=>{if(t.isTransitionMetal()||30===t.number||48===t.number){const i=Es(12);Fs(i,t),Ls(e,i)}else if(Tn.includes(t.number)){const i=Es(13);Fs(i,t),Ls(e,i)}}))}(t,e),function(t,e){t.eachAtom((t=>{const i=Es(8);let r=!1;6===t.number?(r=!0,t.eachBondedAtom((t=>{const e=t.number;6!==e&&1!==e&&(r=!1)}))):9===t.number&&(r=!0),r&&(Fs(i,t),Ls(e,i))}))}(t,e),function(t,e){t.eachAtom((t=>{if($n.includes(t.number)){let i=!1;if(t.eachBondedAtom((t=>{On.includes(t.number)&&(i=!0)})),i){const i=Es(7);Fs(i,t),Ls(e,i)}}}))}(t,e),function(t,e){t.eachAtom((t=>{if(Dn.includes(t.number)&&1===t.bondToElementCount(6)){const i=Es(6);Fs(i,t),Ls(e,i)}}))}(t,e),De&&Me.timeEnd("calculateFeatures"),e}function Gn(t,i=Ln){const r=function(t){const{types:e,centers:i}=t;return{features:t,spatialHash:new Ts(i),contactStore:new Ds,featureSet:new Os(e.length,!1)}}(Vn(t));De&&Me.time("calculateContacts"),function(t,i,r={}){const s=st(r.maxIonicDist,Ln.maxIonicDist),n=st(r.maxPiStackingDist,Ln.maxPiStackingDist),o=st(r.maxPiStackingOffset,Ln.maxPiStackingOffset),a=st(r.maxPiStackingAngle,Ln.maxPiStackingAngle),c=st(r.maxCationPiDist,Ln.maxCationPiDist),l=st(r.maxCationPiOffset,Ln.maxCationPiOffset),h=st(r.masterModelIndex,Ln.masterModelIndex),d=Math.max(s+2,n,c),u=n*n,m=c*c,{features:p,spatialHash:f,contactStore:g,featureSet:y}=i,{types:b,centers:x,atomSets:v}=p,{x:w,y:A,z:_}=x,S=b.length,C=t.atomStore.x,P=t.atomStore.y,I=t.atomStore.z,k=t.getAtomProxy(),M=t.getAtomProxy(),T=function(t,e,i){const r=t.length,s=e.length;for(let n=0;n{if(e<=t)return;if(k.index=v[t][0],M.index=v[e][0],zn(k,M,h))return;const r=b[t],n=b[e];if(Sn(r,n))T(v[t],v[e],s)&&z(t,e,1);else if(Cn(r,n)){if(i<=u){L(v[t],E),L(v[e],F);const i=57.29578*E.angleTo(F);Math.min(N(t,e,F),N(e,t,E))<=o&&(i<=a||i>=180-a||i<=a+90&&i>=90-a)&&z(t,e,3)}}else if(Pn(r,n)&&i<=m){const[i,s]=3===r?[t,e]:[e,t];L(v[i],E),N(s,i,E)<=l&&z(i,s,2)}}))}(t,r,i),function(t,e,i={}){const r=st(i.maxHbondDist,Ln.maxHbondDist),s=st(i.maxHbondSulfurDist,Ln.maxHbondSulfurDist),n=kt(st(i.maxHbondAccAngle,Ln.maxHbondAccAngle)),o=kt(st(i.maxHbondDonAngle,Ln.maxHbondDonAngle)),a=kt(st(i.maxHbondAccPlaneAngle,Ln.maxHbondAccPlaneAngle)),c=kt(st(i.maxHbondDonPlaneAngle,Ln.maxHbondDonPlaneAngle)),l=st(i.masterModelIndex,Ln.masterModelIndex),h=Math.max(r,s),d=r*r,{features:u,spatialHash:m,contactStore:p,featureSet:f}=e,{types:g,centers:y,atomSets:b}=u,{x:x,y:v,z:w}=y,A=g.length,{idealGeometry:_}=vn(t.data),S=t.getAtomProxy(),C=t.getAtomProxy();for(let t=0;t{if(e<=t)return;const r=g[t],s=g[e],h=Mn(r,s);if(!h&&!kn(r,s))return;const[u,m]=5===s?[t,e]:[e,t];if(S.index=b[u][0],C.index=b[m][0],C.index===S.index)return;if(zn(S,C,l))return;if(16!==S.number&&16!==C.number&&i>d)return;if(S.connectedTo(C))return;const y=yn(S,C),x=gn.get(_[S.index])||kt(120);if(y.some((t=>Math.abs(x-t)>o)))return;if(3===_[S.index]){const t=bn(S,C);if(void 0!==t&&t>c)return}const v=yn(C,S),w=gn.get(_[C.index])||kt(120);if(v.some((t=>w-t>n)))return;if(3===_[C.index]){const t=bn(C,S);if(void 0!==t&&t>a)return}f.setBits(u,m);const A=h?8:function(t,e){return t.isWater()&&e.isWater()}(P=S,I=C)?9:function(t,e){return t.isBackbone()&&e.isBackbone()}(P,I)?10:4;var P,I;p.addContact(u,m,A)}))}(t,r,i),function(t,e,i={}){const r=st(i.maxMetalDist,Ln.maxMetalDist),s=st(i.masterModelIndex,Ln.masterModelIndex),{features:n,spatialHash:o,contactStore:a,featureSet:c}=e,{types:l,centers:h,atomSets:d}=n,{x:u,y:m,z:p}=h,f=l.length,g=t.getAtomProxy(),y=t.getAtomProxy();for(let t=0;t{if(e<=t)return;if(g.index=d[t][0],y.index=d[e][0],zn(g,y,s))return;const r=g.isMetal(),n=y.isMetal();if(!r&&!n)return;const[o,h]=r?[l[t],l[e]]:[l[e],l[t]];Bn(o,h)&&(c.setBits(t,e),a.addContact(t,e,7))}))}(t,r,i),function(t,e,i={}){const r=st(i.maxHydrophobicDist,Ln.maxHydrophobicDist),s=st(i.masterModelIndex,Ln.masterModelIndex),{features:n,spatialHash:o,contactStore:a,featureSet:c}=e,{types:l,centers:h,atomSets:d}=n,{x:u,y:m,z:p}=h,f=l.length,g=t.getAtomProxy(),y=t.getAtomProxy();for(let t=0;t{var r,n;e<=t||(g.index=d[t][0],y.index=d[e][0],zn(g,y,s)||9===g.number&&9===y.number||g.connectedTo(y)||(r=l[t],n=l[e],8===r&&8===n&&(c.setBits(t,e),a.addContact(t,e,6))))}))}(t,r,i),function(t,e,i={}){const r=st(i.maxHalogenBondDist,Ln.maxHalogenBondDist),s=kt(st(i.maxHalogenBondAngle,Ln.maxHalogenBondAngle)),n=st(i.masterModelIndex,Ln.masterModelIndex),{features:o,spatialHash:a,contactStore:c,featureSet:l}=e,{types:h,centers:d,atomSets:u}=o,{x:m,y:p,z:f}=d,g=h.length,y=t.getAtomProxy(),b=t.getAtomProxy();for(let t=0;t{if(e<=t)return;if(y.index=u[t][0],b.index=u[e][0],zn(y,b,n))return;if(r=h[t],o=h[e],!(7===r&&6===o||6===r&&7===o))return;var r,o;const[a,d]=6===h[t]?[y,b]:[b,y],m=yn(a,d);if(1!==m.length)return;if(Rn-m[0]>s)return;const p=yn(d,a);0!==p.length&&(p.some((t=>En-t>s))||(l.setBits(t,e),c.addContact(t,e,5)))}))}(t,r,i);const s=function(t){const{index1:e,index2:i,count:r}=t.contactStore,s=Rs({nodeArray1:e,nodeArray2:i,edgeCount:r,nodeCount:t.featureSet.length}),n=new Os(t.contactStore.count,!0);return Object.assign({adjacencyList:s,contactSet:n},t)}(r);return function(t,i,r={}){De&&Me.time("refineLineOfSight");const s=st(r.lineOfSightDistFactor,Ln.lineOfSightDistFactor),n=st(r.masterModelIndex,Ln.masterModelIndex),o=t.spatialHash,{contactSet:a,contactStore:c,features:l}=i,{index1:h,index2:d}=c,{centers:u,atomSets:m}=l,{x:p,y:f,z:g}=u,y=t.getAtomProxy(),b=t.getAtomProxy(),x=t.getAtomProxy(),v=new e,w=new e,A=3*s,_=s*s;a.forEach((t=>{v.set(p[h[t]],f[h[t]],g[h[t]]),w.set(p[d[t]],f[d[t]],g[d[t]]);const e=(v.x+w.x)/2,i=(v.y+w.y)/2,r=(v.z+w.z)/2,s=m[h[t]],c=m[d[t]];y.index=s[0],b.index=c[0],o.eachWithin(e,i,r,A,((e,i)=>{x.index=e,1!==x.number&&x.vdw*x.vdw*_>i&&!Fn(y,x,n)&&!Fn(b,x,n)&&!s.includes(e)&&!c.includes(e)&&v.distanceToSquared(x)>1&&w.distanceToSquared(x)>1&&(a.clear(t),De&&Me.log("removing",y.qualifiedName(),b.qualifiedName(),"because",x.qualifiedName()))}))})),De&&Me.timeEnd("refineLineOfSight")}(t,s,i),function(t,e){const{contactSet:i,contactStore:r,features:s}=e,{type:n,index1:o,index2:a}=r,{atomSets:c}=s,l=t.getAtomProxy(),h=t.getAtomProxy(),d={},u=function(t,e,r){const[s,n]=d[r]||[1/0,-1];t{if(6!==n[t])return;l.index=c[o[t]][0],h.index=c[a[t]][0];const e=l.distanceTo(h);u(e,t,`${l.index}|${h.residueIndex}`),u(e,t,`${h.index}|${l.residueIndex}`)}))}(t,s),i.refineSaltBridges&&function(t,e){const{contactSet:i,contactStore:r,features:s}=e,{type:n,index1:o,index2:a}=r,{atomSets:c}=s,l={},h=function(t,e){l[t]||(l[t]=[]),l[t].push(e)};i.forEach((t=>{1===n[t]&&(c[o[t]].forEach((e=>h(e,t))),c[a[t]].forEach((e=>h(e,t))))})),i.forEach((t=>{if(!function(t){return 4===t||9===t||10===t}(n[t]))return;const e=l[c[o[t]][0]],r=l[c[a[t]][0]];if(!e||!r)return;const s=e.length;for(let n=0;n{3===n[t]&&(c[o[t]].forEach((e=>h(e,t))),c[a[t]].forEach((e=>h(e,t))))})),i.forEach((t=>{if(6!==n[t]&&2!==n[t])return;const e=l[c[o[t]][0]],r=l[c[a[t]][0]];if(!e||!r)return;const s=e.length;for(let n=0;n{1===n[t]&&(c[o[t]].forEach((e=>h(e,t))),c[a[t]].forEach((e=>h(e,t))))})),i.forEach((t=>{if(7!==n[t])return;const e=l[c[o[t]][0]],r=l[c[a[t]][0]];if(!e||!r)return;const s=e.length;for(let t=0;te.getAtomSet(new pe(t)))):e.getAtomSet(new pe(r.filterSele))),o.forEach((t=>{const e=f[t];if(!s.includes(e))return;if(w){const e=l[m[t]][0],i=l[p[t]][0];if(Array.isArray(w)){if(!(w[0].isSet(e)&&w[1].isSet(i)||w[1].isSet(e)&&w[0].isSet(i)))return}else if(!w.isSet(e)&&!w.isSet(i))return}const i=m[t],n=p[t];g.push(h[i],d[i],u[i]),y.push(h[n],d[n],u[n]),b.push(...function(t){switch(t){case 4:case 9:case 10:return Hn.setHex(2851770).toArray();case 6:return Hn.setHex(8421504).toArray();case 5:return Hn.setHex(4259775).toArray();case 1:return Hn.setHex(15779860).toArray();case 7:return Hn.setHex(9191577).toArray();case 2:return Hn.setHex(16744448).toArray();case 3:return Hn.setHex(9220966).toArray();case 8:return Hn.setHex(12967404).toArray();default:return Hn.setHex(13421772).toArray()}}(e)),x.push(r.radius),v.push(t)})),{position1:new Float32Array(g),position2:new Float32Array(y),color:new Float32Array(b),color2:new Float32Array(b),radius:new Float32Array(x),picking:new Qn(v,t,e)}}class qn{constructor(t){this.array=t}get type(){return""}get data(){return{}}getIndex(t){return this.array?this.array[t]:t}getObject(t){return{}}_applyTransformations(t,e,i){return e&&t.applyMatrix4(e.matrix),i&&t.applyMatrix4(i.matrix),t}_getPosition(t){return new e}getPosition(t,e,i){return this._applyTransformations(this._getPosition(t),e,i)}}class Xn extends qn{constructor(t){super(),this.shape=t}get primitive(){}get data(){return this.shape}get type(){return this.primitive.type}getObject(t){return this.primitive.objectFromShape(this.shape,this.getIndex(t))}_getPosition(t){return this.primitive.positionFromShape(this.shape,this.getIndex(t))}}class Yn extends qn{constructor(t,e){super(t),this.structure=e}get type(){return"atom"}get data(){return this.structure}getObject(t){return this.structure.getAtomProxy(this.getIndex(t))}_getPosition(t){return(new e).copy(this.getObject(t))}}class Kn extends qn{constructor(t){super(),this.axes=t}get type(){return"axes"}get data(){return this.axes}getObject(){return{axes:this.axes}}_getPosition(){return this.axes.center.clone()}}class Zn extends qn{constructor(t,e,i){super(t),this.structure=e,this.bondStore=i||e.bondStore}get type(){return"bond"}get data(){return this.structure}getObject(t){const e=this.structure.getBondProxy(this.getIndex(t));return e.bondStore=this.bondStore,e}_getPosition(t){const i=this.getObject(t);return(new e).copy(i.atom1).add(i.atom2).multiplyScalar(.5)}}class Qn extends qn{constructor(t,e,i){super(t),this.contacts=e,this.structure=i}get type(){return"contact"}get data(){return this.contacts}getObject(t){const i=this.getIndex(t),{features:r,contactStore:s}=this.contacts,{centers:n,atomSets:o}=r,{x:a,y:c,z:l}=n,{index1:h,index2:d,type:u}=s,m=h[i],p=d[i];return{center1:new e(a[m],c[m],l[m]),center2:new e(a[p],c[p],l[p]),atom1:this.structure.getAtomProxy(o[m][0]),atom2:this.structure.getAtomProxy(o[p][0]),type:Un(u[i])}}_getPosition(t){const{center1:i,center2:r}=this.getObject(t);return(new e).addVectors(i,r).multiplyScalar(.5)}}class Jn extends qn{constructor(t,e,i){super(t),this.validation=e,this.structure=i}get type(){return"clash"}get data(){return this.validation}getObject(t){const e=this.validation,i=this.getIndex(t);return{validation:e,index:i,clash:e.clashArray[i]}}_getAtomProxyFromSele(t){const e=new pe(t),i=this.structure.getAtomIndices(e)[0];return this.structure.getAtomProxy(i)}_getPosition(t){const i=this.getObject(t).clash,r=this._getAtomProxyFromSele(i.sele1),s=this._getAtomProxyFromSele(i.sele2);return(new e).copy(r).add(s).multiplyScalar(.5)}}class to extends Zn{get type(){return"distance"}}class eo extends qn{get type(){return"ignore"}}class io extends Xn{constructor(t,e){super(t),this.mesh=e}get type(){return"mesh"}getObject(){const t=this.mesh;return{shape:this.shape,name:t.name,serial:t.serial}}_getPosition(){return this.__position||(this.__position=Ur(this.mesh.position)),this.__position}}class ro extends qn{constructor(t,e){super(t),this.surface=e}get type(){return"surface"}get data(){return this.surface}getObject(t){return{surface:this.surface,index:this.getIndex(t)}}_getPosition(){return this.surface.center.clone()}}class so extends qn{constructor(t,e){super(),this.unitcell=t,this.structure=e}get type(){return"unitcell"}get data(){return this.unitcell}getObject(){return{unitcell:this.unitcell,structure:this.structure}}_getPosition(){return this.unitcell.getCenter(this.structure)}}class no extends qn{constructor(t,e){super(t),this.volume=e}get type(){return"volume"}get data(){return this.volume}getObject(t){const e=this.volume,i=this.getIndex(t);return{volume:e,index:i,value:e.data[i]}}_getPosition(t){const i=this.volume.position,r=this.getIndex(t);return new e(i[3*r],i[3*r+1],i[3*r+2])}}class oo extends no{get type(){return"slice"}}function ao(){return new Uint32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0])}function co(){return new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-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1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])}function lo(t,e,i,r,s){var n,o,a,c,l,h,d,u=[[0,4,4,4,2,0,0,0,2,2,0,0],[4,0,4,4,0,8,0,0,0,8,8,0],[4,4,0,4,0,0,8,0,0,0,8,8],[4,4,4,0,0,0,0,1,1,0,0,1],[2,0,0,0,0,8,8,8,2,2,0,0],[0,8,0,0,8,0,8,8,0,8,8,0],[0,0,8,0,8,8,0,8,0,0,8,8],[0,0,0,1,8,8,8,0,1,0,0,1],[2,0,0,1,2,0,0,1,0,2,0,1],[2,8,0,0,2,8,0,0,2,0,8,0],[0,8,8,0,0,8,8,0,0,8,0,8],[0,0,8,1,0,0,8,1,1,0,8,0]],m=0,p=!1,f=!1,g=!1,y=!1,b=-1,x=e*i*r,v=e,w=e*i,A=new Int32Array(12),_=[],S=[],C=[],P=[],I=ao(),k=co();function M(t,e,i){return t+(e-t)*i}function T(t,s,n){return w*(n=(n+d)%r)+v*(s=(s+h)%i)+(t=(t+l)%e)}function B(t,e,i,r,c,l,h){var d=3*t;if(o[d]<0){var u=(m-l)/(h-l),f=n,g=3*a;if(_[g]=i+u,_[g+1]=r,_[g+2]=c,!p){var y=3*t;S[g]=b*M(f[y],f[y+3],u),S[g+1]=b*M(f[y+1],f[y+4],u),S[g+2]=b*M(f[y+2],f[y+5],u)}s&&(P[a]=s[t+Math.round(u)]),o[d]=a,A[e]=a,a+=1}else A[e]=o[d]}function D(t,e,i,r,c,l,h){var d=3*t+1;if(o[d]<0){var u=(m-l)/(h-l),f=n,g=3*a;if(_[g]=i,_[g+1]=r+u,_[g+2]=c,!p){var y=3*t,x=y+3*v;S[g]=b*M(f[y],f[x],u),S[g+1]=b*M(f[y+1],f[x+1],u),S[g+2]=b*M(f[y+2],f[x+2],u)}s&&(P[a]=s[t+Math.round(u)*v]),o[d]=a,A[e]=a,a+=1}else A[e]=o[d]}function $(t,e,i,r,c,l,h){var d=3*t+2;if(o[d]<0){var u=(m-l)/(h-l),f=n,g=3*a;if(_[g]=i,_[g+1]=r,_[g+2]=c+u,!p){var y=3*t,x=y+3*w;S[g]=b*M(f[y],f[x],u),S[g+1]=b*M(f[y+1],f[x+1],u),S[g+2]=b*M(f[y+2],f[x+2],u)}s&&(P[a]=s[t+Math.round(u)*w]),o[d]=a,A[e]=a,a+=1}else A[e]=o[d]}function O(e){var i=3*e;0===n[i]&&(n[i]=t[(e-1+x)%x]-t[(e+1)%x],n[i+1]=t[(e-v+x)%x]-t[(e+v)%x],n[i+2]=t[(e-w+x)%x]-t[(e+w)%x])}function R(e,i,r,s,n){var o,a,l,h,d,b,x;g?(s=T(e,i,r),o=T(e+1,i,r),a=T(e,i+1,r),l=T(e,i,r+1),h=T(e+1,i+1,r),d=T(e+1,i,r+1),b=T(e,i+1,r+1),x=T(e+1,i+1,r+1)):(o=s+1,h=(a=s+v)+1,d=(l=s+w)+1,x=(b=a+w)+1);var _=0,S=t[s],P=t[o],M=t[a],R=t[h],E=t[l],F=t[d],L=t[b],N=t[x];S=m){$=b,M=!0;break}if(M)break}if(M)break}for(M=!1,y=n;y=m){D=y,M=!0;break}if(M)break}if(M)break}for(M=!1,f=s;f=m){B=f,M=!0;break}if(M)break}if(M)break}for(M=!1,b=h;b>=a;--b){for(y=l;y>=n;--y){for(f=c;f>=s;--f)if(d=e*i*b+e*y+f,t[d]>=m){F=b,M=!0;break}if(M)break}if(M)break}for(M=!1,y=l;y>=n;--y){for(b=F;b>=a;--b){for(f=c;f>=s;--f)if(d=e*i*b+e*y+f,t[d]>=m){E=y,M=!0;break}if(M)break}if(M)break}for(M=!1,f=c;f>=s;--f){for(y=E;y>=n;--y){for(b=F;b>=a;--b)if(d=e*i*b+e*y+f,t[d]>=m){O=f,M=!0;break}if(M)break}if(M)break}p?(s=Math.max(0,B-1),n=Math.max(0,D-1),a=Math.max(0,$-1),c=Math.min(e-1,O+1),l=Math.min(i-1,E+1),h=Math.min(r-1,F+1)):(s=Math.max(1,B-1),n=Math.max(1,D-1),a=Math.max(1,$-1),c=Math.min(e-2,O+1),l=Math.min(i-2,E+1),h=Math.min(r-2,F+1))}var L=15;for(b=a;b0?-1:1,n||(n=new Float32Array(3*x)));var I=3*x;if(o&&o.length===I||(o=new Int32Array(I)),a=0,c=0,void 0!==v){var k=v[0].map(Math.round),M=v[1].map(Math.round);l=e*Math.ceil(Math.abs(k[0])/e),h=i*Math.ceil(Math.abs(k[1])/i),d=r*Math.ceil(Math.abs(k[2])/r),E(k[0],k[1],k[2],M[0],M[1],M[2])}else l=h=d=0,E();return _.length=3*a,p||(S.length=3*a),C.length=c,s&&(P.length=a),{position:new Float32Array(_),normal:p?void 0:new Float32Array(S),index:xt(C,_.length/3),atomindex:s?new Int32Array(P):void 0,contour:f}}}He.add("arrow",class extends Xn{get primitive(){return _s}}),He.add("box",class extends Xn{get primitive(){return xs}}),He.add("cone",class extends Xn{get primitive(){return Ss}}),He.add("cylinder",class extends Xn{get primitive(){return As}}),He.add("ellipsoid",class extends Xn{get primitive(){return Cs}}),He.add("octahedron",class extends Xn{get primitive(){return vs}}),He.add("sphere",class extends Xn{get primitive(){return bs}}),He.add("tetrahedron",class extends Xn{get primitive(){return ws}}),He.add("torus",class extends Xn{get primitive(){return Ps}}),He.add("point",class extends Xn{get primitive(){return ks}}),He.add("wideline",class extends Xn{get primitive(){return Ms}}),Object.assign(lo,{__deps:[ao,co,xt]});class ho{constructor(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}copyTo(t){t.data.set(this.data)}}function uo(t,e){let i=0,r=0;const s=e.rows,n=e.cols;let o=0,a=0,c=0;const l=e.data,h=t.data;for(;i(e=Math.abs(e))?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}const xo=1.192092896e-7,vo=1e-37;function wo(t,e,i,r){let s=0,n=0;const o=t.rows,a=t.cols;let c=o,l=a;c>16)?O:-O,t[h*e+u]=$;for(m=0;m<2;m++)for(d=0;d{const e=t.data.sd,i=t.data.p;o(this._makeSurface(e,i.isolevel,i.smooth))}),(a=>{console.warn("Volume.getSurfaceWorker error - trying without worker",a);const c=this.getSurface(t,e,i,r,s,n);o(c)}))}else{const a=this.getSurface(t,e,i,r,s,n);o(a)}}getValueForSigma(t){return this.mean+st(t,2)*this.rms}getSigmaForValue(t){return(st(t,0)-this.mean)/this.rms}get position(){if(!this._position){const t=this.nz,e=this.ny,i=this.nx,r=new Float32Array(i*e*t*3);let s=0;for(let n=0;ni){const t=e;e=i,i=t}const r=t[e];return void 0===r?(t[e]=[i],!0):!r.includes(i)&&(r.push(i),!0)}const i=this.geometry,r=i.index;if(this.parameters.wireframe)if(r){const s=r.array;let n,o=s.length;if(i.drawRange.count!==1/0&&(o=i.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*o)n=this.wireframeIndex;else{n=xt(2*o,i.attributes.position.count)}let a=0;t.length=0;for(let t=0;t2*t?this.wireframeIndex:xt(2*t,t);for(let i=0,r=0;ithis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new M(this.wireframeIndex,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0));else{const t=this.wireframeGeometry.getIndex();if(!t)return void Me.error("Index is null");t.set(this.wireframeIndex),t.needsUpdate=this.wireframeIndexCount>0,t.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}}getRenderOrder(){let t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t}_getMesh(t){this.material||this.makeMaterial();const e=this.geometry,i=this[t];let r;return r=this.isLine?new T(e,i):this.isPoint?new o(e,i):new P(e,i),r.frustumCulled=!1,r.renderOrder=this.getRenderOrder(),r}getMesh(){return this._getMesh("material")}getWireframeMesh(){let t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),t=new T(this.wireframeGeometry,this.wireframeMaterial),t.frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t}getPickingMesh(){return this._getMesh("pickingMaterial")}getShader(t,e){return gi(t,this.getDefines(e))}getVertexShader(t){return this.getShader(this.vertexShader,t)}getFragmentShader(t){return this.getShader(this.fragmentShader,t)}getDefines(t){const e={};return this.parameters.clipNear&&(e.NEAR_CLIP=1),this.parameters.clipRadius&&(e.RADIUS_CLIP=1),"picking"===t?e.PICKING=1:(("background"===t||this.parameters.background)&&(e.NOLIGHT=1),this.parameters.flatShaded&&(e.FLAT_SHADED=1),this.parameters.opaqueBack&&(e.OPAQUE_BACK=1),this.parameters.diffuseInterior&&(e.DIFFUSE_INTERIOR=1),this.parameters.useInteriorColor&&(e.USE_INTERIOR_COLOR=1)),e}getParameters(){return this.parameters}addUniforms(t){this.uniforms=R.merge([this.uniforms,t]),this.pickingUniforms=R.merge([this.pickingUniforms,t])}addAttributes(t){for(let e in t){let i;const r=t[e],s=this.attributeSize*Lo[r.type];r.value?(s!==r.value.length&&Me.error("attribute value has wrong length",e),i=r.value):i=bt("float32",s),this.geometry.setAttribute(e,new M(i,Lo[r.type]).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0))}}updateRenderOrder(){const t=this.getRenderOrder();function e(e){e.renderOrder=t}this.group.children.forEach(e),this.pickingGroup&&this.pickingGroup.children.forEach(e)}updateShader(){const t=this.material,e=this.wireframeMaterial,i=this.pickingMaterial;t.vertexShader=this.getVertexShader(),t.fragmentShader=this.getFragmentShader(),t.needsUpdate=!0,e.vertexShader=this.getShader("Line.vert"),e.fragmentShader=this.getShader("Line.frag"),e.needsUpdate=!0,i.vertexShader=this.getVertexShader("picking"),i.fragmentShader=this.getFragmentShader("picking"),i.needsUpdate=!0}setParameters(t){const e=t,i=this.parameterTypes,r=this.parameters,s={},n={};let o=!1,a=!1;for(const t in e){const c=e[t];void 0!==c&&(r[t]=c,void 0!==i[t]&&(i[t].property&&(!0!==i[t].property?s[i[t].property]=c:s[t]=c),i[t].uniform&&(!0!==i[t].uniform?n[i[t].uniform]=c:n[t]=c),i[t].updateShader&&(o=!0),i[t].updateVisibility&&(a=!0),this.dynamic&&"wireframe"===t&&!0===c&&this.updateWireframeIndex(),"forceTransparent"===t&&(s.transparent=this.transparent),"matrix"===t&&(this.matrix=c)))}this.setProperties(s),this.setUniforms(n),o&&this.updateShader(),a&&this.setVisibility(this.visible)}setAttributes(t){const e=this.geometry,i=e.attributes;for(const r in t){if("picking"===r)continue;const s=t[r],n=s.length;if("index"===r){const t=e.getIndex();if(!t){Me.error("Index is null");continue}e.setDrawRange(0,1/0),n>t.array.length?e.setIndex(new M(s,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(t.set(s),t.count=n,t.needsUpdate=n>0,t.updateRange.count=n,e.setDrawRange(0,n)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{const t=i[r];n>t.array.length?e.setAttribute(r,new M(s,t.itemSize).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(i[r].set(s),i[r].needsUpdate=n>0,i[r].updateRange.count=n)}}}setUniforms(t){if(!t)return;const e=this.material.uniforms,i=this.wireframeMaterial.uniforms,r=this.pickingMaterial.uniforms;for(let s in t)"opacity"===s&&this.setProperties({transparent:this.transparent}),void 0!==e[s]&&(e[s].value.isVector3?e[s].value.copy(t[s]):e[s].value.set?e[s].value.set(t[s]):e[s].value=t[s]),void 0!==i[s]&&(i[s].value.isVector3?i[s].value.copy(t[s]):i[s].value.set?i[s].value.set(t[s]):i[s].value=t[s]),void 0!==r[s]&&(r[s].value.isVector3?r[s].value.copy(t[s]):r[s].value.set?r[s].value.set(t[s]):r[s].value=t[s])}setProperties(t){if(!t)return;const e=this.material,i=this.wireframeMaterial,r=this.pickingMaterial;for(const s in t){const n=s;let o=t[n];"transparent"===n?this.updateRenderOrder():"side"===n&&(o=Fo(o)),e[n]=o,i[n]=o,r[n]=o}e.needsUpdate=!0,i.needsUpdate=!0,r.needsUpdate=!0}setVisibility(t){this.visible=t,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))}dispose(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()}toJSON(){var t={};for(var e in this)"group"!==e&&"wireframeGroup"!==e&&"pickingGroup"!=e&&"picking"!==e&&(t[e]=this[e]);return t}}class Uo extends Go{constructor(t,e={}){super(t,e),this.vertexShader="Mesh.vert",this.fragmentShader="Mesh.frag",this.addAttributes({normal:{type:"v3",value:t.normal}}),void 0===t.normal&&this.geometry.computeVertexNormals()}}class jo extends Uo{constructor(){super(...arguments),this.isSurface=!0}}function Ho(t){t.visible=!0}function Wo(t){t.visible=!1}class qo{constructor(t){this.group=new m,this.wireframeGroup=new m,this.pickingGroup=new m,this.frontMeshes=[],this.backMeshes=[],this.size=t.size,this.side=t.parameters.side,this.visible=t.visible,this.geometry=t.geometry,this.picking=t.picking,this.group=new m,this.wireframeGroup=new m,this.pickingGroup=new m,this.matrix=t.matrix;const e=t,i=new t.constructor({position:new Float32Array(0)});e.makeMaterial(),i.makeMaterial(),i.picking=t.picking,i.geometry=t.geometry,i.wireframeGeometry=t.wireframeGeometry,i.setParameters(t.getParameters()),i.updateShader(),e.setParameters({side:"front"}),i.setParameters({side:"back",opacity:i.parameters.opacity}),this.buffer=t,this.frontBuffer=e,this.backBuffer=i}set matrix(t){Go.prototype.setMatrix.call(this,t)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking&&!this.parameters.disablePicking}get parameters(){return this.buffer.parameters}getParameters(){const t=Object.assign({},this.buffer.parameters);return t.side=this.side,t}getMesh(t){let e,i;return t?(i=this.backBuffer.getPickingMesh(),e=this.frontBuffer.getPickingMesh()):(i=this.backBuffer.getMesh(),e=this.frontBuffer.getMesh()),this.frontMeshes.push(e),this.backMeshes.push(i),this.setParameters({side:this.side}),(new m).add(i,e)}getWireframeMesh(){return this.buffer.getWireframeMesh()}getPickingMesh(){return this.getMesh(!0)}setAttributes(t){this.buffer.setAttributes(t)}setParameters(t){"front"===(t=Object.assign({},t)).side?(this.frontMeshes.forEach(Ho),this.backMeshes.forEach(Wo)):"back"===t.side?(this.frontMeshes.forEach(Wo),this.backMeshes.forEach(Ho)):"double"===t.side&&(this.frontMeshes.forEach(Ho),this.backMeshes.forEach(Ho)),void 0!==t.side&&(this.side=t.side),delete t.side,void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,this.frontBuffer.setParameters(t),void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),delete t.wireframe,this.backBuffer.setParameters(t)}setVisibility(t){this.visible=t,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))}dispose(){this.frontBuffer.dispose(),this.backBuffer.dispose()}toJSON(){var t={};for(var e in this)["side","size","visible","matrix","parameters"].includes(e)&&(t[e]=this[e]);return t}}Ve.add("shader/Line.vert","uniform float clipNear;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/Line.frag","uniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");class Xo extends Go{constructor(){super(...arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}}class Yo extends zr{constructor(t,r,s){super(t,r,s),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},isolevelScroll:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),t instanceof Eo?(this.surface=void 0,this.volume=t):(this.surface=t,this.volume=void 0),this.boxCenter=new e,this.__boxCenter=new e,this.box=new a,this.__box=new a,this._position=new e,this.inverseMatrix=new i,this.setBox=function(){this._position.copy(r.translationGroup.position).negate(),this._position.applyMatrix4(this.inverseMatrix),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(s)}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),this.isolevelType=st(e.isolevelType,"sigma"),this.isolevel=st(e.isolevel,2),this.negateIsolevel=st(e.negateIsolevel,!1),this.isolevelScroll=st(e.isolevelScroll,!1),this.smooth=st(e.smooth,0),this.background=st(e.background,!1),this.opaqueBack=st(e.opaqueBack,!0),this.boxSize=st(e.boxSize,0),this.colorVolume=st(e.colorVolume,void 0),this.contour=st(e.contour,!1),this.useWorker=st(e.useWorker,!0),this.wrap=st(e.wrap,!1),super.init(e),this.inverseMatrix.getInverse(this.matrix),this.build()}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t)})),this.setVisibility(this.visible),t()}prepare(t){if(this.volume){let e;if(e="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(e*=-1),!this.surface||this.__isolevel!==e||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=e,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);const i=e=>{this.surface=e,t()};this.useWorker?this.volume.getSurfaceWorker(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else t()}else t()}create(){const t={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};let e;if(this.contour)e=new Xo(t,this.getBufferParams({wireframe:!1}));else{Object.assign(t,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});const i=new jo(t,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));e=new qo(i)}this.bufferList.push(e)}update(t){if(0===this.bufferList.length)return;const e={};(t=t||{}).position&&(e.position=this.surface.getPosition()),t.color&&(e.color=this.surface.getColor(this.getColorParams())),t.index&&(e.index=this.surface.getIndex()),t.normal&&(e.normal=this.surface.getNormal()),this.bufferList.forEach((function(t){t.setAttributes(e)}))}setParameters(t,e,i){return t&&void 0!==t.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===t.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===t.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=t.isolevelType),t&&t.boxCenter&&(this.boxCenter.copy(t.boxCenter),delete t.boxCenter),t&&t.wireframe&&(t.contour||void 0===t.contour&&this.contour)&&(t.wireframe=!1),super.setParameters(t,e,i),t.matrix&&this.inverseMatrix.getInverse(t.matrix),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),t&&void 0!==t.colorVolume&&e&&(e.color=!0),this.surface&&(void 0!==t.isolevel||void 0!==t.negateIsolevel||void 0!==t.smooth||void 0!==t.wrap||void 0!==t.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this}getColorParams(){const t=super.getColorParams();return t.volume=this.colorVolume,t}dispose(){this.viewer.signals.ticked.remove(this.setBox,this),super.dispose()}}class Ko{static zoomScroll(t,e){t.trackballControls.zoom(e)}static clipNearScroll(t,e){const i=t.getParameters();t.setParameters({clipNear:i.clipNear+e/10})}static focusScroll(t,e){const i=t.getFocus(),r=Math.sign(e)*function(t,e,i){if(t>e)return t;const r=t/e;return((2*i-e)*r+(2*e-3*i))*r*r+i}((100-i)/10,5,.2);t.setFocus(i+r)}static zoomFocusScroll(t,e){t.trackballControls.zoom(e);const i=t.viewer.camera.position.z;t.setFocus(100-Math.abs(i/8))}static isolevelScroll(t,e){const i=Math.sign(e)/10;t.eachRepresentation(((t,e)=>{if(t.repr instanceof Yo){const e=t.getParameters();e.isolevelScroll&&t.setParameters({isolevel:e.isolevel+i})}}))}static panDrag(t,e,i){t.trackballControls.pan(e,i)}static rotateDrag(t,e,i){t.trackballControls.rotate(e,i)}static zRotateDrag(t,e,i){t.trackballControls.zRotate(e,i)}static zoomDrag(t,e,i){t.trackballControls.zoom((e+i)/-2)}static zoomFocusDrag(t,e,i){t.trackballControls.zoom((e+i)/-2);const r=t.viewer.camera.position.z;t.setFocus(100-Math.abs(r/8))}static panComponentDrag(t,e,i){t.trackballControls.panComponent(e,i)}static panAtomDrag(t,e,i){t.trackballControls.panAtom(e,i)}static rotateComponentDrag(t,e,i){t.trackballControls.rotateComponent(e,i)}static movePick(t,e){e&&t.animationControls.move(e.position.clone())}static tooltipPick(t,e){const i=t.tooltip;if(t.getParameters().tooltip&&e){const t=e.mouse.position;i.innerText=e.getLabel(),i.style.bottom=window.innerHeight-t.y+3+"px",i.style.left=t.x+3+"px",i.style.display="block"}else i.style.display="none"}static measurePick(t,e){if(e&&(e.atom||e.bond)){const t=e.atom||e.closestBondAtom;e.component.measurePick(t)}else t.measureClear()}}const Zo={default:[["scroll",Ko.zoomScroll],["scroll-shift",Ko.focusScroll],["scroll-ctrl",Ko.isolevelScroll],["scroll-shift-ctrl",Ko.zoomFocusScroll],["drag-left",Ko.rotateDrag],["drag-right",Ko.panDrag],["drag-ctrl-left",Ko.panDrag],["drag-ctrl-right",Ko.zRotateDrag],["drag-shift-left",Ko.zoomDrag],["drag-middle",Ko.zoomFocusDrag],["drag-ctrl-shift-right",Ko.panComponentDrag],["drag-ctrl-shift-left",Ko.rotateComponentDrag],["clickPick-right",Ko.measurePick],["clickPick-ctrl-left",Ko.measurePick],["clickPick-middle",Ko.movePick],["clickPick-left",Ko.movePick],["hoverPick",Ko.tooltipPick]],pymol:[["drag-left",Ko.rotateDrag],["drag-middle",Ko.panDrag],["drag-right",Ko.zoomDrag],["scroll",Ko.focusScroll],["drag-shift-right",Ko.focusScroll],["clickPick-ctrl+shift-middle",Ko.movePick],["hoverPick",Ko.tooltipPick]],coot:[["scroll",Ko.isolevelScroll],["drag-left",Ko.rotateDrag],["drag-middle",Ko.panDrag],["drag-ctrl-left",Ko.panDrag],["drag-right",Ko.zoomFocusDrag],["drag-ctrl-right",Ko.focusScroll],["clickPick-middle",Ko.movePick],["hoverPick",Ko.tooltipPick]],astexviewer:[["drag-left",Ko.rotateDrag],["drag-ctrl-left",Ko.panDrag],["drag-shift-left",Ko.zoomDrag],["scroll",Ko.focusScroll],["clickPick-middle",Ko.movePick],["hoverPick",Ko.tooltipPick]]};function Qo(t){const e=t.split(/[-+]/);let i="";e.includes("scroll")&&(i="scroll"),e.includes("drag")&&(i="drag"),e.includes("click")&&(i="click"),e.includes("doubleClick")&&(i="doubleClick"),e.includes("hover")&&(i="hover"),e.includes("clickPick")&&(i="clickPick"),e.includes("hoverPick")&&(i="hoverPick");let r=0;e.includes("alt")&&(r+=1),e.includes("ctrl")&&(r+=2),e.includes("meta")&&(r+=4),e.includes("shift")&&(r+=8);let s=0;return e.includes("left")&&(s+=1),e.includes("right")&&(s+=2),e.includes("middle")&&(s+=4),[i,r,s]}class Jo{constructor(t,e={}){this.stage=t,this.actionList=[],this.mouse=t.mouseObserver,this.disabled=e.disabled||!1,this.preset(e.preset||"default")}run(t,...e){if(this.disabled)return;const i=this.mouse.key||0,r=this.mouse.buttons||0;this.actionList.forEach((s=>{s.type===t&&s.key===i&&s.button===r&&s.callback(this.stage,...e)}))}add(t,e){const[i,r,s]=Qo(t);this.actionList.push({type:i,key:r,button:s,callback:e})}remove(t,e){const i=t.includes("*"),[r,s,n]=Qo(t),o=this.actionList.filter((function(t){return!((t.type===r||i&&""===r)&&(t.key===s||i&&0===s)&&(t.button===n||i&&0===n)&&(t.callback===e||void 0===e))}));this.actionList=o}preset(t){this.clear();(Zo[t]||[]).forEach((t=>this.add(t[0],t[1])))}clear(){this.actionList.length=0}}class ta{static autoView(t){t.autoView(1e3)}static toggleAnimations(t){t.animationControls.toggle()}static toggleRock(t){t.toggleRock()}static toggleSpin(t){t.toggleSpin()}static toggleAntialiasing(t){const e=t.getParameters();t.setParameters({sampleLevel:-1===e.sampleLevel?0:-1})}}const ea={default:[["i",ta.toggleSpin],["k",ta.toggleRock],["p",ta.toggleAnimations],["a",ta.toggleAntialiasing],["r",ta.autoView]]};class ia{constructor(t,e={}){this.stage=t,this.actionList=[],this.disabled=e.disabled||!1,this.preset(e.preset||"default")}run(t){this.disabled||this.actionList.forEach((e=>{e.key===t&&e.callback(this.stage)}))}add(t,e){this.actionList.push({key:t,callback:e})}remove(t,e){const i=this.actionList.filter((function(i){return!(i.key===t&&(i.callback===e||void 0===e))}));this.actionList=i}preset(t){this.clear();(ea[t]||[]).forEach((t=>this.add(t[0],t[1])))}clear(){this.actionList.length=0}}class ra{constructor(t){this.stage=t,this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)}_onClick(t,e){const i=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(i),this.controls.run("clickPick",i)}_onHover(t,e){const i=this.stage.pickingControls.pick(t,e);i&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=i.component,this.stage.transformAtom=i.atom),this.stage.signals.hovered.dispatch(i),this.controls.run("hoverPick",i)}dispose(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}}class sa{constructor(t){this.stage=t,this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)}_onMove(){this.stage.tooltip.style.display="none"}_onScroll(t){this.controls.run("scroll",t)}_onDrag(t,e){this.controls.run("drag",t,e)}_onClick(t,e){this.controls.run("click",t,e)}_onDblclick(t,e){this.controls.run("doubleClick",t,e)}_onHover(t,e){this.controls.run("hover",t,e)}dispose(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}}class na{constructor(t){this.stage=t,this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)}_onTick(t){this.animationControls.run(t)}dispose(){this.viewer.signals.ticked.remove(this._onTick,this)}}const oa=!!_e&&{passive:!0};class aa{constructor(t){this.stage=t,this.stage=t,this.controls=t.keyControls,this.domElement=t.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,oa),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)}_onKeydown(){}_onKeyup(){}_onKeypress(t){let e;e="key"in KeyboardEvent.prototype?t.key:String.fromCharCode(t.which||t.keyCode),this.controls.run(e)}_focusDomElement(){this.domElement.focus()}dispose(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,oa),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)}}class ca{constructor(i,r,s,n={}){this.component=i,this.position=r,this.offsetX=st(n.offsetX,0),this.offsetY=st(n.offsetY,0),this.visible=st(n.visible,!0),this.stage=i.stage,this.viewer=i.stage.viewer,this._viewerPosition=new e,this._updateViewerPosition(),this._canvasPosition=new t,this._cameraPosition=new e,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",left:"-10000px"}),this.viewer.wrapper.appendChild(this.element),this.setContent(s),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)}setContent(t){const e=this.element.style.display;if("none"===e&&(this.element.style.left="-10000px",this.element.style.display="block"),t instanceof HTMLElement)this.element.appendChild(t);else{const e=document.createElement("div");e.innerText=t,Object.assign(e.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(e)}this._clientRect=this.element.getBoundingClientRect(),"none"===e&&(this.element.style.display=e)}setVisibility(t){this.visible=t,this.updateVisibility()}getVisibility(){return this.visible&&this.component.parameters.visible}updateVisibility(){this.element.style.display=this.getVisibility()?"block":"none"}_updateViewerPosition(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)}_update(){if(!this.getVisibility())return;const t=this.element.style,e=this._canvasPosition,i=this._viewerPosition,r=this._clientRect;if(this._cameraPosition.copy(i).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)return void(t.display="none");t.display="block";const s=this._cameraPosition.length(),n=this.viewer.scene.fog;t.opacity=(1-Rt(n.near,n.far,s)).toString(),t.zIndex=Math.round(100*(n.far-s)).toString(),this.stage.viewerControls.getPositionOnCanvas(i,e),t.bottom=this.offsetX+e.y+r.height/2+"px",t.left=this.offsetY+e.x-r.width/2+"px"}dispose(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)}}const la=new i,ha=new e,da=new r;class ua{constructor(t){this.component=t,this.signals={changed:new tt.Signal},this.stage=t.stage,this.viewer=t.stage.viewer}get position(){return this.component.position}get rotation(){return this.component.quaternion}changed(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()}spin(t,e){la.getInverse(this.viewer.rotationGroup.matrix),ha.copy(At(t)).applyMatrix4(la),la.extractRotation(this.component.transform),la.premultiply(this.viewer.rotationGroup.matrix),la.getInverse(la),ha.copy(At(t)),ha.applyMatrix4(la),la.makeRotationAxis(ha,e),da.setFromRotationMatrix(la),this.component.quaternion.premultiply(da),this.changed()}}const ma={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"};class pa{constructor(t={}){this.max=10,this.type=st(t.type,"size"),this.scale=st(t.scale,1),this.size=st(t.size,1),this.data=st(t.data,{})}atomRadius(t){let e;switch(this.type){case"vdw":e=t.vdw;break;case"covalent":e=t.covalent;break;case"bfactor":e=t.bfactor||1;break;case"sstruc":const i=t.sstruc;e="h"===i||"g"===i||"i"===i||"e"===i||"b"===i?.25:un.includes(t.atomname)?.4:.1;break;case"data":e=st(this.data[t.index],1);break;case"explicit":e=t.radius,null===e&&(e=this.size);break;default:e=this.size}return Math.min(e*this.scale,this.max)}}pa.types=ma;const fa=new e(-1,-1,-1),ga=new i;class ya{constructor(t){const i=t.rows,r=i/3,s=new ho(i,3),n=new ho(3,3),o=new ho(1,3),a=new ho(3,3),c=new ho(3,3),l=fo(t);go(t,l),uo(s,t),mo(n,s,s),wo(n,o,a,c);const h=new e(l[0],l[1],l[2]),d=new e(a.data[0],a.data[3],a.data[6]),u=new e(a.data[1],a.data[4],a.data[7]),m=new e(a.data[2],a.data[5],a.data[8]),p=d.clone().multiplyScalar(Math.sqrt(o.data[0]/r)),f=u.clone().multiplyScalar(Math.sqrt(o.data[1]/r)),g=m.clone().multiplyScalar(Math.sqrt(o.data[2]/r));this.begA=h.clone().sub(p),this.endA=h.clone().add(p),this.begB=h.clone().sub(f),this.endB=h.clone().add(f),this.begC=h.clone().sub(g),this.endC=h.clone().add(g),this.center=h,this.vecA=p,this.vecB=f,this.vecC=g,this.normVecA=d,this.normVecB=u,this.normVecC=m}getBasisMatrix(t=new i){const e=t;return e.makeBasis(this.normVecB,this.normVecA,this.normVecC),e.determinant()<0&&e.scale(fa),e}getRotationQuaternion(t=new r){const e=t;return e.setFromRotationMatrix(this.getBasisMatrix(ga)),e.inverse()}getProjectedScaleForAtoms(t){let i=-1/0,r=-1/0,s=-1/0,n=-1/0,o=-1/0,a=-1/0;const c=new e,l=new e,h=this.center,d=this.normVecA,u=this.normVecB,m=this.normVecC;return t.eachAtom((function(t){jr(c.copy(t),d,h);const e=l.subVectors(c,h).normalize().dot(d),p=c.distanceTo(h);e>0?p>i&&(i=p):p>r&&(r=p),jr(c.copy(t),u,h);const f=l.subVectors(c,h).normalize().dot(u),g=c.distanceTo(h);f>0?g>s&&(s=g):g>n&&(n=g),jr(c.copy(t),m,h);const y=l.subVectors(c,h).normalize().dot(m),b=c.distanceTo(h);y>0?b>o&&(o=b):b>a&&(a=b)})),{d1a:i,d2a:s,d3a:o,d1b:-r,d2b:-n,d3b:-a}}}class ba{constructor(t,e,i,r){this.volume=t,this.setFilter(e,i,r)}get header(){return this.volume.header}get matrix(){return this.volume.matrix}get normalMatrix(){return this.volume.normalMatrix}get inverseMatrix(){return this.volume.inverseMatrix}get center(){return this.volume.center}get boundingBox(){return this.volume.boundingBox}get min(){return this.volume.min}get max(){return this.volume.max}get mean(){return this.volume.mean}get rms(){return this.volume.rms}_getFilterHash(t,e,i){return JSON.stringify([t,e,i])}setFilter(t,e,i){isNaN(t)&&this.header&&(t=this.header.DMEAN+2*this.header.ARMS),t=void 0===t||isNaN(t)?-1/0:t,e=st(e,1/0),i=st(i,!1);const r=this.volume.data,s=this.volume.position,n=this.volume.atomindex,o=this._getFilterHash(t,e,i);if(o!==this._filterHash){if(t===-1/0&&e===1/0)this.data=r,this.position=s,this.atomindex=n;else{const o=r.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*o),this._positionBuffer=new ArrayBuffer(3*o*4),n&&(this._atomindexBuffer=new ArrayBuffer(4*o)));const a=new Float32Array(this._dataBuffer),c=new Float32Array(this._positionBuffer);let l;n&&(l=new Uint32Array(this._atomindexBuffer));let h=0;for(let d=0;d=t&&u<=e||i&&(ue)){const t=3*h;a[h]=u,c[t+0]=s[o+0],c[t+1]=s[o+1],c[t+2]=s[o+2],n&&l&&(l[h]=n[d]),h+=1}}this.data=new Float32Array(this._dataBuffer,0,h),this.position=new Float32Array(this._positionBuffer,0,3*h),n&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,h))}this._filterHash=o}}}ba.prototype.getValueForSigma=Eo.prototype.getValueForSigma,ba.prototype.getSigmaForValue=Eo.prototype.getSigmaForValue,ba.prototype.getDataAtomindex=Eo.prototype.getDataAtomindex,ba.prototype.getDataPosition=Eo.prototype.getDataPosition,ba.prototype.getDataColor=Eo.prototype.getDataColor,ba.prototype.getDataPicking=Eo.prototype.getDataPicking,ba.prototype.getDataSize=Eo.prototype.getDataSize;class xa{constructor(t,e){const i=Rs({nodeArray1:t.atomIndex1,nodeArray2:t.atomIndex2,edgeCount:t.count,nodeCount:e});this.countArray=i.countArray,this.offsetArray=i.offsetArray,this.indexArray=i.indexArray}}class va extends Bs{get _defaultFields(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]}addBond(t,e,i){this.growIfFull();const r=this.count,s=t.index,n=e.index;s0&&(a[e]=v.angleTo(w));const r=Math.cos(f.angleTo(g));h[e]=180/Math.PI*Math.acos(r);const s=f.length(),x=g.length();c[e]=Math.sqrt(x*s)/Math.max(2,2*(1-r)),l[e]=Math.abs(m.dot(v)),y.copy(f).multiplyScalar(c[e]/s),b.copy(g).multiplyScalar(c[e]/x),y.subVectors(P,y),b.subVectors(I,b),y.toArray(n,i+3),b.toArray(n,i+6),A.subVectors(C,_),A.toArray(d,i),w.copy(v),_.copy(y)}y.fromArray(n,3),b.fromArray(n,6),v.subVectors(y,b).normalize(),C.index=t.getAtomIndexByType(0,S),_.copy(C),x.copy(C),jr(x,v,y),x.toArray(n,0),A.subVectors(_,y),A.toArray(d,0),y.fromArray(n,3*r-6),b.fromArray(n,3*r-9),v.subVectors(y,b).normalize(),C.index=t.getAtomIndexByType(r-1,S),_.copy(C),x.copy(C),jr(x,v,y),x.toArray(n,3*r-3);for(let e=r-3;ei||h.bending[e]>t)&&(E=!0)),E){if(e-p<4){p=e,E=!1;continue}$.index=B.traceAtomIndex,I=h.axis.subarray(3*p+3,3*e),k=h.center.subarray(3*p,3*e+3),C=Ur(I).normalize(),P=Ur(k),M.fromArray(k),jr(M,C,P),T.fromArray(k,k.length-3),jr(T,C,P),C.subVectors(T,M),C.toArray(g,f),P.toArray(y,f),M.toArray(b,f),T.toArray(x,f),u.atomColorToArray($,v,f),w.push($.index),A.push(m.atomRadius($)),_.push(l+p),S.push(l+e+1-p),f+=3,p=e,E=!1}const F=new Float32Array(w);return{axis:new Float32Array(g),center:new Float32Array(y),begin:new Float32Array(b),end:new Float32Array(x),color:new Float32Array(v),picking:new Yn(F,a),size:new Float32Array(A),residueOffset:_,residueCount:S}}}class Ia{constructor(t){this.scoreFunction=t,this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}pop(){const t=this.content[0],e=this.content.pop();return e&&this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t}peek(){return this.content[0]}remove(t){const e=this.content.length;for(let i=0;i0;){const i=Math.floor((t+1)/2)-1,r=this.content[i];if(!(this.scoreFunction(e)this.maxDepth&&(this.maxDepth=t);var o=i-r;if(0===o)return-1;var n=4*this.currentNode,a=this.nodes;if(this.currentNode+=1,1===o)return a[n]=r,a[n+1]=-1,a[n+2]=-1,a[n+3]=e,n;for(var s,c,u,h,l,p=this.indices,d=this.points,f=r+Math.floor(o/2),m=t%3,g=r,y=i-1;y>g;){for(h=d[3*p[u=g+y>>1]+m],c=p[u],p[u]=p[y],p[y]=c,l=g,s=g;se&&o.pop()}var y=n[u+1],v=n[u+2];if(-1!==v||-1!==y){h=-1===v?y:-1===y?v:t[p]<=a[d+p]?y:v,c(h),(o.size()n[3*a[o[t]]+i])throw new Error("left child is > parent!");r+=this.verify(s,e+1)}if(-1!==c){if(n[3*a[o[c]]+i]0},lc.prototype.isBackbone=function(){var t=this.residueType.backboneIndexList;return t.length>0&&t.includes(this.index-this.residueAtomOffset)},lc.prototype.isPolymer=function(){if(this.structure.entityList.length>0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},lc.prototype.isSidechain=function(){return this.isPolymer()&&!this.isBackbone()},lc.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},lc.prototype.isTrace=function(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset},lc.prototype.isHetero=function(){return 1===this.residueType.hetero},lc.prototype.isProtein=function(){return 3===this.residueType.moleculeType},lc.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},lc.prototype.isRna=function(){return 4===this.residueType.moleculeType},lc.prototype.isDna=function(){return 5===this.residueType.moleculeType},lc.prototype.isWater=function(){return 1===this.residueType.moleculeType},lc.prototype.isIon=function(){return 2===this.residueType.moleculeType},lc.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},lc.prototype.isHelix=function(){return vn.includes(this.sstruc)},lc.prototype.isSheet=function(){return bn.includes(this.sstruc)},lc.prototype.isTurn=function(){return xn.includes(this.sstruc)&&this.isProtein()},lc.prototype.isBonded=function(){return 0!==this.bondHash.countArray[this.index]},lc.prototype.isRing=function(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]},lc.prototype.isAromatic=function(){return 1===this.aromatic},lc.prototype.isPolarHydrogen=function(){var t=!1;return 1!==this.number?t:t=!this.hasBondToElement(6)},lc.prototype.isMetal=function(){return this.atomType.isMetal()},lc.prototype.isNonmetal=function(){return this.atomType.isNonmetal()},lc.prototype.isMetalloid=function(){return this.atomType.isMetalloid()},lc.prototype.isHalogen=function(){return this.atomType.isHalogen()},lc.prototype.isDiatomicNonmetal=function(){return this.atomType.isDiatomicNonmetal()},lc.prototype.isPolyatomicNonmetal=function(){return this.atomType.isPolyatomicNonmetal()},lc.prototype.isAlkaliMetal=function(){return this.atomType.isAlkaliMetal()},lc.prototype.isAlkalineEarthMetal=function(){return this.atomType.isAlkalineEarthMetal()},lc.prototype.isNobleGas=function(){return this.atomType.isNobleGas()},lc.prototype.isTransitionMetal=function(){return this.atomType.isTransitionMetal()},lc.prototype.isPostTransitionMetal=function(){return this.atomType.isPostTransitionMetal()},lc.prototype.isLanthanide=function(){return this.atomType.isLanthanide()},lc.prototype.isActinide=function(){return this.atomType.isActinide()},lc.prototype.getDefaultValence=function(){return this.atomType.getDefaultValence()},lc.prototype.getValenceList=function(){return this.atomType.getValenceList()},lc.prototype.getOuterShellElectronCount=function(){return this.atomType.getOuterShellElectronCount()},lc.prototype.distanceTo=function(t){var e=this.atomStore,r=t.atomStore,i=this.index,o=t.index,n=e.x[i]-r.x[o],a=e.y[i]-r.y[o],s=e.z[i]-r.z[o],c=n*n+a*a+s*s;return Math.sqrt(c)},lc.prototype.connectedTo=function(t){var e=this.atomStore,r=t.atomStore,i=this.index,o=t.index;if(e.altloc&&r.altloc){var n=e.altloc[i],a=r.altloc[o];if(0!==n&&0!==a&&32!==n&&32!==a&&n!==a)return!1}var s=e.x[i]-r.x[o],c=e.y[i]-r.y[o],u=e.z[i]-r.z[o],h=s*s+c*c+u*u;if(h<48&&this.isCg())return!0;if(isNaN(h))return!1;var l=this.covalent+t.covalent,p=l+.3,d=l-.5;return hd*d},lc.prototype.positionFromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this},lc.prototype.positionToArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var r=this.index,i=this.atomStore;return t[e+0]=i.x[r],t[e+1]=i.y[r],t[e+2]=i.z[r],t},lc.prototype.positionToVector3=function(t){return void 0===t&&(t=new r),t.x=this.x,t.y=this.y,t.z=this.z,t},lc.prototype.positionFromVector3=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},lc.prototype.positionAdd=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},lc.prototype.positionSub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},lc.prototype.getResidueBonds=function(t){void 0===t&&(t=!1);var e,r,i,o,n=this.residueAtomOffset,a=this.index-this.residueAtomOffset,s=this.residueType.getBonds(),c=s.atomIndices1,u=s.atomIndices2;for(t||(o=[]),e=c.indexOf(a);-1!==e;){if(i=u[e]+n,!o)return i;o.push(i),e=c.indexOf(a,e+1)}for(r=u.indexOf(a);-1!==r;){if(i=c[r]+n,!o)return i;o.push(i),r=u.indexOf(a,r+1)}return o},lc.prototype.qualifiedName=function(t){void 0===t&&(t=!1);var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chainname&&(e+=":"+this.chainname),this.atomname&&(e+="."+this.atomname),this.altloc&&(e+="%"+this.altloc),this.structure.modelStore.count>1&&(e+="/"+this.modelIndex),e},lc.prototype.clone=function(){return new lc(this.structure,this.index)},lc.prototype.toObject=function(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}},Object.defineProperties(lc.prototype,pc);var mc=new Float32Array(3),gc=function(t,e){void 0===e&&(e=!1),He&&je.time("Kdtree build");var r=e?dc:fc,i=new Float32Array(3*t.atomCount),o=new Uint32Array(t.atomCount),n=0;t.eachAtom((function(t){i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z,o[n/3]=t.index,n+=3})),this.atomIndices=o,this.points=i,this.kdtree=new hc(i,r),He&&je.timeEnd("Kdtree build")};gc.prototype.nearest=function(t,e,i){t instanceof r?t.toArray(mc):t instanceof lc&&t.positionToArray(mc);for(var o=this.kdtree.nearest(mc,e,i),n=this.kdtree.indices,a=this.kdtree.nodes,s=this.atomIndices,c=[],u=0,h=o.length;u":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},vc={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#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,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},bc=/^[1-9]$/;function xc(t){var e="";return t.length>0&&(e=":"+wt(t).join(" OR :")),new _e(e)}var _c=function(t){void 0===t&&(t=""),this.name=t,this.partList=[]},wc={type:{configurable:!0}};wc.type.get=function(){return"Assembly"},_c.prototype.addPart=function(t,e){var r=new Ac(t,e);return this.partList.push(r),r},_c.prototype.getAtomCount=function(t){return this.partList.reduce((function(e,r){return e+r.getAtomCount(t)}),0)},_c.prototype.getResidueCount=function(t){return this.partList.reduce((function(e,r){return e+r.getResidueCount(t)}),0)},_c.prototype.getInstanceCount=function(){var t=0;return this.partList.forEach((function(e){t+=e.matrixList.length})),t},_c.prototype.isIdentity=function(t){if(1!==this.partList.length)return!1;var e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new i).equals(e.matrixList[0]))return!1;var r=[];return t.eachChain((function(t){r.push(t.chainname)})),r=wt(r),e.chainList.length===r.length},_c.prototype.getBoundingBox=function(t){var e=new c;return this.partList.forEach((function(r){var i=r.getBoundingBox(t);e.expandByPoint(i.min),e.expandByPoint(i.max)})),e},_c.prototype.getCenter=function(t){return this.getBoundingBox(t).getCenter(new r)},_c.prototype.getSelection=function(){var t=[];return this.partList.forEach((function(e){t=t.concat(e.chainList)})),xc(t)},Object.defineProperties(_c.prototype,wc);var Ac=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=[]),this.matrixList=t,this.chainList=e},Sc={type:{configurable:!0}};Sc.type.get=function(){return"AssemblyPart"},Ac.prototype._getCount=function(t,e){var r=this,i=0;return t.eachChain((function(t){(0===r.chainList.length||r.chainList.includes(t.chainname))&&(i+=t[e])})),this.matrixList.length*i},Ac.prototype.getAtomCount=function(t){return this._getCount(t,"atomCount")},Ac.prototype.getResidueCount=function(t){return this._getCount(t,"residueCount")},Ac.prototype.getBoundingBox=function(t){var e=new c,r=new c,i=this.getSelection(),o=t.getBoundingBox(i);return this.matrixList.forEach((function(t){r.copy(o).applyMatrix4(t),e.expandByPoint(r.min),e.expandByPoint(r.max)})),e},Ac.prototype.getSelection=function(){return xc(this.chainList)},Ac.prototype.getView=function(t){var e=this.getSelection();return e?t.getView(e):t},Ac.prototype.getInstanceList=function(){for(var t=[],e=0,r=this.matrixList.length;e=0}));n.sort((function(t,e){var r=t[0],n=e[0],a=t[1],s=e[1];if(r===n)return a===s?0:a=0}));s.sort((function(t,e){var r=t[0],n=e[0];if(r===n)return 0;var a=xt(i,r),s=xt(i,n);return o[a]0&&this.addResidueType(this.ri-1),u.growIfFull(),u.resno[this.ri]=o,void 0!==a&&(u.sstruc[this.ri]=a.charCodeAt(0)),void 0!==s&&(u.inscode[this.ri]=s.charCodeAt(0)),u.atomOffset[this.ri]=this.ai,u.atomCount[this.ri]=0,u.count+=1,u.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,u.atomCount[this.ri]+=1,this.currentModelindex=t,this.currentChainid=r,this.currentResname=i,this.currentResno=o,this.currentInscode=s,this.currentHetero=n},Cc.prototype.finalize=function(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)};var Ic,Oc,kc,Mc=(Ic=function(t,e,r,i){for(var o=t.structure,n=t.residueIndexStart,a=o.getResidueProxy(),s=o.getResidueProxy(),c=o.getAtomProxy(),u=o.getAtomProxy(),h=Math.max(0,e-2);h<=e;++h)for(var l=2;l<5;++l)if(!(h+l>=t.residueCount)){a.index=n+h,s.index=n+h+l,c.index=a.traceAtomIndex,u.index=s.traceAtomIndex;var p=c.distanceTo(u);if(Math.abs(p-r[l-2])>i)return!1}return!0},Oc=function(t,e){return Ic(t,e,[5.45,5.18,6.37],2.1)},kc=function(t,e){return Ic(t,e,[6.1,10.4,13],1.42)},function(t){He&&je.time("calculateSecondaryStructure"),t.eachPolymer((function(t){if(!(t.residueCount<4)){if(t.isCg())!function(t){for(var e=t.residueStore,i=t.residueIndexStart,o=new cc(t).position,n=new r,a=new r,s=0,c=t.residueCount;s1&&o.bending[s]<20&&(e.sstruc[i+s]="h".charCodeAt(0),e.sstruc[i+s+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;!function(t){for(var e=t.residueStore,r=t.residueIndexStart,i=0,o=t.residueCount;i=e;)o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(r=Math.floor(r/e))%e],i+=1;return i>=5&&je.warn("chainname overflow"),o}function Bc(t,e){void 0===e&&(e=!1),He&&je.time("calculateChainnames");var r=!0;if(t.eachChain((function(t){t.chainname&&(r=!1)})),r){var i=t.modelStore,o=t.chainStore,n=t.residueStore,a=t.getAtomProxy(),s=t.getAtomProxy(),c=0,u=0,h=0,l=0,p=[];1===n.count?p.push({mIndex:0,chainname:"A",rStart:0,rCount:1}):t.eachResidueN(2,(function(t,r){var i=!1,o=t.backboneType,d=r.backboneType;l=t.index,t.modelIndex!==r.modelIndex||t.moleculeType!==r.moleculeType?i=!0:0!==o&&o===d&&(a.index=t.backboneEndAtomIndex,s.index=r.backboneStartAtomIndex,i=e?!a.hasBondTo(s):!a.connectedTo(s)),i||r.index!==n.count-1||(i=!0,l=r.index),i&&(p.push({mIndex:u,chainname:Tc(c),rStart:h,rCount:l-h+1}),c+=1,t.modelIndex!==r.modelIndex&&(c=0,u+=1),r.index===n.count-1&&l!==r.index&&p.push({mIndex:u,chainname:Tc(c),rStart:n.count-1,rCount:1}),h=r.index,l=r.index)})),o.count=0,i.chainCount.fill(0,0,i.count),i.chainOffset.fill(0,0,i.count),p.forEach((function(t){!function(t,e,r,a){for(var s=o.count,c=0;c500)return void je.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());for(var l=t.getBonds(),p=l.atomIndices1,d=l.atomIndices2,f=l.bondOrders,m=p.length,g=0;g0)break;++r}else i=o+1;(r>0||i=3&&-1!==Nc.indexOf(e[0])?e[0]:""}function Vc(t){var e=t.bondHash,r=e.countArray,i=e.offsetArray,o=e.indexArray,n=t.getBondProxy();t.eachResidue((function(t){var e=t.residueType;if(void 0===e.bonds){var a=t.atomOffset,s=[],c=[],u=[],h={},l=a+t.atomCount;t.eachAtom((function(t){for(var e=t.index,p=i[e],d=0,f=r[e];d=l)){var g=n.atomIndex2;if(!(g=l)){if(m>g){var y=g;g=m,m=y}var v=m+"|"+g;void 0===h[v]&&(h[v]=!0,s.push(m-a),c.push(g-a),u.push(n.bondOrder))}}}})),e.bonds={atomIndices1:s,atomIndices2:c,bondOrders:u}}}))}function Gc(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];He&&je.time("concatStructures");var i=new gu(t,""),o=new Cc(i),n=i.atomStore,a=i.atomMap;n.addField("formalCharge",1,"int8"),n.addField("partialCharge",1,"float32");var s={},c=0,u=0,h=0;e.forEach((function(t){t.eachAtom((function(t){n.growIfFull(),n.atomTypeId[c]=a.add(t.atomname,t.element),n.x[c]=t.x,n.y[c]=t.y,n.z[c]=t.z,n.serial[c]=t.serial,n.formalCharge[c]=t.formalCharge,n.partialCharge[c]=t.partialCharge,n.altloc[c]=t.altloc,n.occupancy[c]=t.occupancy,n.bfactor[c]=t.bfactor,o.addAtom(t.modelIndex+h,t.chainname,t.chainid,t.resname,t.resno,1===t.hetero,t.sstruc,t.inscode),s[t.index+u]=c,c+=1})),u+=t.atomStore.count,h+=t.modelStore.count}));var l=i.bondStore,p=i.getAtomProxy(),d=i.getAtomProxy();return u=0,e.forEach((function(t){t.eachBond((function(t){p.index=s[t.atomIndex1+u],d.index=s[t.atomIndex2+u],l.addBond(p,d,t.bondOrder)})),u+=t.atomStore.count})),o.finalize(),$c(i,!0),Rc(i,!0),i.finalizeAtoms(),i.finalizeBonds(),Vc(i),He&&je.timeEnd("concatStructures"),i}var Uc=[3,11,19,37,55,87],Hc=[4,12,20,38,56,88],Wc=[6,15,16,34],qc=[1,7,8,9,17,35,53],Xc=[2,10,18,36,54,86],Yc=[13,30,31,48,49,50,80,81,82,83,84,85,112],Kc=[5,14,32,33,51,52,85],Zc=[9,17,35,53,85],Qc=function(t,e,r){this.structure=t,this.atomname=e,r=r||jc(e),this.element=r,this.number=_n[r]||0,this.vdw=wn[this.number]||2,this.covalent=An[this.number]||1.6};Qc.prototype.getDefaultValence=function(){var t=Sn[this.number];return t?t[0]:-1},Qc.prototype.getValenceList=function(){return Sn[this.number]||[]},Qc.prototype.getOuterShellElectronCount=function(){return Cn[this.number]||2},Qc.prototype.isMetal=function(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()},Qc.prototype.isNonmetal=function(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()},Qc.prototype.isMetalloid=function(){return Kc.includes(this.number)},Qc.prototype.isHalogen=function(){return Zc.includes(this.number)},Qc.prototype.isDiatomicNonmetal=function(){return qc.includes(this.number)},Qc.prototype.isPolyatomicNonmetal=function(){return Wc.includes(this.number)},Qc.prototype.isAlkaliMetal=function(){return Uc.includes(this.number)},Qc.prototype.isAlkalineEarthMetal=function(){return Hc.includes(this.number)},Qc.prototype.isNobleGas=function(){return Xc.includes(this.number)},Qc.prototype.isTransitionMetal=function(){var t=this.number;return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108},Qc.prototype.isPostTransitionMetal=function(){return Yc.includes(this.number)},Qc.prototype.isLanthanide=function(){return this.number>=57&&this.number<=71},Qc.prototype.isActinide=function(){return this.number>=89&&this.number<=103};var Jc=function(t){this.structure=t,this.dict={},this.list=[],this.structure=t};Jc.prototype.add=function(t,e){var r=function(t,e){return t+"|"+e}(t=t.toUpperCase(),e=e?e.toUpperCase():jc(t)),i=this.dict[r];if(void 0===i){var o=new Qc(this.structure,t,e);i=this.list.length,this.dict[r]=i,this.list.push(o)}return i},Jc.prototype.get=function(t){return this.list[t]};var tu=function(t,e,r,i,o,n){this.structure=t,this.bondReferenceAtomIndices=[],this.resname=e,this.atomTypeIdList=r,this.hetero=i?1:0,this.chemCompType=o,this.bonds=n,this.atomCount=r.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();var a=Nn[this.backboneType],s=Nn[this.backboneStartType],c=Nn[this.backboneEndType],u=this.getAtomIndexByName(a.trace);this.traceAtomIndex=ht(u,-1);var h=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=ht(h,-1);var l=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=ht(l,-1);var p=this.getAtomIndexByName(s.backboneStart);this.backboneStartAtomIndex=ht(p,-1);var d,f=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=ht(f,-1),d=Bn.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=ht(d,-1)};tu.prototype.getBackboneIndexList=function(){var t,e=[];switch(this.moleculeType){case 3:t=$n;break;case 4:case 5:t=Ln;break;default:return e}for(var r=this.structure.atomMap,i=this.atomTypeIdList,o=0,n=this.atomCount;o500)He&&je.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(o>50)for(var h=new gc(t,!0),l=t.isCg()?1.2:2.3,p=n;p=0||iu(t,e);this.rings={atomRings:t.atomRings,rings:t.rings}},tu.prototype.isAromatic=function(t){return this.aromaticAtoms=this.getAromatic(t),1===this.aromaticAtoms[t.index-t.residueAtomOffset]},tu.prototype.calculateAromatic=function(t){var e=this,r=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,o=i.map((function(r){return function(t){if(t.some((function(t){return!eu.includes(t.number)})))return!1;var e=0,r=new Ga(3,t.length),i=r.data;return t.forEach((function(t){i[e+0]=t.x,i[e+1]=t.y,i[e+2]=t.z,e+=3})),new Qs(r).vecC.length()<.05}(r.map((function(r){return e.structure.getAtomProxy(r+t.atomOffset)})))})),n=this.aromaticRings=[];i.forEach((function(t,e){o[e]&&(n.push(t),t.forEach((function(t){return r[t]=1})))}))},tu.prototype.assignBondReferenceAtomIndices=function(){var t=this.getBondGraph(),e=this.getRings(),r=e.atomRings,i=e.rings,o=this.bonds,n=o.atomIndices1,a=o.atomIndices2,s=o.bondOrders,c=this.bondReferenceAtomIndices,u=o.atomIndices1.length;c.length=0;for(var h=0;h1)for(var y=0;y1)for(var b=0;b=0;x--)y[v++]=a[x];for(var _=t.rings.length,w=0;w0?n[l]!==c&&n[c]!==l&&ru(t,c,l):(i[l]=1,o[s++]=l,n[l]=c)}}}var ou=4;var nu=function(t){this.structure=t,this.dict={},this.list=[]};nu.prototype.add=function(t,e,r,i,o){void 0===i&&(i="");var n=function(t,e,r,i){return void 0===i&&(i=""),t+"|"+e.join(",")+"|"+(r?1:0)+"|"+i}(t=t.toUpperCase(),e,r,i),a=this.dict[n];if(void 0===a){var s=new tu(this.structure,t,e,r,i,o);a=this.list.length,this.dict[n]=a,this.list.push(s)}return a},nu.prototype.get=function(t){return this.list[t]};var au=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.bondStore=t.bondStore,this._v12=new r,this._v13=new r,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()},su={atom1:{configurable:!0},atom2:{configurable:!0},atomIndex1:{configurable:!0},atomIndex2:{configurable:!0},bondOrder:{configurable:!0}};su.atom1.get=function(){return this.structure.getAtomProxy(this.atomIndex1)},su.atom2.get=function(){return this.structure.getAtomProxy(this.atomIndex2)},su.atomIndex1.get=function(){return this.bondStore.atomIndex1[this.index]},su.atomIndex1.set=function(t){this.bondStore.atomIndex1[this.index]=t},su.atomIndex2.get=function(){return this.bondStore.atomIndex2[this.index]},su.atomIndex2.set=function(t){this.bondStore.atomIndex2[this.index]=t},su.bondOrder.get=function(){return this.bondStore.bondOrder[this.index]},su.bondOrder.set=function(t){this.bondStore.bondOrder[this.index]=t},au.prototype.getOtherAtomIndex=function(t){return t===this.atomIndex1?this.atomIndex2:this.atomIndex1},au.prototype.getOtherAtom=function(t){return this.structure.getAtomProxy(this.getOtherAtomIndex(t.index))},au.prototype.getReferenceAtomIndex=function(){var t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex===e.residueIndex){var r=t.index-t.residueAtomOffset,i=e.index-e.residueAtomOffset,o=t.residueType.getBondReferenceAtomIndex(r,i);if(void 0!==o)return o+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}},au.prototype.calculateShiftDir=function(t){void 0===t&&(t=new r);var e=this._ap1,i=this._ap2,o=this._ap3,n=this._v12,a=this._v13;e.index=this.atomIndex1,i.index=this.atomIndex2;var s=this.getReferenceAtomIndex();n.subVectors(e,i).normalize(),void 0!==s?(o.index=s,a.subVectors(e,o)):a.copy(e),a.normalize();var c=n.dot(a);return 1-Math.abs(c)<1e-5&&(a.set(1,0,0),c=n.dot(a),1-Math.abs(c)<1e-5&&(a.set(0,1,0),c=n.dot(a))),t.copy(a.sub(n.multiplyScalar(c))).normalize()},au.prototype.qualifiedName=function(){return this.atomIndex1+"="+this.atomIndex2},au.prototype.clone=function(){return new au(this.structure,this.index)},au.prototype.toObject=function(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}},Object.defineProperties(au.prototype,su);var cu=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap},uu={entity:{configurable:!0},entityIndex:{configurable:!0},chain:{configurable:!0},chainIndex:{configurable:!0},atomOffset:{configurable:!0},atomCount:{configurable:!0},atomEnd:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0},chainid:{configurable:!0},resno:{configurable:!0},sstruc:{configurable:!0},inscode:{configurable:!0},residueType:{configurable:!0},resname:{configurable:!0},hetero:{configurable:!0},moleculeType:{configurable:!0},backboneType:{configurable:!0},backboneStartType:{configurable:!0},backboneEndType:{configurable:!0},traceAtomIndex:{configurable:!0},direction1AtomIndex:{configurable:!0},direction2AtomIndex:{configurable:!0},backboneStartAtomIndex:{configurable:!0},backboneEndAtomIndex:{configurable:!0},rungEndAtomIndex:{configurable:!0},x:{configurable:!0},y:{configurable:!0},z:{configurable:!0}};uu.entity.get=function(){return this.structure.entityList[this.entityIndex]},uu.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},uu.chain.get=function(){return this.structure.getChainProxy(this.chainIndex)},uu.chainIndex.get=function(){return this.residueStore.chainIndex[this.index]},uu.chainIndex.set=function(t){this.residueStore.chainIndex[this.index]=t},uu.atomOffset.get=function(){return this.residueStore.atomOffset[this.index]},uu.atomOffset.set=function(t){this.residueStore.atomOffset[this.index]=t},uu.atomCount.get=function(){return this.residueStore.atomCount[this.index]},uu.atomCount.set=function(t){this.residueStore.atomCount[this.index]=t},uu.atomEnd.get=function(){return this.atomOffset+this.atomCount-1},uu.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},uu.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},uu.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},uu.resno.get=function(){return this.residueStore.resno[this.index]},uu.resno.set=function(t){this.residueStore.resno[this.index]=t},uu.sstruc.get=function(){return this.residueStore.getSstruc(this.index)},uu.sstruc.set=function(t){this.residueStore.setSstruc(this.index,t)},uu.inscode.get=function(){return this.residueStore.getInscode(this.index)},uu.inscode.set=function(t){this.residueStore.setInscode(this.index,t)},uu.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},uu.resname.get=function(){return this.residueType.resname},uu.hetero.get=function(){return this.residueType.hetero},uu.moleculeType.get=function(){return this.residueType.moleculeType},uu.backboneType.get=function(){return this.residueType.backboneType},uu.backboneStartType.get=function(){return this.residueType.backboneStartType},uu.backboneEndType.get=function(){return this.residueType.backboneEndType},uu.traceAtomIndex.get=function(){return this.residueType.traceAtomIndex+this.atomOffset},uu.direction1AtomIndex.get=function(){return this.residueType.direction1AtomIndex+this.atomOffset},uu.direction2AtomIndex.get=function(){return this.residueType.direction2AtomIndex+this.atomOffset},uu.backboneStartAtomIndex.get=function(){return this.residueType.backboneStartAtomIndex+this.atomOffset},uu.backboneEndAtomIndex.get=function(){return this.residueType.backboneEndAtomIndex+this.atomOffset},uu.rungEndAtomIndex.get=function(){return this.residueType.rungEndAtomIndex+this.atomOffset},uu.x.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.x[e];return t/this.atomCount},uu.y.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.y[e];return t/this.atomCount},uu.z.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.z[e];return t/this.atomCount},cu.prototype.eachAtom=function(t,e){var r=this.atomCount,i=this.atomOffset,o=this.structure._ap,n=i+r;if(e&&e.atomOnlyTest)for(var a=e.atomOnlyTest,s=i;s0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},cu.prototype.isHetero=function(){return 1===this.residueType.hetero},cu.prototype.isWater=function(){return 1===this.residueType.moleculeType},cu.prototype.isIon=function(){return 2===this.residueType.moleculeType},cu.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},cu.prototype.isStandardAminoacid=function(){return this.residueType.isStandardAminoacid()},cu.prototype.isStandardBase=function(){return this.residueType.isStandardBase()},cu.prototype.isHelix=function(){return vn.includes(this.sstruc)},cu.prototype.isSheet=function(){return bn.includes(this.sstruc)},cu.prototype.isTurn=function(){return xn.includes(this.sstruc)&&this.isProtein()},cu.prototype.getAtomType=function(t){return this.atomMap.get(this.atomStore.atomTypeId[t])},cu.prototype.getResname1=function(){return On[this.resname.toUpperCase()]||"X"},cu.prototype.getBackboneType=function(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},cu.prototype.getAtomIndexByName=function(t){var e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e},cu.prototype.hasAtomWithName=function(t){return this.residueType.hasAtomWithName(t)},cu.prototype.getAtomnameList=function(){console.warn("getAtomnameList - might be expensive");for(var t=this.atomCount,e=this.atomOffset,r=new Array(t),i=0;i=e){var i=ht(t,this.structure.getResidueProxy());if(i.index=r,i.connectedTo(this))return i}else if(r===e-1){var o=this.chainStore.residueCount[this.chainIndex],n=ht(t,this.structure.getResidueProxy());if(n.index=e+o-1,n.connectedTo(this))return n}},cu.prototype.getBonds=function(){return this.residueType.getBonds(this)},cu.prototype.getRings=function(){return this.residueType.getRings()},cu.prototype.getAromaticRings=function(){return this.residueType.getAromaticRings(this)},cu.prototype.qualifiedName=function(t){void 0===t&&(t=!1);var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chain&&(e+=":"+this.chainname),e+="/"+this.modelIndex},cu.prototype.clone=function(){return new cu(this.structure,this.index)},cu.prototype.toObject=function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}},Object.defineProperties(cu.prototype,uu);var hu=function(t,e,r){this.structure=t,this.residueIndexStart=e,this.residueIndexEnd=r,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueCount=r-e+1;var i=this.structure.getResidueProxy(this.residueIndexStart),o=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==i.getPreviousConnectedResidue();var n=o.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=o.connectedTo(i),this.__residueProxy=this.structure.getResidueProxy()},lu={chainIndex:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0}};lu.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndexStart]},lu.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},lu.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},hu.prototype.isProtein=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},hu.prototype.isCg=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},hu.prototype.isNucleic=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},hu.prototype.getMoleculeType=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},hu.prototype.getBackboneType=function(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)},hu.prototype.getAtomIndexByType=function(t,e){this.isCyclic?-1===t?t=this.residueCount-1:t===this.residueCount&&(t=0):(-1!==t||this.isPrevConnected||(t+=1),t!==this.residueCount||this.isNextNextConnected||(t-=1));var r,i=this.__residueProxy;switch(i.index=this.residueIndexStart+t,e){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(e)}return r},hu.prototype.eachAtom=function(t,e){this.eachResidue((function(r){r.eachAtom(t,e)}))},hu.prototype.eachAtomN=function(t,e,r){for(var i=this.residueCount,o=new Array(t),n=0;n1&&t(new hu(n,r,u.index)),r=i)):(0!==m&&u.index-r>1&&t(new hu(n,r,u.index)),r=i)}i-r>1&&this.structure.getResidueProxy(r).backboneEndType&&t(new hu(n,r,i))},pu.prototype.qualifiedName=function(){return":"+this.chainname+"/"+this.modelIndex},pu.prototype.clone=function(){return new pu(this.structure,this.index)},pu.prototype.toObject=function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}},Object.defineProperties(pu.prototype,du);var fu=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore},mu={chainOffset:{configurable:!0},chainCount:{configurable:!0},residueOffset:{configurable:!0},atomOffset:{configurable:!0},chainEnd:{configurable:!0},residueEnd:{configurable:!0},atomEnd:{configurable:!0},residueCount:{configurable:!0},atomCount:{configurable:!0}};mu.chainOffset.get=function(){return this.modelStore.chainOffset[this.index]},mu.chainOffset.set=function(t){this.modelStore.chainOffset[this.index]=t},mu.chainCount.get=function(){return this.modelStore.chainCount[this.index]},mu.chainCount.set=function(t){this.modelStore.chainCount[this.index]=t},mu.residueOffset.get=function(){return this.chainStore.residueOffset[this.chainOffset]},mu.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},mu.chainEnd.get=function(){return this.chainOffset+this.chainCount-1},mu.residueEnd.get=function(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},mu.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},mu.residueCount.get=function(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},mu.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},fu.prototype.eachAtom=function(t,e){this.eachChain((function(r){r.eachAtom(t,e)}),e)},fu.prototype.eachResidue=function(t,e){this.eachChain((function(r){r.eachResidue(t,e)}),e)},fu.prototype.eachPolymer=function(t,e){if(e&&e.chainOnlyTest){var r=e.chainOnlyTest;this.eachChain((function(i){r(i)&&i.eachPolymer(t,e)}))}else this.eachChain((function(r){r.eachPolymer(t,e)}))},fu.prototype.eachChain=function(t,e){var r=this.chainCount,i=this.chainOffset,o=this.structure._cp,n=i+r;if(e&&e.test){var a=e.chainOnlyTest;if(a)for(var s=i;s1){var e=i.atomRadius(m);A=e*h/(.5*_),d.calculateShiftDir(E),u?(w=2*l*e,E.multiplyScalar(w),E.negate(),D.subVectors(g,m).multiplyScalar(Math.max(.1,w/1.88)),m.positionToArray(S,b),g.positionToArray(C,b),_>=2&&(B.addVectors(m,E).add(D).toArray(S,b+3),B.addVectors(g,E).sub(D).toArray(C,b+3),_>=3&&(B.subVectors(m,E).add(D).toArray(S,b+6),B.subVectors(g,E).sub(D).toArray(C,b+6)))):(w=(l-h)*e,E.multiplyScalar(w),2===_?(B.addVectors(m,E).toArray(S,b),B.subVectors(m,E).toArray(S,b+3),B.addVectors(g,E).toArray(C,b),B.subVectors(g,E).toArray(C,b+3)):3===_?(m.positionToArray(S,b),B.addVectors(m,E).toArray(S,b+3),B.subVectors(m,E).toArray(S,b+6),g.positionToArray(C,b),B.addVectors(g,E).toArray(C,b+3),B.subVectors(g,E).toArray(C,b+6)):(m.positionToArray(S,b),g.positionToArray(C,b)))}else m.positionToArray(S,b),g.positionToArray(C,b);if(P&&I&&(o.bondColorToArray(d,1,P,b),o.bondColorToArray(d,0,I,b),c&&_>1))for(v=1;v<_;++v)qr(P,b,x=3*v+b,3),qr(I,b,x,3);if(O&&O.array&&(O.array[T]=t,c&&_>1))for(v=1;v<_;++v)O.array[T+v]=t;if(k&&(k[T]=i.atomRadius(m),c&&_>1))for(A=k[T]*h/(u?1:.5*_),v=u?1:0;v<_;++v)k[T+v]=A;if(M&&(M[T]=i.atomRadius(g),c&&_>1))for(A=M[T]*h/(u?1:.5*_),v=u?1:0;v<_;++v)M[T+v]=A;T+=c?_:1})),p},gu.prototype.getBackboneAtomData=function(t){return t=Object.assign({atomSet:this.atomSetCache.__backbone},t),this.getAtomData(t)},gu.prototype.getBackboneBondData=function(t){return t=Object.assign({bondSet:this.getBackboneBondSet(),bondStore:this.backboneBondStore},t),this.getBondData(t)},gu.prototype.getRungAtomData=function(t){return t=Object.assign({atomSet:this.atomSetCache.__rung},t),this.getAtomData(t)},gu.prototype.getRungBondData=function(t){return t=Object.assign({bondSet:this.getRungBondSet(),bondStore:this.rungBondStore},t),this.getBondData(t)},gu.prototype.getBoundingBox=function(t,e){He&&je.time("getBoundingBox"),e=e||new c;var r=1/0,i=1/0,o=1/0,n=-1/0,a=-1/0,s=-1/0;return this.eachAtom((function(t){var e=t.x,c=t.y,u=t.z;en&&(n=e),c>a&&(a=c),u>s&&(s=u)}),t),e.min.set(r,i,o),e.max.set(n,a,s),He&&je.timeEnd("getBoundingBox"),e},gu.prototype.getPrincipalAxes=function(t){He&&je.time("getPrincipalAxes");var e=0,r=new Ga(3,this.atomCount),i=r.data;return this.eachAtom((function(t){i[e+0]=t.x,i[e+1]=t.y,i[e+2]=t.z,e+=3}),t),He&&je.timeEnd("getPrincipalAxes"),new Qs(r)},gu.prototype.atomCenter=function(t){return t?this.getBoundingBox(t).getCenter(new r):this.center.clone()},gu.prototype.hasCoords=function(){if(void 0===this._hasCoords){var t=this.atomStore;this._hasCoords=0!==Yr(t.x)||0!==Xr(t.x)||0!==Yr(t.y)||0!==Xr(t.y)||0!==Yr(t.z)||0!==Xr(t.z)||t.count/this.modelStore.count==1}return this._hasCoords},gu.prototype.getSequence=function(t){var e=[],r=this.getResidueProxy();return this.eachAtom((function(t){r.index=t.residueIndex,t.index===r.traceAtomIndex&&e.push(r.getResname1())}),t),e},gu.prototype.getAtomIndices=function(t){if(t&&t.string){var e=[];return this.eachAtom((function(t){e.push(t.index)}),t),new Uint32Array(e)}return this.getAtomData({what:{index:!0}}).index},gu.prototype.getChainnameCount=function(t){var e=new Set;return this.eachChain((function(t){t.residueCount&&e.add(t.chainname)}),t),e.size},gu.prototype.updatePosition=function(t,e){void 0===e&&(e=!0);var r=0;this.eachAtom((function(e){e.positionFromArray(t,r),r+=3}),void 0),this._hasCoords=void 0,e&&this.refreshPosition()},gu.prototype.refreshPosition=function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new rn(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)},gu.prototype.dispose=function(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet},Object.defineProperties(gu.prototype,yu);var vu=new c,bu=[Yo,Ho,Ko,Xo,Zo,Wo,Uo,qo,Jo,Qo,tn,en],xu={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2},_u=function(t,e){var r=this;void 0===t&&(t="shape"),void 0===e&&(e={}),this.boundingBox=new c,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=t,this.parameters=lt(e,xu),bu.forEach((function(t){Object.keys(t.fields).forEach((function(e){r._primitiveData[t.getShapeKey(e)]=[]})),r._primitiveData[t.getShapeKey("name")]=[]}))},wu={center:{configurable:!0},type:{configurable:!0}};_u.prototype.addBuffer=function(t){this.bufferList.push(t);var e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this},_u.prototype.addMesh=function(t,e,r,i,o){var n;t=Tt(t),e=Tt(e),Array.isArray(r)&&(r=Ct(r,t.length)),i&&(i=Tt(i)),n=void 0===i||0==i.length?{position:t,color:e,index:r}:{position:t,color:e,index:r,normal:i};var a=new Ma(this,Object.assign({serial:this.meshCount,name:o},n)),s=new ws(Object.assign({picking:a},n));return this.bufferList.push(s),vu.setFromArray(t),this.boundingBox.union(vu),this.meshCount+=1,this},_u.prototype.addSphere=function(t,e,r,i){return Uo.objectToShape(this,{position:t,color:e,radius:r,name:i}),this},_u.prototype.addEllipsoid=function(t,e,r,i,o,n){return Zo.objectToShape(this,{position:t,color:e,radius:r,majorAxis:i,minorAxis:o,name:n}),this},_u.prototype.addTorus=function(t,e,r,i,o,n){return Qo.objectToShape(this,{position:t,color:e,radius:r,majorAxis:i,minorAxis:o,name:n}),this},_u.prototype.addCylinder=function(t,e,r,i,o){return Xo.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:o}),this},_u.prototype.addCone=function(t,e,r,i,o){return Ko.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:o}),this},_u.prototype.addArrow=function(t,e,r,i,o){return Yo.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:o}),this},_u.prototype.addBox=function(t,e,r,i,o,n){return Ho.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:o,name:n}),this},_u.prototype.addOctahedron=function(t,e,r,i,o,n){return Wo.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:o,name:n}),this},_u.prototype.addTetrahedron=function(t,e,r,i,o,n){return qo.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:o,name:n}),this},_u.prototype.addText=function(t,e,r,i){return Jo.objectToShape(this,{position:t,color:e,size:r,text:i}),this},_u.prototype.addPoint=function(t,e,r){return tn.objectToShape(this,{position:t,color:e,name:r}),this},_u.prototype.addWideline=function(t,e,r,i,o){return this.parameters.linewidth=i,en.objectToShape(this,{position1:t,position2:e,color:r,name:o}),this},_u.prototype.addLabel=function(t,e,r,i){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,r,i)},_u.prototype.getBufferList=function(){var t=this,e=[];return bu.forEach((function(r){t._primitiveData[r.getShapeKey("color")].length&&e.push(r.bufferFromShape(t,t.parameters))})),this.bufferList.concat(e)},_u.prototype.dispose=function(){var t=this;this.bufferList.forEach((function(t){t.dispose()})),this.bufferList.length=0,bu.forEach((function(e){Object.keys(e.fields).forEach((function(r){t._primitiveData[e.getShapeKey(r)].length=0})),t._primitiveData[e.getShapeKey("name")].length=0}))},wu.center.get=function(){return this._center||(this._center=this.boundingBox.getCenter(new r)),this._center},wu.type.get=function(){return"Shape"},Object.defineProperties(_u.prototype,wu);var Au=function(t){function e(e,r,i){Array.isArray(e)||(e=[e]),t.call(this,e,r,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){t.prototype.init.call(this,e),this.build()},e.prototype.create=function(){this.bufferList.push.apply(this.bufferList,this.buffer)},e.prototype.attach=function(t){var e=this;this.bufferList.forEach((function(t){e.viewer.add(t),t.setParameters(e.getBufferParams())})),this.setVisibility(this.visible),t()},e}(lo),Su=new i,Cu=new F;var Pu=function(t){function e(e,r,i){void 0===r&&(r={}),t.call(this,function(t,e){var r,i=e.attributes.position.array,o=e.index?e.index.array:void 0,n=t.position.length/3,a=i.length/3,s=n*a,c=new Float32Array(3*s),u=new Float32Array(3*s),h=new Float32Array(3*s);return o&&(r=Ct(n*o.length,s)),{position:c,color:h,index:r,normal:u,primitiveId:t.primitiveId||Ur(n,a),picking:t.picking}}(e,i),r),this.updateNormals=!1;var o=i.attributes.position.array,n=i.attributes.normal.array,a=i.index?i.index.array:void 0;this.geoPosition=o,this.geoNormal=n,this.geoIndex=a,this.positionCount=e.position.length/3,this.geoPositionCount=o.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);var s=this.geometry.attributes;if(this.meshPosition=s.position.array,this.meshColor=s.color.array,this.meshNormal=s.normal.array,this.setAttributes(e),a){var c=this.geometry.getIndex();if(!c)return void je.error("Index is null");this.meshIndex=c.array,this.makeIndex()}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setAttributes=function(t,e){void 0===t&&(t={}),void 0===e&&(e=!1);var r,i,o,n,a,s,c,u,h,l=this.geometry.attributes,p=this.updateNormals;t.position&&(r=t.position,o=this.geoPosition,c=this.meshPosition,a=this.transformedGeoPosition,l.position.needsUpdate=!0,(p||e)&&(n=this.geoNormal,h=this.meshNormal,s=this.transformedGeoNormal,l.normal.needsUpdate=!0)),t.color&&(i=t.color,u=this.meshColor,l.color.needsUpdate=!0);for(var d=this.positionCount,f=this.geoPositionCount,m=0;m 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Mu=function(t){function e(e,r,i){void 0===i&&(i={}),t.call(this,r,i),this.index=Ct(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:Gr(this.size)})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={attributeSize:{configurable:!0},indexSize:{configurable:!0}};return r.attributeSize.get=function(){return this.size*this.mappingSize},r.indexSize.get=function(){return this.size*this.mappingIndicesSize},e.prototype.addAttributes=function(e){var r={};for(var i in e){var o=e[i];r[i]={type:o.type,value:null}}t.prototype.addAttributes.call(this,r)},e.prototype.getAttributeIndex=function(t){return 3*t*this.mappingSize},e.prototype.setAttributes=function(t){t&&!t.position&&t.position1&&t.position2&&(t.position=Nr(t.position1,t.position2));var e,r,i,o,n,a,s,c=this.size,u=this.mappingSize,h=this.geometry.attributes;for(var l in t)if("index"!==l&&"picking"!==l){r=t[l],i=(e=h[l]).itemSize,o=e.array;for(var p=0;p0&&this.parameters.alphaTest<=1&&(r.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),r},e.prototype.setUniforms=function(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.tex&&this.tex.dispose()},Object.defineProperties(e.prototype,r),e}(xs);or.add("point",Lu);var Nu=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof ds?(this.surface=void 0,this.volume=new Js(e)):(this.surface=e,this.volume=void 0),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.colorScheme=ht(r.colorScheme,"uniform"),r.colorValue=ht(r.colorValue,14540253),this.thresholdType=ht(r.thresholdType,"sigma"),this.thresholdMin=ht(r.thresholdMin,2),this.thresholdMax=ht(r.thresholdMax,1/0),this.thresholdOut=ht(r.thresholdOut,!1),this.dotType=ht(r.dotType,"point"),this.radius=ht(r.radius,.1),this.scale=ht(r.scale,1),this.pointSize=ht(r.pointSize,1),this.sizeAttenuation=ht(r.sizeAttenuation,!0),this.sortParticles=ht(r.sortParticles,!1),this.useTexture=ht(r.useTexture,!1),this.alphaTest=ht(r.alphaTest,.5),this.forceTransparent=ht(r.forceTransparent,!1),this.edgeBleach=ht(r.edgeBleach,0),t.prototype.init.call(this,r),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach((function(t){e.viewer.add(t)})),this.setVisibility(this.visible),t()},e.prototype.create=function(){var t={};if(this.volume){var e,r,i=this.volume;"sigma"===this.thresholdType?(e=i.getValueForSigma(this.thresholdMin),r=i.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,r=this.thresholdMax),i.setFilter(e,r,this.thresholdOut),Object.assign(t,{position:i.getDataPosition(),color:i.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:i.getDataSize(this.radius,this.scale),picking:i.getDataPicking()})}else{var o=this.surface;Object.assign(t,{position:o.getPosition(),color:o.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:o.getSize(this.radius,this.scale),picking:o.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Fu(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Lu(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)},e.prototype.update=function(t){if(void 0===t&&(t={}),0!==this.bufferList.length){var e={};t.color&&(this.volume?Object.assign(e,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(e,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?Object.assign(e,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(e,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(e)}},e.prototype.setParameters=function(e,r,i){return void 0===r&&(r={}),e&&void 0!==e.thresholdType&&this.volume instanceof ds&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=parseFloat(e.radiusType),r.radius=!0,"sphere"!==this.dotType||Ne&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(r.radius=!0,"sphere"!==this.dotType||Ne&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(r.scale=!0,"sphere"!==this.dotType||Ne&&!this.disableImpostor||(i=!0)),t.prototype.setParameters.call(this,e,r,i),this},e}(lo);er.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),er.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");var zu=new Uint16Array([0,1,2,1,3,2]),ju=new Float32Array([0,1,0,0,1,1,1,0]),Vu=Object.assign({filter:"nearest",forceTransparent:!0},vs),Gu=Object.assign({filter:{updateShader:!0,uniform:!0}},bs),Uu=function(t){function r(r,i){t.call(this,{position:r.position,index:zu,picking:r.picking},i),this.parameterTypes=Gu,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";var o=r.imageData,n=r.width,a=r.height,s=new G(o,n,a);s.flipY=!0,this.tex=s;for(var c=o.length,u=new Uint8Array(c),h=0;h>16&255,u[h+1]=l>>8&255,u[h+2]=255&l}var p=new G(u,n,a);p.flipY=!0,p.minFilter=x,p.magFilter=x,this.pickingTex=p,this.addUniforms({map:{value:s},pickingMap:{value:p},mapSize:{value:new e(n,a)}}),this.geometry.setAttribute("uv",new M(ju,2))}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={defaultParameters:{configurable:!0}};return i.defaultParameters.get=function(){return Vu},r.prototype.getDefines=function(e){var r=t.prototype.getDefines.call(this,e),i=this.parameters.filter;return i.startsWith("cubic")&&(r.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?r.BSPLINE_FILTER=1:i.endsWith("catmulrom")?r.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(r.MITCHELL_FILTER=1)),r},r.prototype.updateTexture=function(){var t=this.tex,e=this.parameters.filter;e.startsWith("cubic")?(t.minFilter=x,t.magFilter=x):"linear"===e?(t.minFilter=A,t.magFilter=A):(t.minFilter=x,t.magFilter=x),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0},r.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this),this.updateTexture();var e=this.material;e.uniforms.map.value=this.tex,e.blending=U,e.needsUpdate=!0;var r=this.wireframeMaterial;r.uniforms.map.value=this.tex,r.blending=U,r.needsUpdate=!0;var i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=U,i.needsUpdate=!0},r.prototype.setUniforms=function(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},Object.defineProperties(r.prototype,i),r}(xs),Hu=function(t,e){var r=e||{};this.dimension=ht(r.dimension,"x"),this.positionType=ht(r.positionType,"percent"),this.position=ht(r.position,30),this.thresholdType=ht(r.thresholdType,"sigma"),this.thresholdMin=ht(r.thresholdMin,-1/0),this.thresholdMax=ht(r.thresholdMax,1/0),this.normalize=ht(r.normalize,!1),this.volume=t};Hu.prototype.getPositionFromCoordinate=function(t){var e,i=this.dimension,o=this.volume,n=o.matrix,a=(new r).setFromMatrixPosition(n)[i],s=(new r).setFromMatrixScale(n)[i];return e="x"===i?o.nx:"y"===i?o.ny:o.nz,Math.round(((t-a)/(e/100)+1)/s)},Hu.prototype.getData=function(t){t=t||{};var e,i=this.volume,o=i.data,n=i.matrix;function a(t){return Math.round(t/100*(e-1))}function s(t,e,r,o){return 3*(r*i.ny*i.nx+e*i.nx+t)+o}e="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;var c,u,h,l,p,d=new Float32Array(12),f=new r,m=0,g=0,y=0,v=i.nx,b=i.ny,x=i.nz;function _(t,e,r,i){f.set(t,e,r).applyMatrix4(n).toArray(d,i)}"x"===this.dimension?(h=a(i.nx),l=i.ny-1,p=i.nz-1,c=i.nz,u=i.ny,v=(m=h)+1,_(h,0,0,0),_(h,l,0,3),_(h,0,p,6),_(h,l,p,9)):"y"===this.dimension?(h=i.nx-1,l=a(i.ny),p=i.nz-1,c=i.nz,u=i.nx,b=(g=l)+1,_(0,l,0,0),_(h,l,0,3),_(0,l,p,6),_(h,l,p,9)):"z"===this.dimension&&(h=i.nx-1,l=i.ny-1,p=a(i.nz),c=i.nx,u=i.ny,x=(y=p)+1,_(0,0,p,0),_(0,l,p,3),_(h,0,p,6),_(h,l,p,9));var w,A,S=0,C=0,P=new Uint8Array(c*u*4),I=new Float32Array(c*u);"sigma"===this.thresholdType?(w=i.getValueForSigma(this.thresholdMin),A=i.getValueForSigma(this.thresholdMax)):(w=this.thresholdMin,A=this.thresholdMax);var O=Object.assign({},t.colorParams,{volume:i});this.normalize&&(O.domain=[0,1]);var k,M=Ze.getScheme(O),T=new Float32Array(3),B=M.getScale(),D=0,E=0;if(this.normalize){D=1/0,k=-1/0;for(var F=g;Fk&&(k=L)}E=k-D}for(var N=g;Nw&&G0?this.list[0]:void 0},oh.prototype.forEach=function(t){return this.list.forEach(t),this},oh.prototype.dispose=function(){return this.forEach((function(t){return t.dispose()}))},Object.defineProperties(oh.prototype,nh);var ah=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setParameters=function(t){return this.forEach((function(e){return e.setParameters(t)}))},e.prototype.setVisibility=function(t){return this.forEach((function(e){return e.setVisibility(t)}))},e.prototype.setSelection=function(t){return this.forEach((function(e){return e.setSelection(t)}))},e.prototype.setColor=function(t){return this.forEach((function(e){return e.setColor(t)}))},e.prototype.update=function(t){return this.forEach((function(e){return e.update(t)}))},e.prototype.build=function(t){return this.forEach((function(e){return e.build(t)}))},e.prototype.dispose=function(t){return this.forEach((function(t){return t.dispose()}))},e}(oh),sh=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},Xu),ch=function(t){function e(e,r,i){var o=this;void 0===i&&(i={}),t.call(this,e,Object.assign({name:r.name},i)),this.trajectory=r,this.signals=Object.assign(this.signals,{frameChanged:new rt,playerChanged:new rt,countChanged:new rt,parametersChanged:new rt}),r.signals.frameChanged.add((function(t){o.signals.frameChanged.dispatch(t)})),r.signals.playerChanged.add((function(t){o.signals.playerChanged.dispatch(t)})),r.signals.countChanged.add((function(t){o.signals.countChanged.dispatch(t)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultParameters:{configurable:!0},type:{configurable:!0}};return r.defaultParameters.get=function(){return sh},r.type.get=function(){return"trajectory"},e.prototype.setFrame=function(t){this.trajectory.setFrame(t)},e.prototype.setParameters=function(t){void 0===t&&(t={}),this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)},e.prototype.dispose=function(){this.trajectory.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(Yu),uh=function(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1},hh={type:{configurable:!0}};hh.type.get=function(){return"Frames"},Object.defineProperties(uh.prototype,hh);var lh=function(t,e){var r,o;if(this.A=new Ga(3,3),this.W=new Ga(1,3),this.U=new Ga(3,3),this.V=new Ga(3,3),this.VH=new Ga(3,3),this.R=new Ga(3,3),this.tmp=new Ga(3,3),this.c=new Ga(3,3),t instanceof gu)r=t.atomCount;else{if(!(t instanceof Float32Array))return;r=t.length/3}if(e instanceof gu)o=e.atomCount;else{if(!(e instanceof Float32Array))return;o=e.length/3}var n=Math.min(r,o),a=new Ga(3,n),s=new Ga(3,n);this.coords1t=new Ga(n,3),this.coords2t=new Ga(n,3),this.transformationMatrix=new i,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,a,n,!1),this.prepCoords(e,s,n,!1),this._superpose(a,s)};lh.prototype._superpose=function(t,e){var r,i,o,n,a,s,c,u,h,l,p,d,f,m,g,y,v,b,x,_,w,A;this.mean1=qa(t),this.mean2=qa(e),Xa(t,this.mean1),Xa(e,this.mean2),Ua(this.coords1t,t),Ua(this.coords2t,e),Ha(this.A,this.coords2t,this.coords1t),Za(this.A,this.W,this.U,this.V),r=this.V,i=this.VH,o=r.data,n=i.data,a=o[4],s=o[8],c=o[5],u=o[7],h=o[0],l=h*a,p=h*c,d=o[3],f=o[1],m=d*f,g=o[2],y=d*g,v=o[6],_=1/(l*s-p*u-m*s+y*u+(b=v*f)*c-(x=v*g)*a),n[0]=(a*s-c*u)*_,n[1]=-(f*s-g*u)*_,n[2]=-(-f*c+g*a)*_,n[3]=-(d*s-c*v)*_,n[4]=(h*s-x)*_,n[5]=-(p-y)*_,n[6]=-(-d*u+a*v)*_,n[7]=-(h*u-b)*_,n[8]=(l-m)*_,Wa(this.R,this.U,this.VH),w=this.R,(A=w.data)[0]*A[4]*A[8]-A[0]*A[5]*A[7]-A[3]*A[1]*A[8]+A[3]*A[2]*A[7]+A[6]*A[1]*A[5]-A[6]*A[2]*A[4]<0&&(He&&je.log("R not a right handed system"),Wa(this.tmp,this.c,this.VH),Wa(this.R,this.U,this.tmp));var S=new Ga(4,4),C=new Ga(4,4),P=new Ga(4,4),I=new Ga(4,4),O=new Ga(4,4),k=new Ga(4,4),M=this.R.data,T=this.mean1,B=this.mean2;I.data.set([1,0,0,-T[0],0,1,0,-T[1],0,0,1,-T[2],0,0,0,1]),O.data.set([M[0],M[1],M[2],0,M[3],M[4],M[5],0,M[6],M[7],M[8],0,0,0,0,1]),k.data.set([1,0,0,B[0],0,1,0,B[1],0,0,1,B[2],0,0,0,1]),Ua(C,I),Ha(S,O,C),Ua(P,S),Ha(C,k,P),Ua(S,C),this.transformationMatrix.elements=S.data},lh.prototype.prepCoords=function(t,e,r,i){var o=0,n=e.data,a=3,s=3*r;if(i&&(s=4*r,a=4),t instanceof gu)t.eachAtom((function(t){o=r)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),i.hasFrame(this._currentFrame)){this._currentStep+=1;var o=this._currentStep/(this.parameters.interpolateStep+1),n=this._currentFrame,a=n[0],s=n[1],c=n[2],u=n[3];i.setFrameInterpolated(a,s,c,u,o,this.parameters.interpolateType),this._previousTime=this._currentTime}else i.loadFrame(this._currentFrame);else{var h=this._next();i.hasFrame(h)?(i.setFrame(h),this._previousTime=this._currentTime):i.loadFrame(h)}window.requestAnimationFrame(this._animate)}},dh.prototype._next=function(){var t,e=this.parameters;return((t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step)>e.end||t=t.end?r=t.start:"backward"===t.direction&&e<=t.start&&(r=t.end),this.traj.setFrame(r),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}},dh.prototype.pause=function(){this._run=!1,this.signals.haltedRunning.dispatch()},dh.prototype.stop=function(){this.pause(),this.traj.setFrame(this.parameters.start)},Object.defineProperties(dh.prototype,fh);var mh=function(t,e,r){var i=this;void 0===r&&(r={}),this.signals={countChanged:new rt,frameChanged:new rt,playerChanged:new rt},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=ht(r.deltaTime,0),this.timeOffset=ht(r.timeOffset,0),this.centerPbc=ht(r.centerPbc,!1),this.removePbc=ht(r.removePbc,!1),this.removePeriodicity=ht(r.removePeriodicity,!1),this.superpose=ht(r.superpose,!1),this.name=t.replace(/^.*[\\/]/,""),this.trajPath=t,this.selection=new _e(ht(r.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((function(){i.selectionIndices=i.structure.getAtomIndices(i.selection),i._resetCache(),i._saveInitialCoords(),i.setFrame(i._currentFrame)}))},gh={frameCount:{configurable:!0},currentFrame:{configurable:!0}};gh.frameCount.get=function(){return this._frameCount},gh.currentFrame.get=function(){return this._currentFrame},mh.prototype._init=function(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new dh(this))},mh.prototype._loadFrameCount=function(){},mh.prototype.setStructure=function(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new _e("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)},mh.prototype._saveInitialCoords=function(){var t=this;this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(function(){return t._saveInitialCoords()}))},mh.prototype._saveStructureCoords=function(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position},mh.prototype.setSelection=function(t){return this.selection.setString(t),this},mh.prototype._getIndices=function(t){var e=0,r=t.test,i=[];return r&&this.structure.eachAtom((function(t){r(t)&&i.push(e),e+=1})),i},mh.prototype._makeSuperposeCoords=function(){var t=3*this.selectionIndices.length;this.coords1=new Float32Array(t),this.coords2=new Float32Array(t);for(var e=this.initialCoords,r=this.coords2,i=0;i0&&this.centerPbc){var o=[e[0],e[4],e[8]],n=function(t,e,r){return[Lr(e,r[0],3,0,t),Lr(e,r[1],3,1,t),Lr(e,r[2],3,2,t)]}(this.backboneIndices,r,o);!function(t,e,r){if(0!==r[0]&&0!==r[8]&&0!==r[4])for(var i=t.length,o=r[0],n=r[1],a=r[2],s=-e[0]+o+o/2,c=-e[1]+n+n/2,u=-e[2]+a+a/2,h=0;h.5&&(t[o+n]-=e[3*n+n]*Math.round(a))}}}(r,e,a)}this.removePbc&&function(t,e){if(0!==e[0]&&0!==e[8]&&0!==e[4]){for(var r=t.length,i=3;i.9*e[3*o+o])if(n>0)for(var a=0;a<3;++a)t[i+a]-=e[3*o+a];else for(var s=0;s<3;++s)t[i+s]+=e[3*o+s]}}}(r,e)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(r),this.frameCache[t]=r,this.boxCache[t]=e,this.frameCacheSize+=1},mh.prototype._setFrameCount=function(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))},mh.prototype.dispose=function(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()},mh.prototype.setPlayer=function(t){this.player=t,this.signals.playerChanged.dispatch(t)},mh.prototype.getFrameTime=function(t){return this.timeOffset+t*this.deltaTime},Object.defineProperties(mh.prototype,gh);var yh=function(t){function e(e,r,i){var o=i||{};o.timeOffset=ht(o.timeOffset,e.timeOffset),o.deltaTime=ht(o.deltaTime,e.deltaTime),t.call(this,"",r,o),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"frames"},e.prototype._makeAtomIndices=function(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0},e.prototype._loadFrame=function(t,e){var r,i=this.frames[t];if(this.atomIndices){var o=this.atomIndices,n=o.length;r=new Float32Array(3*n);for(var a=0;a0&&(i="( "+e.join(" ) AND ( ")+" )"),new _e(i)},e.prototype.getStructure=function(){return this.structure.getStructure()},e.prototype.eachBond=function(t,e){this.structure.eachBond(t,this.getSelection(e))},e.prototype.eachAtom=function(t,e){var r=this.getAtomProxy(),i=this.getAtomSet(e),o=this.atomStore.count;if(i.getSize()=this.V[r][i]?(t="S",this.score=this.S[r][i]):this.V[r][i]>=this.H[r][i]?(t="V",this.score=this.V[r][i]):(t="H",this.score=this.H[r][i]),He&&je.log("Alignment: SCORE",this.score),He&&je.log("Alignment: S, V, H",this.S[r][i],this.V[r][i],this.H[r][i]);r>0&&i>0;)"S"===t?this.S[r][i]===this.S[r-1][i-1]+e(r-1,i-1)?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2=this.seq2[i-1]+this.ali2,--r,--i,t="S"):this.S[r][i]===this.V[r][i]?t="V":this.S[r][i]===this.H[r][i]?t="H":(--r,--i):"V"===t?this.V[r][i]===this.V[r-1][i]+this.gapExtensionPenalty?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r,t="V"):this.V[r][i]===this.S[r-1][i]+this.gap(0)?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r,t="S"):--r:"H"===t?this.H[r][i]===this.H[r][i-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[i-1]+this.ali2,--i,t="H"):this.H[r][i]===this.S[r][i-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[i-1]+this.ali2,--i,t="S"):--i:je.error("Alignment: no matrix");for(;r>0;)this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r;for(;i>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[i-1]+this.ali2,--i;He&&je.timeEnd("Alignment.trace"),He&&je.log([this.ali1,this.ali2])};var Ih=Object.assign({sele:"",defaultAssembly:""},eh),Oh=function(t){function e(e,r,i){var o,n,a,s,c,u=this;void 0===i&&(i={}),t.call(this,e,r,Object.assign({name:r.name},i)),this.structure=r,this.trajList=[],this.signals=Object.assign(this.signals,{trajectoryAdded:new rt,trajectoryRemoved:new rt,defaultAssemblyChanged:new rt}),this.initSelection(this.parameters.sele),this.pickBuffer=(o=4,n=0,a=0,s=[],{has:function(t){return-1!==s.indexOf(t)},get:function(t){return s[t]},push:function(t){s[n]=t,n=(o+n+1)%o,++a},get count(){return a},get data(){return s.slice(0,Math.min(a,o))},clear:function(){a=0,n=0,s.length=0}}),this.pickDict=(c={},{has:function(t){return void 0!==c[JSON.stringify(t)]},add:function(t,e){c[JSON.stringify(t)]=e},del:function(t){delete c[JSON.stringify(t)]},get values(){return Object.keys(c).map((function(t){return c[t]}))}}),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Ve.opacity,color:Ve.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Ve,!0),this.angleRepresentation=this.addRepresentation("angle",Ve,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Ve,!0),this.measureRepresentations=new ah([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((function(){u.updateRepresentations({position:!0})}))}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultParameters:{configurable:!0},type:{configurable:!0}};return r.defaultParameters.get=function(){return Ih},r.type.get=function(){return"structure"},e.prototype.initSelection=function(t){var e=this;this.selection=new _e(t),this.structureView=new _h(this.structure,this.selection),this.selection.signals.stringChanged.add((function(){e.structureView.setSelection(e.selection),e.rebuildRepresentations(),e.rebuildTrajectories()}))},e.prototype.setSelection=function(t){return this.parameters.sele=t,this.selection.setString(t),this},e.prototype.setDefaultAssembly=function(t){if(void 0===this.structure.biomolDict[t]&&(t=""),this.parameters.defaultAssembly!==t){var e={defaultAssembly:t};this.reprList.forEach((function(t){return t.setParameters(e)})),this.measureRepresentations.setParameters(e),this.parameters.defaultAssembly=t,this.signals.defaultAssemblyChanged.dispatch(t)}return this},e.prototype.rebuildRepresentations=function(){this.reprList.forEach((function(t){t.build()})),this.measureRepresentations.build()},e.prototype.rebuildTrajectories=function(){var t=this;this.trajList.forEach((function(e){e.trajectory.setStructure(t.structureView)}))},e.prototype.updateRepresentations=function(e){t.prototype.updateRepresentations.call(this,e),this.measureRepresentations.update(e)},e.prototype.updateRepresentationMatrices=function(){t.prototype.updateRepresentationMatrices.call(this),this.measureRepresentations.setParameters({matrix:this.matrix})},e.prototype.addRepresentation=function(t,e,r){var i=this;void 0===e&&(e={}),void 0===r&&(r=!1),e.defaultAssembly=this.parameters.defaultAssembly;var o=this._addRepresentation(t,this.structureView,e,r);return r||o.signals.parametersChanged.add((function(){return i.measureUpdate()})),o},e.prototype.addTrajectory=function(t,e){void 0===t&&(t=""),void 0===e&&(e={});var r=function(t,e,r){return t&&t instanceof uh?new yh(t,e,r):!t&&e.frames?new vh(t,e,r):t&&"function"==typeof t?new xh(t,e,r):new bh(t,e,r)}(t,this.structureView,e),i=new ch(this.stage,r,e);return this.trajList.push(i),this.signals.trajectoryAdded.dispatch(i),i},e.prototype.removeTrajectory=function(t){var e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)},e.prototype.dispose=function(){this.trajList.slice().forEach((function(t){return t.dispose()})),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),t.prototype.dispose.call(this)},e.prototype.autoView=function(t,e){"number"==typeof t&&(e=t,t=""),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),ht(e,0))},e.prototype.getBoxUntransformed=function(t){return t?this.structureView.getBoundingBox(new _e(t)):this.structureView.boundingBox},e.prototype.getCenterUntransformed=function(t){return t&&"string"==typeof t?this.structure.atomCenter(new _e(t)):this.structure.center},e.prototype.superpose=function(t,e,r,i){return Ph(this.structureView,t.structureView,e,r,i),this.updateRepresentations({position:!0}),this},e.prototype.getMaxRepresentationRadius=function(t){var e=0,r=this.structure.getAtomProxy(t);return this.eachRepresentation((function(t){if(t.getVisibility()){var i=t.repr;e=Math.max(i.getAtomRadius(r),e)}})),e},e.prototype.measurePick=function(t){var e=this.pickBuffer.count;if(this.lastPick===t.index&&e>=1){if(e>1){var r=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,r),2===e?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((function(t){return 2===t.length}))}):3===e?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((function(t){return 3===t.length}))}):4===e&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((function(t){return 4===t.length}))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(t.index)||this.pickBuffer.push(t.index),this.lastPick=t.index;this.measureUpdate()},e.prototype.measureClear=function(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")},e.prototype.measureBuild=function(){var t=this.measureData();this.distanceRepresentation.setParameters({atomPair:t.distance}),this.angleRepresentation.setParameters({atomTriple:t.angle}),this.dihedralRepresentation.setParameters({atomQuad:t.dihedral})},e.prototype.measureUpdate=function(){var t=this,e=this.pickBuffer.data,r={};e.forEach((function(e){var i=Math.max(.1,t.getMaxRepresentationRadius(e));r[e]=i*(2.3-Vt(.1,2,i))})),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:r})},e.prototype.measureData=function(){var t=this.pickDict.values;return{distance:t.filter((function(t){return 2===t.length})),angle:t.filter((function(t){return 3===t.length})),dihedral:t.filter((function(t){return 4===t.length}))}},e.prototype.removeAllMeasurements=function(t){var e=this.pickDict,r=e.values,i=function(t){r.filter((function(e){return e.length===t})).forEach((function(t){return e.del(t.slice().sort())}))};(!t||1&t)&&i(2),(!t||2&t)&&i(3),(!t||4&t)&&i(4),this.measureBuild()},e.prototype.removeMeasurement=function(t){this.pickDict.del(t.slice().sort()),this.measureBuild()},e.prototype.addMeasurement=function(t){if(!(t.length<2||t.length>4)){var e=t.slice().sort();this.pickDict.has(e)||this.pickDict.add(e,t),this.measureBuild()}},Object.defineProperties(e.prototype,r),e}(rh);ir.add("structure",Oh),ir.add("structureview",Oh);var kh=function(t){function e(e,r,i){void 0===i&&(i={}),t.call(this,e,r,Object.assign({name:r.name},i)),this.surface=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"surface"},e.prototype.addRepresentation=function(t,e){return void 0===e&&(e={}),this._addRepresentation(t,this.surface,e)},e.prototype.getBoxUntransformed=function(){return this.surface.boundingBox},e.prototype.getCenterUntransformed=function(){return this.surface.center},e.prototype.dispose=function(){this.surface.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(rh);ir.add("surface",kh);var Mh=function(t){function e(e,r,i){void 0===i&&(i={}),t.call(this,e,r,Object.assign({name:r.name},i)),this.volume=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"volume"},e.prototype.addRepresentation=function(t,e){return void 0===e&&(e={}),this._addRepresentation(t,this.volume,e)},e.prototype.getBoxUntransformed=function(){return this.volume.boundingBox},e.prototype.getCenterUntransformed=function(){return this.volume.center},e.prototype.dispose=function(){this.volume.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(rh);ir.add("volume",Mh);var Th=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.addRepresentation=function(t,e){return this.forEach((function(r){return r.addRepresentation(t,e)}))},e.prototype.autoView=function(t){return this.forEach((function(e){return e.autoView(t)}))},e}(oh);function Bh(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}var Dh=new r,Eh={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"},Fh=function(t,e){void 0===e&&(e={}),this.signals={parametersChanged:new rt,fullscreenChanged:new rt,componentAdded:new rt,componentRemoved:new rt,clicked:new rt,hovered:new rt},this.tasks=new Sr,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new gi(t),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new wi(this.viewer.renderer.domElement),this.viewerControls=new Yi(this),this.trackballControls=new Fi(this),this.pickingControls=new zi(this),this.animationControls=new co(this),this.mouseControls=new Ds(this),this.keyControls=new Rs(this),this.pickingBehavior=new $s(this),this.mouseBehavior=new Ls(this),this.animationBehavior=new Ns(this),this.keyBehavior=new js(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=lt(e,Eh),this.setParameters(this.parameters),this.viewer.animate())};Fh.prototype.setParameters=function(t){void 0===t&&(t={}),pt(this.parameters,t);var e=t,r=this.parameters,i=this.viewer,o=this.trackballControls;return void 0!==e.quality&&this.setQuality(r.quality),void 0!==e.impostor&&this.setImpostor(r.impostor),void 0!==e.rotateSpeed&&(o.rotateSpeed=r.rotateSpeed),void 0!==e.zoomSpeed&&(o.zoomSpeed=r.zoomSpeed),void 0!==e.panSpeed&&(o.panSpeed=r.panSpeed),void 0!==e.mousePreset&&this.mouseControls.preset(r.mousePreset),this.mouseObserver.setParameters({hoverTimeout:r.hoverTimeout}),i.setClip(r.clipNear,r.clipFar,r.clipDist,r.clipMode,r.clipScale),i.setFog(void 0,r.fogNear,r.fogFar),i.setCamera(r.cameraType,r.cameraFov,r.cameraEyeSep),i.setSampling(r.sampleLevel),i.setBackground(r.backgroundColor),i.setLight(r.lightColor,r.lightIntensity,r.ambientColor,r.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this},Fh.prototype.log=function(t){console.log("STAGE LOG",t),this.logList.push(t)},Fh.prototype.getParameters=function(){return Object.assign({},this.parameters)},Fh.prototype.defaultFileRepresentation=function(t){if(t instanceof Oh){var e,r,i;t.setSelection("/0");var o=t.structure;if(o.biomolDict.BU1){var n=o.biomolDict.BU1;e=n.getAtomCount(o),r=n.getResidueCount(o),i=n.getInstanceCount(),t.setDefaultAssembly("BU1")}else e=o.getModelProxy(0).atomCount,r=o.getModelProxy(0).residueCount,i=1;var a=e;Re&&(a*=4);var s=o.atomStore.count/o.residueStore.count<2;s&&(a*=10);var c="chainname",u="RdYlBu",h=!1;if(1===o.getChainnameCount(new _e("polymer and /0"))&&(c="residueindex",u="Spectral",h=!0),He&&console.log(a,e,i,s),r/i<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(i>5&&a>15e3||a>7e5){var l=Math.min(2,Math.max(.1,6e3/(a/i)));s&&(l=Math.min(l,.5)),t.addRepresentation("surface",{colorScheme:c,colorScale:u,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:l,useWorker:!1})}else a>25e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:u,colorReverse:h,lineOnly:!0}):a>1e5?t.addRepresentation("backbone",{colorScheme:c,colorScale:u,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):a>8e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:u,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:u,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),a<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:u,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof kh||t instanceof Mh)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)},Fh.prototype.loadFile=function(t,e){var r=this;void 0===e&&(e={});var i=Object.assign({},this.defaultFileParams,e),o=mr(t).name;this.tasks.increment(),this.log("loading file '"+o+"'");var n=ht(i.ext,mr(t).ext);return(tr.isTrajectory(n)?Promise.reject(new Error("loadFile: ext '"+n+"' is a trajectory and must be loaded into a structure component")):yr(t,i)).then((function(t){r.log("loaded '"+o+"'");var e=r.addComponentFromObject(t,i);return i.defaultRepresentation&&r.defaultFileRepresentation(e),r.tasks.decrement(),e}),(function(t){r.tasks.decrement();var e="error loading file: '"+t+"'";throw r.log(e),e}))},Fh.prototype.loadScript=function(t){var e=this,r=mr(t).name;return this.log("loading script '"+r+"'"),yr(t).then((function(t){e.tasks.increment(),e.log("running script '"+r+"'"),t.run(e).then((function(){e.tasks.decrement(),e.log("finished script '"+r+"'")})),e.log("called script '"+r+"'")}),(function(t){e.tasks.decrement();var i="errored script '"+r+"' \""+t+'"';throw e.log(i),i}))},Fh.prototype.addComponent=function(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):je.warn("Stage.addComponent: no component given")},Fh.prototype.addComponentFromObject=function(t,e){void 0===e&&(e={});var r=ir.get(t.type);if(r){var i=new r(this,t,e);return this.addComponent(i),i}je.warn("no component for object type",t.type)},Fh.prototype.removeComponent=function(t){var e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))},Fh.prototype.removeAllComponents=function(){var t=this;this.compList.slice().forEach((function(e){return t.removeComponent(e)}))},Fh.prototype.handleResize=function(){this.viewer.handleResize()},Fh.prototype.setSize=function(t,e){var r=this.viewer.container;r!==document.body&&(void 0!==t&&(r.style.width=t),void 0!==e&&(r.style.height=e),this.handleResize())},Fh.prototype.toggleFullscreen=function(t){if(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled){var e=this;t=t||this.viewer.container,this.lastFullscreenElement=t,r()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(t.dataset.normalWidth=t.style.width||"",t.dataset.normalHeight=t.style.height||"",t.style.width=window.screen.width+"px",t.style.height=window.screen.height+"px",t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){e.handleResize()}),100))}else je.log("fullscreen mode (currently) not possible");function r(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function i(){if(!r()&&e.lastFullscreenElement){var t=e.lastFullscreenElement;t.style.width=t.dataset.normalWidth||"",t.style.height=t.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i),e.handleResize(),e.signals.fullscreenChanged.dispatch(!1)}}},Fh.prototype.setSpin=function(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)},Fh.prototype.setRock=function(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)},Fh.prototype.toggleSpin=function(){this.setSpin(this.spinAnimation.paused)},Fh.prototype.toggleRock=function(){this.setRock(this.rockAnimation.paused)},Fh.prototype.getFocus=function(){var t=this.parameters;if("scene"!==t.clipMode)return 0;var e=t.clipNear;return"absolute"===t.clipScale&&(e=this.viewer.absoluteToRelative(e)),2*e},Fh.prototype.setFocus=function(t){var e,r,i,o;"scene"===this.parameters.clipMode&&("relative"===this.parameters.clipScale?(i=50,o=function(t){return Nt(t,0,100)}(2*(r=100-(e=Nt(t/2,0,49.9)))-50)):(i=0,o=2*(r=e=this.viewer.relativeToAbsolute(t/2))),this.setParameters({clipNear:e,clipFar:r,fogNear:i,fogFar:o}))},Fh.prototype.getZoomForBox=function(t){var e=t.getSize(Dh),r=Math.max(e.x,e.y,e.z),i=Math.min(e.x,e.y,e.z),o=r+Math.sqrt(i),n=Ft(this.viewer.perspectiveCamera.fov),a=this.viewer.width,s=this.viewer.height,c=s=0;s--)(o=t[s])&&(a=(n<3?o(a):n>3?o(e,r,a):o(e,r))||a);return n>3&&a&&Object.defineProperty(e,r,a),a}ir.add("shape",Rh);var Lh=function(t){function e(e){var r=this;t.call(this,e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=ht(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel((function(t){r.parameters.domain=[t.atomOffset,t.atomEnd],r.scalePerModel[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.index)},e}(Xt);$h([Wt],Lh.prototype,"atomColor",null),Ze.add("atomindex",Lh);var Nh=function(t){function e(e){if(t.call(this,e),e.scale||(this.parameters.scale="OrRd"),!e.domain){var r,i=1/0,o=-1/0;e.sele&&(r=new _e(e.sele)),e.structure.eachAtom((function(t){var e=t.bfactor;i=Math.min(i,e),o=Math.max(o,e)}),r),this.parameters.domain=[i,o]}this.bfactorScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.bfactorScale(t.bfactor)},e}(Xt);$h([Wt],Nh.prototype,"atomColor",null),Ze.add("bfactor",Nh);var zh=function(t){function e(e){var r=this;t.call(this,e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((function(t){var e=0,i={};t.eachChain((function(t){void 0===i[t.chainid]&&(i[t.chainid]=e,e+=1)})),r.parameters.domain=[0,e-1],r.chainidDictPerModel[t.index]=i,r.scalePerModel[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=this.chainidDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainid])},e}(Xt);$h([Wt],zh.prototype,"atomColor",null),Ze.add("chainid",zh);var jh=function(t){function e(e){var r=this;t.call(this,e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((function(t){r.parameters.domain=[t.chainOffset,t.chainEnd],r.scalePerModel[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.chainIndex)},e}(Xt);$h([Wt],jh.prototype,"atomColor",null),Ze.add("chainindex",jh);var Vh=function(t){function e(e){var r=this;t.call(this,e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((function(t){var e=0,i={};t.eachChain((function(t){void 0===i[t.chainname]&&(i[t.chainname]=e,e+=1)})),r.parameters.domain=[0,e-1],r.chainnameDictPerModel[t.index]=i,r.scalePerModel[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=this.chainnameDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainname])},e}(Xt);$h([Wt],Vh.prototype,"atomColor",null),Ze.add("chainname",Vh);var Gh=function(t){function e(e){t.call(this,e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});var r=e.structure.validation;r&&(this.rsrzDict=r.rsrzDict,this.rsccDict=r.rsccDict)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.resno+"";t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;var r=this.rsrzDict[e];if(void 0!==r)return this.rsrzScale(r);var i=this.rsccDict[e];return void 0!==i?this.rsccScale(i):9474192},e}(Xt);$h([Wt],Gh.prototype,"atomColor",null),Ze.add("densityfit",Gh);var Uh={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};var Hh=function(t){function e(e){var i=this;t.call(this,e),this.delta=new r,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);var o=[];e.structure.eachAtom((function(t){var e;if(i.charges[t.index]=(null!==(e=t).partialCharge?e.partialCharge:e.isProtein()&&(Uh[e.resname]&&Uh[e.resname][e.atomname]||Uh.backbone[e.atomname])||0)*t.occupancy,"N"===t.atomname){if(t.bondCount>=3)return;if(t.bondToElementCount(1))return;var n=function(t,e){void 0===e&&(e=new r);var i=!1,o=!1,n=!1;return e.set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom((function(t){if(!i)return"H"===t.atomname?(e.set(t.x,t.y,t.z),void(i=!0)):void(o||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,e.sub(t)):(e.sub(t),o=!0))})),i?e:o&&n?(e.normalize(),e.multiplyScalar(1.04),e.add(t),e):void 0}(t);void 0!==n&&(o.push(n),i.hCharges.push(.25*t.occupancy))}}));var n=e.structure.getBoundingBox();n.expandByScalar(1.04),this.hStore=function(t){for(var e=t.length,r=new Float32Array(e),i=new Float32Array(e),o=new Float32Array(e),n=0;n>1&1431655765))+(i>>2&858993459))+(i>>4)&252645135)>>24}else e=this.geoDict[r]||0;return 0===e?2188972:1===e?16703627:2===e?16018755:e>=3?10813478:9474192},e}(Xt);$h([Wt],Kh.prototype,"atomColor",null),Ze.add("geoquality",Kh);var Zh=function(t){function e(e){t.call(this,e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(var r in Pn)this.resHF[r]=Pn[r][0];if(this.defaultResidueHydrophobicity=In[0],!e.domain){var i=1/0,o=-1/0;for(var n in this.resHF){var a=this.resHF[n];i=Math.min(i,a),o=Math.max(o,a)}this.parameters.domain=[i,0,o]}this.hfScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.hfScale(this.resHF[t.resname]||this.defaultResidueHydrophobicity)},e}(Xt);$h([Wt],Zh.prototype,"atomColor",null),Ze.add("hydrophobicity",Zh);var Qh=function(t){function e(e){t.call(this,e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.modelindexScale(t.modelIndex)},e}(Xt);$h([Wt],Qh.prototype,"atomColor",null),Ze.add("modelindex",Qh);var Jh=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){switch(t.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}},e}(Xt);$h([Wt],Jh.prototype,"atomColor",null),Ze.add("moleculetype",Jh);var tl=function(t){function e(e){t.call(this,e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.occupancyScale(t.occupancy)},e}(Xt);$h([Wt],tl.prototype,"atomColor",null),Ze.add("occupancy",tl);var el=function(t){function e(e){t.call(this,e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.partialchargeScale(t.partialCharge||0)},e}(Xt);function rl(){return 16777215*Math.random()}$h([Wt],el.prototype,"atomColor",null),Ze.add("partialcharge",el);var il=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return rl()},e.prototype.volumeColor=function(){return rl()},e.prototype.positionColor=function(){return rl()},e}(Xt);$h([Wt],il.prototype,"atomColor",null),$h([Wt],il.prototype,"volumeColor",null),$h([Wt],il.prototype,"positionColor",null),Ze.add("random",il);var ol=function(t){function e(e){t.call(this,e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});var r=e.structure.validation;r&&(this.rciDict=r.rciDict)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e="["+t.resname+"]"+t.resno;t.chainname&&(e+=":"+t.chainname);var r=this.rciDict[e];return void 0!==r?this.rciScale(r):9474192},e}(Xt);$h([Wt],ol.prototype,"atomColor",null),Ze.add("randomcoilindex",ol);var nl=function(t){function e(e){var r=this;t.call(this,e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=ht(e.reverse,!0)),e.structure.eachChain((function(t){r.parameters.domain=[t.residueOffset,t.residueEnd],r.scalePerChain[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerChain[t.chainIndex](t.residueIndex)},e}(Xt);$h([Wt],nl.prototype,"atomColor",null),Ze.add("residueindex",nl);var al={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723},sl=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return al[t.resname]||16711935},e}(Xt);$h([Wt],sl.prototype,"atomColor",null),Ze.add("resname",sl);var cl=16711808,ul=10485888,hl=6291584,ll=16762880,pl=6324479,dl=16777215,fl=11403518,ml=16580962,gl=10921722,yl=function(t){function e(e){t.call(this,e),this.residueProxy=e.structure.getResidueProxy()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.sstruc,r=this.residueProxy;return"h"===e?cl:"g"===e?ul:"i"===e?hl:"e"===e||"b"===e?ll:"t"===e?pl:(r.index=t.residueIndex,r.isDna()?fl:r.isRna()?ml:r.isSaccharide()?gl:r.isProtein()||"s"===e||"l"===e?dl:8421504)},e}(Xt);$h([Wt],yl.prototype,"atomColor",null),Ze.add("sstruc",yl);var vl=function(t){function e(e){var r,i;t.call(this,e),e.scale||(this.parameters.scale="rwb"),this.atomData=null===(r=this.parameters.data)||void 0===r?void 0:r.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e,r=null===(e=this.atomData)||void 0===e?void 0:e[t.index];return void 0!==r?this.scale(r):this.parameters.value},e.prototype.bondColor=function(t,e){var r,i=null===(r=this.bondData)||void 0===r?void 0:r[t.index];return void 0!==i?this.scale(i):this.atomProxy?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value},e}(Xt);$h([Wt],vl.prototype,"atomColor",null),$h([Wt],vl.prototype,"bondColor",null),Ze.add("structuredata",vl);var bl=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return this.parameters.value},e.prototype.bondColor=function(){return this.parameters.value},e.prototype.valueColor=function(){return this.parameters.value},e.prototype.volumeColor=function(){return this.parameters.value},e}(Xt);$h([Wt],bl.prototype,"atomColor",null),$h([Wt],bl.prototype,"bondColor",null),$h([Wt],bl.prototype,"valueColor",null),$h([Wt],bl.prototype,"volumeColor",null),Ze.add("uniform",bl);var xl=function(t){function e(e){t.call(this,e),this.valueScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.volumeColor=function(t){return this.valueScale(this.parameters.volume.data[t])},e}(Xt);$h([Wt],xl.prototype,"volumeColor",null),Ze.add("value",xl);var _l=function(t){function e(e){t.call(this,e),this.vec=new r,this.valueScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.positionColor=function(t){var e=this.parameters.volume;if(!e||!e.inverseMatrix)return this.parameters.value;var r=this.vec,i=e.data,o=e.nx,n=e.ny,a=o*n;r.copy(t),r.applyMatrix4(e.inverseMatrix);var s=Math.floor(r.x),c=Math.floor(r.y),u=Math.floor(r.z),h=(u*n+c)*o+s,l=h+1,p=h+o,d=h+a,f=p+1,m=d+1,g=p+a,y=g+1,v=i[h],b=i[l],x=i[p],_=i[d],w=i[f],A=i[m],S=i[g],C=i[y],P=r.x-s,I=r.y-c,O=r.z-u,k=zt(v,b,P),M=zt(_,A,P),T=zt(x,w,P),B=zt(S,C,P),D=zt(k,T,I),E=zt(M,B,I),F=zt(D,E,O);return this.valueScale(F)},e}(Xt);$h([Wt],_l.prototype,"positionColor",null),Ze.add("volume",_l);var wl=function(t){function e(e,r,i){var o=i||{};if(t.call(this,e,r,o),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:Ys.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new _e(o.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){var n={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach((function(t){n[t]=t})),this.parameters.assembly={type:"select",options:n,rebuild:!0}}else this.parameters.assembly=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultScale:{configurable:!0}};return r.defaultScale.get=function(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}},e.prototype.init=function(e){var r=this,i=e||{};i.colorScheme=ht(i.colorScheme,"element"),this.setRadius(i.radius,i),this.radiusType=ht(i.radiusType,"vdw"),this.radiusData=ht(i.radiusData,{}),this.radiusSize=ht(i.radiusSize,1),this.radiusScale=ht(i.radiusScale,1),this.assembly=ht(i.assembly,"default"),this.defaultAssembly=ht(i.defaultAssembly,""),"auto"===i.quality&&(i.quality=this.getQuality()),t.prototype.init.call(this,i),this.selection.signals.stringChanged.add((function(){r.build()})),this.build()},e.prototype.setRadius=function(t,e){var r=Object.keys(Xs);return"string"==typeof t&&r.includes(t.toLowerCase())?e.radiusType=t:void 0!==t&&(e.radiusType="size",e.radiusSize=t),this},e.prototype.getAssembly=function(){var t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]},e.prototype.getQuality=function(){var t,e=this.structureView,r=this.getAssembly();return t=r?r.getAtomCount(e):e.atomCount,Re&&(t*=4),e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"},e.prototype.create=function(){var t=this;if(0!==this.structureView.atomCount)if(this.structureView.hasCoords()){this.needsBuild=!1;var e=this.getAssembly();if(e)e.partList.forEach((function(e,r){var i=e.getView(t.structureView);if(0!==i.atomCount){var o=t.createData(i,r);o&&(o.sview=i,o.instanceList=e.getInstanceList(),t.dataList.push(o))}}));else{var r=this.createData(this.structureView,0);r&&(r.sview=this.structureView,this.dataList.push(r))}}else this.needsBuild=!0},e.prototype.update=function(t){var e=this;!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((function(r){r.bufferList.length>0&&e.updateData(t,r)}),this):Object.assign(this.lazyProps.what,t)},e.prototype.updateData=function(t,e){this.build()},e.prototype.getColorParams=function(){return Object.assign(Object.assign({},t.prototype.getColorParams.call(this)),{structure:this.structure})},e.prototype.getRadiusParams=function(t){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}},e.prototype.getAtomParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)},e.prototype.getBondParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)},e.prototype.getAtomRadius=function(t){return this.structureView.atomSet.isSet(t.index)?new Ys(this.getRadiusParams()).atomRadius(t):0},e.prototype.setSelection=function(t,e){return this.selection.setString(t,e),this},e.prototype.setParameters=function(e,r,i){void 0===r&&(r={}),void 0===i&&(i=!1);var o=e||{};return this.setRadius(o.radius,o),void 0===o.radiusType&&void 0===o.radiusData&&void 0===o.radiusSize&&void 0===o.radiusScale||(r.radius=!0,Ne&&!this.disableImpostor||(i=!0)),void 0!==o.defaultAssembly&&o.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===o.assembly||"default"===o.assembly)&&(i=!0),t.prototype.setParameters.call(this,o,r,i),this},e.prototype.getParameters=function(){return Object.assign(t.prototype.getParameters.call(this),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})},e.prototype.attach=function(t){var e=this.viewer,r=this.bufferList;this.dataList.forEach((function(t){t.bufferList.forEach((function(i){r.push(i),e.add(i,t.instanceList)}))})),this.setVisibility(this.visible),t()},e.prototype.clear=function(){this.dataList.length=0,t.prototype.clear.call(this)},e.prototype.dispose=function(){this.structureView.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(lo),Al=function(t){function e(e,r,i){t.call(this,e,r,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};this.labelVisible=ht(r.labelVisible,!0),this.labelSize=ht(r.labelSize,2),this.labelColor=ht(r.labelColor,16777215),this.labelFontFamily=ht(r.labelFontFamily,"sans-serif"),this.labelFontStyle=ht(r.labelFontstyle,"normal"),this.labelFontWeight=ht(r.labelFontWeight,"bold"),this.labelsdf=ht(r.labelsdf,"Chrome"===De),this.labelXOffset=ht(r.labelXOffset,0),this.labelYOffset=ht(r.labelYOffset,0),this.labelZOffset=ht(r.labelZOffset,.5),this.labelAttachment=ht(r.labelAttachment,"bottom-left"),this.labelBorder=ht(r.labelBorder,!1),this.labelBorderColor=ht(r.labelBorderColor,"lightgrey"),this.labelBorderWidth=ht(r.labelBorderWidth,.15),this.labelBackground=ht(r.labelBackground,!1),this.labelBackgroundColor=ht(r.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=ht(r.labelBackgroundMargin,.5),this.labelBackgroundOpacity=ht(r.labelBackgroundOpacity,1),this.labelFixedSize=ht(r.labelFixedSize,!1),this.lineOpacity=ht(r.lineOpacity,1),this.linewidth=ht(r.linewidth,2),t.prototype.init.call(this,r)},e.prototype.update=function(e){e.position?this.build():t.prototype.update.call(this,e)},e.prototype.updateData=function(t,e){var r={};if(t&&!t.labelSize||Object.assign(r,{size:jr(this.n,this.labelSize)}),!t||t.labelColor){var i=new n(this.labelColor);Object.assign(r,{color:Vr(this.n,i.r,i.g,i.b)})}this.textBuffer.setAttributes(r)},e.prototype.setParameters=function(e,r,i){return void 0===r&&(r={}),void 0===i&&(i=!1),e&&e.labelSize&&(r.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(r.labelColor=!0,i=!0),t.prototype.setParameters.call(this,e,r,i),e&&void 0!==e.opacity&&this.textBuffer.setParameters({opacity:1}),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this},e.prototype.setVisibility=function(e,r){return t.prototype.setVisibility.call(this,e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),r||this.viewer.requestRender(),this},e.prototype.getLabelBufferParams=function(e){return void 0===e&&(e={}),t.prototype.getBufferParams.call(this,Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))},e.prototype.getAtomRadius=function(){return 0},e}(wl);function Sl(t,e){var r=t.getAtomProxy(),i=new _e,o=e.length;if(0===o)return new Float32Array(0);var n=e[0].length,a=t.getAtomSet(),s=new Float32Array(o*n*3),c=0;return e.forEach((function(e){for(var o=!1,u=0;u 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Ol={};var kl={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024},Ml=function(t){void 0===t&&(t={}),this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=lt(t,kl);var e=this.parameters;this.radius=e.size/8,this.padding=e.size/3;var r=this.lineHeight=e.size+2*e.outline+Math.round(e.size/4),i=this.maxWidth=e.width/4,o=this.canvas=document.createElement("canvas");o.width=i,o.height=r;var n=this.context=this.canvas.getContext("2d");n.font=e.style+" "+e.variant+" "+e.weight+" "+e.size+"px "+e.font,n.fillStyle="black",n.textAlign="left",n.textBaseline="bottom",n.lineJoin="round",this.gridOuter=new Float64Array(r*i),this.gridInner=new Float64Array(r*i),this.f=new Float64Array(Math.max(r,i)),this.d=new Float64Array(Math.max(r,i)),this.z=new Float64Array(Math.max(r,i)+1),this.v=new Int16Array(Math.max(r,i)),this.data=new Uint8Array(e.width*e.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=e.width,this.canvas2.height=e.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(var a=32;a<=126;++a)this.map(String.fromCharCode(a));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new W(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0};Ml.prototype.map=function(t){var e=this.parameters;return void 0===this.mapped[t]&&(this.draw(t),this.currentX+this.scratchW>e.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>e.height&&console.warn("canvas to small"),this.mapped[t]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[t]},Ml.prototype.get=function(t){return this.mapped[t]||this.placeholder},Ml.prototype.draw=function(t){var e=this.parameters,r=this.lineHeight,i=e.outline,o=this.context,n=this.maxWidth,a=i,s=r-e.outline,c=o.measureText(t),u=Math.min(n,Math.ceil(c.width+2*a+1)),h=u*r;o.clearRect(0,0,u,r),o.fillText(t,a,s);for(var l=o.getImageData(0,0,u,r),p=l.data,d=0;d= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),er.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Fl=Object.assign({linewidth:2},vs),Rl=Object.assign({linewidth:{uniform:!0}},bs),$l=function(t){function r(r,o){void 0===o&&(o={}),t.call(this,r,o),this.parameterTypes=Rl,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!r.color2&&r.color&&(r.color2=r.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new e},projectionMatrixInverse:{value:new i}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(r),this.makeMapping()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var o={defaultParameters:{configurable:!0}};return o.defaultParameters.get=function(){return Fl},r.prototype.setParameters=function(e){t.prototype.setParameters.call(this,e)},Object.defineProperties(r.prototype,o),r}(Du);or.add("wideline",$l);var Ll=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.side=ht(r.side,"double"),r.opacity=ht(r.opacity,.5),this.atomTriple=ht(r.atomTriple,[]),this.arcVisible=ht(r.arcVisible,!0),this.sectorVisible=ht(r.sectorVisible,!0),this.vectorVisible=ht(r.vectorVisible,!0),t.prototype.init.call(this,r)},e.prototype.createData=function(t){if(t.atomCount&&this.atomTriple.length){var e=function(t,e){return function(t){for(var e=[],r=t.length/9,i=0;i radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Wl=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),ql=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),Xl=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,"v3",e,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.mapping.get=function(){return Wl},r.mappingIndices.get=function(){return ql},r.mappingIndicesSize.get=function(){return 12},r.mappingSize.get=function(){return 6},r.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,r),e}(Mu),Yl=Object.assign({openEnded:!1},vs),Kl=Object.assign({openEnded:{updateShader:!0}},bs),Zl=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,e,r),this.parameterTypes=Kl,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new i},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultParameters:{configurable:!0}};return r.defaultParameters.get=function(){return Yl},e.prototype.getDefines=function(e){var r=t.prototype.getDefines.call(this,e);return this.parameters.openEnded||(r.CAP=1),r},Object.defineProperties(e.prototype,r),e}(Xl);Object.assign({disableImpostor:!1},Gl,Yl);var Ql=function(t,e){return void 0===e&&(e={}),!t.color2&&t.color&&(t.color2=t.color),!Ne||e&&e.disableImpostor?new Hl(t,e):new Zl(t,e)};or.add("cylinder",Ql);var Jl=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radiusSize=ht(r.radiusSize,.5),r.colorValue=ht(r.colorValue,"lightgreen"),r.useInteriorColor=ht(r.useInteriorColor,!0),this.showAxes=ht(r.showAxes,!0),this.showBox=ht(r.showBox,!1),t.prototype.init.call(this,r)},e.prototype.getPrincipalAxes=function(){var t,e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)},e.prototype.getAxesData=function(t){var e=this.getPrincipalAxes(),i=new n(this.colorValue),o=0,a=0;this.showAxes&&(o+=6,a+=3),this.showBox&&(o+=8,a+=12);var s=new Float32Array(3*o),c=Vr(o,i.r,i.g,i.b),u=jr(o,this.radiusSize),h=new Float32Array(3*a),l=new Float32Array(3*a),p=Vr(a,i.r,i.g,i.b),d=jr(a,this.radiusSize),f=0;if(this.showAxes){var m=function(t,e){t.toArray(s,2*f),e.toArray(s,2*f+3),t.toArray(h,f),e.toArray(l,f),f+=3};m(e.begA,e.endA),m(e.begB,e.endB),m(e.begC,e.endC)}if(this.showBox){var g=new r,y=e.getProjectedScaleForAtoms(t),v=y.d1a,b=y.d2a,x=y.d3a,_=y.d1b,w=y.d2b,A=y.d3b,S=2*f,C=function(t,r,i){g.copy(e.center).addScaledVector(e.normVecA,t).addScaledVector(e.normVecB,r).addScaledVector(e.normVecC,i),g.toArray(s,S),S+=3};C(v,b,x),C(v,b,A),C(v,w,A),C(v,w,x),C(_,w,A),C(_,w,x),C(_,b,x),C(_,b,A);var P=f,I=function(t,e){g.fromArray(s,2*f+3*t).toArray(h,P),g.fromArray(s,2*f+3*e).toArray(l,P),P+=3};I(0,1),I(0,3),I(0,6),I(1,2),I(1,7),I(2,3),I(2,4),I(3,5),I(4,5),I(4,7),I(5,6),I(6,7)}var O=new xa(e);return{vertex:{position:s,color:c,radius:u,picking:O},edge:{position1:h,position2:l,color:p,color2:p,radius:d,picking:O}}},e.prototype.create=function(){var t=this.getAxesData(this.structureView);this.sphereBuffer=new Fu(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new Ql(t.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})},e.prototype.createData=function(t){},e.prototype.updateData=function(t,e){var r=this.getAxesData(e.sview),i={},o={};t&&!t.position||(Object.assign(i,{position:r.vertex.position}),Object.assign(o,{position1:r.edge.position1,position2:r.edge.position2})),t&&!t.color||(Object.assign(i,{color:r.vertex.color}),Object.assign(o,{color:r.edge.color,color2:r.edge.color})),t&&!t.radius||(Object.assign(i,{radius:r.vertex.radius}),Object.assign(o,{radius:r.edge.radius})),this.sphereBuffer.setAttributes(i),this.cylinderBuffer.setAttributes(o)},e}(wl);Je.add("axes",Jl);var tp=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radiusType=ht(r.radiusType,"size"),r.radiusSize=ht(r.radiusSize,.15),r.useInteriorColor=ht(r.useInteriorColor,!0),this.aspectRatio=ht(r.aspectRatio,2),this.lineOnly=ht(r.lineOnly,!1),this.cylinderOnly=ht(r.cylinderOnly,!1),this.multipleBond=ht(r.multipleBond,"off"),this.bondSpacing=ht(r.bondSpacing,1),this.bondScale=ht(r.bondScale,.4),this.linewidth=ht(r.linewidth,2),t.prototype.init.call(this,r)},e.prototype.getAtomRadius=function(e){return this.aspectRatio*t.prototype.getAtomRadius.call(this,e)},e.prototype.getAtomParams=function(e,r){var i=t.prototype.getAtomParams.call(this,e,r);return i.radiusParams.scale*=this.aspectRatio,i},e.prototype.getAtomData=function(t,e,r){return t.getAtomData(this.getAtomParams(e,r))},e.prototype.getBondParams=function(e,r){return r=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},r),t.prototype.getBondParams.call(this,e,r)},e.prototype.getBondData=function(t,e,r){return t.getBondData(this.getBondParams(e,r))},e.prototype.createData=function(t){var e=[];if(this.lineOnly)this.lineBuffer=new $l(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{var r=new Ql(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(r),!this.cylinderOnly){var i=new Fu(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(i)}}return{bufferList:e}},e.prototype.updateData=function(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);var r=this.getBondData(e.sview,t);if(this.lineOnly){var i={};t&&!t.position||Object.assign(i,{position1:r.position1,position2:r.position2}),t&&!t.color||Object.assign(i,{color:r.color,color2:r.color2}),e.bufferList[0].setAttributes(i)}else{var o={};if(t&&!t.position||Object.assign(o,{position1:r.position1,position2:r.position2}),t&&!t.color||Object.assign(o,{color:r.color,color2:r.color2}),t&&!t.radius||Object.assign(o,{radius:r.radius}),e.bufferList[0].setAttributes(o),!this.cylinderOnly){var n=this.getAtomData(e.sview,t),a={};t&&!t.position||Object.assign(a,{position:n.position}),t&&!t.color||Object.assign(a,{color:n.color}),t&&!t.radius||Object.assign(a,{radius:n.radius}),e.bufferList[1].setAttributes(a)}}},e.prototype.setParameters=function(e){void 0===e&&(e={});var r=!1,i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),Ne&&!this.disableImpostor||(r=!0)),t.prototype.setParameters.call(this,e,i,r),this},e}(wl);Je.add("ball+stick",tp);var ep=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.aspectRatio=ht(r.aspectRatio,1),r.radiusSize=ht(r.radiusSize,.25),t.prototype.init.call(this,r)},e.prototype.getAtomRadius=function(e){return e.isTrace()?t.prototype.getAtomRadius.call(this,e):0},e.prototype.getAtomData=function(t,e,r){return t.getBackboneAtomData(this.getAtomParams(e,r))},e.prototype.getBondData=function(t,e,r){return t.getBackboneBondData(this.getBondParams(e,r))},e}(tp);Je.add("backbone",ep);var rp=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.aspectRatio=ht(r.aspectRatio,1),r.radiusSize=ht(r.radiusSize,.3),t.prototype.init.call(this,r)},e.prototype.getAtomData=function(t,e,r){return t.getRungAtomData(this.getAtomParams(e,r))},e.prototype.getBondData=function(t,e,r){var i=this.getBondParams(e,r);return Object.assign(i.colorParams,{rung:!0}),t.getRungBondData(i)},e}(tp);Je.add("base",rp);var ip=function(t,e){this.m=t,this.tension=e,this.dt=1/this.m,this.delta=1e-4,this.vec1=new r,this.vec2=new r,this.vDir=new r,this.vTan=new r,this.vNorm=new r,this.vBin=new r,this.m2=Math.ceil(this.m/2)};ip.prototype.interpolateToArr=function(t,e,r,i,o,n,a){n[a+0]=jt(t.x,e.x,r.x,i.x,o,this.tension),n[a+1]=jt(t.y,e.y,r.y,i.y,o,this.tension),n[a+2]=jt(t.z,e.z,r.z,i.z,o,this.tension)},ip.prototype.interpolateToVec=function(t,e,r,i,o,n){n.x=jt(t.x,e.x,r.x,i.x,o,this.tension),n.y=jt(t.y,e.y,r.y,i.y,o,this.tension),n.z=jt(t.z,e.z,r.z,i.z,o,this.tension)},ip.prototype.interpolatePosition=function(t,e,r,i,o,n){for(var a=0;a1&&(u=1),this.interpolateToVec(t,e,r,i,c,this.vec1),this.interpolateToVec(t,e,r,i,u,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(o,h)}},ip.prototype.vectorSubdivide=function(t,e,r,i,o){for(var n,a=e.next(),s=e.next(),c=e.next(),u=e.size,h=u-1,l=i||0,p=0;p0&&r0;So(w,v,A);var T=Ao(w,x)<0;if(To(w,x,Ao(x,b)),So(S,b,w),To(w,x,Ao(x,_)),So(C,_,w),0!==ko(S)&&0!==ko(C)){Bo(S,S),Bo(C,C);var B=n[M]=function(t,e){var r=t[0],i=t[1],o=t[2],n=e[0],a=e[1],s=e[2],c=i*s-o*a,u=o*n-r*s,h=r*a-i*n,l=Math.sqrt(c*c+u*u+h*h),p=r*n+i*a+o*s;return Math.atan2(l,p)}(S,C);s[M]=($r*B).toFixed(1)+String.fromCharCode(176),wo(O,S,x),Bo(O,O),Ao(O,C)<0&&$o(O,O),Cl(w,A,S,O,B/2),Io(w,a,3*M);var D=Math.ceil(B/r),E=D+(e.extendLine?4:2),F=e.extendLine?36:0,R=new Float32Array(3*E),$=new Float32Array(3*E),L=new Float32Array(9*D),N=new Float32Array(F);c[M]=R,u[M]=$,h[M]=L,l[M]=N,e.extendLine&&(o?(So(w,m,y),Bo(w,w),To(P,w,1/Ao(S,w)),Co(P,P,y)):(To(P,b,1/Ao(S,b)),Co(P,P,g)),T?(So(w,v,g),Bo(w,w),To(I,w,1/Ao(C,w)),Co(I,I,g)):(To(I,_,1/Ao(C,_)),Co(I,I,y))),Co(k,A,S);var z=0;e.extendLine?(Io(m,R,z),Io(P,$,z),Io(P,R,z+=3),Io(k,$,z),z+=3,Io(P,N,0),Io(k,N,3),Io(o?y:g,N,6),Io(o?y:g,N,9),Io(k,N,12),Io(A,N,15)):(Io(A,R,z),Io(k,$,z),z+=3);for(var j=function(t,e){var r=9*e;Io(A,L,r),Io(k,L,r+3),Io(k,R,z),Cl(k,A,S,O,t),Io(k,L,r+6),Io(k,$,z),z+=3},V=0,G=r;G=3&&(o=mp(n)),void 0!==o&&r.push(o)}return this.frontHistogramBinBordersBuffer=s(r.map((function(t){return t.frontHistogramBinBorders})),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=s(r.map((function(t){return t.backHistogramBinBorders})),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=s(r.map((function(t){return t.adjacentBondArrows})),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=s(r.map((function(t){return t.distantBondArrows})),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=c(r.map((function(t){return t.opaqueMiddleDisc})),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=c(r.map((function(t){return t.frontHistogram})),this.getHistogramBufferParameters()),this.backHistogramBuffer=c(r.map((function(t){return t.backHistogram})),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}function a(t){for(var e=t.map((function(t){return t.length})),r=new Float32Array(Kr(e)),i=0,o=0;o0&&(i-=l,n=n.subarray(0,3*i));var d=new cn(c.count,!0);return{text:o,position:n,bondSet:d,bondStore:c}},e.prototype.getBondData=function(t,e,r){var i=t.getBondData(this.getBondParams(e,r));return i.picking&&(i.picking=new Ca(i.picking.array,i.picking.structure,r.bondStore)),i},e.prototype.createData=function(t){if(t.atomCount&&this.atomPair.length){var e=this.atomPair.length,r=new n(this.labelColor),i=this.getDistanceData(t,this.atomPair);this.textBuffer=new El({position:i.position,size:jr(e,this.labelSize),color:Vr(e,r.r,r.g,r.b),text:i.text},this.getLabelBufferParams());var o={bondSet:i.bondSet,bondStore:i.bondStore},a=this.getBondData(t,{position:!0,color:!0,picking:!0,radius:this.useCylinder},o);return this.useCylinder?this.distanceBuffer=new Ql(a,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new $l(No(a),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:i.bondSet,bondStore:i.bondStore,position:i.position,bufferList:[this.textBuffer,this.distanceBuffer]}}},e.prototype.updateData=function(e,r){t.prototype.updateData.call(this,e,r);var i={bondSet:r.bondSet,bondStore:r.bondStore},o=this.getBondData(r.sview,e,i),n={};e&&!e.color||Object.assign(n,{color:o.color,color2:o.color2}),e&&!e.radius||Object.assign(n,{radius:o.radius}),this.distanceBuffer.setAttributes(n)},e.prototype.setParameters=function(e){return t.prototype.setParameters.call(this,e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this},e}(Al);function yp(t){return 2*(t.position.length/3)*3}Je.add("distance",gp);var vp=Object.assign({scale:1,color:"grey"},vs),bp=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,{position:new Float32Array(yp(e)),color:new Float32Array(yp(e))},r),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";var i=new n(this.parameters.color),o=this.geometry.attributes;Vr(yp(e)/3,i.r,i.g,i.b,o.color.array),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultParameters:{configurable:!0}};return r.defaultParameters.get=function(){return vp},e.prototype.setAttributes=function(t){void 0===t&&(t={});var e,r,i,o=this.geometry.attributes;t.position&&t.vector&&(e=t.position,r=t.vector,i=o.position.array,o.position.needsUpdate=!0);var n=this.size/2,a=this.parameters.scale;if(e&&r)for(var s=0;s radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),er.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var wp=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Ap=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]),Sp=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,"v3",e,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.mapping.get=function(){return wp},r.mappingIndices.get=function(){return Ap},r.mappingIndicesSize.get=function(){return 36},r.mappingSize.get=function(){return 8},r.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,r),e}(Mu),Cp=Object.assign({shrink:.14},vs),Pp=Object.assign({shrink:{uniform:!0}},bs),Ip=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,e,r),this.parameterTypes=Pp,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new i},modelViewProjectionMatrixInverse:{value:new i},modelViewMatrixInverseTranspose:{value:new i},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultParameters:{configurable:!0}};return r.defaultParameters.get=function(){return Cp},Object.defineProperties(e.prototype,r),e}(Sp);Object.assign({disableImpostor:!1},Gl,Cp);var Op=function(t,e){return void 0===e&&(e={}),!Ne||e&&e.disableImpostor?(t.radius=function(t,e){for(var r=t.length,i=new Float32Array(r),o=0;o0;)i[s]=arguments[s+3];for(var c=a(t,e,r),u=0;uu?p[m]=-1:(c=Math.sqrt(u-s),p[m]=Math.floor(c)),++m;f[g]=l,d[g]=p}}function C(r){var i,o,n,s,l,m,v,x,_,w,A,S,C,P,I,O,k,M,T=3*r,B=r;i=Math.floor(.5+a*(t[T]+p[0])),o=Math.floor(.5+a*(t[T+1]+p[1])),n=Math.floor(.5+a*(t[T+2]+p[2]));var D,E=e[B],F=d[E],R=0,$=u*h,L=f[E];for(w=0;w=c||P>=u||I>=h)){var N=C*$+P*h+I;if(g)if(1&y[N]){if(1&y[N]){var z=b[N];z!==T&&v*v+x*x+_*_<(s=i+v-Math.floor(.5+a*(t[z]+p[0])))*s+(l=o+x-Math.floor(.5+a*(t[z+1]+p[1])))*l+(m=n+_-Math.floor(.5+a*(t[z+2]+p[2])))*m&&(b[N]=r)}}else y[N]|=1,b[N]=r;else y[N]|=1}R++}}function P(e){var r,i;for(console.time("EDTSurface fillvoxels"),r=0,i=y.length;r=c||A>=u||S>=h)){var $=w*R+A*h+S;if(2&y[$]){if(g){var L=b[$];v*v+x*x+_*_<(s=Math.floor(.5+a*(t[L]+p[0])))*s+(l=Math.floor(.5+a*(t[L+1]+p[1])))*l+(m=Math.floor(.5+a*(t[L+2]+p[2])))*m&&(b[$]=r)}}else y[$]|=2,g&&(b[$]=r)}E++}}function O(){var t,e,r,i;console.time("EDTSurface fastdistancemap");var o,n=Dp(c,u,h,Uint16Array,3),a=u*h,l=m*m,p=0;for(t=0;t0);var w,A=s*s,S=new Uint16Array(3);for(t=0;t=A)||(y[o]|=4,g&&2&y[o]&&(n.toArray(t,e,r,S),w=S[0]*a+S[1]*h+S[2],b[o]=b[w])));console.timeEnd("EDTSurface fastdistancemap")}function k(t,e,r,i){var o,n,a,s,l,p,d,f,m,g,b,x,_=new Uint16Array(3),w=0;if(0===r)return w;var S=-1,C=-1,P=-1,I=u*h;for(d=0,m=r;d-1&&C-1&&P-1&&(1&y[b=S*I+h*C+P]&&!(2&y[b])?(e.fromArray(S,C,P,_),g=(s=S-_[0])*s+(l=C-_[1])*l+(p=P-_[2])*p,v[b]=g,y[b]|=2,y[b]|=4,i[w]=S,i[w+1]=C,i[w+2]=P,w+=3):1&y[b]&&2&y[b]&&(g=(s=S-_[0])*s+(l=C-_[1])*l+(p=P-_[2])*p)-1&&C-1&&P-1&&(1&y[b=S*I+h*C+P]&&!(2&y[b])?(e.fromArray(S,C,P,_),g=(s=S-_[0])*s+(l=C-_[1])*l+(p=P-_[2])*p,v[b]=g,y[b]|=2,y[b]|=4,i[w]=S,i[w+1]=C,i[w+2]=P,w+=3):1&y[b]&&2&y[b]&&(g=(s=S-_[0])*s+(l=C-_[1])*l+(p=P-_[2])*p)-1&&C-1&&P-1&&(1&y[b=S*I+h*C+P]&&!(2&y[b])?(e.fromArray(S,C,P,_),g=(s=S-_[0])*s+(l=C-_[1])*l+(p=P-_[2])*p,v[b]=g,y[b]|=2,y[b]|=4,i[w]=S,i[w+1]=C,i[w+2]=P,w+=3):1&y[b]&&2&y[b]&&(g=(s=S-_[0])*s+(l=C-_[1])*l+(p=P-_[2])*p)-1&&a-1&&l-1&&sM&&(M=E)}return{neighbourListLength:27*M+1,withinRadii:function(o,n,a,s,l){for(var p=0,d=f(o,c),m=f(n,u),g=f(a,h),y=Math.max(0,d-1),_=Math.max(0,m-1),A=Math.max(0,g-1),S=Math.min(v,d+2),C=Math.min(b,m+2),k=Math.min(x,g+2),M=y;Mp&&(p=h[D]);var E;E=us(k,M,p,f,0),f=E.scaleFactor,y=E.dim,v=E.matrix,O=Math.max(5,2+Math.floor(d*f)),b=jr(y[0]*y[1]*y[2],-1001),x=new Int32Array(b.length),_=new Float32Array(y[0]),w=new Float32Array(y[1]),A=new Float32Array(y[2]),$(_,k[0],1/f),$(w,k[1],1/f),$(A,k[2],1/f),function(){var t=0,e=2*Math.PI/g;C=new Float32Array(g),S=new Float32Array(g);for(var r=0;r=0;){if(n!==i&&n!==o&&N(n,t,e,r))return T=n,n;n=I[++a]}return T=-1,-1}function N(e,r,i,o){var n=3*e,a=l[e],s=t[n]-r,c=t[n+1]-i,u=t[n+2]-o;return s*s+c*c+u*u0&&l=0;)t0)continue;var vt=void 0,bt=void 0,xt=void 0,_t=void 0,wt=0;if(N){if(wt=10===(_t=h.split(Wd)).length?1:0,v=_t[2],X&&"CA"!==v)continue;vt=parseFloat(_t[6-wt]),bt=parseFloat(_t[7-wt]),xt=parseFloat(_t[8-wt])}else{if(v=h.substr(12,4).trim(),X&&"CA"!==v)continue;vt=parseFloat(h.substr(30,8)),bt=parseFloat(h.substr(38,8)),xt=parseFloat(h.substr(46,8))}if(q){var At=3*a;if(n[At+0]=vt,n[At+1]=bt,n[At+2]=xt,a+=1,Z)continue}var St=void 0;N?(p=parseInt(_t[1]),St="",b="H"===h[0]?1:0,d=wt?"":_t[4],f=parseInt(_t[5-wt]),y="",m=_t[3],_="",g=1):(p=parseInt(h.substr(6,5),U),G&&99999===p&&(U=16),b="H"===h[0]?1:0,d=h[21].trim(),f=parseInt(h.substr(22,4),H),G&&9999===f&&(H=16),y=h[26].trim(),m=h.substr(17,4).trim()||"MOL",x=parseFloat(h.substr(60,6)),_=h[16].trim(),g=parseFloat(h.substr(54,6)),t||(z?(St=h.substr(76,3).trim())in zn&&(St=zn[St]):(St=h.substr(76,2).trim(),d||(d=h.substr(72,4).trim())),w=parseInt((h.substr(79,1)+h.substr(78,1)).trim()))),lt.growIfFull(),lt.atomTypeId[ft]=ht.add(v,St),lt.x[ft]=vt,lt.y[ft]=bt,lt.z[ft]=xt,lt.serial[ft]=p,lt.altloc[ft]=_.charCodeAt(0),lt.occupancy[ft]=isNaN(g)?0:g,N?(lt.partialCharge[ft]=parseFloat(_t[9-wt]),lt.radius[ft]=parseFloat(_t[10-wt])):(lt.bfactor[ft]=isNaN(x)?0:x,z&&(lt.partialCharge[ft]=parseFloat(h.substr(70,6))),isFinite(w)&&(lt.formalCharge||lt.addField("formalCharge",1,"int8"),lt.formalCharge[ft]=w));var Ct=qd(f,d,y);!b||ot[Ct]||Ud.includes(m)?D||E===d||(B=(T+=1).toString()):E===d&&R===m&&(En.includes(m)||F===f&&$===y)||(B=(T+=1).toString(),F=f,R=m,$=y),V.addAtom(mt,d,B,m,f,b,void 0,y),J[p]=ft,ft+=1,D=!1,E=d}else if("CONECT"===l){var Pt=J[parseInt(h.substr(6,5))],It=[11,16,21,26],Ot={};if(void 0===Pt)continue;for(var kt=0;kt<4;++kt){var Mt=parseInt(h.substr(It[kt],5));if(!Number.isNaN(Mt)&&void 0!==(Mt=J[Mt]))if(Pt0)continue;var nt=it[u].replace(Zd,"");if(O&&"CA"!==nt)continue;var at=parseFloat(it[b]),st=parseFloat(it[x]),ct=parseFloat(it[_]);if(I){var ut=3*e;if(t[ut+0]=at,t[ut+1]=st,t[ut+2]=ct,e+=1,X>0)continue}var ht=it[h],lt=parseInt(it[-1!==s?s:c]),pt=it[v];pt="?"===pt?"":pt;var dt=it[a],ft=it[l],mt="H"===it[f][0]?1:0,gt=it[g],yt=parseFloat(it[w]),vt=parseFloat(it[A]),bt=it[d];if(bt="."===bt?"":bt,H.growIfFull(),H.atomTypeId[q]=U.add(nt,gt),H.x[q]=at,H.y[q]=st,H.z[q]=ct,H.serial[q]=parseInt(it[m]),H.bfactor[q]=isNaN(yt)?0:yt,H.occupancy[q]=isNaN(vt)?0:vt,H.altloc[q]=bt.charCodeAt(0),C.addAtom(X,dt,ft,ht,lt,mt,void 0,pt),He){var xt=T[ft];void 0!==xt&&xt!==dt&&He&&je.warn(xt,dt)}T[ft]=dt;var _t=it[p];B[_t]||(B[_t]=new Set),B[_t].add(S.chainStore.count-1),q+=1}else{var wt=n.match(Kd),At=wt.length;N===L.length&&(N=0);for(var St=0;Stl*l)return n.growIfFull(),n.atomTypeId[g]=n.atomTypeId[t],n.x[g]=d.x,n.y[g]=d.y,n.z[g]=d.z,n.occupancy[g]=n.occupancy[t],n.serial[g]=g,n.altloc[g]="A".charCodeAt(0),o.addAtom(0,"","","HET",1,!0),void(g+=1)}}}))},x=0;x0){a=a.split("(");var u=c(a[0]),h=c(a[1]);Object.keys(u).forEach((function(t){Object.keys(h).forEach((function(e){var r=new i;r.multiplyMatrices(u[t],h[e]),o[t+"x"+e]=r}))}))}else o=c(a);var l=[];for(var p in o)l.push(o[p]);var d=t;/^(0|[1-9][0-9]*)$/.test(d)&&(d="BU"+d);for(var f=s.asym_id_list[e].split(","),m=0,g=f.length;mw){var A=_;_=w,w=A;var S=f;f=b,b=S}if(0!==_&&0!==w)for(var C=0;Cv)continue}l=I.substr(5,5).trim(),p=parseInt(I.substr(0,5)),d=parseInt(I.substr(15,5)),x.growIfFull(),x.atomTypeId[_]=b.add(h),x.x[_]=M,x.y[_]=T,x.z[_]=B,x.serial[_]=d,i.addAtom(w,"","",l,p,0,"l"),_+=1}}}(0,r.length,r)})),i.finalize(),r.finalizeAtoms(),Bc(r),Dc(r),r.finalizeBonds(),Mc(r),He&&je.timeEnd("GroParser._parse "+this.name)},Object.defineProperties(e.prototype,r),e}(Ld);tr.add("gro",af);var sf=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function cf(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function uf(t){return cf(DataView,t)}function hf(t){return cf(Int8Array,t)}function lf(t){return cf(Int32Array,t,4)}function pf(t,e){var r=t.length/2;e||(e=new Int16Array(r));for(var i=0,o=0;in&&++s;e=new Int32Array(s)}for(r=0,i=0;ro){for(var n=[],a=0;a0&&(p.biomolDict.NCS=st)}var ut=d.unitCell;ut&&Array.isArray(ut)&&ut[0]?p.unitcell=new Vd({a:ut[0],b:ut[1],c:ut[2],alpha:ut[3],beta:ut[4],gamma:ut[5],spacegroup:d.spaceGroup}):p.unitcell=void 0,$c(p,!0),Rc(p,!0),p.finalizeAtoms(),p.finalizeBonds(),Lc(p),He&&je.timeEnd("MmtfParser._parse "+this.name)},Object.defineProperties(e.prototype,r),e}(Ld);tr.add("mmtf",Sf);var Cf=/\s+/,Pf={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0},If=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"mol2"},e.prototype._parse=function(){He&&je.time("Mol2Parser._parse "+this.name);var t,e,r=this.structure,i=this.structureBuilder,o=this.firstModelOnly,n=this.asTrajectory,a=r.frames,s=!1,c=r.atomMap,u=r.atomStore;u.resize(Math.round(this.streamer.data.length/60)),u.addField("partialCharge",1,"float32");var h=0,l=0,p=0,d=-1,f=0,m=0,g=r.getAtomProxy(),y=r.getAtomProxy();this.streamer.eachChunkOfLines((function(v){!function(v,b,x){for(var _=v;_MOLECULE"===w?(m=1,l=0,++d):"@ATOM"===w?(m=2,p=u.count,n&&(e=0,t=new Float32Array(3*f),a.push(t),d>0&&(s=!0))):m="@BOND"===w?3:0;else if(1===m){if(0===l)r.title=w,r.id=w;else if(1===l){var A=w.split(Cf);f=parseInt(A[0])}++l}else if(2===m){var S=w.split(Cf);if(o&&d>0)continue;var C=parseFloat(S[2]),P=parseFloat(S[3]),I=parseFloat(S[4]);if(n){var O=3*e;if(t[O+0]=C,t[O+1]=P,t[O+2]=I,e+=1,s)continue}var k=S[0],M=S[1],T=S[5].split(".")[0],B=S[6]?parseInt(S[6]):1,D=S[7]?S[7]:"",E=S[8]?parseFloat(S[8]):0;u.growIfFull(),u.atomTypeId[h]=c.add(M,T),u.x[h]=C,u.y[h]=P,u.z[h]=I,u.serial[h]=k,u.partialCharge[h]=E,i.addAtom(d,"","",D,B,1),h+=1}else if(3===m){if(o&&d>0)continue;if(n&&d>0)continue;var F=w.split(Cf);g.index=parseInt(F[1])-1+p,y.index=parseInt(F[2])-1+p;var R=Pf[F[3]];r.bondStore.addBond(g,y,R)}}}(0,v.length,v)})),i.finalize(),r.finalizeAtoms(),Bc(r),Rc(r,!0),$c(r,!0),r.finalizeBonds(),Vc(r),Mc(r),He&&je.timeEnd("Mol2Parser._parse "+this.name)},Object.defineProperties(e.prototype,r),e}(Ld);tr.add("mol2",If);var Of=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"pdbqt"},Object.defineProperties(e.prototype,r),e}(Xd);tr.add("pdbqt",Of);var kf=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"pqr"},Object.defineProperties(e.prototype,r),e}(Xd);tr.add("pqr",kf);var Mf=/> +<(.+)>/,Tf=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"sdf"},e.prototype._parse=function(){He&&je.time("SdfParser._parse "+this.name);var t=this.structure,e=this.structureBuilder,r=this.firstModelOnly,i=this.asTrajectory,o=this.streamer.peekLines(2);t.id=o[0].trim(),t.title=o[1].trim();var n,a,s=t.frames,c=!1,u=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/50)),h.addField("formalCharge",1,"int8");var l,p,d,f,m,g,y,v,b,x,_,w,A,S,C=t.getAtomProxy(),P=t.getAtomProxy(),I=0,O=0,k=0,M=0,T=[],B=!1,D={};t.extraData.sdf=T;var E=!1,F=!1,R=!1,$=[],L=[],N=new Map;this.streamer.eachChunkOfLines((function(o){!function(o,z,j){for(var V=o;V-1)?N.clear():(p=parseInt(G.substr(0,3)),d=parseInt(G.substr(3,3)),y=(g=m=(f=4)+p)+d,i&&(a=0,n=new Float32Array(3*p),s.push(n),k>0&&(c=!0)));else if(E&&"COUNTS"===$[0])p=parseInt($[1]),i&&(a=0,n=new Float32Array(3*p),s.push(n),k>0&&(c=!0));else if(E&&2==$.length)"ATOM"===$[1]?"BEGIN"===$[0]?F=!0:"END"===$[0]&&(F=!1):"BOND"===$[1]&&("BEGIN"===$[0]?R=!0:"END"===$[0]&&(R=!1));else if(F||!E&&O>=f&&O0)continue;var U=0;if(E){if(v=parseFloat($[2]),b=parseFloat($[3]),x=parseFloat($[4]),w=$[1],A=parseInt($[0]),N.set(A,I),_=w+A,$.length>6){var H=$.slice(6).find((function(t){return 0===t.indexOf("CHG=")}));H&&(U=parseInt(H.substring(4)))}}else v=parseFloat(G.substr(0,10)),b=parseFloat(G.substr(10,10)),x=parseFloat(G.substr(20,10)),w=G.substr(31,3).trim(),_=w+(I-M+1);if(i){var W=3*a;if(n[W+0]=v,n[W+1]=b,n[W+2]=x,a+=1,c)continue}h.growIfFull(),h.atomTypeId[I]=u.add(_,w),h.x[I]=v,h.y[I]=b,h.z[I]=x,h.serial[I]=E?A:I,h.formalCharge[I]=U,e.addAtom(k,"","","HET",1,1),I+=1}else if(R||!E&&O>=g&&O0)continue;if(i&&k>0)continue;E?(C.index=N.get(parseInt($[2])),P.index=N.get(parseInt($[3])),S=parseInt($[1])):(C.index=parseInt(G.substr(0,3))-1+M,P.index=parseInt(G.substr(3,3))-1+M,S=parseInt(G.substr(6,3))),t.bondStore.addBond(C,P,S)}else if("M CHG"===G.substr(0,6))for(var q=parseInt(G.substr(6,3)),X=0,Y=10;X"===G.charAt(0)&&(l=G.match(Mf))?(B=l[1],D[B]=[]):!1!==B&&G&&D[B].push(G);++O}}}(0,o.length,o)})),e.finalize(),t.finalizeAtoms(),t.finalizeBonds(),Vc(t),He&&je.timeEnd("SdfParser._parse "+this.name)},e.prototype._postProcess=function(){Vc(this.structure)},Object.defineProperties(e.prototype,r),e}(Ld);tr.add("sdf",Tf),tr.add("sd",Tf),tr.add("mol",Tf);function Bf(t,e,r){return parseInt(t.substr(e,r).trim())}var Df=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"prmtop"},e.prototype._parse=function(){He&&je.time("PrmtopParser._parse "+this.name);var t=this.structure,e=this.structureBuilder,r=t.atomMap,i=t.atomStore;i.addField("partialCharge",1,"float32"),i.addField("radius",1,"float32");var o,n,a,s,c,u=[],h={},l=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];l.forEach((function(t){h[t]=0}));var p,d,f,m,g,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(t){!function(t,e,r){for(var v=t;v0)je.error("dcd format with fixed atoms unsupported, aborting");else{for(var g=n.NATOM,y=4*g,v=0,b=n.NSET;v=1&&(r.timeOffset=(n.ISTART-1)*r.deltaTime),He&&je.timeEnd("DcdParser._parse "+this.name)}},Object.defineProperties(e.prototype,r),e}(zf);function Vf(t,e){if(t)throw new TypeError("Not a valid NetCDF v3.x file: "+e)}function Gf(t){t.offset%4!=0&&t.skip(4-t.offset%4)}function Uf(t){var e=t.readUint32(),r=t.readChars(e);return Gf(t),r}tr.add("dcd",jf);var Hf=1,Wf=2,qf=3,Xf=4,Yf=5,Kf=6;function Zf(t){switch(Number(t)){case Hf:return"byte";case Wf:return"char";case qf:return"short";case Xf:return"int";case Yf:return"float";case Kf:return"double";default:return"undefined"}}function Qf(t){switch(Number(t)){case Hf:case Wf:return 1;case qf:return 2;case Xf:case Yf:return 4;case Kf:return 8;default:return-1}}function Jf(t){switch(String(t)){case"byte":return Hf;case"char":return Wf;case"short":return qf;case"int":return Xf;case"float":return Yf;case"double":return Kf;default:return-1}}function tm(t,e){if(1!==t){for(var r=new Array(t),i=0;i6,"non valid type "+d);var f=t.readUint32(),m=t.readUint32();2===r&&(Vf(m>0,"offsets larger than 4GB not supported"),m=t.readUint32()),h[0]===e&&(n+=f),i[s]={name:c,dimensions:h,attributes:p,type:Zf(d),size:f,offset:m,record:h[0]===e}}return{variables:i,recordStep:n}}(t,i.recordId,e);return r.variables=o.variables,r.recordDimension.recordStep=o.recordStep,r}function im(t){var e,r=t.readUint32();if(0===r)return Vf(0!==t.readUint32(),"wrong empty tag for list of attributes"),[];Vf(12!==r,"wrong tag for list of attributes");var i=t.readUint32();e=new Array(i);for(var o=0;o6,"non valid type "+a);var s=t.readUint32(),c=em(t,a,s);Gf(t),e[o]={name:n,type:Zf(a),value:c}}return e}var om=function(t){var e=new wr(t);e.setBigEndian(),Vf("CDF"!==e.readChars(3),"should start with CDF");var r=e.readByte();Vf(r>2,"unknown version"),this.header=rm(e,r),this.buffer=e},nm={version:{configurable:!0},recordDimension:{configurable:!0},dimensions:{configurable:!0},globalAttributes:{configurable:!0},variables:{configurable:!0}};nm.version.get=function(){return 1===this.header.version?"classic format":"64-bit offset format"},nm.recordDimension.get=function(){return this.header.recordDimension},nm.dimensions.get=function(){return this.header.dimensions},nm.globalAttributes.get=function(){return this.header.globalAttributes},nm.variables.get=function(){return this.header.variables},om.prototype.hasDataVariable=function(t){return-1!==this.header.variables.findIndex((function(e){return e.name===t}))},om.prototype.getDataVariable=function(t){var e;return Vf(void 0===(e="string"==typeof t?this.header.variables.find((function(e){return e.name===t})):t),"variable not found"),this.buffer.seek(e.offset),e.record?function(t,e,r){for(var i=Jf(e.type),o=e.size?e.size/Qf(i):1,n=r.length,a=new Array(n),s=r.recordStep,c=0;c=1&&(e.timeOffset=o[0]),o.length>=2&&(e.deltaTime=o[1]-o[0]),He&&je.timeEnd("NctrajParser._parse "+this.name)},Object.defineProperties(e.prototype,r),e}(zf);tr.add("nctraj",am),tr.add("ncdf",am),tr.add("nc",am);var sm=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},isBinary:{configurable:!0}};return r.type.get=function(){return"trr"},r.isBinary.get=function(){return!0},e.prototype._parse=function(){He&&je.time("TrrParser._parse "+this.name);for(var t=Pt(this.streamer.data),e=new DataView(t),r=this.frames,i=r.coordinates,o=r.boxes,n=r.times,a=0;;){a+=8;var s=e.getInt32(a);a+=4,a+=s;var c=e.getInt32(a+8),u=e.getInt32(a+12),h=e.getInt32(a+16),l=e.getInt32(a+28),p=e.getInt32(a+32),d=e.getInt32(a+36),f=e.getInt32(a+40);a+=52;var m=c/9,g=3*f;if(8===m?n.push(e.getFloat64(a)):n.push(e.getFloat32(a)),a+=2*m,c){var y=new Float32Array(9);if(8===m)for(var v=0;v<9;++v)y[v]=10*e.getFloat64(a),a+=8;else for(var b=0;b<9;++b)y[b]=10*e.getFloat32(a),a+=4;o.push(y)}if(a+=u,a+=h,l){var x=void 0;if(8===m){x=new Float32Array(g);for(var _=0;_>8&65280|S>>24&255}x=new Float32Array(t,a,g);for(var C=0;C=t.byteLength)break}n.length>=1&&(r.timeOffset=n[0]),n.length>=2&&(r.deltaTime=n[1]-n[0]),He&&je.timeEnd("TrrParser._parse "+this.name)},Object.defineProperties(e.prototype,r),e}(zf);tr.add("trr",sm);var cm=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function um(t){for(var e=1,r=0;t>=e&&r<32;)r++,e<<=1;return r}var hm=new Uint8Array(32);function lm(t,e){var r=1,i=0;hm[0]=1;for(var o=0;o>=8;for(;0!==a;)hm[n++]=255&a,a>>=8;r=n}var s=1;for(r--;hm[r]>=s;)i++,s*=2;return i+8*r}function pm(t,e,r,i){for(var o=(1<=8;)c|=(a=a<<8|e[s++])>>n<0&&(n>(n-=r)&(1<8;)dm[s++]=pm(t,e,8,a),i-=8;i>0&&(dm[s++]=pm(t,e,i,a));for(var c=r-1;c>0;c--){for(var u=0,h=s-1;h>=0;h--){var l=(u=u<<8|dm[h])/o[c]|0;dm[h]=l,u-=l*o[c]}n[c]=u}n[0]=dm[0]|dm[1]<<8|dm[2]<<16|dm[3]<<24}var mm=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},isBinary:{configurable:!0}};return r.type.get=function(){return"xtc"},r.isBinary.get=function(){return!0},e.prototype._parse=function(){He&&je.time("XtcParser._parse "+this.name);for(var t=Pt(this.streamer.data),e=new DataView(t),r=this.frames,i=r.coordinates,o=r.boxes,n=r.times,a=new Int32Array(6),s=new Int32Array(3),c=new Int32Array(3),u=new Uint32Array(3),h=new Float32Array(3),l=new Float32Array(3),p=0,d=new Int32Array(3),f=new Uint32Array(d.buffer);;){var m=void 0,g=e.getInt32(p+4);p+=12;var y=3*g;n.push(e.getFloat32(p)),p+=4;for(var v=new Float32Array(9),b=0;b<9;++b)v[b]=10*e.getFloat32(p),p+=4;if(o.push(v),g<=9){m=new Float32Array(g);for(var x=0;x16777215?(c[0]=um(s[0]),c[1]=um(s[1]),c[2]=um(s[2]),S=0):S=lm(3,s);var C=e.getInt32(p);p+=4;var P=C-1,I=cm[P=9>P?9:P]/2|0,O=cm[C]/2|0;u[0]=u[1]=u[2]=cm[C];var k=4*Math.ceil(e.getInt32(p)/4);p+=4;var M=1/A,T=0,B=0,D=new Uint8Array(t,p);for(h[0]=h[1]=h[2]=0;B0){h[0]=h[1]=h[2]=0;for(var F=0;F9?cm[C-1]/2|0:0):E>0&&(I=O,O=cm[C]/2|0),u[0]=u[1]=u[2]=cm[C],0===u[0]||0===u[1]||0===u[2])return void console.error("(xdrfile error) Undefined error.")}p+=k}for(var $=0;$=t.byteLength)break}n.length>=1&&(r.timeOffset=n[0]),n.length>=2&&(r.deltaTime=n[1]-n[0]),He&&je.timeEnd("XtcParser._parse "+this.name)},Object.defineProperties(e.prototype,r),e}(zf);tr.add("xtc",mm);var gm=function(t){function e(e,r){var i=r||{};t.call(this,e,i),this.volume=new ds(this.name,this.path),this.voxelSize=ht(i.voxelSize,1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},__objName:{configurable:!0}};return r.type.get=function(){return"volume"},r.__objName.get=function(){return"volume"},e.prototype._afterParse=function(){this.volume.setMatrix(this.getMatrix()),t.prototype._afterParse.call(this)},e.prototype.getMatrix=function(){return new i},Object.defineProperties(e.prototype,r),e}(Rd),ym=/\s+/,vm=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,bm=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var o={type:{configurable:!0}};return o.type.get=function(){return"cube"},e.prototype._parse=function(){He&&je.time("CubeParser._parse "+this.name);var t=this.volume,e=this.streamer.peekLines(6),i={},o=.529177210859*this.voxelSize;function n(t,r){var i=e[t].trim().split(ym)[r];return parseFloat(i)}i.atomCount=Math.abs(n(2,0)),i.originX=.529177210859*n(2,1),i.originY=.529177210859*n(2,2),i.originZ=.529177210859*n(2,3),i.NVX=n(3,0),i.NVY=n(4,0),i.NVZ=n(5,0),i.basisX=new r(n(3,1),n(3,2),n(3,3)).multiplyScalar(o),i.basisY=new r(n(4,1),n(4,2),n(4,3)).multiplyScalar(o),i.basisZ=new r(n(5,1),n(5,2),n(5,3)).multiplyScalar(o);var a=new Float32Array(i.NVX*i.NVY*i.NVZ),s=0,c=0,u=n(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(t){!function(t,e,r){for(var o=t;o=i.atomCount+6+u)for(var h=n.match(vm),l=0,p=h.length;l>8&255}i.xStart=n[0],i.yStart=n[1],i.zStart=n[2],i.xExtent=n[3],i.yExtent=n[4],i.zExtent=n[5],i.xRate=n[6],i.yRate=n[7],i.zRate=n[8];var l=1/n[17],p=l*this.voxelSize;i.xlen=n[9]*p,i.ylen=n[10]*p,i.zlen=n[11]*p,i.alpha=n[12]*l,i.beta=n[13]*l,i.gamma=n[14]*l,t=n[15]/100,e=n[16],i.gamma=n[14]*l}r.header=i,He&&je.log(i,t,e);for(var d=new Float32Array(i.xExtent*i.yExtent*i.zExtent),f=512,m=Math.ceil(i.xExtent/8),g=Math.ceil(i.yExtent/8),y=Math.ceil(i.zExtent/8),v=0;vo){var u=r[i].trim();if(""!==u)for(var h=u.split(_m),l=0,p=h.length;l=o&&(f-o)%p!=0&&d=0?r-1:r+e/3)},parseNormalIndex:function(t,e){var r=parseInt(t,10);return 3*(r>=0?r-1:r+e/3)},addVertex:function(t,e,r){var i=this.vertices,o=this.object.geometry.vertices;o.push(i[t+0]),o.push(i[t+1]),o.push(i[t+2]),o.push(i[e+0]),o.push(i[e+1]),o.push(i[e+2]),o.push(i[r+0]),o.push(i[r+1]),o.push(i[r+2])},addVertexLine:function(t){var e=this.vertices,r=this.object.geometry.vertices;r.push(e[t+0]),r.push(e[t+1]),r.push(e[t+2])},addNormal:function(t,e,r){var i=this.normals,o=this.object.geometry.normals;o.push(i[t+0]),o.push(i[t+1]),o.push(i[t+2]),o.push(i[e+0]),o.push(i[e+1]),o.push(i[e+2]),o.push(i[r+0]),o.push(i[r+1]),o.push(i[r+2])},addFace:function(t,e,r,i,o,n,a,s){var c,u=this.vertices.length,h=this.parseVertexIndex(t,u),l=this.parseVertexIndex(e,u),p=this.parseVertexIndex(r,u);if(void 0===i?this.addVertex(h,l,p):(c=this.parseVertexIndex(i,u),this.addVertex(h,l,c),this.addVertex(l,p,c)),void 0!==o){var d=this.normals.length;h=this.parseNormalIndex(o,d),l=o===n?h:this.parseNormalIndex(n,d),p=o===a?h:this.parseNormalIndex(a,d),void 0===i?this.addNormal(h,l,p):(c=this.parseNormalIndex(s,d),this.addNormal(h,l,c),this.addNormal(l,p,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,r=0,i=t.length;r0?b.setAttribute("normal",new M(new Float32Array(v.normals),3)):b.computeVertexNormals(),y.push(b)}}return y}};var Gm=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"obj"},e.prototype.getLoader=function(){return new Vm},Object.defineProperties(e.prototype,r),e}(jm);tr.add("obj",Gm);var Um=function(){this.propertyNameMapping={}};Um.prototype={constructor:Um,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),r="",i=0;i=i.elements[a].count&&(a++,s=0);var h=this.parseASCIIElement(i.elements[a].properties,u);this.handleElement(r,i.elements[a].name,h),s++}}return this.postProcess(r)},postProcess:function(t){if(t.useColor){for(var e=0;e/g,""),{declaration:e(),root:r()};function e(){if(o(/^<\?xml\s*/)){for(var t={attributes:{}};!n()&&!a("?>");){var e=i();if(!e)return t;t.attributes[e.name]=e.value}return o(/\?>\s*/),t}}function r(){var t=o(Qm);if(t){for(var e,s={name:t[1],attributes:{},children:[]};!(n()||a(">")||a("?>")||a("/>"));){var c=i();if(!c)return s;s.attributes[c.name]=c.value}if(o(/^\s*\/>\s*/))return s;for(o(/\??>\s*/),s.content=function(){var t=o(Jm);if(t)return t[1];return""}();e=r();)s.children.push(e);return o(/^<\/[\w-:.]+>\s*/),s}}function i(){var t,e=o(tg);if(e)return{name:e[1],value:(t=e[2],t.replace(Zm,""))}}function o(e){var r=t.match(e);if(r)return t=t.slice(r[0].length),r}function n(){return 0===t.length}function a(e){return 0===t.indexOf(e)}}var rg=function(t){function e(e,r){var i=r||{};t.call(this,e,i),this.useDomParser=ht(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},__objName:{configurable:!0},isXml:{configurable:!0}};return r.type.get=function(){return"xml"},r.__objName.get=function(){return"xml"},r.isXml.get=function(){return!0},e.prototype.__xmlParser=function(t){return eg(t)},e.prototype.__domParser=function(t){return(new window.DOMParser).parseFromString(t,"text/xml")},e.prototype._parse=function(){He&&je.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),He&&je.timeEnd("XmlParser._parse "+this.name)},Object.defineProperties(e.prototype,r),e}(Rd);function ig(t,e){var r=t.getNamedItem(e);return null!==r?r.value:""}function og(t,e,r){void 0===r&&(r=!1);var i=ig(t,"icode").trim(),o=ig(t,"chain").trim(),n=ig(t,"altcode"),a=ig(t,"resnum");return i&&(a+="^"+i),o&&(a+=":"+o),e&&(a+="."+e),r&&n.trim()&&(a+="%"+n),a+="/"+(parseInt(ig(t,"model"))-1)}function ng(t){var e=ig(t,"chain").trim(),r="["+ig(t,"rescode")+"]"+ig(t,"resnum");return e&&(r+=":"+e),r}function ag(t,e,r){void 0===t[e]?t[e]=r:t[e]|=r}function sg(t,e){return null!==t&&t.value===e}function cg(t,e,r){for(var i=0,o=e.getElementsByTagName("clash"),n=0,a=o.length;n0&&(i+=1),e.getElementsByTagName("bond-outlier").length>0&&(i+=1),e.getElementsByTagName("plane-outlier").length>0&&(i+=1),sg(r.getNamedItem("rota"),"OUTLIER")&&(i+=1),sg(r.getNamedItem("rama"),"OUTLIER")&&(i+=1),sg(r.getNamedItem("RNApucker"),"outlier")&&(i+=1),i}tr.add("xml",rg);var ug=function(t,e){this.name=t,this.path=e,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"},hg={type:{configurable:!0}};hg.type.get=function(){return"validation"},ug.prototype.fromXml=function(t){He&&je.time("Validation.fromXml");var e=this.rsrzDict,r=this.rsccDict,i=this.rciDict,o=this.clashDict,n=this.clashArray,a=this.geoDict,s=this.geoAtomDict,c=this.atomDict,u=t.getElementsByTagName("Entry");if(1===u.length){var h=u[0].getElementsByTagName("chemical_shift_list");if(1===h.length)for(var l=h[0].getElementsByTagName("random_coil_index"),p=0,d=l.length;p0&&(a[R]=$)}else{var L=E.getElementsByTagName("clash"),N=E.getElementsByTagName("mog-bond-outlier"),z=E.getElementsByTagName("mog-angle-outlier");if(N.length>0||z.length>0||L.length>0){var j={};s[R]=j;for(var V=0,G=L.length;V>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{n=n+(o=o+e[i++]|0)|0}while(--a);o%=65521,n%=65521}return o|n<<16|0}tr.add("validation",lg);var mg=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();function gg(t,e,r,i){var o=mg,n=i+r;t^=-1;for(var a=i;a>>8^o[255&(t^e[a])];return-1^t}function yg(t,e){var r,i,o,n,a,s,c,u,h,l,p,d,f,m,g,y,v,b,x,_,w,A,S,C,P;r=t.state,i=t.next_in,C=t.input,o=i+(t.avail_in-5),n=t.next_out,P=t.output,a=n-(e-t.avail_out),s=n+(t.avail_out-257),c=r.dmax,u=r.wsize,h=r.whave,l=r.wnext,p=r.window,d=r.hold,f=r.bits,m=r.lencode,g=r.distcode,y=(1<>>=x=b>>>24,f-=x,0===(x=b>>>16&255))P[n++]=65535&b;else{if(!(16&x)){if(0==(64&x)){b=m[(65535&b)+(d&(1<>>=x,f-=x),f<15&&(d+=C[i++]<>>=x=b>>>24,f-=x,!(16&(x=b>>>16&255))){if(0==(64&x)){b=g[(65535&b)+(d&(1<c){t.msg="invalid distance too far back",r.mode=30;break t}if(d>>>=x,f-=x,w>(x=n-a)){if((x=w-x)>h&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(A=0,S=p,0===l){if(A+=u-x,x<_){_-=x;do{P[n++]=p[A++]}while(--x);A=n-w,S=P}}else if(l2;)P[n++]=S[A++],P[n++]=S[A++],P[n++]=S[A++],_-=3;_&&(P[n++]=S[A++],_>1&&(P[n++]=S[A++]))}else{A=n-w;do{P[n++]=P[A++],P[n++]=P[A++],P[n++]=P[A++],_-=3}while(_>2);_&&(P[n++]=P[A++],_>1&&(P[n++]=P[A++]))}break}}break}}while(i>3,d&=(1<<(f-=_<<3))-1,t.next_in=i,t.next_out=n,t.avail_in=i=1&&0===M[_];_--);if(w>_&&(w=_),0===_)return o[n++]=20971520,o[n++]=20971520,s.bits=1,0;for(x=1;x<_&&0===M[x];x++);for(w0&&(0===t||1!==_))return-1;for(T[1]=0,v=1;v<15;v++)T[v+1]=T[v]+M[v];for(b=0;b852||2===t&&P>592)return 1;for(;;){f=v-S,a[b]d?(m=B[D+a[b]],g=O[k+a[b]]):(m=96,g=0),c=1<>S)+(u-=c)]=f<<24|m<<16|g|0}while(0!==u);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,b++,0==--M[v]){if(v===_)break;v=e[r+a[b]]}if(v>w&&(I&l)!==h){for(0===S&&(S=w),p+=x,C=1<<(A=v-S);A+S<_&&!((C-=M[A+S])<=0);)A++,C<<=1;if(P+=1<852||2===t&&P>592)return 1;o[h=I&l]=w<<24|A<<16|p-n|0}}return 0!==I&&(o[p+I]=v-S<<24|64<<16|0),s.bits=w,0}function Ag(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function Sg(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Cg(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,0):-2}(t)):-2}function Pg(t,e){var r,i;return t?(i=new Sg,t.state=i,i.window=null,r=function(t,e){var r,i;return t&&t.state?(i=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?-2:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,Cg(t))):-2}(t,e),0!==r&&(t.state=null),r):-2}var Ig,Og,kg=!0;function Mg(t){if(kg){var e;for(Ig=new Int32Array(512),Og=new Int32Array(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(wg(1,t.lens,0,288,Ig,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;wg(2,t.lens,0,32,Og,0,t.work,{bits:5}),kg=!1}t.lencode=Ig,t.lenbits=9,t.distcode=Og,t.distbits=5}function Tg(t,e,r,i){var o,n=t.state;return null===n.window&&(n.wsize=1<=n.wsize?(dg(n.window,e,r-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((o=n.wsize-n.wnext)>i&&(o=i),dg(n.window,e,r-i,o,n.wnext),(i-=o)?(dg(n.window,e,r-i,i,0),n.wnext=i,n.whave=n.wsize):(n.wnext+=o,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,r.check=gg(r.check,I,2,0),u=0,h=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){t.msg="unknown compression method",r.mode=30;break}if(h-=4,w=8+(15&(u>>>=4)),0===r.wbits)r.wbits=w;else if(w>r.wbits){t.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(I[0]=255&u,I[1]=u>>>8&255,r.check=gg(r.check,I,2,0)),u=0,h=0,r.mode=3;case 3:for(;h<32;){if(0===s)break t;s--,u+=i[n++]<>>8&255,I[2]=u>>>16&255,I[3]=u>>>24&255,r.check=gg(r.check,I,4,0)),u=0,h=0,r.mode=4;case 4:for(;h<16;){if(0===s)break t;s--,u+=i[n++]<>8),512&r.flags&&(I[0]=255&u,I[1]=u>>>8&255,r.check=gg(r.check,I,2,0)),u=0,h=0,r.mode=5;case 5:if(1024&r.flags){for(;h<16;){if(0===s)break t;s--,u+=i[n++]<>>8&255,r.check=gg(r.check,I,2,0)),u=0,h=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>s&&(d=s),d&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),dg(r.head.extra,i,n,d,w)),512&r.flags&&(r.check=gg(r.check,i,d,n)),s-=d,n+=d,r.length-=d),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break t;d=0;do{w=i[n+d++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w))}while(w&&d>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=12;break;case 10:for(;h<32;){if(0===s)break t;s--,u+=i[n++]<>>=7&h,h-=7&h,r.mode=27;break}for(;h<3;){if(0===s)break t;s--,u+=i[n++]<>>=1)){case 0:r.mode=14;break;case 1:if(Mg(r),r.mode=20,6===e){u>>>=2,h-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=30}u>>>=2,h-=2;break;case 14:for(u>>>=7&h,h-=7&h;h<32;){if(0===s)break t;s--,u+=i[n++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,u=0,h=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(d=r.length){if(d>s&&(d=s),d>c&&(d=c),0===d)break t;dg(o,i,n,d,a),s-=d,n+=d,c-=d,a+=d,r.length-=d;break}r.mode=12;break;case 17:for(;h<14;){if(0===s)break t;s--,u+=i[n++]<>>=5,h-=5,r.ndist=1+(31&u),u>>>=5,h-=5,r.ncode=4+(15&u),u>>>=4,h-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,h-=3}for(;r.have<19;)r.lens[O[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},A=wg(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,A){t.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,v=65535&P,!((g=P>>>24)<=h);){if(0===s)break t;s--,u+=i[n++]<>>=g,h-=g,r.lens[r.have++]=v;else{if(16===v){for(C=g+2;h>>=g,h-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=30;break}w=r.lens[r.have-1],d=3+(3&u),u>>>=2,h-=2}else if(17===v){for(C=g+3;h>>=g)),u>>>=3,h-=3}else{for(C=g+7;h>>=g)),u>>>=7,h-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=w}}if(30===r.mode)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},A=wg(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,A){t.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},A=wg(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,A){t.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(s>=6&&c>=258){t.next_out=a,t.avail_out=c,t.next_in=n,t.avail_in=s,r.hold=u,r.bits=h,yg(t,p),a=t.next_out,o=t.output,c=t.avail_out,n=t.next_in,i=t.input,s=t.avail_in,u=r.hold,h=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;y=(P=r.lencode[u&(1<>>16&255,v=65535&P,!((g=P>>>24)<=h);){if(0===s)break t;s--,u+=i[n++]<>b)])>>>16&255,v=65535&P,!(b+(g=P>>>24)<=h);){if(0===s)break t;s--,u+=i[n++]<>>=b,h-=b,r.back+=b}if(u>>>=g,h-=g,r.back+=g,r.length=v,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=12;break}if(64&y){t.msg="invalid literal/length code",r.mode=30;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(C=r.extra;h>>=r.extra,h-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;y=(P=r.distcode[u&(1<>>16&255,v=65535&P,!((g=P>>>24)<=h);){if(0===s)break t;s--,u+=i[n++]<>b)])>>>16&255,v=65535&P,!(b+(g=P>>>24)<=h);){if(0===s)break t;s--,u+=i[n++]<>>=b,h-=b,r.back+=b}if(u>>>=g,h-=g,r.back+=g,64&y){t.msg="invalid distance code",r.mode=30;break}r.offset=v,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(C=r.extra;h>>=r.extra,h-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===c)break t;if(d=p-c,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=30;break}d>r.wnext?(d-=r.wnext,f=r.wsize-d):f=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=o,f=a-r.offset,d=r.length;d>c&&(d=c),c-=d,r.length-=d;do{o[a++]=m[f++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===c)break t;o[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;h<32;){if(0===s)break t;s--,u|=i[n++]<=252?6:$g>=248?5:$g>=240?4:$g>=224?3:$g>=192?2:1;function Lg(t){var e,r,i,o,n,a=t.length,s=0;for(o=0;o>>6,e[n++]=128|63&r):r<65536?(e[n++]=224|r>>>12,e[n++]=128|r>>>6&63,e[n++]=128|63&r):(e[n++]=240|r>>>18,e[n++]=128|r>>>12&63,e[n++]=128|r>>>6&63,e[n++]=128|63&r);return e}function Ng(t,e){var r,i,o,n,a=e||t.length,s=new Array(2*a);for(i=0,r=0;r4)s[i++]=65533,r+=n-1;else{for(o&=2===n?31:3===n?15:7;n>1&&r1?s[i++]=65533:o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|1023&o)}return function(t,e){if(e<65537&&(t.subarray&&Fg||!t.subarray&&Eg))return String.fromCharCode.apply(null,pg(t,e));for(var r="",i=0;it.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+Rg[t[r]]>e?r:e}Rg[254]=Rg[254]=1;var jg={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Vg(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Gg(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Ug=Object.prototype.toString;function Hg(t){if(!(this instanceof Hg))return new Hg(t);this.options=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i])}}return t}({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Vg,this.strm.avail_out=0;var r,i,o,n=Pg(this.strm,e.windowBits);if(0!==n)throw new Error(jg[n]);this.header=new Gg,r=this.strm,i=this.header,r&&r.state&&(0==(2&(o=r.state).wrap)||(o.head=i,i.done=!1))}Hg.prototype.push=function(t,e){var r,i,o,n,a,s,c=this.strm,u=this.options.chunkSize,h=this.options.dictionary,l=!1;if(this.ended)return!1;i=e===~~e?e:!0===e?4:0,"string"==typeof t?c.input=function(t){for(var e=new Uint8Array(t.length),r=0,i=e.length;r0||0===c.avail_out)&&1!==r);return 1===r&&(i=4),4===i?(r=function(t){if(!t||!t.state)return-2;var e=t.state;return e.window&&(e.window=null),t.state=null,0}(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==i||(this.onEnd(0),c.avail_out=0,!0)},Hg.prototype.onData=function(t){this.chunks.push(t)},Hg.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,r,i,o,n,a;for(i=0,e=0,r=t.length;ethis.maxDepth&&(this.maxDepth=t);const s=r-i;if(0===s)return-1;const n=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===s)return o[n]=i,o[n+1]=-1,o[n+2]=-1,o[n+3]=e,n;const a=this.indices,c=this.points,l=i+Math.floor(s/2),h=t%3;let d,u,m,p,f,g=i,y=r-1;for(;y>g;){for(m=g+y>>1,p=c[3*a[m]+h],u=a[m],a[m]=a[y],a[y]=u,f=g,d=g;d-t[1])),s=this.nodes,n=this.points,o=this.indices,a=c=>{let l,h;const d=this.getNodeDepth(c)%3,u=3*o[s[c]],m=[n[u+0],n[u+1],n[u+2]],p=this.metric(t,m);function f(t,i){r.push([t,i]),r.size()>e&&r.pop()}const g=s[c+1],y=s[c+2];if(-1===y&&-1===g)return void((r.size()n[3*o[s[t]]+r])throw new Error("left child is > parent!");i+=this.verify(a,e+1)}if(-1!==c){if(n[3*o[s[c]]+r]0}isBackbone(){const t=this.residueType.backboneIndexList;return t.length>0&&t.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const t=this.residueType.moleculeType;return 3===t||4===t||5===t}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const t=this.residueType.backboneType;return 4===t||5===t||6===t}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const t=this.residueType.moleculeType;return 4===t||5===t}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return Hs.includes(this.sstruc)}isSheet(){return Ws.includes(this.sstruc)}isTurn(){return qs.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let t=!1;return 1!==this.number||(t=!this.hasBondToElement(6)),t}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(t){const e=this.atomStore,i=t.atomStore,r=this.index,s=t.index,n=e.x[r]-i.x[s],o=e.y[r]-i.y[s],a=e.z[r]-i.z[s],c=n*n+o*o+a*a;return Math.sqrt(c)}connectedTo(t){const e=this.atomStore,i=t.atomStore,r=this.index,s=t.index;if(e.altloc&&i.altloc){const t=e.altloc[r],n=i.altloc[s];if(0!==t&&0!==n&&32!==t&&32!==n&&t!==n)return!1}const n=e.x[r]-i.x[s],o=e.y[r]-i.y[s],a=e.z[r]-i.z[s],c=n*n+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+t.covalent,h=l+.3,d=l-.5;return cd*d}positionFromArray(t,e=0){return this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this}positionToArray(t=[],e=0){const i=this.index,r=this.atomStore;return t[e+0]=r.x[i],t[e+1]=r.y[i],t[e+2]=r.z[i],t}positionToVector3(t){return void 0===t&&(t=new e),t.x=this.x,t.y=this.y,t.z=this.z,t}positionFromVector3(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}positionAdd(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}positionSub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}getResidueBonds(t=!1){const e=this.residueAtomOffset,i=this.index-this.residueAtomOffset,r=this.residueType.getBonds(),s=r.atomIndices1,n=r.atomIndices2;let o,a,c,l;for(t||(l=[]),o=s.indexOf(i);-1!==o;){if(c=n[o]+e,!l)return c;l.push(c),o=s.indexOf(i,o+1)}for(a=n.indexOf(i);-1!==a;){if(c=s[a]+e,!l)return c;l.push(c),a=n.indexOf(i,a+1)}return l}qualifiedName(t=!1){var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chainname&&(e+=":"+this.chainname),this.atomname&&(e+="."+this.atomname),this.altloc&&(e+="%"+this.altloc),this.structure.modelStore.count>1&&(e+="/"+this.modelIndex),e}clone(){return new Ma(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function Ta(t,e){const i=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return i*i+r*r+s*s}function Ba(t,e){return Math.sqrt(Ta(t,e))}const Da=new Float32Array(3);class $a{constructor(t,e=!1){De&&Me.time("Kdtree build");const i=e?Ta:Ba,r=new Float32Array(3*t.atomCount),s=new Uint32Array(t.atomCount);let n=0;t.eachAtom((function(t){r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z,s[n/3]=t.index,n+=3})),this.atomIndices=s,this.points=r,this.kdtree=new ka(r,i),De&&Me.timeEnd("Kdtree build")}nearest(t,i,r){t instanceof e?t.toArray(Da):t instanceof Ma&&t.positionToArray(Da);const s=this.kdtree.nearest(Da,i,r),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,c=[];for(let t=0,e=s.length;t":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Ra={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$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+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Ea=/^[1-9]$/;function Fa(t){let e="";return t.length>0&&(e=":"+gt(t).join(" OR :")),new pe(e)}class La{constructor(t=""){this.name=t,this.partList=[]}get type(){return"Assembly"}addPart(t,e){const i=new Na(t,e);return this.partList.push(i),i}getAtomCount(t){return this.partList.reduce(((e,i)=>e+i.getAtomCount(t)),0)}getResidueCount(t){return this.partList.reduce(((e,i)=>e+i.getResidueCount(t)),0)}getInstanceCount(){let t=0;return this.partList.forEach((function(e){t+=e.matrixList.length})),t}isIdentity(t){if(1!==this.partList.length)return!1;const e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new i).equals(e.matrixList[0]))return!1;let r=[];return t.eachChain((function(t){r.push(t.chainname)})),r=gt(r),e.chainList.length===r.length}getBoundingBox(t){const e=new a;return this.partList.forEach((function(i){const r=i.getBoundingBox(t);e.expandByPoint(r.min),e.expandByPoint(r.max)})),e}getCenter(t){return this.getBoundingBox(t).getCenter(new e)}getSelection(){let t=[];return this.partList.forEach((function(e){t=t.concat(e.chainList)})),Fa(t)}}class Na{constructor(t=[],e=[]){this.matrixList=t,this.chainList=e}get type(){return"AssemblyPart"}_getCount(t,e){let i=0;return t.eachChain((t=>{(0===this.chainList.length||this.chainList.includes(t.chainname))&&(i+=t[e])})),this.matrixList.length*i}getAtomCount(t){return this._getCount(t,"atomCount")}getResidueCount(t){return this._getCount(t,"residueCount")}getBoundingBox(t){const e=new a,i=new a,r=this.getSelection(),s=t.getBoundingBox(r);return this.matrixList.forEach((function(t){i.copy(s).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)})),e}getSelection(){return Fa(this.chainList)}getView(t){const e=this.getSelection();return e?t.getView(e):t}getInstanceList(){const t=[];for(let e=0,i=this.matrixList.length;e0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=s,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=t,this.currentChainid=i,this.currentResname=r,this.currentResno=s,this.currentInscode=a,this.currentHetero=n}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function Va(t,e){if(!e)return;De&&Me.time("assignSecondaryStructure");const i=[];t.eachModel((function(t){t.eachChain((function(t){i.push(t.chainname)}))}));const r=i.slice().sort(),s=[];r.forEach((function(t){s.push(i.indexOf(t))}));const n=e.helices.filter((function(t){return pt(r,t[0])>=0}));n.sort((function(t,e){const i=t[0],n=e[0],o=t[1],a=e[1];if(i===n)return o===a?0:o=0}));a.sort((function(t,e){const i=t[0],n=e[0];if(i===n)return 0;const o=pt(r,i),a=pt(r,n);return s[o]=t.residueCount)continue;o.index=n+s,a.index=n+s+e,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[e-2])>r)return!1}return!0},i=function(e,i){return t(e,i,[5.45,5.18,6.37],2.1)},r=function(e,i){return t(e,i,[6.1,10.4,13],1.42)};return function(t){De&&Me.time("calculateSecondaryStructure"),t.eachPolymer((function(t){if(t.residueCount<4)return;if(t.isCg())!function(t){const i=t.residueStore,r=t.residueIndexStart,s=new Pa(t).position,n=new e,o=new e;for(let e=0,a=t.residueCount;e1&&s.bending[e]<20&&(i.sstruc[r+e]="h".charCodeAt(0),i.sstruc[r+e+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;!function(t){const e=t.residueStore,s=t.residueIndexStart;for(let n=0,o=t.residueCount;n=e;)i=Math.floor(i/e),s+=Ua[i%e],r+=1;return r>=5&&Me.warn("chainname overflow"),s}function Ha(t,e=!1){De&&Me.time("calculateChainnames");let i=!0;if(t.eachChain((function(t){t.chainname&&(i=!1)})),i){const i=t.modelStore,r=t.chainStore,s=t.residueStore,n=function(t,e,n,o){const a=r.count;for(let t=0;t500)return void Me.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());const s=t.getBonds(),l=s.atomIndices1,h=s.atomIndices2,d=s.bondOrders,u=l.length;for(let e=0;e{u.forEach((i=>{e.push(t.clone().multiply(i))}))})),h.addPart(e)}else h.addPart(d);const m=new e,p=new La("SUPERCELL"),f=Array.prototype.concat.call(l(m.set(1,0,0)),l(m.set(0,1,0)),l(m.set(0,0,1)),l(m.set(-1,0,0)),l(m.set(0,-1,0)),l(m.set(0,0,-1)),l(m.set(1,1,0)),l(m.set(1,0,1)),l(m.set(0,1,1)),l(m.set(-1,-1,0)),l(m.set(-1,0,-1)),l(m.set(0,-1,-1)),l(m.set(1,-1,-1)),l(m.set(1,1,-1)),l(m.set(1,-1,1)),l(m.set(-1,1,1)),l(m.set(-1,-1,1)),l(m.set(-1,1,-1)),l(m.set(0,1,-1)),l(m.set(0,-1,1)),l(m.set(1,0,-1)),l(m.set(-1,0,1)),l(m.set(1,-1,0)),l(m.set(-1,1,0)),l(),l(m.set(1,1,1)),l(m.set(-1,-1,-1)));if(t.biomolDict.NCS){const t=[];f.forEach((function(e){u.forEach((function(i){t.push(e.clone().multiply(i))}))})),p.addPart(t)}else p.addPart(f);t.biomolDict.UNITCELL=h,t.biomolDict.SUPERCELL=p,De&&Me.timeEnd("buildUnitcellAssembly")}const Qa=["H","C","O","N","S","P"],Ja=["NA","CL","FE"];function tc(t){let e=t.toUpperCase(),i=0,r=0;for(let t=0;t0)break;++i}else r=t+1;(i>0||r=3&&-1!==Qa.indexOf(e[0])?e[0]:""}function ec(t){const e=t.bondHash,i=e.countArray,r=e.offsetArray,s=e.indexArray,n=t.getBondProxy();t.eachResidue((function(t){const e=t.residueType;if(void 0!==e.bonds)return;var o=t.atomOffset,a=[],c=[],l=[],h={};const d=o+t.atomCount;t.eachAtom((function(t){const e=t.index,u=r[e];for(let t=0,r=i[e];t=d)continue;let i=n.atomIndex2;if(i=d)continue;if(e>i){const t=i;i=e,e=t}const r=e+"|"+i;void 0===h[r]&&(h[r]=!0,a.push(e-o),c.push(i-o),l.push(n.bondOrder))}})),e.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}function ic(t,...e){De&&Me.time("concatStructures");const i=new Cc(t,""),r=new za(i),s=i.atomStore,n=i.atomMap;s.addField("formalCharge",1,"int8"),s.addField("partialCharge",1,"float32");const o={};let a=0,c=0,l=0;e.forEach((t=>{t.eachAtom((t=>{s.growIfFull(),s.atomTypeId[a]=n.add(t.atomname,t.element),s.x[a]=t.x,s.y[a]=t.y,s.z[a]=t.z,s.serial[a]=t.serial,s.formalCharge[a]=t.formalCharge,s.partialCharge[a]=t.partialCharge,s.altloc[a]=t.altloc,s.occupancy[a]=t.occupancy,s.bfactor[a]=t.bfactor,r.addAtom(t.modelIndex+l,t.chainname,t.chainid,t.resname,t.resno,1===t.hetero,t.sstruc,t.inscode),o[t.index+c]=a,a+=1})),c+=t.atomStore.count,l+=t.modelStore.count}));const h=i.bondStore,d=i.getAtomProxy(),u=i.getAtomProxy();return c=0,e.forEach((t=>{t.eachBond((t=>{d.index=o[t.atomIndex1+c],u.index=o[t.atomIndex2+c],h.addBond(d,u,t.bondOrder)})),c+=t.atomStore.count})),r.finalize(),Ka(i,!0),Ya(i,!0),i.finalizeAtoms(),i.finalizeBonds(),ec(i),De&&Me.timeEnd("concatStructures"),i}const rc=[3,11,19,37,55,87],sc=[4,12,20,38,56,88],nc=[6,15,16,34],oc=[1,7,8,9,17,35,53],ac=[2,10,18,36,54,86],cc=[13,30,31,48,49,50,80,81,82,83,84,85,112],lc=[5,14,32,33,51,52,85],hc=[9,17,35,53,85];class dc{constructor(t,e,i){this.structure=t,this.atomname=e,i=i||tc(e),this.element=i,this.number=Xs[i]||0,this.vdw=Ys[this.number]||2,this.covalent=Ks[this.number]||1.6}getDefaultValence(){const t=Zs[this.number];return t?t[0]:-1}getValenceList(){return Zs[this.number]||[]}getOuterShellElectronCount(){return Qs[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return lc.includes(this.number)}isHalogen(){return hc.includes(this.number)}isDiatomicNonmetal(){return oc.includes(this.number)}isPolyatomicNonmetal(){return nc.includes(this.number)}isAlkaliMetal(){return rc.includes(this.number)}isAlkalineEarthMetal(){return sc.includes(this.number)}isNobleGas(){return ac.includes(this.number)}isTransitionMetal(){const t=this.number;return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108}isPostTransitionMetal(){return cc.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class uc{constructor(t){this.structure=t,this.dict={},this.list=[],this.structure=t}add(t,e){const i=function(t,e){return t+"|"+e}(t=t.toUpperCase(),e=e?e.toUpperCase():tc(t));let r=this.dict[i];if(void 0===r){const s=new dc(this.structure,t,e);r=this.list.length,this.dict[i]=r,this.list.push(s)}return r}get(t){return this.list[t]}}class mc{constructor(t,e,i,r,s,n){this.structure=t,this.bondReferenceAtomIndices=[],this.resname=e,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=s,this.bonds=n,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=mn[this.backboneType],a=mn[this.backboneStartType],c=mn[this.backboneEndType],l=this.getAtomIndexByName(o.trace);this.traceAtomIndex=st(l,-1);const h=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=st(h,-1);const d=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=st(d,-1);const u=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=st(u,-1);const m=this.getAtomIndexByName(c.backboneEnd);let p;this.backboneEndAtomIndex=st(m,-1),p=on.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=st(p,-1)}getBackboneIndexList(){const t=[];let e;switch(this.moleculeType){case 3:e=dn;break;case 4:case 5:e=un;break;default:return t}const i=this.structure.atomMap,r=this.atomTypeIdList;for(let s=0,n=this.atomCount;s500)De&&Me.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(s>50){const e=new $a(t,!0),s=t.isCg()?1.2:2.3;for(let t=n;t=0||yc(t,e);this.rings={atomRings:t.atomRings,rings:t.rings}}isAromatic(t){return this.aromaticAtoms=this.getAromatic(t),1===this.aromaticAtoms[t.index-t.residueAtomOffset]}calculateAromatic(t){const e=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,r=i.map((e=>function(t){if(t.some((t=>!pc.includes(t.number))))return!1;let e=0;const i=new ho(3,t.length),r=i.data;t.forEach((t=>{r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}));return new ya(i).vecC.length()this.structure.getAtomProxy(e+t.atomOffset)))))),s=this.aromaticRings=[];i.forEach(((t,i)=>{r[i]&&(s.push(t),t.forEach((t=>e[t]=1)))}))}assignBondReferenceAtomIndices(){const t=this.getBondGraph(),e=this.getRings(),i=e.atomRings,r=e.rings,s=this.bonds,n=s.atomIndices1,o=s.atomIndices2,a=s.bondOrders,c=this.bondReferenceAtomIndices,l=s.atomIndices1.length;c.length=0;for(let e=0;e1)for(let i=0;i1)for(let i=0;i=0;t--)p[f++]=o[t];const g=t.rings.length;for(let e=0;e0?n[c]!==e&&n[e]!==c&&gc(t,e,c):(r[c]=1,s[a++]=c,n[c]=e)}}}const bc=4;class xc{constructor(t){this.structure=t,this.dict={},this.list=[]}add(t,e,i,r="",s){const n=function(t,e,i,r=""){return t+"|"+e.join(",")+"|"+(i?1:0)+"|"+r}(t=t.toUpperCase(),e,i,r);let o=this.dict[n];if(void 0===o){const a=new mc(this.structure,t,e,i,r,s);o=this.list.length,this.dict[n]=o,this.list.push(a)}return o}get(t){return this.list[t]}}class vc{constructor(t,i=0){this.structure=t,this.index=i,this.bondStore=t.bondStore,this._v12=new e,this._v13=new e,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(t){this.bondStore.atomIndex1[this.index]=t}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(t){this.bondStore.atomIndex2[this.index]=t}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(t){this.bondStore.bondOrder[this.index]=t}getOtherAtomIndex(t){return t===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(t){return this.structure.getAtomProxy(this.getOtherAtomIndex(t.index))}getReferenceAtomIndex(){const t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex!==e.residueIndex)return;const i=t.index-t.residueAtomOffset,r=e.index-e.residueAtomOffset,s=t.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==s)return s+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}calculateShiftDir(t=new e){const i=this._ap1,r=this._ap2,s=this._ap3,n=this._v12,o=this._v13;i.index=this.atomIndex1,r.index=this.atomIndex2;const a=this.getReferenceAtomIndex();n.subVectors(i,r).normalize(),void 0!==a?(s.index=a,o.subVectors(i,s)):o.copy(i),o.normalize();let c=n.dot(o);return 1-Math.abs(c)<1e-5&&(o.set(1,0,0),c=n.dot(o),1-Math.abs(c)<1e-5&&(o.set(0,1,0),c=n.dot(o))),t.copy(o.sub(n.multiplyScalar(c))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new vc(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class wc{constructor(t,e=0){this.structure=t,this.index=e,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(t){this.residueStore.chainIndex[this.index]=t}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(t){this.residueStore.atomOffset[this.index]=t}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(t){this.residueStore.atomCount[this.index]=t}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(t){this.residueStore.resno[this.index]=t}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(t){this.residueStore.setSstruc(this.index,t)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(t){this.residueStore.setInscode(this.index,t)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.x[e];return t/this.atomCount}get y(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.y[e];return t/this.atomCount}get z(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.z[e];return t/this.atomCount}eachAtom(t,e){const i=this.atomCount,r=this.atomOffset,s=this.structure._ap,n=r+i;if(e&&e.atomOnlyTest){const i=e.atomOnlyTest;for(let e=r;e0)return this.entity.isPolymer();{const t=this.residueType.moleculeType;return 3===t||4===t||5===t}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return Hs.includes(this.sstruc)}isSheet(){return Ws.includes(this.sstruc)}isTurn(){return qs.includes(this.sstruc)&&this.isProtein()}getAtomType(t){return this.atomMap.get(this.atomStore.atomTypeId[t])}getResname1(){return en[this.resname.toUpperCase()]||"X"}getBackboneType(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(t){let e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e}hasAtomWithName(t){return this.residueType.hasAtomWithName(t)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const t=this.atomCount,e=this.atomOffset,i=new Array(t);for(let r=0;r=e){const e=st(t,this.structure.getResidueProxy());if(e.index=i,e.connectedTo(this))return e}else if(i===e-1){const i=this.chainStore.residueCount[this.chainIndex],r=st(t,this.structure.getResidueProxy());if(r.index=e+i-1,r.connectedTo(this))return r}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(t=!1){let e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chain&&(e+=":"+this.chainname),e+="/"+this.modelIndex,e}clone(){return new wc(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class Ac{constructor(t,e,i){this.structure=t,this.residueIndexStart=e,this.residueIndexEnd=i,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueCount=i-e+1;const r=this.structure.getResidueProxy(this.residueIndexStart),s=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();const n=s.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=s.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)}getAtomIndexByType(t,e){this.isCyclic?-1===t?t=this.residueCount-1:t===this.residueCount&&(t=0):(-1!==t||this.isPrevConnected||(t+=1),t!==this.residueCount||this.isNextNextConnected||(t-=1));const i=this.__residueProxy;let r;switch(i.index=this.residueIndexStart+t,e){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(e)}return r}eachAtom(t,e){this.eachResidue((function(i){i.eachAtom(t,e)}))}eachAtomN(t,e,i){const r=this.residueCount,s=new Array(t);for(let e=0;e1&&t(new Ac(n,i,l.index)),i=r)):(o!==Ns&&l.index-i>1&&t(new Ac(n,i,l.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneEndType&&t(new Ac(n,i,r))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new _c(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class Sc{constructor(t,e=0){this.structure=t,this.index=e,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(t){this.modelStore.chainOffset[this.index]=t}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(t){this.modelStore.chainCount[this.index]=t}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(t,e){this.eachChain((function(i){i.eachAtom(t,e)}),e)}eachResidue(t,e){this.eachChain((function(i){i.eachResidue(t,e)}),e)}eachPolymer(t,e){if(e&&e.chainOnlyTest){const i=e.chainOnlyTest;this.eachChain((function(r){i(r)&&r.eachPolymer(t,e)}))}else this.eachChain((function(i){i.eachPolymer(t,e)}))}eachChain(t,e){const i=this.chainCount,r=this.chainOffset,s=this.structure._cp,n=r+i;if(e&&e.test){const i=e.chainOnlyTest;if(i)for(let e=r;e{const i=3*e;a.index=t,l&&a.positionToArray(l,i),h&&n.atomColorToArray(a,h,i),d&&(d.array[e]=t),u&&(u[e]=s.atomRadius(a)),m&&(m[e]=t)})),o}getBondData(t){const i=Object.assign({},t);i.colorParams&&(i.colorParams.structure=this.getStructure());const r=i.what,s=st(i.bondSet,this.bondSet),n=st(i.multipleBond,"off"),o="off"!==n,a="offset"===n,c=st(i.bondScale,.4),l=st(i.bondSpacing,1);let h,d;const u={},m=this.getBondProxy();i.bondStore&&(m.bondStore=i.bondStore);const p=this.getAtomProxy(),f=this.getAtomProxy();let g;if(o){const t=m.bondStore.bondOrder;g=0,s.forEach((function(e){g+=t[e]}))}else g=s.getSize();r&&!r.position||(u.position1=new Float32Array(3*g),u.position2=new Float32Array(3*g)),r&&!r.color||!i.colorParams||(u.color=new Float32Array(3*g),u.color2=new Float32Array(3*g),d=Fe.getScheme(i.colorParams)),r&&!r.picking||(u.picking=new Zn(new Float32Array(g),this.getStructure(),i.bondStore)),(!r||r.radius||o&&r.position)&&(h=new pa(i.radiusParams)),r&&!r.radius||(u.radius=new Float32Array(g),i.radius2&&(u.radius2=new Float32Array(g)));const{position1:y,position2:b,color:x,color2:v,picking:w,radius:A,radius2:_}=u;let S,C,P,I,k,M,T=0;const B=new e,D=new e,$=new e;return s.forEach((t=>{if(C=3*T,m.index=t,p.index=m.atomIndex1,f.index=m.atomIndex2,I=m.bondOrder,y)if(o&&I>1){const t=h.atomRadius(p);M=t*c/(.5*I),m.calculateShiftDir($),a?(k=2*l*t,$.multiplyScalar(k),$.negate(),D.subVectors(f,p).multiplyScalar(Math.max(.1,k/1.88)),p.positionToArray(y,C),f.positionToArray(b,C),I>=2&&(B.addVectors(p,$).add(D).toArray(y,C+3),B.addVectors(f,$).sub(D).toArray(b,C+3),I>=3&&(B.subVectors(p,$).add(D).toArray(y,C+6),B.subVectors(f,$).sub(D).toArray(b,C+6)))):(k=(l-c)*t,$.multiplyScalar(k),2===I?(B.addVectors(p,$).toArray(y,C),B.subVectors(p,$).toArray(y,C+3),B.addVectors(f,$).toArray(b,C),B.subVectors(f,$).toArray(b,C+3)):3===I?(p.positionToArray(y,C),B.addVectors(p,$).toArray(y,C+3),B.subVectors(p,$).toArray(y,C+6),f.positionToArray(b,C),B.addVectors(f,$).toArray(b,C+3),B.subVectors(f,$).toArray(b,C+6)):(p.positionToArray(y,C),f.positionToArray(b,C)))}else p.positionToArray(y,C),f.positionToArray(b,C);if(x&&v&&(d.bondColorToArray(m,1,x,C),d.bondColorToArray(m,0,v,C),o&&I>1))for(S=1;S1))for(S=1;S1))for(M=A[T]*c/(a?1:.5*I),S=a?1:0;S1))for(M=_[T]*c/(a?1:.5*I),S=a?1:0;S{const e=t.x,a=t.y,l=t.z;en&&(n=e),a>o&&(o=a),l>c&&(c=l)}),t),e.min.set(i,r,s),e.max.set(n,o,c),De&&Me.timeEnd("getBoundingBox"),e}getPrincipalAxes(t){De&&Me.time("getPrincipalAxes");let e=0;const i=new ho(3,this.atomCount),r=i.data;return this.eachAtom((t=>{r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}),t),De&&Me.timeEnd("getPrincipalAxes"),new ya(i)}atomCenter(t){return t?this.getBoundingBox(t).getCenter(new e):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const t=this.atomStore;this._hasCoords=0!==Di(t.x)||0!==Bi(t.x)||0!==Di(t.y)||0!==Bi(t.y)||0!==Di(t.z)||0!==Bi(t.z)||t.count/this.modelStore.count==1}return this._hasCoords}getSequence(t){const e=[],i=this.getResidueProxy();return this.eachAtom((function(t){i.index=t.residueIndex,t.index===i.traceAtomIndex&&e.push(i.getResname1())}),t),e}getAtomIndices(t){if(t&&t.string){const e=[];return this.eachAtom((function(t){e.push(t.index)}),t),new Uint32Array(e)}{const t={what:{index:!0}};return this.getAtomData(t).index}}getChainnameCount(t){const e=new Set;return this.eachChain((function(t){t.residueCount&&e.add(t.chainname)}),t),e.size}updatePosition(t,e=!0){let i=0;this.eachAtom((function(e){e.positionFromArray(t,i),i+=3}),void 0),this._hasCoords=void 0,e&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new Ts(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const Pc=new a,Ic=[_s,xs,Ss,As,Cs,vs,bs,ws,Is,Ps,ks,Ms],kc={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class Mc{constructor(t="shape",e={}){this.boundingBox=new a,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=t,this.parameters=nt(e,kc),Ic.forEach((t=>{Object.keys(t.fields).forEach((e=>{this._primitiveData[t.getShapeKey(e)]=[]})),this._primitiveData[t.getShapeKey("name")]=[]}))}addBuffer(t){this.bufferList.push(t);const e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this}addMesh(t,e,i,r,s){let n;t=Ct(t),e=Ct(e),Array.isArray(i)&&(i=xt(i,t.length)),r&&(r=Ct(r)),n=void 0===r||0==r.length?{position:t,color:e,index:i}:{position:t,color:e,index:i,normal:r};const o=new io(this,Object.assign({serial:this.meshCount,name:s},n)),a=new Uo(Object.assign({picking:o},n));return this.bufferList.push(a),Pc.setFromArray(t),this.boundingBox.union(Pc),this.meshCount+=1,this}addSphere(t,e,i,r){return bs.objectToShape(this,{position:t,color:e,radius:i,name:r}),this}addEllipsoid(t,e,i,r,s,n){return Cs.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addTorus(t,e,i,r,s,n){return Ps.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addCylinder(t,e,i,r,s){return As.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addCone(t,e,i,r,s){return Ss.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addArrow(t,e,i,r,s){return _s.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addBox(t,e,i,r,s,n){return xs.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addOctahedron(t,e,i,r,s,n){return vs.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addTetrahedron(t,e,i,r,s,n){return ws.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addText(t,e,i,r){return Is.objectToShape(this,{position:t,color:e,size:i,text:r}),this}addPoint(t,e,i){return ks.objectToShape(this,{position:t,color:e,name:i}),this}addWideline(t,e,i,r,s){return this.parameters.linewidth=r,Ms.objectToShape(this,{position1:t,position2:e,color:i,name:s}),this}addLabel(t,e,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,i,r)}getBufferList(){const t=[];return Ic.forEach((e=>{this._primitiveData[e.getShapeKey("color")].length&&t.push(e.bufferFromShape(this,this.parameters))})),this.bufferList.concat(t)}dispose(){this.bufferList.forEach((function(t){t.dispose()})),this.bufferList.length=0,Ic.forEach((t=>{Object.keys(t.fields).forEach((e=>{this._primitiveData[t.getShapeKey(e)].length=0})),this._primitiveData[t.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new e)),this._center}get type(){return"Shape"}}class Tc extends zr{constructor(t,e,i){Array.isArray(t)||(t=[t]),super(t,e,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=t,this.init(i)}init(t){super.init(t),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t),t.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),t()}}const Bc=new i,Dc=new O;class $c extends Uo{constructor(t,e={},i){super(function(t,e){const i=e.attributes.position.array,r=e.index?e.index.array:void 0,s=t.position.length/3,n=i.length/3,o=s*n,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return r&&(h=xt(s*r.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:t.primitiveId||Ii(s,n),picking:t.picking}}(t,i),e),this.updateNormals=!1;const r=i.attributes.position.array,s=i.attributes.normal.array,n=i.index?i.index.array:void 0;this.geoPosition=r,this.geoNormal=s,this.geoIndex=n,this.positionCount=t.position.length/3,this.geoPositionCount=r.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(t),n){const t=this.geometry.getIndex();if(!t)return void Me.error("Index is null");this.meshIndex=t.array,this.makeIndex()}}setAttributes(t={},e=!1){const i=this.geometry.attributes;let r,s,n,o,a,c,l,h,d;const u=this.updateNormals;t.position&&(r=t.position,n=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(u||e)&&(o=this.geoNormal,d=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),t.color&&(s=t.color,h=this.meshColor,i.color.needsUpdate=!0);const m=this.positionCount,p=this.geoPositionCount;for(let t=0;t 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Fc extends Go{constructor(t,e,i={}){super(e,i),this.index=xt(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:t,value:null}}),this.setAttributes({primitiveId:Pi(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(t){const e={};for(const i in t){const r=t[i];e[i]={type:r.type,value:null}}super.addAttributes(e)}getAttributeIndex(t){return 3*t*this.mappingSize}setAttributes(t){t&&!t.position&&t.position1&&t.position2&&(t.position=Ai(t.position1,t.position2));const e=this.size,i=this.mappingSize,r=this.geometry.attributes;let s,n,o,a,c,l,h;for(const d in t)if("index"!==d&&"picking"!==d){n=t[d],s=r[d],o=s.itemSize,a=s.array;for(let t=0;t0&&this.parameters.alphaTest<=1&&(e.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),e}setUniforms(t){t&&void 0!==t.edgeBleach&&(this.makeTexture(),t.map=this.tex),super.setUniforms(t)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}je.add("point",Wc);class qc extends zr{constructor(t,e,i){super(t,e,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),t instanceof Eo?(this.surface=void 0,this.volume=new ba(t)):(this.surface=t,this.volume=void 0),this.init(i)}init(t){var e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),this.thresholdType=st(e.thresholdType,"sigma"),this.thresholdMin=st(e.thresholdMin,2),this.thresholdMax=st(e.thresholdMax,1/0),this.thresholdOut=st(e.thresholdOut,!1),this.dotType=st(e.dotType,"point"),this.radius=st(e.radius,.1),this.scale=st(e.scale,1),this.pointSize=st(e.pointSize,1),this.sizeAttenuation=st(e.sizeAttenuation,!0),this.sortParticles=st(e.sortParticles,!1),this.useTexture=st(e.useTexture,!1),this.alphaTest=st(e.alphaTest,.5),this.forceTransparent=st(e.forceTransparent,!1),this.edgeBleach=st(e.edgeBleach,0),super.init(e),this.build()}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t)})),this.setVisibility(this.visible),t()}create(){var t={};if(this.volume){var e,i,r=this.volume;"sigma"===this.thresholdType?(e=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,i=this.thresholdMax),r.setFilter(e,i,this.thresholdOut),Object.assign(t,{position:r.getDataPosition(),color:r.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:r.getDataSize(this.radius,this.scale),picking:r.getDataPicking()})}else{var s=this.surface;Object.assign(t,{position:s.getPosition(),color:s.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:s.getSize(this.radius,this.scale),picking:s.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Gc(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Wc(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(t={}){if(0===this.bufferList.length)return;const e={};t.color&&(this.volume?Object.assign(e,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(e,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?Object.assign(e,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(e,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(e)}setParameters(t,e={},i){return t&&void 0!==t.thresholdType&&this.volume instanceof Eo&&("value"===this.thresholdType&&"sigma"===t.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===t.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=t.thresholdType),t&&void 0!==t.radiusType&&("radius"===t.radiusType?this.radius=.1:this.radius=parseFloat(t.radiusType),e.radius=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),t&&void 0!==t.radius&&(e.radius=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),t&&void 0!==t.scale&&(e.scale=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),super.setParameters(t,e,i),this}}Ve.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),Ve.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const Xc=new Uint16Array([0,1,2,1,3,2]),Yc=new Float32Array([0,1,0,0,1,1,1,0]),Kc=Object.assign({filter:"nearest",forceTransparent:!0},zo),Zc=Object.assign({filter:{updateShader:!0,uniform:!0}},Vo);class Qc extends Go{constructor(e,i){super({position:e.position,index:Xc,picking:e.picking},i),this.parameterTypes=Zc,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:r,width:s,height:n}=e,o=new G(r,s,n);o.flipY=!0,this.tex=o;const a=r.length,c=new Uint8Array(a);for(let t=0;t>16&255,c[t+1]=e>>8&255,c[t+2]=255&e}const l=new G(c,s,n);l.flipY=!0,l.minFilter=x,l.magFilter=x,this.pickingTex=l,this.addUniforms({map:{value:o},pickingMap:{value:l},mapSize:{value:new t(s,n)}}),this.geometry.setAttribute("uv",new M(Yc,2))}get defaultParameters(){return Kc}getDefines(t){const e=super.getDefines(t),i=this.parameters.filter;return i.startsWith("cubic")&&(e.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?e.BSPLINE_FILTER=1:i.endsWith("catmulrom")?e.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(e.MITCHELL_FILTER=1)),e}updateTexture(){const t=this.tex,e=this.parameters.filter;e.startsWith("cubic")?(t.minFilter=x,t.magFilter=x):"linear"===e?(t.minFilter=A,t.magFilter=A):(t.minFilter=x,t.magFilter=x),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const t=this.material;t.uniforms.map.value=this.tex,t.blending=U,t.needsUpdate=!0;const e=this.wireframeMaterial;e.uniforms.map.value=this.tex,e.blending=U,e.needsUpdate=!0;const i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=U,i.needsUpdate=!0}setUniforms(t){t&&void 0!==t.filter&&(this.updateTexture(),t.map=this.tex),super.setUniforms(t)}}class Jc{constructor(t,e){const i=e||{};this.dimension=st(i.dimension,"x"),this.positionType=st(i.positionType,"percent"),this.position=st(i.position,30),this.thresholdType=st(i.thresholdType,"sigma"),this.thresholdMin=st(i.thresholdMin,-1/0),this.thresholdMax=st(i.thresholdMax,1/0),this.normalize=st(i.normalize,!1),this.volume=t}getPositionFromCoordinate(t){const i=this.dimension,r=this.volume,s=r.matrix,n=(new e).setFromMatrixPosition(s)[i],o=(new e).setFromMatrixScale(s)[i];let a;return a="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((t-n)/(a/100)+1)/o)}getData(t){t=t||{};const i=this.volume,r=i.data,s=i.matrix;let n;function o(t){return Math.round(t/100*(n-1))}function a(t,e,r,s){return 3*(r*i.ny*i.nx+e*i.nx+t)+s}n="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const c=new Float32Array(12),l=new e;let h,d,u,m,p,f=0,g=0,y=0,b=i.nx,x=i.ny,v=i.nz;function w(t,e,i,r){l.set(t,e,i).applyMatrix4(s).toArray(c,r)}"x"===this.dimension?(u=o(i.nx),m=i.ny-1,p=i.nz-1,h=i.nz,d=i.ny,f=u,b=f+1,w(u,0,0,0),w(u,m,0,3),w(u,0,p,6),w(u,m,p,9)):"y"===this.dimension?(u=i.nx-1,m=o(i.ny),p=i.nz-1,h=i.nz,d=i.nx,g=m,x=g+1,w(0,m,0,0),w(u,m,0,3),w(0,m,p,6),w(u,m,p,9)):"z"===this.dimension&&(u=i.nx-1,m=i.ny-1,p=o(i.nz),h=i.nx,d=i.ny,y=p,v=y+1,w(0,0,p,0),w(0,m,p,3),w(u,0,p,6),w(u,m,p,9));let A=0,_=0;const S=new Uint8Array(h*d*4),C=new Float32Array(h*d);let P,I;"sigma"===this.thresholdType?(P=i.getValueForSigma(this.thresholdMin),I=i.getValueForSigma(this.thresholdMax)):(P=this.thresholdMin,I=this.thresholdMax);const k=Object.assign({},t.colorParams,{volume:i});this.normalize&&(k.domain=[0,1]);const M=Fe.getScheme(k),T=new Float32Array(3),B=M.getScale();let D,$=0,O=0;if(this.normalize){$=1/0,D=-1/0;for(let t=g;tD&&(D=s)}O=D-$}for(let t=g;tP&&n{this.viewer.add(t)})),this.setVisibility(this.visible),t()}create(){const t=new Jc(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),e=new Qc(t.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(e)}}function el(t){Me.error(`makeRepresentation: representation type ${t} unknown`)}const il={name:"some element",status:""};class rl{constructor(t,e={}){this.stage=t,this.signals={statusChanged:new et,nameChanged:new et,disposed:new et},this.parameters=nt(e,this.defaultParameters),this.uuid=Bt()}get defaultParameters(){return il}get name(){return this.parameters.name}setStatus(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this}setName(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this}dispose(){this.signals.disposed.dispatch()}}const sl=Object.assign({visible:!0},il);class nl extends rl{constructor(t,e,i={},r){super(t,Object.assign({name:e.type},i)),this.parent=r,this.signals=Object.assign({visibilityChanged:new et,parametersChanged:new et},this.signals),this.setRepresentation(e)}get defaultParameters(){return sl}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(t){this._disposeRepresentation(),this.repr=t,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(t){return this.parameters.visible=t,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(t){return this.repr.update(t),this}build(t){return this.repr.build(t),this}setSelection(t){const e=this.repr;return e.setSelection&&e.setSelection(t),this}setParameters(t){return this.repr.setParameters(t),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(t){return this.repr.setColor(t),this}}const ol=new i,al=new e,cl={name:"",status:"",visible:!0};class ll{constructor(t,s,n={}){this.stage=t,this.object=s,this.signals={representationAdded:new et,representationRemoved:new et,visibilityChanged:new et,matrixChanged:new et,statusChanged:new et,nameChanged:new et,disposed:new et},this.reprList=[],this.annotationList=[],this.matrix=new i,this.position=new e,this.quaternion=new r,this.scale=new e(1,1,1),this.transform=new i,this.parameters=nt(n,this.defaultParameters),this.uuid=Bt(),this.viewer=t.viewer,this.controls=new ua(this)}get defaultParameters(){return cl}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(t){return Array.isArray(t)?this.position.fromArray(t):this.position.copy(t),this.updateMatrix(),this}setRotation(t){if(Array.isArray(t))if(3===t.length){const e=(new j).fromArray(t);this.quaternion.setFromEuler(e)}else this.quaternion.fromArray(t);else t instanceof j?this.quaternion.setFromEuler(t):this.quaternion.copy(t);return this.updateMatrix(),this}setScale(t){return this.scale.set(t,t,t),this.updateMatrix(),this}setTransform(t){return this.transform.copy(t),this.updateMatrix(),this}updateMatrix(){const t=this.getCenterUntransformed(al);this.matrix.makeTranslation(-t.x,-t.y,-t.z),ol.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(ol),ol.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(ol);const e=this.position;ol.makeTranslation(e.x+t.x,e.y+t.y,e.z+t.z),this.matrix.premultiply(ol),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((t=>{t.setParameters({matrix:this.matrix})}))}addAnnotation(t,e,i){const r=new ca(this,t,e,i);return this.annotationList.push(r),r}eachAnnotation(t){this.annotationList.slice().forEach(t)}removeAnnotation(t){const e=this.annotationList.indexOf(t);-1!==e&&(this.annotationList.splice(e,1),t.dispose())}removeAllAnnotations(){this.eachAnnotation((t=>t.dispose())),this.annotationList.length=0}_addRepresentation(t,e,i,r=!1){const s=i||{},n=this.stage.getParameters();s.matrix=this.matrix.clone(),s.quality=s.quality||n.quality,s.disableImpostor=st(s.disableImpostor,!n.impostor),s.useWorker=st(s.useWorker,n.workerDefault),s.visible=st(s.visible,!0);const o=Object.assign({},s,{visible:this.parameters.visible&&s.visible}),a=function(t,e,i,r){var s;if(De&&Me.time("makeRepresentation "+t),e instanceof Cc){if(!(s=Ne.get(t)))return void el(t)}else if(e instanceof Oo)if("surface"===t)s=Yo;else{if("dot"!==t)return void el(t);s=qc}else if(e instanceof Eo)if("surface"===t)s=Yo;else if("dot"===t)s=qc;else{if("slice"!==t)return void el(t);s=tl}else if(e instanceof Mc)s=Tc,e=e.getBufferList();else{if("buffer"!==t)return void Me.error("makeRepresentation: object "+e+" unknown");s=Tc}const n=new s(e,i,r);return De&&Me.timeEnd("makeRepresentation "+t),n}(t,e,this.viewer,o),c=new nl(this.stage,a,s,this);return r||(this.reprList.push(c),this.signals.representationAdded.dispatch(c)),c}addBufferRepresentation(t,e){return this._addRepresentation.call(this,"buffer",t,e)}hasRepresentation(t){return-1!==this.reprList.indexOf(t)}eachRepresentation(t){this.reprList.slice().forEach(t)}removeRepresentation(t){const e=this.reprList.indexOf(t);-1!==e&&(this.reprList.splice(e,1),t.dispose(),this.signals.representationRemoved.dispatch(t))}updateRepresentations(t){this.reprList.forEach((e=>e.update(t))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((t=>t.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(t){return this.parameters.visible=t,this.eachRepresentation((t=>t.updateVisibility())),this.eachAnnotation((t=>t.updateVisibility())),this.signals.visibilityChanged.dispatch(t),this}setStatus(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this}setName(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this}getBox(...t){return this.getBoxUntransformed(...t).clone().applyMatrix4(this.matrix)}getCenter(...t){return this.getCenterUntransformed(...t).clone().applyMatrix4(this.matrix)}getZoom(...t){return this.stage.getZoomForBox(this.getBox(...t))}getBoxUntransformed(...t){return new a}getCenterUntransformed(...t){return this.getBoxUntransformed().getCenter(new e)}autoView(t){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),st(t,0))}}class hl{constructor(t=[]){this.list=t;const e=t.length;for(let i=0;i0?this.list[0]:void 0}forEach(t){return this.list.forEach(t),this}dispose(){return this.forEach((t=>t.dispose()))}}class dl extends hl{setParameters(t){return this.forEach((e=>e.setParameters(t)))}setVisibility(t){return this.forEach((e=>e.setVisibility(t)))}setSelection(t){return this.forEach((e=>e.setSelection(t)))}setColor(t){return this.forEach((e=>e.setColor(t)))}update(t){return this.forEach((e=>e.update(t)))}build(t){return this.forEach((e=>e.build(t)))}dispose(t){return this.forEach((t=>t.dispose()))}}const ul=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},il);class ml extends rl{constructor(t,e,i={}){super(t,Object.assign({name:e.name},i)),this.trajectory=e,this.signals=Object.assign(this.signals,{frameChanged:new et,playerChanged:new et,countChanged:new et,parametersChanged:new et}),e.signals.frameChanged.add((t=>{this.signals.frameChanged.dispatch(t)})),e.signals.playerChanged.add((t=>{this.signals.playerChanged.dispatch(t)})),e.signals.countChanged.add((t=>{this.signals.countChanged.dispatch(t)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return ul}get type(){return"trajectory"}setFrame(t){this.trajectory.setFrame(t)}setParameters(t={}){this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)}dispose(){this.trajectory.dispose(),super.dispose()}}class pl{constructor(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class fl{constructor(t,e){let r,s;if(this.A=new ho(3,3),this.W=new ho(1,3),this.U=new ho(3,3),this.V=new ho(3,3),this.VH=new ho(3,3),this.R=new ho(3,3),this.tmp=new ho(3,3),this.c=new ho(3,3),t instanceof Cc)r=t.atomCount;else{if(!(t instanceof Float32Array))return;r=t.length/3}if(e instanceof Cc)s=e.atomCount;else{if(!(e instanceof Float32Array))return;s=e.length/3}const n=Math.min(r,s),o=new ho(3,n),a=new ho(3,n);this.coords1t=new ho(n,3),this.coords2t=new ho(n,3),this.transformationMatrix=new i,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,o,n,!1),this.prepCoords(e,a,n,!1),this._superpose(o,a)}_superpose(t,e){this.mean1=fo(t),this.mean2=fo(e),go(t,this.mean1),go(e,this.mean2),uo(this.coords1t,t),uo(this.coords2t,e),mo(this.A,this.coords2t,this.coords1t),wo(this.A,this.W,this.U,this.V),function(t,e){const i=t.data,r=e.data,s=i[4],n=i[8],o=i[5],a=i[7],c=i[0],l=c*s,h=c*o,d=i[3],u=i[1],m=d*u,p=i[2],f=d*p,g=i[6],y=g*u,b=g*p,x=1/(l*n-h*a-m*n+f*a+y*o-b*s);r[0]=(s*n-o*a)*x,r[1]=-(u*n-p*a)*x,r[2]=-(-u*o+p*s)*x,r[3]=-(d*n-o*g)*x,r[4]=(c*n-b)*x,r[5]=-(h-f)*x,r[6]=-(-d*a+s*g)*x,r[7]=-(c*a-y)*x,r[8]=(l-m)*x}(this.V,this.VH),po(this.R,this.U,this.VH),function(t){const e=t.data;return e[0]*e[4]*e[8]-e[0]*e[5]*e[7]-e[3]*e[1]*e[8]+e[3]*e[2]*e[7]+e[6]*e[1]*e[5]-e[6]*e[2]*e[4]}(this.R)<0&&(De&&Me.log("R not a right handed system"),po(this.tmp,this.c,this.VH),po(this.R,this.U,this.tmp));const i=new ho(4,4),r=new ho(4,4),s=new ho(4,4),n=new ho(4,4),o=new ho(4,4),a=new ho(4,4),c=this.R.data,l=this.mean1,h=this.mean2;n.data.set([1,0,0,-l[0],0,1,0,-l[1],0,0,1,-l[2],0,0,0,1]),o.data.set([c[0],c[1],c[2],0,c[3],c[4],c[5],0,c[6],c[7],c[8],0,0,0,0,1]),a.data.set([1,0,0,h[0],0,1,0,h[1],0,0,1,h[2],0,0,0,1]),uo(r,n),mo(i,o,r),uo(s,i),mo(r,a,s),uo(i,r),this.transformationMatrix.elements=i.data}prepCoords(t,e,i,r){let s=0;const n=e.data;let o=3,a=3*i;if(r&&(a=4*i,o=4),t instanceof Cc)t.eachAtom((function(t){s{t!==this&&this.pause()}),this);const i=st(t.frameCount,1);this.traj=t,this.parameters=nt(e,gl),this.parameters.end=Math.min(st(e.end,i-1),i-1),this.parameters.step=st(e.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,t.signals.countChanged.add((t=>{this.parameters.end=Math.min(st(this.parameters.end,t-1),t-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(t={}){ot(this.parameters,t),void 0!==t.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const t=this._currentTime-this._previousTime,e=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/e,r=this.traj;if(r&&r.frameCount&&!r.inProgress&&t>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),r.hasFrame(this._currentFrame)){this._currentStep+=1;const t=this._currentStep/(this.parameters.interpolateStep+1),[e,i,s,n]=this._currentFrame;r.setFrameInterpolated(e,i,s,n,t,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{const t=this._next();r.hasFrame(t)?(r.setFrame(t),this._previousTime=this._currentTime):r.loadFrame(t)}window.requestAnimationFrame(this._animate)}_next(){const t=this.parameters;let e;return e="forward"===this._direction?this.traj.currentFrame+t.step:this.traj.currentFrame-t.step,(e>t.end||e=t.end?i=t.start:"backward"===t.direction&&e<=t.start&&(i=t.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class bl{constructor(t,e,i={}){this.signals={countChanged:new et,frameChanged:new et,playerChanged:new et},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=st(i.deltaTime,0),this.timeOffset=st(i.timeOffset,0),this.centerPbc=st(i.centerPbc,!1),this.removePbc=st(i.removePbc,!1),this.removePeriodicity=st(i.removePeriodicity,!1),this.superpose=st(i.superpose,!1),this.name=t.replace(/^.*[\\/]/,""),this.trajPath=t,this.selection=new pe(st(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new yl(this))}_loadFrameCount(){}setStructure(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new pe("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(t){return this.selection.setString(t),this}_getIndices(t){let e=0;const i=t.test,r=[];return i&&this.structure.eachAtom((t=>{i(t)&&r.push(e),e+=1})),r}_makeSuperposeCoords(){const t=3*this.selectionIndices.length;this.coords1=new Float32Array(t),this.coords2=new Float32Array(t);const e=this.initialCoords,i=this.coords2;for(let r=0;r!!this.frameCache[t])):!!this.frameCache[t]}setFrame(t,e){return void 0===t||(this.inProgress=!0,-1===t||this.frameCache[t]?(this._updateStructure(t),e&&e()):this.loadFrame(t,(()=>{this._updateStructure(t),e&&e()}))),this}_interpolate(t,e,i,r,s,n){const o=this.frameCache;let a;a="spline"===n?function(t,e,i,r,s){const n=t.length,o=new Float32Array(n);for(let a=0;a{this._interpolate(t,e,i,r,s,n),o&&o()})):(this._interpolate(t,e,i,r,s,n),o&&o()),this}loadFrame(t,e){Array.isArray(t)?t.forEach((t=>{this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,(()=>{delete this.loadQueue[t]})))})):this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,(()=>{delete this.loadQueue[t],e&&e()})))}_loadFrame(t,e){Me.error("Trajectory._loadFrame not implemented",t,e)}_updateStructure(t){this._disposed?console.error("updateStructure: traj disposed"):(-1===t?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[t]),this.structure.trajectory={name:this.trajPath,frame:t},this._currentFrame=t,this.inProgress=!1,this.signals.frameChanged.dispatch(t))}_doSuperpose(t){const e=3*this.selectionIndices.length,i=this.coords1,r=this.coords2;for(let r=0;r0&&this.centerPbc){const t=[e[0],e[4],e[8]],r=function(t,e,i){return[wi(e,i[0],3,0,t),wi(e,i[1],3,1,t),wi(e,i[2],3,2,t)]}(this.backboneIndices,i,t);!function(t,e,i){if(0===i[0]||0===i[8]||0===i[4])return;const r=t.length,s=i[0],n=i[1],o=i[2],a=-e[0]+s+s/2,c=-e[1]+n+n/2,l=-e[2]+o+o/2;for(let e=0;e.5&&(t[s+r]-=e[3*r+r]*Math.round(n))}}(i,e,t)}this.removePbc&&function(t,e){if(0===e[0]||0===e[8]||0===e[4])return;const i=t.length;for(let r=3;r.9*e[3*i+i])if(s>0)for(let s=0;s<3;++s)t[r+s]-=e[3*i+s];else for(let s=0;s<3;++s)t[r+s]+=e[3*i+s]}}(i,e)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[t]=i,this.boxCache[t]=e,this.frameCacheSize+=1}_setFrameCount(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(t){this.player=t,this.signals.playerChanged.dispatch(t)}getFrameTime(t){return this.timeOffset+t*this.deltaTime}}class xl extends bl{constructor(t,e,i){const r=i||{};r.timeOffset=st(r.timeOffset,t.timeOffset),r.deltaTime=st(r.deltaTime,t.deltaTime),super("",e,r),this.name=t.name,this.path=t.path,this.frames=t.coordinates,this.boxes=t.boxes,this._init(e)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(t,e){let i;const r=this.frames[t];if(this.atomIndices){const t=this.atomIndices,e=t.length;i=new Float32Array(3*e);for(let s=0;s{const s=i.response;if(!s)return void Me.error(`empty arrayBuffer for '${r}'`);const n=new Int32Array(s,0,1)[0],o=new Float32Array(s,8,9),a=new Float32Array(s,44);this._process(t,o,a,n),"function"==typeof e&&e()}),!1),i.send(s)}_loadFrameCount(){const t=new XMLHttpRequest,e=qe.getCountUrl(this.trajPath);t.open("GET",e,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class Al extends bl{constructor(t,e,i){super("",e,i),this.requestCallback=t,this._init(e)}get type(){return"callback"}_makeAtomIndices(){const t=[];if("StructureView"===this.structure.type){const e=this.structure.getAtomIndices(),i=e.length;let r=e[0],s=e[0];for(let n=1;n{this._process(t,i,r,s),"function"==typeof e&&e()}),t,this.atomIndices)}_loadFrameCount(){this.requestCallback((t=>this._setFrameCount(t)))}}Cc.prototype.getView=function(t){return new _l(this,t)};class _l extends Cc{constructor(t,i){super(),this.structure=t,this.selection=i,this.center=new e,this.boundingBox=new a,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(t){this.structure._hasCoords=t}refresh(){De&&Me.time("StructureView.refresh"),this.atomSetCache={};const t=this.structure;if(this.selection.isAllSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=t.atomSet.clone(),this.bondSet=t.bondSet.clone();for(let t in this.atomSetDict){const e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.clone()}this.atomCount=t.atomCount,this.bondCount=t.bondCount,this.boundingBox.copy(t.boundingBox),this.center.copy(t.center)}else if(this.selection.isNoneSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=new Os(t.atomCount),this.bondSet=new Os(t.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Os(t.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),t.atomSet&&(this.atomSet=this.atomSet.intersection(t.atomSet)),this.bondSet=this.getBondSet();for(let t in this.atomSetDict){const e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new e)}De&&Me.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(t){this.selection=t,this.refresh()}getSelection(t){const e=[];t&&t.string&&e.push(t.string);const i=this.structure.getSelection();i&&i.string&&e.push(i.string),this.selection&&this.selection.string&&e.push(this.selection.string);let r="";return e.length>0&&(r=`( ${e.join(" ) AND ( ")} )`),new pe(r)}getStructure(){return this.structure.getStructure()}eachBond(t,e){this.structure.eachBond(t,this.getSelection(e))}eachAtom(t,e){const i=this.getAtomProxy(),r=this.getAtomSet(e),s=this.atomStore.count;if(r.getSize()=this.V[i][r]?(e="S",this.score=this.S[i][r]):this.V[i][r]>=this.H[i][r]?(e="V",this.score=this.V[i][r]):(e="H",this.score=this.H[i][r]),De&&Me.log("Alignment: SCORE",this.score),De&&Me.log("Alignment: S, V, H",this.S[i][r],this.V[i][r],this.H[i][r]);i>0&&r>0;)"S"===e?this.S[i][r]===this.S[i-1][r-1]+t(i-1,r-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--i,--r,e="S"):this.S[i][r]===this.V[i][r]?e="V":this.S[i][r]===this.H[i][r]?e="H":(--i,--r):"V"===e?this.V[i][r]===this.V[i-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="V"):this.V[i][r]===this.S[i-1][r]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="S"):--i:"H"===e?this.H[i][r]===this.H[i][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,e="H"):this.H[i][r]===this.S[i][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,e="S"):--r:Me.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;De&&Me.timeEnd("Alignment.trace"),De&&Me.log([this.ali1,this.ali2])}}function kl(t,e,i=!1,r="",s=""){let n,o,a,c,l;if(i){let i=t,h=e;r&&s&&(i=t.getView(new pe(r)),h=e.getView(new pe(s)));const d=i.getSequence(),u=h.getSequence(),m=new Il(d.join(""),u.join(""));let p,f;m.calc(),m.trace(),n=0,o=0,a=m.ali1.length;const g=[],y=[];for(let t=0;tt[e]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Te.opacity,color:Te.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Te,!0),this.angleRepresentation=this.addRepresentation("angle",Te,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Te,!0),this.measureRepresentations=new dl([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return Ml}get type(){return"structure"}initSelection(t){this.selection=new pe(t),this.structureView=new _l(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(t){return this.parameters.sele=t,this.selection.setString(t),this}setDefaultAssembly(t){if(void 0===this.structure.biomolDict[t]&&(t=""),this.parameters.defaultAssembly!==t){const e={defaultAssembly:t};this.reprList.forEach((t=>t.setParameters(e))),this.measureRepresentations.setParameters(e),this.parameters.defaultAssembly=t,this.signals.defaultAssemblyChanged.dispatch(t)}return this}rebuildRepresentations(){this.reprList.forEach((t=>{t.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((t=>{t.trajectory.setStructure(this.structureView)}))}updateRepresentations(t){super.updateRepresentations(t),this.measureRepresentations.update(t)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(t,e={},i=!1){e.defaultAssembly=this.parameters.defaultAssembly;const r=this._addRepresentation(t,this.structureView,e,i);return i||r.signals.parametersChanged.add((()=>this.measureUpdate())),r}addTrajectory(t="",e={}){const i=function(t,e,i){let r;return r=t&&t instanceof pl?new xl(t,e,i):!t&&e.frames?new vl(t,e,i):t&&"function"==typeof t?new Al(t,e,i):new wl(t,e,i),r}(t,this.structureView,e),r=new ml(this.stage,i,e);return this.trajList.push(r),this.signals.trajectoryAdded.dispatch(r),r}removeTrajectory(t){const e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)}dispose(){this.trajList.slice().forEach((t=>t.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(t,e){"number"==typeof t&&(e=t,t=""),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),st(e,0))}getBoxUntransformed(t){let e;return e=t?this.structureView.getBoundingBox(new pe(t)):this.structureView.boundingBox,e}getCenterUntransformed(t){return t&&"string"==typeof t?this.structure.atomCenter(new pe(t)):this.structure.center}superpose(t,e,i,r){return kl(this.structureView,t.structureView,e,i,r),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(t){let e=0;const i=this.structure.getAtomProxy(t);return this.eachRepresentation((t=>{if(t.getVisibility()){const r=t.repr;e=Math.max(r.getAtomRadius(i),e)}})),e}measurePick(t){const e=this.pickBuffer.count;if(this.lastPick===t.index&&e>=1){if(e>1){const t=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,t),2===e?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((t=>2===t.length))}):3===e?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((t=>3===t.length))}):4===e&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((t=>4===t.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(t.index)||this.pickBuffer.push(t.index),this.lastPick=t.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const t=this.measureData();this.distanceRepresentation.setParameters({atomPair:t.distance}),this.angleRepresentation.setParameters({atomTriple:t.angle}),this.dihedralRepresentation.setParameters({atomQuad:t.dihedral})}measureUpdate(){const t=this.pickBuffer.data,e={};t.forEach((t=>{const i=Math.max(.1,this.getMaxRepresentationRadius(t));e[t]=i*(2.3-Rt(.1,2,i))})),this.spacefillRepresentation.setSelection(t.length?"@"+t.join(","):"none"),t.length&&this.spacefillRepresentation.setParameters({radiusData:e})}measureData(){const t=this.pickDict.values;return{distance:t.filter((t=>2===t.length)),angle:t.filter((t=>3===t.length)),dihedral:t.filter((t=>4===t.length))}}removeAllMeasurements(t){const e=this.pickDict,i=e.values,r=function(t){i.filter((e=>e.length===t)).forEach((t=>e.del(t.slice().sort())))};(!t||1&t)&&r(2),(!t||2&t)&&r(3),(!t||4&t)&&r(4),this.measureBuild()}removeMeasurement(t){this.pickDict.del(t.slice().sort()),this.measureBuild()}addMeasurement(t){if(t.length<2||t.length>4)return;const e=t.slice().sort();this.pickDict.has(e)||this.pickDict.add(e,t),this.measureBuild()}}Ue.add("structure",Tl),Ue.add("structureview",Tl);class Bl extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.surface=e}get type(){return"surface"}addRepresentation(t,e={}){return this._addRepresentation(t,this.surface,e)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}Ue.add("surface",Bl);class Dl extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.volume=e}get type(){return"volume"}addRepresentation(t,e={}){return this._addRepresentation(t,this.volume,e)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}Ue.add("volume",Dl);class $l extends hl{addRepresentation(t,e){return this.forEach((i=>i.addRepresentation(t,e)))}autoView(t){return this.forEach((e=>e.autoView(t)))}}function Ol(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}const Rl=new e,El={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Fl{constructor(t,e={}){this.signals={parametersChanged:new et,fullscreenChanged:new et,componentAdded:new et,componentRemoved:new et,clicked:new et,hovered:new et},this.tasks=new ui,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Ji(t),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new sr(this.viewer.renderer.domElement),this.viewerControls=new kr(this),this.trackballControls=new gr(this),this.pickingControls=new xr(this),this.animationControls=new Lr(this),this.mouseControls=new Jo(this),this.keyControls=new ia(this),this.pickingBehavior=new ra(this),this.mouseBehavior=new sa(this),this.animationBehavior=new na(this),this.keyBehavior=new aa(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=nt(e,El),this.setParameters(this.parameters),this.viewer.animate())}setParameters(t={}){ot(this.parameters,t);const e=t,i=this.parameters,r=this.viewer,s=this.trackballControls;return void 0!==e.quality&&this.setQuality(i.quality),void 0!==e.impostor&&this.setImpostor(i.impostor),void 0!==e.rotateSpeed&&(s.rotateSpeed=i.rotateSpeed),void 0!==e.zoomSpeed&&(s.zoomSpeed=i.zoomSpeed),void 0!==e.panSpeed&&(s.panSpeed=i.panSpeed),void 0!==e.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),r.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),r.setFog(void 0,i.fogNear,i.fogFar),r.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),r.setSampling(i.sampleLevel),r.setBackground(i.backgroundColor),r.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(t){console.log("STAGE LOG",t),this.logList.push(t)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof Tl){let e,i,r;t.setSelection("/0");const s=t.structure;if(s.biomolDict.BU1){const n=s.biomolDict.BU1;e=n.getAtomCount(s),i=n.getResidueCount(s),r=n.getInstanceCount(),t.setDefaultAssembly("BU1")}else e=s.getModelProxy(0).atomCount,i=s.getModelProxy(0).residueCount,r=1;let n=e;Se&&(n*=4);const o=s.atomStore.count/s.residueStore.count<2;o&&(n*=10);let a="chainname",c="RdYlBu",l=!1;if(1===s.getChainnameCount(new pe("polymer and /0"))&&(a="residueindex",c="Spectral",l=!0),De&&console.log(n,e,r,o),i/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&n>15e3||n>7e5){let e=Math.min(2,Math.max(.1,6e3/(n/r)));o&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:a,colorScale:c,colorReverse:l,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else n>25e4?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,lineOnly:!0}):n>1e5?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,quality:"low",disableImpostor:!0,radiusScale:2}):n>8e4?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:a,colorScale:c,colorReverse:l,radiusScale:.7,aspectRatio:5,quality:"auto"}),n<5e4&&t.addRepresentation("base",{colorScheme:a,colorScale:c,colorReverse:l,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof Bl||t instanceof Dl)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(t,e={}){const i=Object.assign({},this.defaultFileParams,e),r=ri(t).name;this.tasks.increment(),this.log(`loading file '${r}'`);const s=st(i.ext,ri(t).ext);let n;return n=ze.isTrajectory(s)?Promise.reject(new Error(`loadFile: ext '${s}' is a trajectory and must be loaded into a structure component`)):ni(t,i),n.then((t=>{this.log(`loaded '${r}'`);const e=this.addComponentFromObject(t,i);return i.defaultRepresentation&&this.defaultFileRepresentation(e),this.tasks.decrement(),e}),(t=>{this.tasks.decrement();const e=`error loading file: '${t}'`;throw this.log(e),e}))}loadScript(t){const e=ri(t).name;return this.log(`loading script '${e}'`),ni(t).then((t=>{this.tasks.increment(),this.log(`running script '${e}'`),t.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${e}'`)})),this.log(`called script '${e}'`)}),(t=>{this.tasks.decrement();const i=`errored script '${e}' "${t}"`;throw this.log(i),i}))}addComponent(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):Me.warn("Stage.addComponent: no component given")}addComponentFromObject(t,e={}){const i=Ue.get(t.type);if(i){const r=new i(this,t,e);return this.addComponent(r),r}Me.warn("no component for object type",t.type)}removeComponent(t){const e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))}removeAllComponents(){this.compList.slice().forEach((t=>this.removeComponent(t)))}handleResize(){this.viewer.handleResize()}setSize(t,e){const i=this.viewer.container;i!==document.body&&(void 0!==t&&(i.style.width=t),void 0!==e&&(i.style.height=e),this.handleResize())}toggleFullscreen(t){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void Me.log("fullscreen mode (currently) not possible");const e=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&e.lastFullscreenElement){const t=e.lastFullscreenElement;t.style.width=t.dataset.normalWidth||"",t.style.height=t.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),e.handleResize(),e.signals.fullscreenChanged.dispatch(!1)}}t=t||this.viewer.container,this.lastFullscreenElement=t,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(t.dataset.normalWidth=t.style.width||"",t.dataset.normalHeight=t.style.height||"",t.style.width=window.screen.width+"px",t.style.height=window.screen.height+"px",t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){e.handleResize()}),100))}setSpin(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const t=this.parameters;if("scene"!==t.clipMode)return 0;let e=t.clipNear;return"absolute"===t.clipScale&&(e=this.viewer.absoluteToRelative(e)),2*e}setFocus(t){if("scene"!==this.parameters.clipMode)return;let e,i,r,s;"relative"===this.parameters.clipScale?(e=Dt(t/2,0,49.9),i=100-e,r=50,s=function(t){return Dt(t,0,100)}(2*i-50)):(e=this.viewer.relativeToAbsolute(t/2),i=e,r=0,s=2*i),this.setParameters({clipNear:e,clipFar:i,fogNear:r,fogFar:s})}getZoomForBox(t){const e=t.getSize(Rl),i=Math.max(e.x,e.y,e.z),r=Math.min(e.x,e.y,e.z);let s=i+Math.sqrt(r);const n=kt(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(t).then((t=>{this.tasks.decrement(),e(t)})).catch((t=>{this.tasks.decrement(),i(t)}))}))}))}setImpostor(t){this.parameters.impostor=t;const e=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!e.includes(i.getType()))return;const r=i.getParameters();r.disableImpostor=!t,i.build(r)}))}setQuality(t){this.parameters.quality=t;const e=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(r){const s=r.getParameters();if(!e.includes(r.getType())){if(!i.includes(r.getType()))return;if(!s.disableImpostor)return void(r.repr.quality=t)}s.quality=t,r.build(s)}))}eachComponent(t,e){this.compList.slice().forEach((i=>{void 0!==e&&e!==i.type||t(i)}))}eachRepresentation(t,e){this.eachComponent((i=>{i.reprList.slice().forEach((r=>{void 0!==e&&e!==r.getType()||t(r,i)}))}))}getComponentsByName(t){const e=[];return this.eachComponent((i=>{(void 0===t||Ol(t,i))&&e.push(i)})),new $l(e)}getComponentsByObject(t){const e=[];return this.eachComponent((i=>{i.object===t&&e.push(i)})),new $l(e)}getRepresentationsByName(t){const e=[];return this.eachRepresentation(((i,r)=>{(void 0===t||Ol(t,i))&&e.push(i)})),new dl(e)}measureClear(){this.eachComponent((t=>t.measureClear()),"structure")}measureUpdate(){this.eachComponent((t=>t.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}}class Ll extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.shape=e}get type(){return"shape"}addRepresentation(t,e={}){return this._addRepresentation(t,this.shape,e)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Nl(t,e,i,r){var s,n=arguments.length,o=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(e,i,o):s(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o}Ue.add("shape",Ll);class zl extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=st(t.reverse,!0)),this.scalePerModel={},t.structure.eachModel((t=>{this.parameters.domain=[t.atomOffset,t.atomEnd],this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){return this.scalePerModel[t.modelIndex](t.index)}}Nl([Nt],zl.prototype,"atomColor",null),Fe.add("atomindex",zl);class Vl extends zt{constructor(t){if(super(t),t.scale||(this.parameters.scale="OrRd"),!t.domain){let e,i=1/0,r=-1/0;t.sele&&(e=new pe(t.sele)),t.structure.eachAtom((function(t){const e=t.bfactor;i=Math.min(i,e),r=Math.max(r,e)}),e),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}atomColor(t){return this.bfactorScale(t.bfactor)}}Nl([Nt],Vl.prototype,"atomColor",null),Fe.add("bfactor",Vl);class Gl extends zt{constructor(t){super(t),this.chainidDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{let e=0;const i={};t.eachChain((function(t){void 0===i[t.chainid]&&(i[t.chainid]=e,e+=1)})),this.parameters.domain=[0,e-1],this.chainidDictPerModel[t.index]=i,this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){const e=this.chainidDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainid])}}Nl([Nt],Gl.prototype,"atomColor",null),Fe.add("chainid",Gl);class Ul extends zt{constructor(t){super(t),this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{this.parameters.domain=[t.chainOffset,t.chainEnd],this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){return this.scalePerModel[t.modelIndex](t.chainIndex)}}Nl([Nt],Ul.prototype,"atomColor",null),Fe.add("chainindex",Ul);class jl extends zt{constructor(t){super(t),this.chainnameDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{let e=0;const i={};t.eachChain((function(t){void 0===i[t.chainname]&&(i[t.chainname]=e,e+=1)})),this.parameters.domain=[0,e-1],this.chainnameDictPerModel[t.index]=i,this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){const e=this.chainnameDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainname])}}Nl([Nt],jl.prototype,"atomColor",null),Fe.add("chainname",jl);class Hl extends zt{constructor(t){super(t),this.rsrzDict={},this.rsccDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const e=t.structure.validation;e&&(this.rsrzDict=e.rsrzDict,this.rsccDict=e.rsccDict)}atomColor(t){let e=t.resno+"";t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;const i=this.rsrzDict[e];if(void 0!==i)return this.rsrzScale(i);const r=this.rsccDict[e];return void 0!==r?this.rsccScale(r):9474192}}Nl([Nt],Hl.prototype,"atomColor",null),Fe.add("densityfit",Hl);const Wl={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class ql extends zt{constructor(t){super(t),this.delta=new e,this.hCharges=[],t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(t.structure.atomCount);const i=[];t.structure.eachAtom((t=>{var r;if(this.charges[t.index]=(null!==(r=t).partialCharge?r.partialCharge:r.isProtein()&&(Wl[r.resname]&&Wl[r.resname][r.atomname]||Wl.backbone[r.atomname])||0)*t.occupancy,"N"===t.atomname){if(t.bondCount>=3)return;if(t.bondToElementCount(1))return;const r=function(t,i=new e){let r=!1,s=!1,n=!1;return i.set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom((function(t){if(!r)return"H"===t.atomname?(i.set(t.x,t.y,t.z),void(r=!0)):void(s||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,i.sub(t)):(i.sub(t),s=!0))})),r?i:s&&n?(i.normalize(),i.multiplyScalar(1.04),i.add(t),i):void 0}(t);void 0!==r&&(i.push(r),this.hCharges.push(.25*t.occupancy))}}));const r=t.structure.getBoundingBox();r.expandByScalar(1.04),this.hStore=function(t){const e=t.length,i=new Float32Array(e),r=new Float32Array(e),s=new Float32Array(e);for(let e=0;e{const s=e[t];0!==s&&(r+=s/i)})),this.hHash.eachWithin(t.x,t.y,t.z,12,((t,e)=>{const s=i[t];0!==s&&(r+=s/e)})),this.scale(332*r)}}Nl([Nt],ql.prototype,"positionColor",null),Fe.add("electrostatic",ql);const Xl={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class Yl extends zt{constructor(t){t.value=st(t.value,Xl.C),super(t)}atomColor(t){const e=t.element;return"C"===e?this.parameters.value:Xl[e]||16777215}}Nl([Nt],Yl.prototype,"atomColor",null),Fe.add("element",Yl);class Kl extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="Spectral"),t.domain||(this.parameters.domain=[0,t.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(t){return this.entityindexScale(t.entityIndex)}}Nl([Nt],Kl.prototype,"atomColor",null),Fe.add("entityindex",Kl);class Zl extends zt{atomColor(t){const e=t.entity;switch(e?e.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Nl([Nt],Zl.prototype,"atomColor",null),Fe.add("entitytype",Zl);class Ql extends zt{constructor(t){super(t),this.geoAtomDict={},this.geoDict={};const e=t.structure.validation;e&&(this.geoAtomDict=e.geoAtomDict,this.geoDict=e.geoDict)}atomColor(t){let e,i=t.resno+"";t.inscode&&(i+="^"+t.inscode),t.chainname&&(i+=":"+t.chainname),i+="/"+t.modelIndex;const r=this.geoAtomDict[i];if(void 0!==r){const i=r[t.atomname]||0;s=i,e=16843009*((s=(858993459&(s-=s>>1&1431655765))+(s>>2&858993459))+(s>>4)&252645135)>>24}else e=this.geoDict[i]||0;var s;return 0===e?2188972:1===e?16703627:2===e?16018755:e>=3?10813478:9474192}}Nl([Nt],Ql.prototype,"atomColor",null),Fe.add("geoquality",Ql);class Jl extends zt{constructor(t){super(t),this.resHF={},t.scale||(this.parameters.scale="RdYlGn");for(const t in Js)this.resHF[t]=Js[t][0];if(this.defaultResidueHydrophobicity=tn[0],!t.domain){let t=1/0,e=-1/0;for(const i in this.resHF){const r=this.resHF[i];t=Math.min(t,r),e=Math.max(e,r)}this.parameters.domain=[t,0,e]}this.hfScale=this.getScale()}atomColor(t){return this.hfScale(this.resHF[t.resname]||this.defaultResidueHydrophobicity)}}Nl([Nt],Jl.prototype,"atomColor",null),Fe.add("hydrophobicity",Jl);class th extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rainbow"),t.domain||(this.parameters.domain=[0,t.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(t){return this.modelindexScale(t.modelIndex)}}Nl([Nt],th.prototype,"atomColor",null),Fe.add("modelindex",th);class eh extends zt{atomColor(t){switch(t.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Nl([Nt],eh.prototype,"atomColor",null),Fe.add("moleculetype",eh);class ih extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="PuBu"),t.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(t){return this.occupancyScale(t.occupancy)}}Nl([Nt],ih.prototype,"atomColor",null),Fe.add("occupancy",ih);class rh extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(t){return this.partialchargeScale(t.partialCharge||0)}}function sh(){return 16777215*Math.random()}Nl([Nt],rh.prototype,"atomColor",null),Fe.add("partialcharge",rh);class nh extends zt{atomColor(){return sh()}volumeColor(){return sh()}positionColor(){return sh()}}Nl([Nt],nh.prototype,"atomColor",null),Nl([Nt],nh.prototype,"volumeColor",null),Nl([Nt],nh.prototype,"positionColor",null),Fe.add("random",nh);class oh extends zt{constructor(t){super(t),this.rciDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const e=t.structure.validation;e&&(this.rciDict=e.rciDict)}atomColor(t){let e=`[${t.resname}]${t.resno}`;t.chainname&&(e+=":"+t.chainname);const i=this.rciDict[e];return void 0!==i?this.rciScale(i):9474192}}Nl([Nt],oh.prototype,"atomColor",null),Fe.add("randomcoilindex",oh);class ah extends zt{constructor(t){super(t),this.scalePerChain={},t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=st(t.reverse,!0)),t.structure.eachChain((t=>{this.parameters.domain=[t.residueOffset,t.residueEnd],this.scalePerChain[t.index]=this.getScale()}))}atomColor(t){return this.scalePerChain[t.chainIndex](t.residueIndex)}}Nl([Nt],ah.prototype,"atomColor",null),Fe.add("residueindex",ah);const ch={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class lh extends zt{atomColor(t){return ch[t.resname]||16711935}}Nl([Nt],lh.prototype,"atomColor",null),Fe.add("resname",lh);const hh=16711808,dh=10485888,uh=6291584,mh=16762880,ph=6324479,fh=16777215,gh=11403518,yh=16580962,bh=10921722;class xh extends zt{constructor(t){super(t),this.residueProxy=t.structure.getResidueProxy()}atomColor(t){const e=t.sstruc,i=this.residueProxy;return"h"===e?hh:"g"===e?dh:"i"===e?uh:"e"===e||"b"===e?mh:"t"===e?ph:(i.index=t.residueIndex,i.isDna()?gh:i.isRna()?yh:i.isSaccharide()?bh:i.isProtein()||"s"===e||"l"===e?fh:8421504)}}Nl([Nt],xh.prototype,"atomColor",null),Fe.add("sstruc",xh);class vh extends zt{constructor(t){var e,i;super(t),t.scale||(this.parameters.scale="rwb"),this.atomData=null===(e=this.parameters.data)||void 0===e?void 0:e.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(t){var e;const i=null===(e=this.atomData)||void 0===e?void 0:e[t.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(t,e){var i;const r=null===(i=this.bondData)||void 0===i?void 0:i[t.index];return void 0!==r?this.scale(r):this.atomProxy?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Nl([Nt],vh.prototype,"atomColor",null),Nl([Nt],vh.prototype,"bondColor",null),Fe.add("structuredata",vh);class wh extends zt{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Nl([Nt],wh.prototype,"atomColor",null),Nl([Nt],wh.prototype,"bondColor",null),Nl([Nt],wh.prototype,"valueColor",null),Nl([Nt],wh.prototype,"volumeColor",null),Fe.add("uniform",wh);class Ah extends zt{constructor(t){super(t),this.valueScale=this.getScale()}volumeColor(t){return this.valueScale(this.parameters.volume.data[t])}}Nl([Nt],Ah.prototype,"volumeColor",null),Fe.add("value",Ah);class _h extends zt{constructor(t){super(t),this.vec=new e,this.valueScale=this.getScale()}positionColor(t){const e=this.parameters.volume;if(!e||!e.inverseMatrix)return this.parameters.value;const i=this.vec,r=e.data,s=e.nx,n=e.ny,o=s*n;i.copy(t),i.applyMatrix4(e.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*n+c)*s+a,d=h+1,u=h+s,m=h+o,p=u+1,f=m+1,g=u+o,y=g+1,b=r[h],x=r[d],v=r[u],w=r[m],A=r[p],_=r[f],S=r[g],C=r[y],P=i.x-a,I=i.y-c,k=i.z-l,M=$t(b,x,P),T=$t(w,_,P),B=$t(v,A,P),D=$t(S,C,P),$=$t(M,B,I),O=$t(T,D,I),R=$t($,O,k);return this.valueScale(R)}}Nl([Nt],_h.prototype,"positionColor",null),Fe.add("volume",_h);class Sh extends zr{constructor(t,e,i){const r=i||{};if(super(t,e,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:pa.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new pe(r.sele),this.dataList=[],this.structure=t,this.structureView=this.structure.getView(this.selection),t.biomolDict){const e={default:"default","":t.unitcell?"AU":"FULL"};Object.keys(t.biomolDict).forEach((function(t){e[t]=t})),this.parameters.assembly={type:"select",options:e,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"element"),this.setRadius(e.radius,e),this.radiusType=st(e.radiusType,"vdw"),this.radiusData=st(e.radiusData,{}),this.radiusSize=st(e.radiusSize,1),this.radiusScale=st(e.radiusScale,1),this.assembly=st(e.assembly,"default"),this.defaultAssembly=st(e.defaultAssembly,""),"auto"===e.quality&&(e.quality=this.getQuality()),super.init(e),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(t,e){const i=Object.keys(ma);return"string"==typeof t&&i.includes(t.toLowerCase())?e.radiusType=t:void 0!==t&&(e.radiusType="size",e.radiusSize=t),this}getAssembly(){const t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]}getQuality(){let t;const e=this.structureView,i=this.getAssembly();t=i?i.getAtomCount(e):e.atomCount,Se&&(t*=4);return e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const t=this.getAssembly();if(t)t.partList.forEach(((t,e)=>{const i=t.getView(this.structureView);if(0===i.atomCount)return;const r=this.createData(i,e);r&&(r.sview=i,r.instanceList=t.getInstanceList(),this.dataList.push(r))}));else{const t=this.createData(this.structureView,0);t&&(t.sview=this.structureView,this.dataList.push(t))}}update(t){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((e=>{e.bufferList.length>0&&this.updateData(t,e)}),this):Object.assign(this.lazyProps.what,t)}updateData(t,e){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(t){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)}getBondParams(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)}getAtomRadius(t){if(this.structureView.atomSet.isSet(t.index)){return new pa(this.getRadiusParams()).atomRadius(t)}return 0}setSelection(t,e){return this.selection.setString(t,e),this}setParameters(t,e={},i=!1){const r=t||{};return this.setRadius(r.radius,r),void 0===r.radiusType&&void 0===r.radiusData&&void 0===r.radiusSize&&void 0===r.radiusScale||(e.radius=!0,Ie&&!this.disableImpostor||(i=!0)),void 0!==r.defaultAssembly&&r.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===r.assembly||"default"===r.assembly)&&(i=!0),super.setParameters(r,e,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(t){const e=this.viewer,i=this.bufferList;this.dataList.forEach((function(t){t.bufferList.forEach((function(r){i.push(r),e.add(r,t.instanceList)}))})),this.setVisibility(this.visible),t()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class Ch extends Sh{constructor(t,e,i){super(t,e,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(t){const e=t||{};this.labelVisible=st(e.labelVisible,!0),this.labelSize=st(e.labelSize,2),this.labelColor=st(e.labelColor,16777215),this.labelFontFamily=st(e.labelFontFamily,"sans-serif"),this.labelFontStyle=st(e.labelFontstyle,"normal"),this.labelFontWeight=st(e.labelFontWeight,"bold"),this.labelsdf=st(e.labelsdf,"Chrome"===Ae),this.labelXOffset=st(e.labelXOffset,0),this.labelYOffset=st(e.labelYOffset,0),this.labelZOffset=st(e.labelZOffset,.5),this.labelAttachment=st(e.labelAttachment,"bottom-left"),this.labelBorder=st(e.labelBorder,!1),this.labelBorderColor=st(e.labelBorderColor,"lightgrey"),this.labelBorderWidth=st(e.labelBorderWidth,.15),this.labelBackground=st(e.labelBackground,!1),this.labelBackgroundColor=st(e.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=st(e.labelBackgroundMargin,.5),this.labelBackgroundOpacity=st(e.labelBackgroundOpacity,1),this.labelFixedSize=st(e.labelFixedSize,!1),this.lineOpacity=st(e.lineOpacity,1),this.linewidth=st(e.linewidth,2),super.init(e)}update(t){t.position?this.build():super.update(t)}updateData(t,e){const i={};if(t&&!t.labelSize||Object.assign(i,{size:Si(this.n,this.labelSize)}),!t||t.labelColor){const t=new s(this.labelColor);Object.assign(i,{color:Ci(this.n,t.r,t.g,t.b)})}this.textBuffer.setAttributes(i)}setParameters(t,e={},i=!1){return t&&t.labelSize&&(e.labelSize=!0),t&&(t.labelColor||0===t.labelColor)&&(e.labelColor=!0,i=!0),super.setParameters(t,e,i),t&&void 0!==t.opacity&&this.textBuffer.setParameters({opacity:1}),t&&void 0!==t.labelVisible&&this.setVisibility(this.visible),this}setVisibility(t,e){return super.setVisibility(t,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),e||this.viewer.requestRender(),this}getLabelBufferParams(t={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},t,{opacity:1}))}getAtomRadius(){return 0}}function Ph(t,e){const i=t.getAtomProxy(),r=new pe,s=e.length;if(0===s)return new Float32Array(0);const n=e[0].length,o=t.getAtomSet(),a=new Float32Array(s*n*3);let c=0;return e.forEach((function(e){let s=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Th={};const Bh={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class Dh{constructor(t={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=nt(t,Bh);const e=this.parameters;this.radius=e.size/8,this.padding=e.size/3;const i=this.lineHeight=e.size+2*e.outline+Math.round(e.size/4),r=this.maxWidth=e.width/4,s=this.canvas=document.createElement("canvas");s.width=r,s.height=i;const n=this.context=this.canvas.getContext("2d");n.font=`${e.style} ${e.variant} ${e.weight} ${e.size}px ${e.font}`,n.fillStyle="black",n.textAlign="left",n.textBaseline="bottom",n.lineJoin="round",this.gridOuter=new Float64Array(i*r),this.gridInner=new Float64Array(i*r),this.f=new Float64Array(Math.max(i,r)),this.d=new Float64Array(Math.max(i,r)),this.z=new Float64Array(Math.max(i,r)+1),this.v=new Int16Array(Math.max(i,r)),this.data=new Uint8Array(e.width*e.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=e.width,this.canvas2.height=e.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let t=32;t<=126;++t)this.map(String.fromCharCode(t));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new H(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(t){const e=this.parameters;return void 0===this.mapped[t]&&(this.draw(t),this.currentX+this.scratchW>e.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>e.height&&console.warn("canvas to small"),this.mapped[t]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[t]}get(t){return this.mapped[t]||this.placeholder}draw(t){const e=this.parameters,i=this.lineHeight,r=e.outline,s=this.context,n=this.maxWidth,o=r,a=i-e.outline,c=s.measureText(t),l=Math.min(n,Math.ceil(c.width+2*o+1)),h=l*i;s.clearRect(0,0,l,i),s.fillText(t,o,a);const d=s.getImageData(0,0,l,i),u=d.data;for(let t=0;t= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Fh=Object.assign({linewidth:2},zo),Lh=Object.assign({linewidth:{uniform:!0}},Vo);class Nh extends zc{constructor(e,r={}){super(e,r),this.parameterTypes=Lh,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new t},projectionMatrixInverse:{value:new i}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Fh}setParameters(t){super.setParameters(t)}}je.add("wideline",Nh);class zh extends Ch{constructor(t,e,i){super(t,e,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(t){const e=t||{};e.side=st(e.side,"double"),e.opacity=st(e.opacity,.5),this.atomTriple=st(e.atomTriple,[]),this.arcVisible=st(e.arcVisible,!0),this.sectorVisible=st(e.sectorVisible,!0),this.vectorVisible=st(e.vectorVisible,!0),super.init(e)}createData(t){if(!t.atomCount||!this.atomTriple.length)return;const e=function(t,e){return function(t){const e=[],i=t.length/9;for(let r=0;r radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Xh=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Yh=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class Kh extends Fc{constructor(t,e={}){super("v3",t,e)}get mapping(){return Xh}get mappingIndices(){return Yh}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const Zh=Object.assign({openEnded:!1},zo),Qh=Object.assign({openEnded:{updateShader:!0}},Vo);class Jh extends Kh{constructor(t,e={}){super(t,e),this.parameterTypes=Qh,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new i},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}get defaultParameters(){return Zh}getDefines(t){const e=Kh.prototype.getDefines.call(this,t);return this.parameters.openEnded||(e.CAP=1),e}}Object.assign({disableImpostor:!1},Hh,Zh);const td=class{constructor(t,e={}){return!t.color2&&t.color&&(t.color2=t.color),!Ie||e&&e.disableImpostor?new qh(t,e):new Jh(t,e)}};je.add("cylinder",td);class ed extends Sh{constructor(t,e,i){super(t,e,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(t){const e=t||{};e.radiusSize=st(e.radiusSize,.5),e.colorValue=st(e.colorValue,"lightgreen"),e.useInteriorColor=st(e.useInteriorColor,!0),this.showAxes=st(e.showAxes,!0),this.showBox=st(e.showBox,!1),super.init(e)}getPrincipalAxes(){let t;const e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)}getAxesData(t){const i=this.getPrincipalAxes(),r=new s(this.colorValue);let n=0,o=0;this.showAxes&&(n+=6,o+=3),this.showBox&&(n+=8,o+=12);const a=new Float32Array(3*n),c=Ci(n,r.r,r.g,r.b),l=Si(n,this.radiusSize),h=new Float32Array(3*o),d=new Float32Array(3*o),u=Ci(o,r.r,r.g,r.b),m=Si(o,this.radiusSize);let p=0;if(this.showAxes){const t=function(t,e){t.toArray(a,2*p),e.toArray(a,2*p+3),t.toArray(h,p),e.toArray(d,p),p+=3};t(i.begA,i.endA),t(i.begB,i.endB),t(i.begC,i.endC)}if(this.showBox){const r=new e,{d1a:s,d2a:n,d3a:o,d1b:c,d2b:l,d3b:u}=i.getProjectedScaleForAtoms(t);let m=2*p;const f=function(t,e,s){r.copy(i.center).addScaledVector(i.normVecA,t).addScaledVector(i.normVecB,e).addScaledVector(i.normVecC,s),r.toArray(a,m),m+=3};f(s,n,o),f(s,n,u),f(s,l,u),f(s,l,o),f(c,l,u),f(c,l,o),f(c,n,o),f(c,n,u);let g=p;const y=function(t,e){r.fromArray(a,2*p+3*t).toArray(h,g),r.fromArray(a,2*p+3*e).toArray(d,g),g+=3};y(0,1),y(0,3),y(0,6),y(1,2),y(1,7),y(2,3),y(2,4),y(3,5),y(4,5),y(4,7),y(5,6),y(6,7)}const f=new Kn(i);return{vertex:{position:a,color:c,radius:l,picking:f},edge:{position1:h,position2:d,color:u,color2:u,radius:m,picking:f}}}create(){const t=this.getAxesData(this.structureView);this.sphereBuffer=new Gc(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new td(t.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(t){}updateData(t,e){const i=this.getAxesData(e.sview),r={},s={};t&&!t.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(s,{position1:i.edge.position1,position2:i.edge.position2})),t&&!t.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(s,{color:i.edge.color,color2:i.edge.color})),t&&!t.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(s,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(s)}}Ne.add("axes",ed);class id extends Sh{constructor(t,e,i){super(t,e,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(t){var e=t||{};e.radiusType=st(e.radiusType,"size"),e.radiusSize=st(e.radiusSize,.15),e.useInteriorColor=st(e.useInteriorColor,!0),this.aspectRatio=st(e.aspectRatio,2),this.lineOnly=st(e.lineOnly,!1),this.cylinderOnly=st(e.cylinderOnly,!1),this.multipleBond=st(e.multipleBond,"off"),this.bondSpacing=st(e.bondSpacing,1),this.bondScale=st(e.bondScale,.4),this.linewidth=st(e.linewidth,2),super.init(e)}getAtomRadius(t){return this.aspectRatio*super.getAtomRadius(t)}getAtomParams(t,e){var i=super.getAtomParams(t,e);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(t,e,i){return t.getAtomData(this.getAtomParams(e,i))}getBondParams(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},e),super.getBondParams(t,e)}getBondData(t,e,i){return t.getBondData(this.getBondParams(e,i))}createData(t){const e=[];if(this.lineOnly)this.lineBuffer=new Nh(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{const i=new td(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(i),!this.cylinderOnly){const i=new Gc(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(i)}}return{bufferList:e}}updateData(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);const i=this.getBondData(e.sview,t);if(this.lineOnly){const r={};t&&!t.position||Object.assign(r,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(r,{color:i.color,color2:i.color2}),e.bufferList[0].setAttributes(r)}else{var r={};if(t&&!t.position||Object.assign(r,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(r,{color:i.color,color2:i.color2}),t&&!t.radius||Object.assign(r,{radius:i.radius}),e.bufferList[0].setAttributes(r),!this.cylinderOnly){var s=this.getAtomData(e.sview,t),n={};t&&!t.position||Object.assign(n,{position:s.position}),t&&!t.color||Object.assign(n,{color:s.color}),t&&!t.radius||Object.assign(n,{radius:s.radius}),e.bufferList[1].setAttributes(n)}}}setParameters(t={}){let e=!1;const i={};return(t.aspectRatio||t.bondSpacing||t.bondScale)&&(Object.assign(i,{radius:!0}),Ie&&!this.disableImpostor||(e=!0)),super.setParameters(t,i,e),this}}Ne.add("ball+stick",id);class rd extends id{constructor(t,e,i){super(t,e,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(t){var e=t||{};e.aspectRatio=st(e.aspectRatio,1),e.radiusSize=st(e.radiusSize,.25),super.init(e)}getAtomRadius(t){return t.isTrace()?super.getAtomRadius(t):0}getAtomData(t,e,i){return t.getBackboneAtomData(this.getAtomParams(e,i))}getBondData(t,e,i){return t.getBackboneBondData(this.getBondParams(e,i))}}Ne.add("backbone",rd);class sd extends id{constructor(t,e,i){super(t,e,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(t){let e=t||{};e.aspectRatio=st(e.aspectRatio,1),e.radiusSize=st(e.radiusSize,.3),super.init(e)}getAtomData(t,e,i){return t.getRungAtomData(this.getAtomParams(e,i))}getBondData(t,e,i){let r=this.getBondParams(e,i);return Object.assign(r.colorParams,{rung:!0}),t.getRungBondData(r)}}Ne.add("base",sd);class nd{constructor(t,i){this.m=t,this.tension=i,this.dt=1/this.m,this.delta=1e-4,this.vec1=new e,this.vec2=new e,this.vDir=new e,this.vTan=new e,this.vNorm=new e,this.vBin=new e,this.m2=Math.ceil(this.m/2)}interpolateToArr(t,e,i,r,s,n,o){n[o+0]=Ot(t.x,e.x,i.x,r.x,s,this.tension),n[o+1]=Ot(t.y,e.y,i.y,r.y,s,this.tension),n[o+2]=Ot(t.z,e.z,i.z,r.z,s,this.tension)}interpolateToVec(t,e,i,r,s,n){n.x=Ot(t.x,e.x,i.x,r.x,s,this.tension),n.y=Ot(t.y,e.y,i.y,r.y,s,this.tension),n.z=Ot(t.z,e.z,i.z,r.z,s,this.tension)}interpolatePosition(t,e,i,r,s,n){for(var o=0;o1&&(l=1),this.interpolateToVec(t,e,i,r,c,this.vec1),this.interpolateToVec(t,e,i,r,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(s,h)}}vectorSubdivide(t,e,i,r,s){let n,o=e.next(),a=e.next(),c=e.next();const l=e.size,h=l-1;let d=r||0;for(let r=0;r0&&e{if(t.residueCount<4)return;i.push(t);const r=this.getSpline(t),s=this.getAspectRatio(t),n=r.getSubdividedPosition(),o=r.getSubdividedOrientation(),a=r.getSubdividedColor(this.getColorParams()),c=r.getSubdividedPicking(),l=r.getSubdividedSize(this.getRadiusParams());e.push(new hd(Object.assign({},n,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:s,capped:this.capped})))}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){De&&Me.time(this.type+" repr update"),t=t||{};for(var i=0,r=e.polymerList.length;i0;Qr(A,b,_);const s=Zr(A,v)<0;if(ns(A,v,Zr(v,x)),Qr(S,x,A),ns(A,v,Zr(v,w)),Qr(C,w,A),0===rs(S)||0===rs(C))continue;os(S,S),os(C,C);const D=n[T]=us(S,C);a[T]=(vi*D).toFixed(1)+String.fromCharCode(176),Kr(k,S,v),os(k,k),Zr(k,C)<0&&ds(k,k),Ih(A,_,S,k,D/2),es(A,o,3*T);const $=Math.ceil(D/i),O=$+(e.extendLine?4:2),R=e.extendLine?36:0,E=new Float32Array(3*O),F=new Float32Array(3*O),L=new Float32Array(9*$),N=new Float32Array(R);c[T]=E,l[T]=F,h[T]=L,d[T]=N,e.extendLine&&(r?(Qr(A,f,y),os(A,A),ns(P,A,1/Zr(S,A)),Jr(P,P,y)):(ns(P,x,1/Zr(S,x)),Jr(P,P,g)),s?(Qr(A,b,g),os(A,A),ns(I,A,1/Zr(C,A)),Jr(I,I,g)):(ns(I,w,1/Zr(C,w)),Jr(I,I,y))),Jr(M,_,S);let z=0;e.extendLine?(es(f,E,z),es(P,F,z),z+=3,es(P,E,z),es(M,F,z),z+=3,es(P,N,0),es(M,N,3),es(r?y:g,N,6),es(r?y:g,N,9),es(M,N,12),es(_,N,15)):(es(_,E,z),es(M,F,z),z+=3);const V=function(t,e){const i=9*e;es(_,L,i),es(M,L,i+3),es(M,E,z),Ih(M,_,S,k,t),es(M,L,i+6),es(M,F,z),z+=3};let G=0;for(let t=i;t{const e=pd(i,t);Object.assign(t,e)})),e.side=st(e.side,"double"),e.opacity=st(e.opacity,.5),e.radiusType=st(e.radiusType,"size"),e.radiusSize=st(e.radiusSize,.15),super.init(e)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(t){if(!t.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((e=>e.atomPositions=Ph(t,[e.atomQuad])));const e=this.scaleBinToSectorArea?function(t){return Math.sqrt(t)}:function(t){return t};function i(t){const e=t.map((t=>t.length)),i=new Float32Array($i(e));let r=0;for(let e=0;et.startPoints))),position2:i(t.map((t=>t.endPoints))),color:i(t.map((t=>t.startColors))),color2:i(t.map((t=>t.endColors)))},e)}function s(t,e){return new Uo({position:i(t.map((t=>t.triangles))),color:i(t.map((t=>t.triangleColors)))},e)}this.histogramsData.forEach((t=>t.histogram360Scaled=t.histogram360.map(e)));const n=[];for(let t=0;t=3&&(e=yd(i)),void 0!==e&&n.push(e)}return this.frontHistogramBinBordersBuffer=r(n.map((t=>t.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=r(n.map((t=>t.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=r(n.map((t=>t.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=r(n.map((t=>t.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=s(n.map((t=>t.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=s(n.map((t=>t.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=s(n.map((t=>t.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(t){return super.setParameters(t,{},!1),t&&void 0!==t.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(t,e){return super.setVisibility(t,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),e||this.viewer.requestRender(),this}}function yd(t){const e=t.atomPositions,i=t.histogram360Scaled,r=i.length<=180?360:2*i.length,s={triangles:new Float32Array(3*r*3),triangleColors:fd(t.opaqueMiddleDiscColor,3*r)},n={triangles:new Float32Array(3*i.length*3),triangleColors:fd(t.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:fd(t.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:fd(t.histogramBinBorderColor,i.length),endColors:fd(t.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:fd(t.histogramBinBorderColor,i.length),endColors:fd(t.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:fd(t.adjacentBondArrowColor,i.length),endColors:fd(t.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:fd(t.distantBondArrowColor,i.length),endColors:fd(t.distantBondArrowColor,i.length)},d=Yr(),u=Yr(),m=Yr(),p=Yr(),f=Yr(),g=Yr(),y=Yr(),b=Yr(),x=Yr(),v=Yr(),w=Yr(),A=Yr(),_=Yr(),S=Yr(),C=Yr(),P=Yr(),I=[d,u,m,p];for(let t=0;t{let u=e[0],m=e[1];if("number"==typeof u&&Number.isInteger(u)&&"number"==typeof m&&Number.isInteger(m)){if(!d.get(u)||!d.get(m))return void(h+=1);c.index=u,l.index=m}else{n.setString(u),o.setString(m);var p=t.getAtomIndices(n),f=t.getAtomIndices(o);if(!p.length||!f.length)return void(h+=1);c.index=p[0],l.index=f[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":r[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(g/10).toFixed(2)+" nm";break;default:r[i]=g.toFixed(2)}var y=3*i;s[y+0]=(c.x+l.x)/2,s[y+1]=(c.y+l.y)/2,s[y+2]=(c.z+l.z)/2})),h>0&&(i-=h,s=s.subarray(0,3*i));var u=new Os(a.count,!0);return{text:r,position:s,bondSet:u,bondStore:a}}getBondData(t,e,i){const r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new to(r.picking.array,r.picking.structure,i.bondStore)),r}createData(t){if(!t.atomCount||!this.atomPair.length)return;const e=this.atomPair.length,i=new s(this.labelColor),r=this.getDistanceData(t,this.atomPair);this.textBuffer=new Eh({position:r.position,size:Si(e,this.labelSize),color:Ci(e,i.r,i.g,i.b),text:r.text},this.getLabelBufferParams());const n={bondSet:r.bondSet,bondStore:r.bondStore},o=this.getBondData(t,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new td(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Nh(ps(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:r.bondSet,bondStore:r.bondStore,position:r.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(t,e){super.updateData(t,e);const i={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(e.sview,t,i),s={};t&&!t.color||Object.assign(s,{color:r.color,color2:r.color2}),t&&!t.radius||Object.assign(s,{radius:r.radius}),this.distanceBuffer.setAttributes(s)}setParameters(t){return super.setParameters(t,{},!1),this.useCylinder||(t&&t.lineOpacity&&this.distanceBuffer.setParameters({opacity:t.lineOpacity}),t&&void 0!==t.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),t&&t.linewidth&&this.distanceBuffer.setParameters({linewidth:t.linewidth})),this}}function xd(t){return 2*(t.position.length/3)*3}Ne.add("distance",bd);const vd=Object.assign({scale:1,color:"grey"},zo);class wd extends Go{constructor(t,e={}){super({position:new Float32Array(xd(t)),color:new Float32Array(xd(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const i=new s(this.parameters.color),r=this.geometry.attributes;Ci(xd(t)/3,i.r,i.g,i.b,r.color.array),this.setAttributes(t)}get defaultParameters(){return vd}setAttributes(t={}){const e=this.geometry.attributes;let i,r,s;t.position&&t.vector&&(i=t.position,r=t.vector,s=e.position.array,e.position.needsUpdate=!0);const n=this.size/2,o=this.parameters.scale;if(i&&r)for(let t=0;t{if(t.residueCount<4)return;i.push(t);const r=new Ca(t),s=r.getPosition(),n=r.getColor(this.getColorParams()),o=r.getSize(this.getRadiusParams()),a=r.getPicking();e.push(new Gc({position:s.center,color:n.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new wd({position:s.center,vector:s.axis},this.getBufferParams({color:"skyblue",scale:1})),new wd({position:s.center,vector:s.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){De&&Me.time(this.type+" repr update"),t=t||{};for(let i=0,r=e.polymerList.length;i radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),Ve.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Sd=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Cd=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class Pd extends Fc{constructor(t,e={}){super("v3",t,e)}get mapping(){return Sd}get mappingIndices(){return Cd}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const Id=Object.assign({shrink:.14},zo),kd=Object.assign({shrink:{uniform:!0}},Vo);class Md extends Pd{constructor(t,e={}){super(t,e),this.parameterTypes=kd,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new i},modelViewProjectionMatrixInverse:{value:new i},modelViewMatrixInverseTranspose:{value:new i},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}get defaultParameters(){return Id}}Object.assign({disableImpostor:!1},Hh,Id);const Td=class{constructor(t,e={}){return!Ie||e&&e.disableImpostor?(t.radius=function(t,e){const i=t.length,r=new Float32Array(i);for(let s=0;sa.push(r.atomLabel(t)))))}else if("residue"===this.labelGrouping){e&&!e.position||(c=[]),e&&!e.color||(h=[]),e&&!e.radius||(l=[]),e&&!e.text||(a=[]),i.colorParams&&(i.colorParams.structure=t.getStructure());const d=Fe.getScheme(i.colorParams),u=new pa(i.radiusParams),m=t.getAtomProxy();let p=0;t.eachResidue((t=>{const i=3*p;t.isProtein()||t.isNucleic()?(m.index=t.traceAtomIndex,e&&!e.position||m.positionToArray(c,i)):(m.index=t.atomOffset,e&&!e.position||t.positionToArray(c,i)),e&&!e.color||d.atomColorToArray(m,h,i),e&&!e.radius||(l[p]=u.atomRadius(m)),e&&!e.text||a.push(r.atomLabel(m)),++p})),e&&!e.position||(s=new Float32Array(c)),e&&!e.color||(o=new Float32Array(h)),e&&!e.radius||(n=new Float32Array(l))}return{position:s,size:n,color:o,text:a}}createData(t){return{bufferList:[new Eh(this.getTextData(t,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(t,e){e.bufferList[0].setAttributes(this.getTextData(e.sview,t))}getAtomRadius(){return 0}}function Od(t){const e=t.getAtomSet(),i=t.getBondSet(),r=t.getBondProxy();return i.forEach((function(t){r.index=t,e.clear(r.atomIndex1),e.clear(r.atomIndex2)})),e}Ne.add("label",$d);class Rd extends Sh{constructor(t,e,i){super(t,e,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(t){var e=t||{};this.multipleBond=st(e.multipleBond,"off"),this.bondSpacing=st(e.bondSpacing,1),this.linewidth=st(e.linewidth,2),this.lines=st(e.lines,!0),this.crosses=st(e.crosses,"lone"),this.crossSize=st(e.crossSize,.4),super.init(e)}getAtomRadius(t){return.1}getBondParams(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},e),super.getBondParams(t,e)}_crossData(t,e){if(t&&!t.position&&!t.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Od(e)});const r=e.getAtomData(this.getAtomParams(t,i)),s={},n=r.position,o=r.color,a=r.picking,c=(n||o).length,l=3*c;let h=new Float32Array(0),d=new Float32Array(0),u=new Float32Array(0),m=new Float32Array(0),p=0,f=new Float32Array(0);t&&!t.position||(h=s.position1=new Float32Array(l),d=s.position2=new Float32Array(l),p=this.crossSize/2),t&&!t.color||(u=s.color=new Float32Array(l),m=s.color2=new Float32Array(l)),t&&!t.picking||(f=new Float32Array(3*r.picking.array.length));for(let e=0;el?u[f]=-1:(c=Math.sqrt(l-a),u[f]=Math.floor(c)),++f;p[g]=d,m[g]=u}}function k(i){var r,s,n,a,d,f,b,v,w,A,S,C,P,I,k,M,T,B,D=3*i,$=i;r=Math.floor(.5+o*(t[D]+u[0])),s=Math.floor(.5+o*(t[D+1]+u[1])),n=Math.floor(.5+o*(t[D+2]+u[2]));var O,R=e[$],E=m[R],F=0,L=l*h,N=p[R];for(A=0;A=c||I>=l||k>=h)){var z=P*L+I*h+k;if(g)if(y[z]&_){if(y[z]&_){var V=x[z];V!==D&&b*b+v*v+w*w<(a=r+b-Math.floor(.5+o*(t[V]+u[0])))*a+(d=s+v-Math.floor(.5+o*(t[V+1]+u[1])))*d+(f=n+w-Math.floor(.5+o*(t[V+2]+u[2])))*f&&(x[z]=i)}}else y[z]|=_,x[z]=i;else y[z]|=_}F++}}function M(e){var i,r;for(console.time("EDTSurface fillvoxels"),i=0,r=y.length;i=c||_>=l||C>=h)){var L=A*F+_*h+C;if(y[L]&S){if(g){var N=x[L];b*b+v*v+w*w<(a=Math.floor(.5+o*(t[N]+u[0])))*a+(d=Math.floor(.5+o*(t[N+1]+u[1])))*d+(f=Math.floor(.5+o*(t[N+2]+u[2])))*f&&(x[L]=i)}}else y[L]|=S,g&&(x[L]=i)}R++}}function B(){var t,e,i,r;console.time("EDTSurface fastdistancemap");var s,n=Ed(c,l,h,Uint16Array,3),o=l*h,d=f*f,u=0;for(t=0;t0);var A,P=a*a,I=new Uint16Array(3);for(t=0;t=P)||(y[s]|=C,g&&y[s]&S&&(n.toArray(t,e,i,I),A=I[0]*o+I[1]*h+I[2],x[s]=x[A])));console.timeEnd("EDTSurface fastdistancemap")}function D(t,e,i,r){var s,n,o,a,d,u,m,p,f,g,x,v,w=new Uint16Array(3),A=0;if(0===i)return A;var I=-1,k=-1,M=-1,T=l*h;for(m=0,f=i;m-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&o-1&&d-1&&aT&&(T=O)}return{neighbourListLength:27*T+1,withinRadii:function(s,n,o,a,d){for(var u=0,m=p(s,c),f=p(n,l),g=p(o,h),y=Math.max(0,m-1),w=Math.max(0,f-1),_=Math.max(0,g-1),S=Math.min(b,m+2),C=Math.min(x,f+2),M=Math.min(v,g+2),T=y;Tu&&(u=h[t]);!function(){const t=$o(c,l,u,p,0);p=t.scaleFactor,y=t.dim,b=t.matrix,$=Math.max(5,2+Math.floor(m*p)),x=Si(y[0]*y[1]*y[2],-1001),v=new Int32Array(x.length),w=new Float32Array(y[0]),A=new Float32Array(y[1]),_=new Float32Array(y[2]),R(w,c[0],1/p),R(A,c[1],1/p),R(_,c[2],1/p)}(),function(){var t=0,e=2*Math.PI/g;C=new Float32Array(g),S=new Float32Array(g);for(var i=0;i=0;){if(n!==r&&n!==s&&F(n,t,e,i))return k=n,n;n=I[++o]}return k=-1,-1}function F(e,i,r,s){var n=3*e,o=d[e],a=t[n]-i,c=t[n+1]-r,l=t[n+2]-s;return a*a+c*c+l*l0&&u=0;)t{e(this._makeSurface(t.data.sd,i))}),(t=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",t),this.worker.terminate(),this.worker=void 0;const r=this.getSurface(i);e(r)}))}else{const t=this.getSurface(i);e(t)}}dispose(){this.worker&&this.worker.terminate()}}class Vd extends Sh{constructor(t,e,i){super(t,e,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),e.disablePicking=st(e.disablePicking,!0),this.surfaceType=st(e.surfaceType,"ms"),this.probeRadius=st(e.probeRadius,1.4),this.smooth=st(e.smooth,2),this.scaleFactor=st(e.scaleFactor,2),this.cutoff=st(e.cutoff,0),this.contour=st(e.contour,!1),this.background=st(e.background,!1),this.opaqueBack=st(e.opaqueBack,!0),this.filterSele=st(e.filterSele,""),this.colorVolume=st(e.colorVolume,void 0),this.useWorker=st(e.useWorker,!0),super.init(t)}prepareData(t,i,r){let s=this.__infoList[i];if(s||(s={},this.__infoList[i]=s),s.molsurf&&s.sele===t.selection.string)r(i);else{if(this.filterSele){const s=t.structure.getView(new pe(this.filterSele)),n=s.boundingBox.getSize(new e),o=Math.max(n.x,n.y,n.z),a=t.getAtomSetWithinPoint(s.center,o/2+6);if(0===(t=t.getView(new pe(t.getAtomSetWithinSelection(a,3).toSeleString()))).atomCount)return void r(i)}s.sele=t.selection.string,s.molsurf=new zd(t);const n=this.getSurfaceParams(),o=t=>{s.surface=t,r(i)};this.useWorker?s.molsurf.getSurfaceWorker(n,o):o(s.molsurf.getSurface(n))}}prepare(t){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((t=>{t&&t.molsurf&&t.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void t();const e=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,t()},i="default"===this.assembly?this.defaultAssembly:this.assembly,r=this.structure.biomolDict[i];r?r.partList.forEach(((t,i)=>{const s=t.getView(this.structureView);this.prepareData(s,i,(t=>{t===r.partList.length-1&&e()}))})):this.prepareData(this.structureView,0,e)}createData(t,e){const i=this.__infoList[e],r=i.surface;if(!r)return;const s={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,t)},n=[];if(r.contour){const t=new Xo(s,this.getBufferParams({wireframe:!1}));n.push(t)}else{Object.assign(s,{normal:r.getNormal(),picking:r.getPicking(t.getStructure())});const e=new jo(s,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const t=new qo(e);n.push(t)}else n.push(e)}return{bufferList:n,info:i}}updateData(t,e){const i={};if(t.position||t.radius)return this.__forceNewMolsurf=!0,void this.build();t.color&&(i.color=e.info.surface.getColor(this.getColorParams())),t.index&&(i.index=e.info.surface.getFilteredIndex(this.filterSele,e.sview)),e.bufferList[0].setAttributes(i)}setParameters(t,e={},i){return t&&t.filterSele&&(e.index=!0),t&&void 0!==t.colorVolume&&(e.color=!0),t&&t.wireframe&&(t.contour||void 0===t.contour&&this.contour)&&(t.wireframe=!1),super.setParameters(t,e,i),this}getSurfaceParams(t={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},t)}getColorParams(){const t=super.getColorParams();return t.volume=this.colorVolume,t}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((t=>{t&&t.molsurf&&t.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}Ne.add("surface",Vd);class Gd extends Sh{constructor(t,e,i){super(t,e,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(t){var e=t||{};this.pointSize=st(e.pointSize,1),this.sizeAttenuation=st(e.sizeAttenuation,!0),this.sortParticles=st(e.sortParticles,!1),this.useTexture=st(e.useTexture,!1),this.alphaTest=st(e.alphaTest,.5),this.forceTransparent=st(e.forceTransparent,!1),this.edgeBleach=st(e.edgeBleach,0),super.init(e)}createData(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new Wc(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||Object.assign(r,{position:i.position}),t&&!t.color||Object.assign(r,{color:i.color}),e.bufferList[0].setAttributes(r)}getAtomRadius(){return.1}}Ne.add("point",Gd),Ve.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const Ud=new Uint16Array([0,1,2,1,3,2]);function jd(t){return 3*(4*(t.position.length/3-1))}class Hd extends Uo{constructor(t,e={}){super({position:new Float32Array(jd(t)),color:new Float32Array(jd(t)),index:xt(jd(t),jd(t)/3),normal:new Float32Array(jd(t)),picking:t.picking},e),this.vertexShader="Ribbon.vert";const i=t.position.length/3-1,r=4*i,s=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(s)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),t.primitiveId=Pi(i),this.setAttributes(t),this.makeIndex()}setAttributes(t={}){const e=this.size/4,i=this.geometry.attributes;let r,s,n,o,a,c,l,h,d,u,m,p,f,g,y,b,x,v,w;t.position&&(r=t.position,l=i.position.array,i.position.needsUpdate=!0),t.normal&&(s=t.normal,h=i.normal.array,i.normal.needsUpdate=!0),t.size&&(n=t.size,d=i.size.array,i.size.needsUpdate=!0),t.dir&&(o=t.dir,u=i.dir.array,i.dir.needsUpdate=!0),t.color&&(a=t.color,m=i.color.array,i.color.needsUpdate=!0),t.primitiveId&&(c=t.primitiveId,p=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let A=n?n[0]:null;for(f=0;f{if(!(t.residueCount<4)){i.push(t);var r=new od(t,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedOrientation(),o=r.getSubdividedColor(this.getColorParams()),a=r.getSubdividedPicking(),c=r.getSubdividedSize(this.getRadiusParams());e.push(new Hd({position:s.position,normal:n.binormal,dir:n.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i{if(t.residueCount<4||t.isNucleic())return;const s=new Pa(t),n=s.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e+=n.size.length,i.push(n),r.push(s)}),t.getSelection());const s={begin:new Float32Array(3*e),end:new Float32Array(3*e),size:new Float32Array(e),color:new Float32Array(3*e),picking:{}};let n=new Float32Array(e),o=0;i.forEach((function(t){s.begin.set(t.begin,3*o),s.end.set(t.end,3*o),s.size.set(t.size,o),s.color.set(t.color,3*o),n.set(t.picking.array,o),o+=t.size.length})),e&&(s.picking=new Yn(n,t.getStructure()));return{bufferList:[new td({position1:s.begin,position2:s.end,color:s.color,color2:s.color,radius:s.size,picking:s.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:r,axisData:s}}updateData(t,e){if((t=t||{}).position)this.build();else{var i={};if(t.color||t.radius){var r=0;e.helixbundleList.forEach((i=>{var s=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t.color&&e.axisData.color.set(s.color,3*r),(t.radius||t.scale)&&e.axisData.size.set(s.size,r),r+=s.size.length})),t.color&&Object.assign(i,{color:e.axisData.color,color2:e.axisData.color}),(t.radius||t.scale)&&Object.assign(i,{radius:e.axisData.size})}e.bufferList[0].setAttributes(i)}}}Ne.add("rocket",qd);class Xd extends dd{constructor(t,e,i){super(t,e,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(t){var e=t||{};e.aspectRatio=1,e.tension=st(e.tension,.5),e.radiusScale=st(e.radiusScale,5),e.smoothSheet=!1,this.smooth=st(e.smooth,2),super.init(e)}getSpline(t){var e=new Ca(t);return new od(t,this.getSplineParams({directional:!1,positionIterator:e.getCenterIterator(this.smooth)}))}}Ne.add("rope",Xd);class Yd extends Sh{constructor(t,e,i){super(t,e,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(t){var e=t||{};e.useInteriorColor=st(e.useInteriorColor,!0),super.init(e)}createData(t){return{bufferList:[new Gc(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||Object.assign(r,{position:i.position}),t&&!t.color||Object.assign(r,{color:i.color}),t&&!t.radius||Object.assign(r,{radius:i.radius}),e.bufferList[0].setAttributes(r)}}function Kd(t){return 3*(t.position.length/3-1)*2}Ne.add("spacefill",Yd);class Zd extends Go{constructor(t,e={}){super({position:new Float32Array(Kd(t)),color:new Float32Array(Kd(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(t)}setAttributes(t){let e,i,r,s;const n=this.geometry.attributes;if(t.position&&(e=t.position,r=n.position.array,n.position.needsUpdate=!0),t.color&&(i=t.color,s=n.color.array,n.color.needsUpdate=!0),!e&&!i)return void Me.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let t=0;t{if(!(t.residueCount<4)){i.push(t);var r=new od(t,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedColor(this.getColorParams());e.push(new Zd(Object.assign({},s,n),this.getBufferParams()))}}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i{t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox)}))}}const lu=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},zo);class hu{constructor(t,e={}){this.group=new m,this.wireframeGroup=new m,this.pickingGroup=new m,this.visible=!0,this.parameters=nt(e,this.defaultParameters),this.splitPosition=new Float32Array(t.position1.length),this.cylinderRadius=new Float32Array(t.radius.length);const r=this.makeAttributes(t),s={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new td(r.cylinder,s),this.coneBuffer=new au(r.cone,s),this.geometry=new cu([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=st(e.matrix,new i),this.picking=t.picking}get defaultParameters(){return lu}set matrix(t){Go.prototype.setMatrix.call(this,t)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(t={}){const i=this.splitPosition,r=this.cylinderRadius,s=this.parameters.aspectRatio;let n,o;const a={},c={};if(t.radius){for(n=0,o=r.length;n(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){De&&Me.log(this[this.__objName])}}class Nu extends Lu{constructor(t,e){var i=e||{};super(t,i),this.firstModelOnly=st(i.firstModelOnly,!1),this.asTrajectory=st(i.asTrajectory,!1),this.cAlphaOnly=st(i.cAlphaOnly,!1),this.structure=new Cc(this.name,this.path),this.structureBuilder=new za(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class zu{constructor(t,e,i="",r,s=[]){this.structure=t,this.index=e,this.description=i,this.entityType=function(t){switch(t=t.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(r||""),this.chainIndexList=s,s.forEach((function(i){t.chainStore.entityIndex[i]=e}))}get type(){return function(t){switch(t){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(t){const e=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){e.index=i,t(e)}))}}const Vu={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class Gu{constructor(t=Vu){this.cartToFrac=new i,this.fracToCart=new i,this.a=t.a,this.b=t.b,this.c=t.c,this.alpha=t.alpha,this.beta=t.beta,this.gamma=t.gamma,this.spacegroup=t.spacegroup;const e=kt(this.alpha),r=kt(this.beta),s=kt(this.gamma),n=Math.cos(e),o=Math.cos(r),a=Math.cos(s),c=Math.sin(r),l=Math.sin(s);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-n*n-o*o-a*a+2*n*o*a),void 0===t.cartToFrac){const t=this.a*this.b*l/this.volume,e=(o*a-n)/(c*l);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*l,0,0,this.c*o,-this.c*c*e,1/t,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(t.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(t){const i=new Float32Array(24);if(t.unitcell){const r=t.unitcell,s=t.center.clone().applyMatrix4(r.cartToFrac).floor(),n=new e;let o=0;const a=function(t,e,a){n.set(t,e,a).add(s).applyMatrix4(r.fracToCart).toArray(i,o),o+=3};a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1)}return i}getCenter(t){return function(t,i=new e){const r=t.length;for(let e=0;e0)continue;let e,i,r,s,a,g=0;if(n){if(s=S.split(Wu),g=10===s.length?1:0,D=s[2],p&&"CA"!==D)continue;e=parseFloat(s[6-g]),i=parseFloat(s[7-g]),r=parseFloat(s[8-g])}else{if(D=S.substr(12,4).trim(),p&&"CA"!==D)continue;e=parseFloat(S.substr(30,8)),i=parseFloat(S.substr(38,8)),r=parseFloat(S.substr(46,8))}if(m){const t=3*b;if(y[t+0]=e,y[t+1]=i,y[t+2]=r,b+=1,x)continue}n?(P=parseInt(s[1]),a="",$="H"===S[0]?1:0,I=g?"":s[4],k=parseInt(s[5-g]),B="",M=s[3],R="",T=1):(P=parseInt(S.substr(6,5),h),l&&99999===P&&(h=16),$="H"===S[0]?1:0,I=S[21].trim(),k=parseInt(S.substr(22,4),d),l&&9999===k&&(d=16),B=S[26].trim(),M=S.substr(17,4).trim()||"MOL",O=parseFloat(S.substr(60,6)),R=S[16].trim(),T=parseFloat(S.substr(54,6)),t||(o?(a=S.substr(76,3).trim(),a in pn&&(a=pn[a])):(a=S.substr(76,2).trim(),I||(I=S.substr(72,4).trim())),E=parseInt((S.substr(79,1)+S.substr(78,1)).trim()))),dt.growIfFull(),dt.atomTypeId[pt]=ht.add(D,a),dt.x[pt]=e,dt.y[pt]=i,dt.z[pt]=r,dt.serial[pt]=P,dt.altloc[pt]=R.charCodeAt(0),dt.occupancy[pt]=isNaN(T)?0:T,n?(dt.partialCharge[pt]=parseFloat(s[9-g]),dt.radius[pt]=parseFloat(s[10-g])):(dt.bfactor[pt]=isNaN(O)?0:O,o&&(dt.partialCharge[pt]=parseFloat(S.substr(70,6))),isFinite(E)&&(dt.formalCharge||dt.addField("formalCharge",1,"int8"),dt.formalCharge[pt]=E));const v=qu(k,I,B);!$||K[v]||ju.includes(M)?tt||et===I||(Q+=1,J=Q.toString()):et===I&&rt===M&&(cn.includes(M)||it===k&&st===B)||(Q+=1,J=Q.toString(),it=k,rt=M,st=B),c.addAtom(ft,I,J,M,k,$,void 0,B),U[P]=pt,pt+=1,tt=!1,et=I}else if("CONECT"===C){const t=U[parseInt(S.substr(6,5))],e=[11,16,21,26],i={};if(void 0===t)continue;for(let r=0;r<4;++r){let s=parseInt(S.substr(e[r],5));if(!Number.isNaN(s)&&(s=U[s],void 0!==s))if(t0)continue;const s=e[l].replace(Zu,"");if(k&&"CA"!==s)continue;const T=parseFloat(e[x]),$=parseFloat(e[v]),O=parseFloat(e[w]);if(I){const e=3*r;if(t[e+0]=T,t[e+1]=$,t[e+2]=O,r+=1,X>0)continue}const R=e[h],E=parseInt(e[-1!==a?a:c]);let F=e[b];F="?"===F?"":F;const L=e[o],N=e[d],z="H"===e[p][0]?1:0,V=e[g],Y=parseFloat(e[A]),K=parseFloat(e[_]);let Z=e[m];if(Z="."===Z?"":Z,H.growIfFull(),H.atomTypeId[q]=j.add(s,V),H.x[q]=T,H.y[q]=$,H.z[q]=O,H.serial[q]=parseInt(e[f]),H.bfactor[q]=isNaN(Y)?0:Y,H.occupancy[q]=isNaN(K)?0:K,H.altloc[q]=Z.charCodeAt(0),C.addAtom(X,L,N,R,E,z,void 0,F),De){const t=B[N];void 0!==t&&t!==L&&De&&Me.warn(t,L)}B[N]=L;const Q=e[u];D[Q]||(D[Q]=new Set),D[Q].add(S.chainStore.count-1),q+=1}else{const t=n.match(Ku),e=t.length;N===L.length&&(N=0);for(let i=0;ic*c)return n.growIfFull(),n.atomTypeId[m]=n.atomTypeId[t],n.x[m]=h.x,n.y[m]=h.y,n.z[m]=h.z,n.occupancy[m]=n.occupancy[t],n.serial[m]=m,n.altloc[m]="A".charCodeAt(0),s.addAtom(0,"","","HET",1,!0),void(m+=1)}}}))}}(T,S,C),C.finalize(),S.finalizeAtoms(),Wa(S),S.finalizeBonds();else{var Y=function(t,e,i){var r,s,n,o,a=[],c=[],l=t.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(tm(l,"id"),r=0,s=l.beg_auth_seq_id.length;r0){o=o.split("(");var l=c(o[0]),h=c(o[1]);Object.keys(l).forEach((function(t){Object.keys(h).forEach((function(e){var r=new i;r.multiplyMatrices(l[t],h[e]),s[t+"x"+e]=r}))}))}else s=c(o);var d=[];for(var u in s)d.push(s[u]);var m=t;/^(0|[1-9][0-9]*)$/.test(m)&&(m="BU"+m);for(var p=a.asym_id_list[e].split(","),f=0,g=p.length;fA){var _=w;w=A,A=_;var S=p;p=x,x=S}if(0!==w&&0!==A)for(var C=0;Cb)continue}d=I.substr(5,5).trim(),u=parseInt(I.substr(0,5)),m=parseInt(I.substr(15,5)),v.growIfFull(),v.atomTypeId[w]=x.add(h),v.x[w]=T,v.y[w]=B,v.z[w]=D,v.serial[w]=m,r.addAtom(A,"","",d,u,0,"l"),w+=1}}}(0,i.length,i)})),r.finalize(),i.finalizeAtoms(),Ha(i),Wa(i),i.finalizeBonds(),Ga(i),De&&Me.timeEnd("GroParser._parse "+this.name)}});var nm=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function om(t,e,i){return e?new t(e.buffer,e.byteOffset,e.byteLength/(i||1)):void 0}function am(t){return om(DataView,t)}function cm(t){return om(Int8Array,t)}function lm(t){return om(Int32Array,t,4)}function hm(t,e){var i=t.length/2;e||(e=new Int16Array(i));for(var r=0,s=0;rn&&++a;e=new Int32Array(a)}for(i=0,r=0;is){for(var n=[],o=0;o0&&(o.biomolDict[t]=e)}const O=a.unitCell;O&&Array.isArray(O)&&O[0]?o.unitcell=new Gu({a:O[0],b:O[1],c:O[2],alpha:O[3],beta:O[4],gamma:O[5],spacegroup:a.spaceGroup}):o.unitcell=void 0,Ka(o,!0),Ya(o,!0),o.finalizeAtoms(),o.finalizeBonds(),Za(o),De&&Me.timeEnd("MmtfParser._parse "+this.name)}});const Am=/\s+/,_m={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};ze.add("mol2",class extends Nu{get type(){return"mol2"}_parse(){De&&Me.time("Mol2Parser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=t.frames;let n,o,a=!1;const c=t.atomMap,l=t.atomStore;l.resize(Math.round(this.streamer.data.length/60)),l.addField("partialCharge",1,"float32");let h=0,d=0,u=0,m=-1,p=0,f=0;const g=t.getAtomProxy(),y=t.getAtomProxy();this.streamer.eachChunkOfLines((function(b){!function(b,x,v){for(let w=b;wMOLECULE"===b?(f=1,d=0,++m):"@ATOM"===b?(f=2,u=l.count,r&&(o=0,n=new Float32Array(3*p),s.push(n),m>0&&(a=!0))):f="@BOND"===b?3:0;else if(1===f){if(0===d)t.title=b,t.id=b;else if(1===d){const t=b.split(Am);p=parseInt(t[0])}++d}else if(2===f){const t=b.split(Am);if(i&&m>0)continue;const s=parseFloat(t[2]),d=parseFloat(t[3]),u=parseFloat(t[4]);if(r){const t=3*o;if(n[t+0]=s,n[t+1]=d,n[t+2]=u,o+=1,a)continue}const p=t[0],f=t[1],g=t[5].split(".")[0],y=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",v=t[8]?parseFloat(t[8]):0;l.growIfFull(),l.atomTypeId[h]=c.add(f,g),l.x[h]=s,l.y[h]=d,l.z[h]=u,l.serial[h]=p,l.partialCharge[h]=v,e.addAtom(m,"","",x,y,1),h+=1}else if(3===f){if(i&&m>0)continue;if(r&&m>0)continue;const e=b.split(Am);g.index=parseInt(e[1])-1+u,y.index=parseInt(e[2])-1+u;const s=_m[e[3]];t.bondStore.addBond(g,y,s)}}}(0,b.length,b)})),e.finalize(),t.finalizeAtoms(),Ha(t),Ya(t,!0),Ka(t,!0),t.finalizeBonds(),ec(t),Ga(t),De&&Me.timeEnd("Mol2Parser._parse "+this.name)}});ze.add("pdbqt",class extends Xu{get type(){return"pdbqt"}});ze.add("pqr",class extends Xu{get type(){return"pqr"}});const Sm=/> +<(.+)>/;class Cm extends Nu{get type(){return"sdf"}_parse(){De&&Me.time("SdfParser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=this.streamer.peekLines(2);t.id=s[0].trim(),t.title=s[1].trim();const n=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/50)),h.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),u=t.getAtomProxy();let m=0,p=0,f=0,g=0;const y=[];let b,x,v,w,A,_,S,C,P,I,k,M,T,B,D=!1,$={};t.extraData.sdf=y;let O=!1,R=!1,E=!1,F=[],L=[];const N=new Map;this.streamer.eachChunkOfLines((function(s){!function(s,z,V){for(let G=s;G-1,O?N.clear():(x=parseInt(s.substr(0,3)),v=parseInt(s.substr(3,3)),w=4,A=w+x,_=A,S=_+v,r&&(a=0,o=new Float32Array(3*x),n.push(o),f>0&&(c=!0)));else if(O&&"COUNTS"===F[0])x=parseInt(F[1]),r&&(a=0,o=new Float32Array(3*x),n.push(o),f>0&&(c=!0));else if(O&&2==F.length)"ATOM"===F[1]?"BEGIN"===F[0]?R=!0:"END"===F[0]&&(R=!1):"BOND"===F[1]&&("BEGIN"===F[0]?E=!0:"END"===F[0]&&(E=!1));else if(R||!O&&p>=w&&p0)continue;let t=0;if(O){if(C=parseFloat(F[2]),P=parseFloat(F[3]),I=parseFloat(F[4]),M=F[1],T=parseInt(F[0]),N.set(T,m),k=M+T,F.length>6){let e=F.slice(6).find((t=>0===t.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else C=parseFloat(s.substr(0,10)),P=parseFloat(s.substr(10,10)),I=parseFloat(s.substr(20,10)),M=s.substr(31,3).trim(),k=M+(m-g+1);if(r){const t=3*a;if(o[t+0]=C,o[t+1]=P,o[t+2]=I,a+=1,c)continue}h.growIfFull(),h.atomTypeId[m]=l.add(k,M),h.x[m]=C,h.y[m]=P,h.z[m]=I,h.serial[m]=O?T:m,h.formalCharge[m]=t,e.addAtom(f,"","","HET",1,1),m+=1}else if(E||!O&&p>=_&&p0)continue;if(r&&f>0)continue;O?(d.index=N.get(parseInt(F[2])),u.index=N.get(parseInt(F[3])),B=parseInt(F[1])):(d.index=parseInt(s.substr(0,3))-1+g,u.index=parseInt(s.substr(3,3))-1+g,B=parseInt(s.substr(6,3))),t.bondStore.addBond(d,u,B)}else if("M CHG"===s.substr(0,6)){const t=parseInt(s.substr(6,3));for(let e=0,i=10;e"===s.charAt(0)&&(b=s.match(Sm))?(D=b[1],$[D]=[]):!1!==D&&s&&$[D].push(s);++p}}}(0,s.length,s)})),e.finalize(),t.finalizeAtoms(),t.finalizeBonds(),ec(t),De&&Me.timeEnd("SdfParser._parse "+this.name)}_postProcess(){ec(this.structure)}}ze.add("sdf",Cm),ze.add("sd",Cm),ze.add("mol",Cm);function Pm(t,e,i){return parseInt(t.substr(e,i).trim())}class Im extends Nu{get type(){return"prmtop"}_parse(){De&&Me.time("PrmtopParser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=t.atomMap,r=t.atomStore;r.addField("partialCharge",1,"float32"),r.addField("radius",1,"float32");const s=[],n={},o=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let a,c,l,h,d;o.forEach((t=>{n[t]=0}));let u,m,p,f,g,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(t){!function(t,e,i){for(let b=t;b0)return void Me.error("dcd format with fixed atoms unsupported, aborting");const p=n.NATOM,f=4*p;for(let i=0,a=n.NSET;i=1&&(i.timeOffset=(n.ISTART-1)*i.deltaTime),De&&Me.timeEnd("DcdParser._parse "+this.name)}});const Em={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Fm(t){switch(Number(t)){case Em.BYTE:return"byte";case Em.CHAR:return"char";case Em.SHORT:return"short";case Em.INT:return"int";case Em.FLOAT:return"float";case Em.DOUBLE:return"double";default:return"undefined"}}function Lm(t){switch(Number(t)){case Em.BYTE:case Em.CHAR:return 1;case Em.SHORT:return 2;case Em.INT:case Em.FLOAT:return 4;case Em.DOUBLE:return 8;default:return-1}}function Nm(t){switch(String(t)){case"byte":return Em.BYTE;case"char":return Em.CHAR;case"short":return Em.SHORT;case"int":return Em.INT;case"float":return Em.FLOAT;case"double":return Em.DOUBLE;default:return-1}}function zm(t,e){if(1!==t){const i=new Array(t);for(let r=0;r6,"non valid type "+h);const d=t.readUint32();let u=t.readUint32();2===i&&($m(u>0,"offsets larger than 4GB not supported"),u=t.readUint32()),c[0]===e&&(n+=d),s[r]={name:o,dimensions:c,attributes:l,type:Fm(h),size:d,offset:u,record:c[0]===e}}}return{variables:s,recordStep:n}}(t,r.recordId,e);return i.variables=s.variables,i.recordDimension.recordStep=s.recordStep,i}function qm(t){let e;const i=t.readUint32();if(i===Gm)return $m(t.readUint32()!==Gm,"wrong empty tag for list of attributes"),[];{$m(i!==Hm,"wrong tag for list of attributes");const r=t.readUint32();e=new Array(r);for(let i=0;i6,"non valid type "+s);const n=t.readUint32(),o=Vm(t,s,n);Om(t),e[i]={name:r,type:Fm(s),value:o}}}return e}class Xm{constructor(t){const e=new hi(t);e.setBigEndian(),$m("CDF"!==e.readChars(3),"should start with CDF");const i=e.readByte();$m(i>2,"unknown version"),this.header=Wm(e,i),this.buffer=e}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(t){return-1!==this.header.variables.findIndex((function(e){return e.name===t}))}getDataVariable(t){let e;return e="string"==typeof t?this.header.variables.find((function(e){return e.name===t})):t,$m(void 0===e,"variable not found"),this.buffer.seek(e.offset),e.record?function(t,e,i){const r=Nm(e.type),s=e.size?e.size/Lm(r):1,n=i.length,o=new Array(n),a=i.recordStep;for(let e=0;e=1&&(e.timeOffset=s[0]),s.length>=2&&(e.deltaTime=s[1]-s[0]),De&&Me.timeEnd("NctrajParser._parse "+this.name)}}ze.add("nctraj",Ym),ze.add("ncdf",Ym),ze.add("nc",Ym);ze.add("trr",class extends Dm{get type(){return"trr"}get isBinary(){return!0}_parse(){De&&Me.time("TrrParser._parse "+this.name);const t=vt(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,s=i.boxes,n=i.times;let o=0;for(;;){o+=8;const i=e.getInt32(o);o+=4,o+=i;const a=e.getInt32(o+8),c=e.getInt32(o+12),l=e.getInt32(o+16),h=e.getInt32(o+28),d=e.getInt32(o+32),u=e.getInt32(o+36),m=e.getInt32(o+40);o+=52;const p=a/9,f=3*m;if(8===p?n.push(e.getFloat64(o)):n.push(e.getFloat32(o)),o+=2*p,a){const t=new Float32Array(9);if(8===p)for(let i=0;i<9;++i)t[i]=10*e.getFloat64(o),o+=8;else for(let i=0;i<9;++i)t[i]=10*e.getFloat32(o),o+=4;s.push(t)}if(o+=c,o+=l,h){let i;if(8===p){i=new Float32Array(f);for(let t=0;t>8&65280|i>>24&255}i=new Float32Array(t,o,f);for(let t=0;t=t.byteLength)break}n.length>=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),De&&Me.timeEnd("TrrParser._parse "+this.name)}});const Km=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function Zm(t){let e=1,i=0;for(;t>=e&&i<32;)i++,e<<=1;return i}const Qm=new Uint8Array(32);function Jm(t,e){let i=1,r=0;Qm[0]=1;for(let r=0;r>=8;for(;0!==s;)Qm[t++]=255&s,s>>=8;i=t}let s=1;for(i--;Qm[i]>=s;)r++,s*=2;return r+8*i}function tp(t,e,i,r){const s=(1<=8;)o=o<<8|e[a++],c|=o>>n<0&&(n>n&(1<8;)ep[a++]=tp(t,e,8,o),r-=8;r>0&&(ep[a++]=tp(t,e,r,o));for(let t=i-1;t>0;t--){let e=0;for(let i=a-1;i>=0;i--){e=e<<8|ep[i];const r=e/s[t]|0;ep[i]=r,e-=r*s[t]}n[t]=e}n[0]=ep[0]|ep[1]<<8|ep[2]<<16|ep[3]<<24}ze.add("xtc",class extends Dm{get type(){return"xtc"}get isBinary(){return!0}_parse(){De&&Me.time("XtcParser._parse "+this.name);const t=vt(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,s=i.boxes,n=i.times,o=new Int32Array(6),a=new Int32Array(3),c=new Int32Array(3),l=new Uint32Array(3),h=new Float32Array(3),d=new Float32Array(3);let u=0;const m=new Int32Array(3),p=new Uint32Array(m.buffer);for(;;){let i;const f=e.getInt32(u+4);u+=12;const g=3*f;n.push(e.getFloat32(u)),u+=4;const y=new Float32Array(9);for(let t=0;t<9;++t)y[t]=10*e.getFloat32(u),u+=4;if(s.push(y),f<=9){i=new Float32Array(f);for(let t=0;t16777215?(c[0]=Zm(a[0]),c[1]=Zm(a[1]),c[2]=Zm(a[2]),f=0):f=Jm(3,a);let y=e.getInt32(u);u+=4;let b=y-1;b=9>b?9:b;let x=Km[b]/2|0,v=Km[y]/2|0;l[0]=l[1]=l[2]=Km[y];let w=4*Math.ceil(e.getInt32(u)/4);u+=4;const A=1/n;let _=0,S=0;const C=new Uint8Array(t,u);for(h[0]=h[1]=h[2]=0;S0){h[0]=h[1]=h[2]=0;for(let t=0;t<_;t+=3){if(ip(m,C,3,y,l,h,p),S++,h[0]+=d[0]-v,h[1]+=d[1]-v,h[2]+=d[2]-v,0===t){let t=h[0];h[0]=d[0],d[0]=t,t=h[1],h[1]=d[1],d[1]=t,t=h[2],h[2]=d[2],d[2]=t,i[r++]=d[0]*A,i[r++]=d[1]*A,i[r++]=d[2]*A}else d[0]=h[0],d[1]=h[1],d[2]=h[2];i[r++]=h[0]*A,i[r++]=h[1]*A,i[r++]=h[2]*A}}else i[r++]=h[0]*A,i[r++]=h[1]*A,i[r++]=h[2]*A;if(y+=t,t<0?(v=x,x=y>9?Km[y-1]/2|0:0):t>0&&(x=v,v=Km[y]/2|0),l[0]=l[1]=l[2]=Km[y],0===l[0]||0===l[1]||0===l[2])return void console.error("(xdrfile error) Undefined error.")}u+=w}for(let t=0;t=t.byteLength)break}n.length>=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),De&&Me.timeEnd("XtcParser._parse "+this.name)}});class rp extends Lu{constructor(t,e){const i=e||{};super(t,i),this.volume=new Eo(this.name,this.path),this.voxelSize=st(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new i}}const sp=/\s+/,np=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,op=.529177210859;class ap extends rp{get type(){return"cube"}_parse(){De&&Me.time("CubeParser._parse "+this.name);const t=this.volume,i=this.streamer.peekLines(6),r={},s=op*this.voxelSize;function n(t,e){var r=i[t].trim().split(sp)[e];return parseFloat(r)}r.atomCount=Math.abs(n(2,0)),r.originX=n(2,1)*op,r.originY=n(2,2)*op,r.originZ=n(2,3)*op,r.NVX=n(3,0),r.NVY=n(4,0),r.NVZ=n(5,0),r.basisX=new e(n(3,1),n(3,2),n(3,3)).multiplyScalar(s),r.basisY=new e(n(4,1),n(4,2),n(4,3)).multiplyScalar(s),r.basisZ=new e(n(5,1),n(5,2),n(5,3)).multiplyScalar(s);const o=new Float32Array(r.NVX*r.NVY*r.NVZ);let a=0,c=0;const l=n(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(t){!function(t,e,i){for(let s=t;s=r.atomCount+6+l){const e=t.match(np);for(let t=0,i=e.length;t>8&255}e.xStart=n[0],e.yStart=n[1],e.zStart=n[2],e.xExtent=n[3],e.yExtent=n[4],e.zExtent=n[5],e.xRate=n[6],e.yRate=n[7],e.zRate=n[8];const t=1/n[17],s=t*this.voxelSize;e.xlen=n[9]*s,e.ylen=n[10]*s,e.zlen=n[11]*s,e.alpha=n[12]*t,e.beta=n[13]*t,e.gamma=n[14]*t,i=n[15]/100,r=n[16],e.gamma=n[14]*t}t.header=e,De&&Me.log(e,i,r);const c=new Float32Array(e.xExtent*e.yExtent*e.zExtent);let l=512;const h=Math.ceil(e.xExtent/8),d=Math.ceil(e.yExtent/8),u=Math.ceil(e.zExtent/8);for(var m=0;ms){const t=i[r].trim();if(""!==t){const e=t.split(lp);for(let t=0,i=e.length;t=s&&(p-s)%u!=0&&m=0?i-1:i+e/3)},parseNormalIndex:function(t,e){var i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},addVertex:function(t,e,i){var r=this.vertices,s=this.object.geometry.vertices;s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addVertexLine:function(t){var e=this.vertices,i=this.object.geometry.vertices;i.push(e[t+0]),i.push(e[t+1]),i.push(e[t+2])},addNormal:function(t,e,i){var r=this.normals,s=this.object.geometry.normals;s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addFace:function(t,e,i,r,s,n,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(t,l),d=this.parseVertexIndex(e,l),u=this.parseVertexIndex(i,l);if(void 0===r?this.addVertex(h,d,u):(c=this.parseVertexIndex(r,l),this.addVertex(h,d,c),this.addVertex(d,u,c)),void 0!==s){var m=this.normals.length;h=this.parseNormalIndex(s,m),d=s===n?h:this.parseNormalIndex(n,m),u=s===o?h:this.parseNormalIndex(o,m),void 0===r?this.addNormal(h,d,u):(c=this.parseNormalIndex(a,m),this.addNormal(h,d,c),this.addNormal(d,u,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,i=0,r=t.length;i0?x.setAttribute("normal",new M(new Float32Array(b.normals),3)):x.computeVertexNormals(),y.push(x)}}return y}};ze.add("obj",class extends Ip{get type(){return"obj"}getLoader(){return new kp}});const Mp=function(){this.propertyNameMapping={}};Mp.prototype={constructor:Mp,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",r=0;r=r.elements[o].count&&(o++,a=0);var h=this.parseASCIIElement(r.elements[o].properties,l);this.handleElement(i,r.elements[o].name,h),a++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e{const s=r.length;for(let n=0;n/g,""),{declaration:e(),root:i()};function e(){if(!s(/^<\?xml\s*/))return;const t={attributes:{}};for(;!n()&&!o("?>");){const e=r();if(!e)return t;t.attributes[e.name]=e.value}return s(/\?>\s*/),t}function i(){const t=s(Dp);if(!t)return;const e={name:t[1],attributes:{},children:[]};for(;!(n()||o(">")||o("?>")||o("/>"));){const t=r();if(!t)return e;e.attributes[t.name]=t.value}if(s(/^\s*\/>\s*/))return e;let a;for(s(/\??>\s*/),e.content=function(){const t=s($p);return t?t[1]:""}();a=i();)e.children.push(a);return s(/^<\/[\w-:.]+>\s*/),e}function r(){const t=s(Op);var e;if(t)return{name:t[1],value:(e=t[2],e.replace(Bp,""))}}function s(e){const i=t.match(e);if(i)return t=t.slice(i[0].length),i}function n(){return 0===t.length}function o(e){return 0===t.indexOf(e)}}class Ep extends Lu{constructor(t,e){const i=e||{};super(t,i),this.useDomParser=st(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(t){return Rp(t)}__domParser(t){return(new window.DOMParser).parseFromString(t,"text/xml")}_parse(){De&&Me.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),De&&Me.timeEnd("XmlParser._parse "+this.name)}}function Fp(t,e){const i=t.getNamedItem(e);return null!==i?i.value:""}function Lp(t,e,i=!1){const r=Fp(t,"icode").trim(),s=Fp(t,"chain").trim(),n=Fp(t,"altcode");let o=Fp(t,"resnum");return r&&(o+="^"+r),s&&(o+=":"+s),e&&(o+="."+e),i&&n.trim()&&(o+="%"+n),o+="/"+(parseInt(Fp(t,"model"))-1),o}function Np(t){const e=Fp(t,"chain").trim();let i=`[${Fp(t,"rescode")}]${Fp(t,"resnum")}`;return e&&(i+=`:${e}`),i}function zp(t,e,i){void 0===t[e]?t[e]=i:t[e]|=i}function Vp(t,e){return null!==t&&t.value===e}function Gp(t,e,i){let r=0;const s=e.getElementsByTagName("clash");for(let e=0,i=s.length;e0&&(r+=1);e.getElementsByTagName("bond-outlier").length>0&&(r+=1);return e.getElementsByTagName("plane-outlier").length>0&&(r+=1),Vp(i.getNamedItem("rota"),"OUTLIER")&&(r+=1),Vp(i.getNamedItem("rama"),"OUTLIER")&&(r+=1),Vp(i.getNamedItem("RNApucker"),"outlier")&&(r+=1),r}ze.add("xml",Ep);class Up{constructor(t,e){this.name=t,this.path=e,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){De&&Me.time("Validation.fromXml");const e=this.rsrzDict,i=this.rsccDict,r=this.rciDict,s=this.clashDict,n=this.clashArray,o=this.geoDict,a=this.geoAtomDict,c=this.atomDict,l=t.getElementsByTagName("Entry");if(1===l.length){const t=l[0].getElementsByTagName("chemical_shift_list");if(1===t.length){const e=t[0].getElementsByTagName("random_coil_index");for(let t=0,i=e.length;t0&&(o[r]=t)}else{const t=e.getElementsByTagName("clash"),i=e.getElementsByTagName("mog-bond-outlier"),n=e.getElementsByTagName("mog-angle-outlier");if(i.length>0||n.length>0||t.length>0){const e={};a[r]=e;for(let i=0,r=t.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(s=s+e[r++]|0)|0}while(--o);s%=65521,n%=65521}return s|n<<16|0}ze.add("validation",class extends Ep{constructor(t,e){super(t,e||{}),this.useDomParser=!0,this.validation=new Up(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),De&&Me.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),De&&Me.timeEnd("ValidationParser._parse "+this.name)}});var qp=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();function Xp(t,e,i,r){var s=qp,n=r+i;t^=-1;for(var o=r;o>>8^s[255&(t^e[o])];return-1^t}var Yp=30,Kp=12;function Zp(t,e){var i,r,s,n,o,a,c,l,h,d,u,m,p,f,g,y,b,x,v,w,A,_,S,C,P;i=t.state,r=t.next_in,C=t.input,s=r+(t.avail_in-5),n=t.next_out,P=t.output,o=n-(e-t.avail_out),a=n+(t.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,d=i.wnext,u=i.window,m=i.hold,p=i.bits,f=i.lencode,g=i.distcode,y=(1<>>=v=x>>>24,p-=v,0===(v=x>>>16&255))P[n++]=65535&x;else{if(!(16&v)){if(0==(64&v)){x=f[(65535&x)+(m&(1<>>=v,p-=v),p<15&&(m+=C[r++]<>>=v=x>>>24,p-=v,!(16&(v=x>>>16&255))){if(0==(64&v)){x=g[(65535&x)+(m&(1<c){t.msg="invalid distance too far back",i.mode=Yp;break t}if(m>>>=v,p-=v,A>(v=n-o)){if((v=A-v)>h&&i.sane){t.msg="invalid distance too far back",i.mode=Yp;break t}if(_=0,S=u,0===d){if(_+=l-v,v2;)P[n++]=S[_++],P[n++]=S[_++],P[n++]=S[_++],w-=3;w&&(P[n++]=S[_++],w>1&&(P[n++]=S[_++]))}else{_=n-A;do{P[n++]=P[_++],P[n++]=P[_++],P[n++]=P[_++],w-=3}while(w>2);w&&(P[n++]=P[_++],w>1&&(P[n++]=P[_++]))}break}}break}}while(r>3,m&=(1<<(p-=w<<3))-1,t.next_in=r,t.next_out=n,t.avail_in=r=1&&0===T[w];w--);if(A>w&&(A=w),0===w)return s[n++]=20971520,s[n++]=20971520,a.bits=1,0;for(v=1;v0&&(t===ef||1!==w))return-1;for(B[1]=0,b=1;bJp||t===sf&&P>tf)return 1;for(;;){p=b-S,o[x]m?(f=D[$+o[x]],g=k[M+o[x]]):(f=96,g=0),c=1<>S)+(l-=c)]=p<<24|f<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,x++,0==--T[b]){if(b===w)break;b=e[i+o[x]]}if(b>A&&(I&d)!==h){for(0===S&&(S=A),u+=v,C=1<<(_=b-S);_+SJp||t===sf&&P>tf)return 1;s[h=I&d]=A<<24|_<<16|u-n|0}}return 0!==I&&(s[u+I]=b-S<<24|64<<16|0),a.bits=A,0}var hf=1,df=2,uf=0,mf=-2,pf=1,ff=12,gf=30,yf=852,bf=592;function xf(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function vf(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function wf(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=pf,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(yf),e.distcode=e.distdyn=new Int32Array(bf),e.sane=1,e.back=-1,uf):mf}(t)):mf}function Af(t,e){var i,r;return t?(r=new vf,t.state=r,r.window=null,i=function(t,e){var i,r;return t&&t.state?(r=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?mf:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,wf(t))):mf}(t,e),i!==uf&&(t.state=null),i):mf}var _f,Sf,Cf=!0;function Pf(t){if(Cf){var e;for(_f=new Int32Array(512),Sf=new Int32Array(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(lf(hf,t.lens,0,288,_f,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;lf(df,t.lens,0,32,Sf,0,t.work,{bits:5}),Cf=!1}t.lencode=_f,t.lenbits=9,t.distcode=Sf,t.distbits=5}function If(t,e,i,r){var s,n=t.state;return null===n.window&&(n.wsize=1<=n.wsize?(Hp(n.window,e,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((s=n.wsize-n.wnext)>r&&(s=r),Hp(n.window,e,i-r,s,n.wnext),(r-=s)?(Hp(n.window,e,i-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=Xp(i.check,I,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=gf;break}if(8!=(15&l)){t.msg="unknown compression method",i.mode=gf;break}if(h-=4,A=8+(15&(l>>>=4)),0===i.wbits)i.wbits=A;else if(A>i.wbits){t.msg="invalid window size",i.mode=gf;break}i.dmax=1<>8&1),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Xp(i.check,I,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break t;a--,l+=r[n++]<>>8&255,I[2]=l>>>16&255,I[3]=l>>>24&255,i.check=Xp(i.check,I,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break t;a--,l+=r[n++]<>8),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Xp(i.check,I,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break t;a--,l+=r[n++]<>>8&255,i.check=Xp(i.check,I,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((m=i.length)>a&&(m=a),m&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Hp(i.head.extra,r,n,m,A)),512&i.flags&&(i.check=Xp(i.check,r,m,n)),a-=m,n+=m,i.length-=m),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break t;m=0;do{A=r[n+m++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&m>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=ff;break;case 10:for(;h<32;){if(0===a)break t;a--,l+=r[n++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break t;a--,l+=r[n++]<>>=1)){case 0:i.mode=14;break;case 1:if(Pf(i),i.mode=20,6===e){l>>>=2,h-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=gf}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break t;a--,l+=r[n++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=gf;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(m=i.length){if(m>a&&(m=a),m>c&&(m=c),0===m)break t;Hp(s,r,n,m,o),a-=m,n+=m,c-=m,o+=m,i.length-=m;break}i.mode=ff;break;case 17:for(;h<14;){if(0===a)break t;a--,l+=r[n++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=gf;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[k[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},_=lf(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,_){t.msg="invalid code lengths set",i.mode=gf;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=g,h-=g,i.lens[i.have++]=b;else{if(16===b){for(C=g+2;h>>=g,h-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=gf;break}A=i.lens[i.have-1],m=3+(3&l),l>>>=2,h-=2}else if(17===b){for(C=g+3;h>>=g)),l>>>=3,h-=3}else{for(C=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+m>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=gf;break}for(;m--;)i.lens[i.have++]=A}}if(i.mode===gf)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=gf;break}if(i.lenbits=9,S={bits:i.lenbits},_=lf(hf,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,_){t.msg="invalid literal/lengths set",i.mode=gf;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},_=lf(df,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,_){t.msg="invalid distances set",i.mode=gf;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(a>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=n,t.avail_in=a,i.hold=l,i.bits=h,Zp(t,u),o=t.next_out,s=t.output,c=t.avail_out,n=t.next_in,r=t.input,a=t.avail_in,l=i.hold,h=i.bits,i.mode===ff&&(i.back=-1);break}for(i.back=0;y=(P=i.lencode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=b,0===y){i.mode=26;break}if(32&y){i.back=-1,i.mode=ff;break}if(64&y){t.msg="invalid literal/length code",i.mode=gf;break}i.extra=15&y,i.mode=22;case 22:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;y=(P=i.distcode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&y){t.msg="invalid distance code",i.mode=gf;break}i.offset=b,i.extra=15&y,i.mode=24;case 24:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=gf;break}i.mode=25;case 25:if(0===c)break t;if(m=u-c,i.offset>m){if((m=i.offset-m)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=gf;break}m>i.wnext?(m-=i.wnext,p=i.wsize-m):p=i.wnext-m,m>i.length&&(m=i.length),f=i.window}else f=s,p=o-i.offset,m=i.length;m>c&&(m=c),c-=m,i.length-=m;do{s[o++]=f[p++]}while(--m);0===i.length&&(i.mode=21);break;case 26:if(0===c)break t;s[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break t;a--,l|=r[n++]<=252?6:$f>=248?5:$f>=240?4:$f>=224?3:$f>=192?2:1;function Of(t){var e,i,r,s,n,o=t.length,a=0;for(s=0;s>>6,e[n++]=128|63&i):i<65536?(e[n++]=224|i>>>12,e[n++]=128|i>>>6&63,e[n++]=128|63&i):(e[n++]=240|i>>>18,e[n++]=128|i>>>12&63,e[n++]=128|i>>>6&63,e[n++]=128|63&i);return e}function Rf(t,e){var i,r,s,n,o=e||t.length,a=new Array(2*o);for(r=0,i=0;i4)a[r++]=65533,i+=n-1;else{for(s&=2===n?31:3===n?15:7;n>1&&i1?a[r++]=65533:s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|1023&s)}return function(t,e){if(e<65537&&(t.subarray&&Bf||!t.subarray&&Tf))return String.fromCharCode.apply(null,jp(t,e));for(var i="",r=0;rt.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Df[t[i]]>e?i:e}Df[254]=Df[254]=1;var Ff=0,Lf={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Nf(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function zf(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Vf=Object.prototype.toString;function Gf(t){if(!(this instanceof Gf))return new Gf(t);this.options=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])}}return t}({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nf,this.strm.avail_out=0;var i,r,s,n=Af(this.strm,e.windowBits);if(n!==Ff)throw new Error(Lf[n]);this.header=new zf,i=this.strm,r=this.header,i&&i.state&&(0==(2&(s=i.state).wrap)||(s.head=r,r.done=!1))}Gf.prototype.push=function(t,e){var i,r,s,n,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,d=!1;if(this.ended)return!1;r=e===~~e?e:!0===e?4:0,"string"==typeof t?c.input=function(t){for(var e=new Uint8Array(t.length),i=0,r=e.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(t){if(!t||!t.state)return mf;var e=t.state;return e.window&&(e.window=null),t.state=null,uf}(this.strm),this.onEnd(i),this.ended=!0,i===Ff):2!==r||(this.onEnd(Ff),c.avail_out=0,!0)},Gf.prototype.onData=function(t){this.chunks.push(t)},Gf.prototype.onEnd=function(t){t===Ff&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,i,r,s,n,o;for(r=0,e=0,i=t.length;e({path:t,data:e.data})))}getUrl(t){const e=ri(t);return`${this.baseUrl}file/${e.path}${e.query}`}getCountUrl(t){const e=ri(t);return`${this.baseUrl}traj/numframes/${e.path}${e.query}`}getFrameUrl(t,e){const i=ri(t);return`${this.baseUrl}traj/frame/${e}/${i.path}${i.query}`}getFrameParams(t,e){return`atomIndices=${e.join(";")}`}getPathUrl(t,e){const i=ri(t);return`${this.baseUrl}traj/path/${e}/${i.path}${i.query}`}getExt(t){return ri(t).ext}}function eg(t,e){return{type:"integer",max:t,min:e}}function ig(t,e,i){return{type:"number",precision:t,max:e,min:i}}function rg(t,e,i){return{type:"range",step:t,max:e,min:i}}function sg(...t){return{type:"select",options:t.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:e})),{})}}const ng={backgroundColor:{type:"color"},quality:sg("auto","low","medium","high"),sampleLevel:rg(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:ig(1,10,0),zoomSpeed:ig(1,10,0),panSpeed:ig(1,10,0),clipNear:rg(1,100,0),clipFar:rg(1,100,0),clipDist:eg(200,0),clipMode:sg("scene","camera"),clipScale:sg("relative","absolute"),fogNear:rg(1,100,0),fogFar:rg(1,100,0),cameraType:sg("perspective","orthographic","stereo"),cameraEyeSep:ig(3,1,.01),cameraFov:rg(1,120,15),lightColor:{type:"color"},lightIntensity:ig(2,10,0),ambientColor:{type:"color"},ambientIntensity:ig(2,10,0),hoverTimeout:eg(1e4,-1),tooltip:{type:"boolean"},mousePreset:sg(...Object.keys(Zo))};const og="2.2.0";export{zh as AngleRepresentation,hu as ArrowBuffer,La as Assembly,ed as AxesRepresentation,rd as BackboneRepresentation,id as BallAndStickRepresentation,sd as BaseRepresentation,fu as BoxBuffer,Tc as BufferRepresentation,dd as CartoonRepresentation,hl as Collection,zt as Colormaker,Fe as ColormakerRegistry,ll as Component,$l as ComponentCollection,au as ConeBuffer,ud as ContactRepresentation,ui as Counter,td as CylinderBuffer,Le as DatasourceRegistry,De as Debug,Ge as DecompressorRegistry,gd as DihedralHistogramRepresentation,md as DihedralRepresentation,bd as DistanceRepresentation,wu as EllipsoidBuffer,pl as Frames,Ad as HelixorientRepresentation,Bd as HyperballRepresentation,$a as Kdtree,ta as KeyActions,$d as LabelRepresentation,tr as LeftMouseButton,_d as LicoriceRepresentation,Rd as LineRepresentation,We as ListingDatasource,tg as MdsrvDatasource,Te as MeasurementDefaultParams,Uo as MeshBuffer,er as MiddleMouseButton,zd as MolecularSurface,Vd as MolecularSurfaceRepresentation,Ko as MouseActions,Pu as OctahedronBuffer,ze as ParserRegistry,ai as PdbWriter,br as PickingProxy,Wc as PointBuffer,Gd as PointRepresentation,Nr as Queue,dl as RepresentationCollection,nl as RepresentationElement,Ne as RepresentationRegistry,Wd as RibbonRepresentation,ir as RightMouseButton,qd as RocketRepresentation,Xd as RopeRepresentation,Re as ScriptExtensions,ci as SdfWriter,pe as Selection,Mc as Shape,Ll as ShapeComponent,Yd as SpacefillRepresentation,Ts as SpatialHash,Gc as SphereBuffer,Fl as Stage,Jf as StaticDatasource,di as StlWriter,Cc as Structure,Tl as StructureComponent,Ml as StructureComponentDefaultParameters,Sh as StructureRepresentation,fl as Superposition,Bl as SurfaceComponent,Bu as TetrahedronBuffer,Eh as TextBuffer,Fu as TorusBuffer,Qd as TraceRepresentation,qe as TrajectoryDatasource,yl as TrajectoryPlayer,Jd as TubeRepresentation,ng as UIStageParameters,tu as UnitcellRepresentation,eu as ValidationRepresentation,og as Version,Ji as Viewer,Eo as Volume,Dl as VolumeComponent,Nh as WidelineBuffer,ni as autoLoad,ic as concatStructures,dt as download,at as flatten,si as getDataInfo,ri as getFileInfo,rt as getQuery,tc as guessElement,Oe as setDebug,Xe as setListingDatasource,Be as setMeasurementDefaultParams,Ye as setTrajectoryDatasource,kl as superpose,ut as throttle,gt as uniqueArray}; //# sourceMappingURL=ngl.esm.js.map diff --git a/dist/ngl.esm.js.map b/dist/ngl.esm.js.map index 64a36f7d..3edfb398 100644 --- a/dist/ngl.esm.js.map +++ b/dist/ngl.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"ngl.esm.js","sources":["../src/polyfills.js","../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/parser/parser-registry.ts","../src/worker/worker-utils.ts","../src/worker/worker-registry.ts","../src/globals.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../src/writer/writer.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/utils/io-buffer.ts","../src/writer/stl-writer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/constants.ts","../src/stage/mouse-observer.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/parser/dcd-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../src/parser/validation-parser.ts","../lib/pako_inflate.es6.js","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/datasource/mdsrv-datasource.ts","../src/ui/parameters.ts","../src/version.ts","../src/ngl.ts"],"sourcesContent":["/**\n * @file shims\n * @private\n * @author Alexander Rose \n */\n\n/// ///////////\n// Polyfills\n\nif (typeof window !== 'undefined') {\n (function () {\n 'use strict'\n // Console-polyfill. MIT license.\n // https://github.com/paulmillr/console-polyfill\n // Make it safe to do console.log() always.\n\n window.console = window.console || {}\n var con = window.console\n var prop, method\n var empty = {}\n var dummy = function () {}\n var properties = 'memory'.split(',')\n var methods = (\n 'assert,clear,count,debug,dir,dirxml,error,exception,group,' +\n 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +\n 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn'\n ).split(',')\n\n while ((prop = properties.pop())) if (!con[prop]) con[prop] = empty\n while ((method = methods.pop())) if (!con[method]) con[method] = dummy\n })()\n}\n\nif (typeof window !== 'undefined' && typeof window.HTMLCanvasElement !== 'undefined' && !window.HTMLCanvasElement.prototype.toBlob) {\n // http://code.google.com/p/chromium/issues/detail?id=67587#57\n Object.defineProperty(window.HTMLCanvasElement.prototype, 'toBlob', {\n\n value: function (callback, type, quality) {\n var bin = window.atob(this.toDataURL(type, quality).split(',')[ 1 ])\n var len = bin.length\n var len32 = len >> 2\n var a8 = new Uint8Array(len)\n var a32 = new Uint32Array(a8.buffer, 0, len32)\n\n for (var i = 0, j = 0; i < len32; i++) {\n a32[i] = (\n bin.charCodeAt(j++) |\n bin.charCodeAt(j++) << 8 |\n bin.charCodeAt(j++) << 16 |\n bin.charCodeAt(j++) << 24\n )\n }\n\n var tailLength = len & 3\n\n while (tailLength--) {\n a8[ j ] = bin.charCodeAt(j++)\n }\n\n callback(new window.Blob([ a8 ], { 'type': type || 'image/png' }))\n }\n\n })\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt\nMath.cbrt = Math.cbrt || function (x) {\n var y = Math.pow(Math.abs(x), 1 / 3)\n return x < 0 ? -y : y\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\nif (!Math.sign) {\n Math.sign = function (x) {\n // If x is NaN, the result is NaN.\n // If x is -0, the result is -0.\n // If x is +0, the result is +0.\n // If x is negative and not -0, the result is -1.\n // If x is positive and not +0, the result is +1.\n x = +x // convert to a number\n if (x === 0 || isNaN(x)) {\n return Number(x)\n }\n return x > 0 ? 1 : -1\n }\n}\n\nif (!Number.isInteger) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\n Number.isInteger = function isInteger (nVal) {\n return typeof nVal === 'number' && isFinite(nVal) && nVal > -9007199254740992 && nVal < 9007199254740992 && Math.floor(nVal) === nVal\n }\n}\n\nif (!Number.isNaN) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN\n Number.isNaN = function isNaN (value) {\n return value !== value // eslint-disable-line no-self-compare\n }\n}\n\nif (!Object.assign) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n Object.defineProperty(Object, 'assign', {\n\n enumerable: false,\n configurable: true,\n writable: true,\n\n value: function (target/*, firstSource */) {\n 'use strict'\n if (target === undefined || target === null) { throw new TypeError('Cannot convert first argument to object') }\n\n var to = Object(target)\n\n var hasPendingException = false\n var pendingException\n\n for (var i = 1; i < arguments.length; i++) {\n var nextSource = arguments[i]\n if (nextSource === undefined || nextSource === null) { continue }\n\n var keysArray = Object.keys(Object(nextSource))\n for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {\n var nextKey = keysArray[nextIndex]\n try {\n var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey)\n if (desc !== undefined && desc.enumerable) { to[nextKey] = nextSource[nextKey] }\n } catch (e) {\n if (!hasPendingException) {\n hasPendingException = true\n pendingException = e\n }\n }\n }\n\n if (hasPendingException) { throw pendingException }\n }\n\n return to\n }\n\n })\n}\n\nif (!String.prototype.startsWith) {\n /*! https://mths.be/startswith v0.2.0 by @mathias */\n\n (function () {\n 'use strict' // needed to support `apply`/`call` with `undefined`/`null`\n var defineProperty = (function () {\n // IE 8 only supports `Object.defineProperty` on DOM elements\n var result\n try {\n var object = {}\n var $defineProperty = Object.defineProperty\n result = $defineProperty(object, object, object) && $defineProperty\n } catch (error) {} // eslint-disable-line no-empty\n return result\n }())\n var toString = {}.toString\n var startsWith = function (search) {\n if (this === null) {\n throw TypeError()\n }\n var string = String(this)\n if (search && toString.call(search) === '[object RegExp]') {\n throw TypeError()\n }\n var stringLength = string.length\n var searchString = String(search)\n var searchLength = searchString.length\n var position = arguments.length > 1 ? arguments[1] : undefined\n // `ToInteger`\n var pos = position ? Number(position) : 0\n if (Number.isNaN(pos)) {\n pos = 0\n }\n var start = Math.min(Math.max(pos, 0), stringLength)\n // Avoid the `indexOf` call if no match is possible\n if (searchLength + start > stringLength) {\n return false\n }\n var index = -1\n while (++index < searchLength) {\n if (string.charCodeAt(start + index) !== searchString.charCodeAt(index)) {\n return false\n }\n }\n return true\n }\n if (defineProperty) {\n defineProperty(String.prototype, 'startsWith', {\n 'value': startsWith,\n 'configurable': true,\n 'writable': true\n })\n } else {\n // eslint-disable-next-line no-extend-native\n String.prototype.startsWith = startsWith\n }\n }())\n}\n\nif (!String.prototype.endsWith) {\n // eslint-disable-next-line no-extend-native\n String.prototype.endsWith = function (searchString, position) {\n var subjectString = this.toString()\n if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {\n position = subjectString.length\n }\n position -= searchString.length\n var lastIndex = subjectString.indexOf(searchString, position)\n return lastIndex !== -1 && lastIndex === position\n }\n}\n\nif (!String.prototype.repeat) {\n // eslint-disable-next-line no-extend-native\n String.prototype.repeat = function (count) {\n 'use strict'\n if (this === null) {\n throw new TypeError('can\\'t convert ' + this + ' to object')\n }\n var str = '' + this\n count = +count\n if (Number.isNaN(count)) {\n count = 0\n }\n if (count < 0) {\n throw new RangeError('repeat count must be non-negative')\n }\n if (count === Infinity) {\n throw new RangeError('repeat count must be less than infinity')\n }\n count = Math.floor(count)\n if (str.length === 0 || count === 0) {\n return ''\n }\n // Ensuring count is a 31-bit integer allows us to heavily optimize the\n // main part. But anyway, most current (August 2014) browsers can't handle\n // strings 1 << 28 chars or longer, so:\n if (str.length * count >= 1 << 28) {\n throw new RangeError('repeat count must not overflow maximum string size')\n }\n var rpt = ''\n for (;;) {\n if ((count & 1) === 1) {\n rpt += str\n }\n count >>>= 1\n if (count === 0) {\n break\n }\n str += str\n }\n // Could we try:\n // return Array(count + 1).join(this);\n return rpt\n }\n}\n\nif (!String.prototype.includes) {\n // eslint-disable-next-line no-extend-native\n String.prototype.includes = function (search, start) {\n 'use strict'\n if (typeof start !== 'number') {\n start = 0\n }\n\n if (start + search.length > this.length) {\n return false\n } else {\n return this.indexOf(search, start) !== -1\n }\n }\n}\n\nif (!Array.prototype.includes) {\n // eslint-disable-next-line no-extend-native\n Array.prototype.includes = function (searchElement /*, fromIndex */) {\n 'use strict'\n if (this == null) {\n throw new TypeError('Array.prototype.includes called on null or undefined')\n }\n\n var O = Object(this)\n var len = parseInt(O.length, 10) || 0\n if (len === 0) {\n return false\n }\n var n = parseInt(arguments[1], 10) || 0\n var k\n if (n >= 0) {\n k = n\n } else {\n k = len + n\n if (k < 0) { k = 0 }\n }\n var currentElement\n while (k < len) {\n currentElement = O[k]\n if (searchElement === currentElement ||\n (Number.isNaN(searchElement) && Number.isNaN(currentElement))\n ) {\n return true\n }\n k++\n }\n return false\n }\n}\n\n// Production steps of ECMA-262, Edition 6, 22.1.2.1\n// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from\nif (!Array.from) {\n Array.from = (function () {\n var toStr = Object.prototype.toString\n var isCallable = function (fn) {\n return typeof fn === 'function' || toStr.call(fn) === '[object Function]'\n }\n var toInteger = function (value) {\n var number = Number(value)\n if (isNaN(number)) { return 0 }\n if (number === 0 || !isFinite(number)) { return number }\n return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number))\n }\n var maxSafeInteger = Math.pow(2, 53) - 1\n var toLength = function (value) {\n var len = toInteger(value)\n return Math.min(Math.max(len, 0), maxSafeInteger)\n }\n\n // The length property of the from method is 1.\n return function from (arrayLike/*, mapFn, thisArg */) {\n // 1. Let C be the this value.\n var C = this\n\n // 2. Let items be ToObject(arrayLike).\n var items = Object(arrayLike)\n\n // 3. ReturnIfAbrupt(items).\n if (arrayLike == null) {\n throw new TypeError('Array.from requires an array-like object - not null or undefined')\n }\n\n // 4. If mapfn is undefined, then let mapping be false.\n var mapFn = arguments.length > 1 ? arguments[1] : void undefined\n var T\n if (typeof mapFn !== 'undefined') {\n // 5. else\n // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.\n if (!isCallable(mapFn)) {\n throw new TypeError('Array.from: when provided, the second argument must be a function')\n }\n\n // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.\n if (arguments.length > 2) {\n T = arguments[2]\n }\n }\n\n // 10. Let lenValue be Get(items, \"length\").\n // 11. Let len be ToLength(lenValue).\n var len = toLength(items.length)\n\n // 13. If IsConstructor(C) is true, then\n // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.\n // 14. a. Else, Let A be ArrayCreate(len).\n var A = isCallable(C) ? Object(new C(len)) : new Array(len)\n\n // 16. Let k be 0.\n var k = 0\n // 17. Repeat, while k < len… (also steps a - h)\n var kValue\n while (k < len) {\n kValue = items[k]\n if (mapFn) {\n A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k)\n } else {\n A[k] = kValue\n }\n k += 1\n }\n // 18. Let putStatus be Put(A, \"length\", len, true).\n A.length = len\n // 20. Return A.\n return A\n }\n }())\n}\n\nif (typeof window !== 'undefined') {\n (function () {\n // http://paulirish.com/2011/requestanimationframe-for-smart-animating/\n // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating\n\n // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel\n\n // MIT license\n\n var lastTime = 0\n var vendors = [ 'ms', 'moz', 'webkit', 'o' ]\n\n for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {\n window.requestAnimationFrame = (\n window[ vendors[ x ] + 'RequestAnimationFrame' ]\n )\n\n window.cancelAnimationFrame = (\n window[ vendors[ x ] + 'CancelAnimationFrame' ] ||\n window[ vendors[ x ] + 'CancelRequestAnimationFrame' ]\n )\n }\n\n if (!window.requestAnimationFrame) {\n window.requestAnimationFrame = function (callback/*, element */) {\n var currTime = new Date().getTime()\n var timeToCall = Math.max(0, 16 - (currTime - lastTime))\n\n var id = window.setTimeout(function () {\n var time = currTime + timeToCall\n callback(time)\n }, timeToCall)\n\n lastTime = currTime + timeToCall\n\n return id\n }\n }\n\n if (!window.cancelAnimationFrame) {\n window.cancelAnimationFrame = function (id) {\n clearTimeout(id)\n }\n }\n }())\n}\n\nif (Function.prototype.name === undefined && Object.defineProperty !== undefined) {\n // Missing in IE9-11.\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name\n\n // eslint-disable-next-line no-extend-native\n Object.defineProperty(Function.prototype, 'name', {\n\n get: function () {\n return this.toString().match(/^\\s*function\\s*(\\S*)\\s*\\(/)[ 1 ]\n }\n\n })\n}\n\nif (typeof window !== 'undefined') {\n if (window.performance === undefined) {\n /* global self */\n self.performance = {}\n }\n\n if (window.performance.now === undefined) {\n (function () {\n var start = Date.now()\n\n window.performance.now = function () {\n return Date.now() - start\n }\n })()\n }\n}\n\nif (Object.defineProperty !== undefined) {\n // Missing in IE < 13\n // MIT license\n // Copyright (c) 2016 Financial Times\n // https://github.com/Financial-Times/polyfill-service\n if (Number.MAX_SAFE_INTEGER === undefined) {\n Object.defineProperty(Number, 'MAX_SAFE_INTEGER', {\n enumerable: false,\n configurable: false,\n writable: false,\n value: Math.pow(2, 53) - 1\n })\n }\n if (Number.MIN_SAFE_INTEGER === undefined) {\n Object.defineProperty(Number, 'MIN_SAFE_INTEGER', {\n enumerable: false,\n configurable: false,\n writable: false,\n value: -(Math.pow(2, 53) - 1)\n })\n }\n}\n","/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] === undefined) continue\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ',\n 'F 4/m -3 2/c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure) {\n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false) {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n const bonds = r.getBonds()\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const nn = atomIndices1.length\n\n for (let i = 0; i < nn; ++i) {\n const rai1 = atomIndices1[ i ]\n const rai2 = atomIndices2[ i ]\n const ai1 = rai1 + offset\n const ai2 = rai2 + offset\n const tmp = atomBondMap[ ai1 ]\n if (tmp !== undefined && tmp[ ai2 ] !== undefined) {\n bp.index = tmp[ ai2 ]\n const residueTypeBondIndex = r.residueType.getBondIndex(rai1, rai2)! // TODO\n // overwrite residueType bondOrder with value from existing bond\n bondOrders[ residueTypeBondIndex ] = bp.bondOrder\n } else {\n a1.index = ai1\n a2.index = ai2\n // only add bond if not already in bondStore\n bondStore.addBond(a1, a2, bondOrders[ i ])\n }\n }\n }\n\n // get RNA/DNA rung pseudo bonds\n const traceAtomIndex = r.residueType.traceAtomIndex\n const rungEndAtomIndex = r.residueType.rungEndAtomIndex\n if (traceAtomIndex !== -1 && rungEndAtomIndex !== -1) {\n a1.index = r.traceAtomIndex\n a2.index = r.rungEndAtomIndex\n rungBondStore.addBond(a1, a2)\n rungAtomSet.set(a1.index)\n rungAtomSet.set(a2.index)\n }\n })\n\n structure.atomSetDict.rung = rungAtomSet\n\n if (Debug) Log.timeEnd('calculateBondsWithin')\n}\n\nexport function calculateBondsBetween (structure: Structure, onlyAddBackbone = false, useExistingBonds = false) {\n if (Debug) Log.time('calculateBondsBetween')\n\n const bondStore = structure.bondStore\n const backboneBondStore = structure.backboneBondStore\n const backboneAtomSet = structure.getAtomSet(false)\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n if (backboneBondStore.count === 0) {\n backboneBondStore.resize(structure.residueStore.count)\n }\n\n function addBondIfConnected (rp1: ResidueProxy, rp2: ResidueProxy) {\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if ((useExistingBonds && ap1.hasBondTo(ap2)) || ap1.connectedTo(ap2)) {\n if (!onlyAddBackbone) {\n bondStore.addBond(ap1, ap2, 1) // assume single bond\n }\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n backboneBondStore.addBond(ap1, ap2)\n backboneAtomSet.set(ap1.index)\n backboneAtomSet.set(ap2.index)\n }\n }\n }\n\n structure.eachResidueN(2, addBondIfConnected)\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n\n // check for cyclic chains\n structure.eachChain(function (cp) {\n if (cp.residueCount === 0) return\n rp1.index = cp.residueOffset\n rp2.index = cp.residueOffset + cp.residueCount - 1\n addBondIfConnected(rp2, rp1)\n })\n\n structure.atomSetDict.backbone = backboneAtomSet\n\n if (!onlyAddBackbone) {\n if (Debug) Log.time('calculateBondsBetween inter')\n const spatialHash = structure.spatialHash\n structure.eachResidue(function (rp) {\n if (rp.backboneType === UnknownBackboneType && !rp.isWater()) {\n rp.eachAtom(function (ap) {\n if (ap.isMetal()) return\n spatialHash!.eachWithin(ap.x, ap.y, ap.z, 4, function (idx) { // TODO\n ap2.index = idx\n if (ap.modelIndex === ap2.modelIndex &&\n ap.residueIndex !== ap2.residueIndex &&\n !ap2.isMetal()\n ) {\n bondStore.addBondIfConnected(ap, ap2, 1) // assume single bond\n }\n })\n })\n }\n })\n if (Debug) Log.timeEnd('calculateBondsBetween inter')\n }\n\n if (Debug) Log.timeEnd('calculateBondsBetween')\n}\n\nexport function buildUnitcellAssembly (structure: Structure) {\n if (!structure.unitcell) return\n\n if (Debug) Log.time('buildUnitcellAssembly')\n\n const uc = structure.unitcell\n\n const structureCenterFrac = structure.center.clone().applyMatrix4(uc.cartToFrac)\n const centerFrac = structureCenterFrac.clone().floor()\n const symopDict: { [K: string]: Matrix4 } = getSymmetryOperations(uc.spacegroup)\n\n const centerFracSymop = new Vector3()\n const positionFracSymop = new Vector3()\n\n function getMatrixList (shift?: Vector3) {\n const matrixList: Matrix4[] = []\n\n Object.keys(symopDict).forEach(function (name) {\n const m = symopDict[ name ].clone()\n\n centerFracSymop.copy(structureCenterFrac).applyMatrix4(m).floor()\n positionFracSymop.setFromMatrixPosition(m)\n positionFracSymop.sub(centerFracSymop)\n positionFracSymop.add(centerFrac)\n\n if (shift) positionFracSymop.add(shift)\n\n m.setPosition(positionFracSymop)\n m.multiplyMatrices(uc.fracToCart, m)\n m.multiply(uc.cartToFrac)\n\n matrixList.push(m)\n })\n\n return matrixList\n }\n\n const unitcellAssembly = new Assembly('UNITCELL')\n const unitcellMatrixList = getMatrixList()\n const ncsMatrixList: Matrix4[] = []\n if (structure.biomolDict.NCS) {\n ncsMatrixList.push(\n new Matrix4(), ...structure.biomolDict.NCS.partList[ 0 ].matrixList\n )\n const ncsUnitcellMatrixList: Matrix4[] = []\n unitcellMatrixList.forEach(sm => {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n}\n\nclass PdbParser extends StructureParser {\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: number, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H') ? 1 : 0\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, 0, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, 1)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, 1)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file Version\n * @private\n * @author Alexander Rose \n */\n\nimport * as data from '../package.json'\n\n/**\n * Version name\n * @type {String}\n */\nconst Version = (data as any).version as string\n\nexport default Version\n","/**\n * @file ngl\n * @private\n * @author Alexander Rose \n */\n\nimport './polyfills'\nimport _Promise from 'promise-polyfill'\n\n/**\n * The NGL module. These members are available in the `NGL` namespace when using the {@link https://github.com/umdjs/umd|UMD} build in the `ngl.js` file.\n * @module NGL\n */\n\nexport {\n Debug, setDebug,\n MeasurementDefaultParams, setMeasurementDefaultParams,\n ScriptExtensions, ColormakerRegistry,\n DatasourceRegistry, DecompressorRegistry,\n ParserRegistry, RepresentationRegistry,\n setListingDatasource, setTrajectoryDatasource,\n ListingDatasource, TrajectoryDatasource\n} from './globals'\nexport { autoLoad, getDataInfo, getFileInfo } from './loader/loader-utils'\nimport Selection from './selection/selection'\nimport PdbWriter from './writer/pdb-writer'\nimport SdfWriter from './writer/sdf-writer'\nimport StlWriter from './writer/stl-writer'\nimport Stage from './stage/stage'\nimport Viewer from './viewer/viewer'\nimport Collection from './component/collection'\nimport ComponentCollection from './component/component-collection'\nimport Component from './component/component'\nimport ShapeComponent from './component/shape-component'\nimport StructureComponent, {StructureRepresentationType} from './component/structure-component'\nimport SurfaceComponent from './component/surface-component'\nimport VolumeComponent, {VolumeRepresentationType} from './component/volume-component'\nimport RepresentationCollection from './component/representation-collection'\nimport RepresentationElement from './component/representation-element'\nimport Assembly from './symmetry/assembly'\nimport TrajectoryPlayer from './trajectory/trajectory-player'\nimport Superposition from './align/superposition'\nexport { superpose } from './align/align-utils'\nexport { guessElement, concatStructures } from './structure/structure-utils'\n\nexport { flatten, throttle, download, getQuery, uniqueArray } from './utils'\nimport Queue from './utils/queue'\nimport Counter from './utils/counter'\nimport Frames from './trajectory/frames'\n\n//\n\nimport Colormaker from './color/colormaker'\n\nimport './color/atomindex-colormaker'\nimport './color/bfactor-colormaker'\nimport './color/chainid-colormaker'\nimport './color/chainindex-colormaker'\nimport './color/chainname-colormaker'\nimport './color/densityfit-colormaker'\nimport './color/electrostatic-colormaker'\nimport './color/element-colormaker'\nimport './color/entityindex-colormaker'\nimport './color/entitytype-colormaker'\nimport './color/geoquality-colormaker'\nimport './color/hydrophobicity-colormaker'\nimport './color/modelindex-colormaker'\nimport './color/moleculetype-colormaker'\nimport './color/occupancy-colormaker'\nimport './color/partialcharge-colormaker'\nimport './color/random-colormaker'\nimport './color/randomcoilindex-colormaker'\nimport './color/residueindex-colormaker'\nimport './color/resname-colormaker'\nimport './color/sstruc-colormaker'\nimport './color/structuredata-colormaker'\nimport './color/uniform-colormaker'\nimport './color/value-colormaker'\nimport './color/volume-colormaker'\n\n//\n\nimport './component/shape-component'\nimport './component/structure-component'\nimport './component/surface-component'\nimport './component/volume-component'\n\n//\n\nimport AngleRepresentation, {AngleRepresentationParameters} from './representation/angle-representation'\nimport AxesRepresentation, {AxesRepresentationParameters} from './representation/axes-representation'\nimport BackboneRepresentation from './representation/backbone-representation'\nimport BallAndStickRepresentation, {BallAndStickRepresentationParameters} from './representation/ballandstick-representation'\nimport BaseRepresentation from './representation/base-representation'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './representation/cartoon-representation'\nimport ContactRepresentation, {ContactRepresentationParameters} from './representation/contact-representation'\nimport DihedralRepresentation, {DihedralRepresentationParameters} from './representation/dihedral-representation'\nimport DihedralHistogramRepresentation, {DihedralHistogramRepresentationParameters} from './representation/dihedral-histogram-representation'\nimport DistanceRepresentation, {DistanceRepresentationParameters} from './representation/distance-representation'\nimport HelixorientRepresentation from './representation/helixorient-representation'\nimport HyperballRepresentation, {HyperballRepresentationParameters} from './representation/hyperball-representation'\nimport LabelRepresentation, {LabelRepresentationParameters} from './representation/label-representation'\nimport LicoriceRepresentation from './representation/licorice-representation'\nimport LineRepresentation, {LineRepresentationParameters} from './representation/line-representation'\nimport MolecularSurfaceRepresentation, {MolecularSurfaceRepresentationParameters} from './representation/molecularsurface-representation'\nimport PointRepresentation, {PointRepresentationParameters} from './representation/point-representation'\nimport RibbonRepresentation, {RibbonRepresentationParameters} from './representation/ribbon-representation'\nimport RocketRepresentation, {RocketRepresentationParameters} from './representation/rocket-representation'\nimport RopeRepresentation from './representation/rope-representation'\nimport SpacefillRepresentation from './representation/spacefill-representation'\nimport StructureRepresentation, {StructureRepresentationParameters} from './representation/structure-representation'\nimport TraceRepresentation, {TraceRepresentationParameters} from './representation/trace-representation'\nimport TubeRepresentation from './representation/tube-representation'\nimport UnitcellRepresentation, {UnitcellRepresentationParameters} from './representation/unitcell-representation'\nimport ValidationRepresentation from './representation/validation-representation'\n\nimport BufferRepresentation from './representation/buffer-representation'\nimport ArrowBuffer from './buffer/arrow-buffer'\nimport BoxBuffer from './buffer/box-buffer'\nimport ConeBuffer from './buffer/cone-buffer'\nimport CylinderBuffer from './buffer/cylinder-buffer'\nimport EllipsoidBuffer from './buffer/ellipsoid-buffer'\nimport MeshBuffer from './buffer/mesh-buffer'\nimport OctahedronBuffer from './buffer/octahedron-buffer'\nimport PointBuffer from './buffer/point-buffer'\nimport SphereBuffer from './buffer/sphere-buffer'\nimport TetrahedronBuffer from './buffer/tetrahedron-buffer'\nimport TextBuffer from './buffer/text-buffer'\nimport TorusBuffer from './buffer/torus-buffer'\nimport WidelineBuffer from './buffer/wideline-buffer'\n\n//\n\nimport './parser/cif-parser'\nimport './parser/gro-parser'\nimport './parser/mmtf-parser'\nimport './parser/mol2-parser'\nimport './parser/pdb-parser'\nimport './parser/pdbqt-parser'\nimport './parser/pqr-parser'\nimport './parser/sdf-parser'\n\nimport './parser/prmtop-parser'\nimport './parser/psf-parser'\nimport './parser/top-parser'\n\nimport './parser/dcd-parser'\nimport './parser/nctraj-parser'\nimport './parser/trr-parser'\nimport './parser/xtc-parser'\n\nimport './parser/cube-parser'\nimport './parser/dsn6-parser'\nimport './parser/dx-parser'\nimport './parser/dxbin-parser'\nimport './parser/mrc-parser'\nimport './parser/xplor-parser'\n\nimport './parser/kin-parser'\nimport './parser/obj-parser'\nimport './parser/ply-parser'\n\nimport './parser/csv-parser'\nimport './parser/json-parser'\nimport './parser/msgpack-parser'\nimport './parser/netcdf-parser'\nimport './parser/text-parser'\nimport './parser/xml-parser'\n\nimport './parser/validation-parser'\n\n//\n\nimport Shape from './geometry/shape'\nimport Kdtree from './geometry/kdtree'\nimport SpatialHash from './geometry/spatial-hash'\nimport Structure from './structure/structure'\nimport MolecularSurface from './surface/molecular-surface'\nimport Volume from './surface/volume'\n\n//\n\nimport './utils/gzip-decompressor'\n\n//\n\nimport './datasource/rcsb-datasource'\nimport './datasource/pubchem-datasource'\nimport './datasource/passthrough-datasource'\nimport './datasource/alphafold-datasource'\nimport StaticDatasource from './datasource/static-datasource'\nimport MdsrvDatasource from './datasource/mdsrv-datasource'\n\n//\n\nexport {\n LeftMouseButton, MiddleMouseButton, RightMouseButton\n} from './constants'\nexport {MouseActionCallback} from './controls/mouse-actions'\nimport MouseActions from './controls/mouse-actions'\nimport KeyActions from './controls/key-actions'\nimport PickingProxy from './controls/picking-proxy'\n\n//\n\nexport { Signal } from 'signals'\nexport {\n Matrix3, Matrix4, Vector2, Vector3, Box3, Quaternion, Euler, Plane, Color\n} from 'three'\n\n//\n\nexport { UIStageParameters } from './ui/parameters'\nexport { StageParameters } from './stage/stage'\nexport { StructureComponentDefaultParameters } from './component/structure-component'\n\n//\n\nimport Version from './version'\n\nif (!(window as any).Promise) {\n (window as any).Promise = _Promise\n}\n\nexport {\n Version,\n StaticDatasource,\n MdsrvDatasource,\n Colormaker,\n Selection,\n PdbWriter,\n SdfWriter,\n StlWriter,\n Stage,\n Viewer,\n Collection,\n ComponentCollection,\n RepresentationCollection,\n RepresentationElement,\n Component,\n ShapeComponent,\n StructureComponent,\n SurfaceComponent,\n VolumeComponent,\n StructureRepresentationType,\n VolumeRepresentationType,\n\n Assembly,\n TrajectoryPlayer,\n Superposition,\n Frames,\n\n Queue,\n Counter,\n\n AngleRepresentation,\n AngleRepresentationParameters,\n AxesRepresentation,\n AxesRepresentationParameters,\n BackboneRepresentation,\n BallAndStickRepresentation,\n BallAndStickRepresentationParameters,\n BaseRepresentation,\n CartoonRepresentation,\n CartoonRepresentationParameters,\n ContactRepresentation,\n ContactRepresentationParameters,\n DihedralRepresentation,\n DihedralRepresentationParameters,\n DihedralHistogramRepresentation,\n DihedralHistogramRepresentationParameters,\n DistanceRepresentation,\n DistanceRepresentationParameters,\n HelixorientRepresentation,\n HyperballRepresentation,\n HyperballRepresentationParameters,\n LabelRepresentation,\n LabelRepresentationParameters,\n LicoriceRepresentation,\n LineRepresentation,\n LineRepresentationParameters,\n MolecularSurfaceRepresentation,\n MolecularSurfaceRepresentationParameters,\n PointRepresentation,\n PointRepresentationParameters,\n RibbonRepresentation,\n RibbonRepresentationParameters,\n RocketRepresentation,\n RocketRepresentationParameters,\n RopeRepresentation,\n SpacefillRepresentation,\n StructureRepresentation,\n StructureRepresentationParameters,\n TraceRepresentation,\n TraceRepresentationParameters,\n TubeRepresentation,\n UnitcellRepresentation,\n UnitcellRepresentationParameters,\n ValidationRepresentation,\n\n BufferRepresentation,\n ArrowBuffer,\n BoxBuffer,\n ConeBuffer,\n CylinderBuffer,\n EllipsoidBuffer,\n MeshBuffer,\n OctahedronBuffer,\n PointBuffer,\n SphereBuffer,\n TetrahedronBuffer,\n TextBuffer,\n TorusBuffer,\n WidelineBuffer,\n\n Shape,\n\n Structure,\n Kdtree,\n SpatialHash,\n MolecularSurface,\n Volume,\n\n MouseActions,\n KeyActions,\n PickingProxy\n}\n"],"names":["toStr","isCallable","maxSafeInteger","toLength","start","getQuery","id","window","const","m","RegExp","exec","location","search","decodeURIComponent","defaults","value","defaultValue","undefined","createParams","params","defaultParams","o","Object","assign","k","updateParams","newParams","flatten","array","ret","let","i","length","Array","isArray","push","getProtocol","protocol","match","getBrowser","ua","navigator","userAgent","test","openUrl","url","open","href","download","data","downloadName","isSafari","isChromeIos","a","document","createElement","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","result","readAsDataURL","objectUrlCreated","URL","createObjectURL","style","display","body","appendChild","target","click","removeChild","revokeObjectURL","str","replace","throttle","func","wait","options","context","args","timeout","previous","later","leading","Date","now","apply","remaining","this","arguments","clearTimeout","trailing","setTimeout","lexicographicCompare","elm1","elm2","binarySearchIndexOf","element","compareFunction","low","high","mid","cmp","rangeInSortedArray","min","max","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sort","filter","index","sorted","uint8ToString","u8a","chunkSize","c","String","fromCharCode","subarray","join","getTypedArray","arrayType","arraySize","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Float32Array","Error","getUintArray","sizeOrArray","maxUint","ensureBuffer","buffer","ArrayBuffer","_ensureClassFromArray","constructor","fromArray","ensureVector3","v","Vector3","ensureMatrix4","Matrix4","ensureQuaternion","q","Quaternion","ensureFloat32Array","arg","toLowerCaseString","toString","toLowerCase","console","prop","method","con","empty","dummy","properties","split","methods","pop","HTMLCanvasElement","prototype","toBlob","defineProperty","callback","type","quality","bin","atob","toDataURL","len","len32","a8","a32","j","charCodeAt","tailLength","Math","cbrt","x","y","pow","abs","sign","isNaN","Number","isInteger","nVal","isFinite","floor","enumerable","configurable","writable","TypeError","pendingException","to","hasPendingException","nextSource","keysArray","keys","nextIndex","nextKey","desc","getOwnPropertyDescriptor","e","startsWith","object","$defineProperty","error","string","call","stringLength","searchString","searchLength","position","pos","endsWith","subjectString","lastIndex","indexOf","repeat","count","RangeError","Infinity","rpt","includes","searchElement","O","parseInt","currentElement","n","from","fn","number","toInteger","arrayLike","C","items","T","mapFn","kValue","A","lastTime","vendors","requestAnimationFrame","cancelAnimationFrame","currTime","getTime","timeToCall","Function","name","get","performance","self","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","Registry","_dict","prototypeAccessors","names","degToRad","deg","add","key","chars","uuid","generateUUID","r","rnd","random","clamp","lerp","stop","alpha","spline","p0","p1","p2","p3","t","tension","v0","v1","t2","smoothstep","normalize","colorSpace","ScaleDefaultParameters","scale","mode","domain","reverse","tmpColor","Color","manageColor","_target","_name","descriptor","originalMethod","fromTo","bind","set","convertSRGBToLinear","getHex","kwd","Colormaker","parameters","structure","atomProxy","getAtomProxy","getScale","p","slice","chroma","out","colorToArray","color","offset","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","s","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","rules","negate","f","subTests","hasOwnProperty","and","operator","na","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","signals","stringChanged","Signal","setString","silent","retSelection","newSelection","oldSelection","selectionStack","trim","charAt","substr","chunks","createNewContext","getPrevContext","pushRule","rule","not","cu","toUpperCase","sele","substring","chain","negate2","resi","resiSingle","resiRange","map","resnameList","indexList","b","lastRule","parseSele","message","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","dispatch","isAllSelection","isNoneSelection","defineProperties","SelectionColormaker","super","colormakerList","selectionList","dataList","forEach","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set1","Set2","Set3","Dark2","Paired","Pastel1","Pastel2","Accent","rainbow","rwb","ColormakerModes","rgb","hsv","hsl","hsi","lab","hcl","schemes","userSchemes","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","MySelectionColormaker","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","getWorkerDeps","vars","deps","sym","__deps","makeWorkerString","onmessage","__name","postId","__postId","aMessage","transferList","postMessage","makeWorkerBlob","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","Browser","SupportsPassiveEventHandler","opts","addEventListener","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","log","info","warn","time","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","linewidth","opacity","labelUnit","arcVisible","planeVisible","setMeasurementDefaultParams","Debug","setDebug","ListingDatasource","TrajectoryDatasource","ScriptExtensions","_WorkerRegistry","_ColormakerRegistry","DatasourceRegistry","RepresentationRegistry","_ParserRegistry","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","setListingDatasource","setTrajectoryDatasource","Streamer","src","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","then","decompressFn","_chunk","end","chunk","peekLines","chunkToLines","lines","chunkCount","asText","partialLine","isLast","idx","lastIndexOf","str2","concat","nextChunk","nextChunkOfLines","d","eachChunk","round","eachChunkOfLines","chunkNo","dispose","FileStreamer","Promise","resolve","reject","file","onload","event","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","status","response","statusText","responseType","send","Loader","ext","dir","path","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","load","parse","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","Writer","getBlob","getData","mimeType","defaultName","defaultExt","PdbWriter","renumberSerial","remarks","ensureArray","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","sprintf","trajectory","ia","im","charge","chargeSign","hasModels","modelStore","eachModel","eachAtom","formatString","hetero","serial","formalCharge","toPrecision","z","occupancy","bfactor","getSelection","getString","SdfWriter","idString","titleString","countsString","chargeLines","title","atomCount","bondCount","pairs","ap","nCharges","formatAtom","line","formatBond","bp","bondOrder","_writeHeader","_writeCTab","_writeFooter","eachBond","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","reset","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","toArray","StlWriter","surface","triangles","output","vector","vectorNorm1","vectorNorm2","vectorNorm3","indices","normal","addVectors","Counter","countChanged","signalsWrapper","clear","change","delta","increment","decrement","listen","counter","unlisten","has","remove","onZeroOnce","Stats","updated","maxDuration","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","update","startTime","currentTime","reInclude","shaderCache","getShader","defines","hash","definesText","getDefines","shaderText","ShaderChunk","WebGLRenderingContext","wrcp","_getShaderParameter","getShaderParameter","_getShaderInfoLog","getShaderInfoLog","_getProgramParameter","getProgramParameter","program","pname","LINK_STATUS","_getProgramInfoLog","getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","renderer","camera","viewer","canvas","_viewer","_factor","factor","_antialias","antialias","_onProgress","onProgress","_onFinish","onFinish","_n","_width","width","_height","height","_ctx","getContext","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","offsetX","offsetY","setViewOffset","render","w","h","drawImage","domElement","ceil","_finalize","view","renderAsync","TwoPI","PI","RAD2DEG","circularMean","stride","cosMean","sinMean","angle","cos","sin","atan2","calculateCenterArray","array1","array2","center","calculateDirectionArray","direction","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","copyArray","dst","srcOffset","dstOffset","copyWithin","arrayMax","il","arrayMin","arraySum","sum","arrayMean","ImageDefaultParameters","transparent","makeImage","ref","originalClearAlpha","getClearAlpha","backgroundColor","getClearColor","setLineWidthAndPixelSize","invert","scene","traverse","material","uniforms","size","__seen","trimCanvas","bg","g","doBreak","off","canvasHeight","canvasWidth","pixels","getImageData","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","blob","setClearAlpha","requestRender","vertex","matrix","modelViewProjectionMatrix","resolution","Vector2","projectionMatrixInverse","projectionMatrixTranspose","updateCameraUniforms","group","getInverse","projectionMatrix","copy","transpose","u","loadShader","gl","shaderSource","shaderType","shader","createShader","compileShader","COMPILE_STATUS","deleteShader","getExtension","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","createProgram","attachShader","attrib","bindAttribLocation","linkProgram","deleteProgram","useProgram","positionLocation","getAttribLocation","colorLoc","getUniformLocation","positionBuffer","createBuffer","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","enableVertexAttribArray","vertexAttribPointer","FLOAT","whiteTex","createTexture","whiteData","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","tex","texParameteri","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","uniform4fv","drawArrays","TRIANGLES","clearColor","COLOR_BUFFER_BIT","pixel","readPixels","floatPixel","getError","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","onBeforeRender","geometry","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","modelViewMatrix","multiplyMatrices","matrixWorldInverse","matrixWorld","materialProperties","pu","getUniforms","setValue","Viewer","idOrElement","boundingBox","Box3","boundingBoxSize","boundingBoxLength","memory","programs","geometries","textures","calls","vertices","faces","points","distVector","ticked","rendered","elm","getElementById","container","HTMLElement","innerWidth","innerHeight","box","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","cameraDistance","fogColor","fogNear","fogFar","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","LinearEncoding","lookAt","perspectiveCamera","PerspectiveCamera","orthographicCamera","OrthographicCamera","stereoCamera","StereoCamera","aspect","eyeSep","updateProjectionMatrix","stats","Scene","rotationGroup","Group","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","fog","Fog","spotLight","SpotLight","ambientLight","AmbientLight","dpr","devicePixelRatio","WebGLRenderer","preserveDrawingBuffer","innerHTML","setPixelRatio","setSize","autoClear","sortObjects","outputEncoding","capabilities","isWebGL2","extensions","supportsHalfFloat","dprWidth","dprHeight","JSON","stringify","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","WebGLRenderTarget","minFilter","NearestFilter","magFilter","stencilBuffer","format","RGBAFormat","FloatType","UnsignedByteType","texture","generateMipmaps","encoding","setRenderTarget","sampleTarget","LinearFilter","holdTarget","compositeUniforms","tForeground","Uniform","compositeMaterial","ShaderMaterial","vertexShader","fragmentShader","premultipliedAlpha","blending","AdditiveBlending","depthTest","depthWrite","compositeCamera","compositeScene","Mesh","PlaneGeometry","positions","bbGeometry","BufferGeometry","setIndex","BufferAttribute","setAttribute","bbMaterial","uColor","boundingBoxMesh","LineSegments","updateHelper","attributes","needsUpdate","isEmpty","computeBoundingSphere","instanceList","instance","addBuffer","wireframeGroup","background","pickable","setUserData","children","userData","mesh","getMesh","applyMatrix4","wireframeMesh","getWireframeMesh","quaternion","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","instanceMatrix","updateGeometry","computeBoundingBox","geoBoundingBox","clone","equals","expandByScalar","union","updateNode","node","makeEmpty","getSize","getPickingPixels","imgBuffer","readRenderTargetPixels","getImage","picking","imgBuffer2","ctx","imgData","putImageData","setLight","intensity","near","far","setClearColor","getStyle","level","setOutputEncoding","setColorWorkflow","sRGBEncoding","setCamera","fov","up","updateZoom","setClip","dist","left","right","top","bottom","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","pick","pid","picker","pixelBuffer","oid","getObjectById","tan","zoom","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","getWorldPosition","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","updateMatrix","updateMatrixWorld","pixelRatio","getPixelRatio","ortho","nearClip","updateMaterialUniforms","traverseVisible","Points","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","tmpTab","__zArray","__sortArray","__cmpFn","ai","bi","arr","tmp","stack","sp","swap","tmp2","quicksortCmp","attr","itemSize","sortProjectedPosition","__setVisibility","helper","visible","__updateLights","setLength","__renderPickingGroup","__renderModelGroup","renderTarget","__renderSuperSample","baseSampleWeight","sampleWeight","clearViewOffset","__renderStereo","_renderTarget","setScissorTest","setScissor","setViewport","cameraL","__render","cameraR","lastRenderedPicking","rendering","LeftMouseButton","MiddleMouseButton","RightMouseButton","getTouchDistance","dx","touches","pageX","dy","pageY","sqrt","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","preventDefault","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","detail","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","distanceTo","lastTouchDistance","touchDistance","removeEventListener","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","multiplyScalar","_getRotateXY","_getCameraRotation","extractRotation","multiply","makeRotationY","_transformPanVector","transform","premultiply","pan","translate","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","rotate","setFromAxisAngle","makeRotationFromQuaternion","applyMatrix","zRotate","dz","makeRotationZ","rotateComponent","makeRotationAxis","setFromRotationMatrix","tmpVec","PickingProxy","pickingData","closestBondAtom","closeAtom","arrow","axes","cone","clash","contact","cylinder","distance","ellipsoid","octahedron","point","sphere","tetrahedron","torus","unitcell","unknown","volume","wideline","getComponentsByObject","list","getObject","getPosition","atom1","v2","atom2","acp1","getPositionOnCanvas","acp2","ca","acp","radius","getMaxRepresentationRadius","_objectIfType","getLabel","msg","qualifiedName","shape","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","rotation","project","getCameraDistance","getOrientation","setPosition","orient","decompose","setRotationFromQuaternion","spin","axis","rotateOnAxis","align","basis","setRotationFromMatrix","Animation","duration","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","toggle","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","lerpVectors","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","slerp","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","prototypeAccessors$1","every","animation","AnimationControls","animationList","finishedList","splice","rock","move","zoomMove","orientTo","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","next","shift","kill","Representation","lazy","step","clipRadius","precision","clipCenter","flatShaded","side","front","back","double","wireframe","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","roughness","metalness","diffuse","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","init","setColor","lazyProps","build","bufferParams","what","tp","sphereDetail","radialSegments","openEnded","disableImpostor","getColorParams","getBufferParams","val","prepare","cb","create","updateWhat","_make","manualAttach","disposed","attach","setVisibility","noRenderRequest","updateParameters","int","float","parseFloat","getParameters","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","calculateMeanVector3","projectPointOnVector","origin","sub","projectOnVector","minX","minY","minZ","maxX","maxY","maxZ","l","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","ax","ay","az","bx","by","bz","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","color2","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","col","rad","getFixedLengthWrappedDashData","drawing","k3","kprev","vl","inv","getNextWorker","nextWorker","minPending","Primitive","staticAccessors","Picker","Buffer","getShapeKey","expandBoundingBox","valueToShape","_primitiveData","fields","objectToShape","valueFromShape","objectFromShape","arrayFromShape","dataFromShape","bufferFromShape","SpherePrimitive","positionFromShape","expandByPoint","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","text","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","ix","iy","iz","dSq","Store","_fields","_defaultFields","size$1","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","index1","index2","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","indexArray","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","state","addFeature","features","groups","centers","atomSets","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","intersection","intersects","getIntersectionSize","makeIntersection","wordsA","answer","toSeleString","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","HE","LI","BE","B","N","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","trace","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","Map","calcAngles","ap1","ap2","angles","d1","d2","subVectors","eachBondedAtom","angleTo","calcPlaneAngle","x1","v12","neighbours","ni","cross","ValenceModel","implicitH","totalH","idealGeometry","hydrogenCount","bondToElementCount","assignCharge","assignH","degree","valence","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","flag","a2","getOtherAtom","b2","atomicNumber2","isConjugated","multiBond","implicitHCount","geom","ba","oa","calculateHydrogensCharge","chg","implH","totH","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","addChargedContacts","contacts","maxIonicDist","ContactDefaultParams","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","masterIdx","masterModelIndex","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","spatialHash","contactStore","featureSet","atomStore","v3","n1","n2","getNormal","atoms","crossVectors","getOffset","projectOnPlane","ct","loop","invalidAtomContact","ti","tj","isIonicInteraction","atomSet1","atomSet2","maxDist","sn","sm","si","sj","areAtomSetsWithinDist","isPiStacking","isCationPi","isHistidineNitrogen","IonicTypeMetals","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","isMasterContact","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","addGroup","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","createContacts","maxHbondDistSq","donor","acceptor","isWeak","isWeakHydrogenBond","isHydrogenBond","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","c1","c2","lineOfSightDist","lineOfSightDistFactorSq","cx","cy","cz","as1","as2","vdw","distanceToSquared","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","setHex","contactColor","ContactPicker","getIndex","_applyTransformations","_getPosition","ShapePicker","primitive","CylinderPicker","prototypeAccessors$2","ArrowPicker","prototypeAccessors$3","AtomPicker","prototypeAccessors$4","AxesPicker","prototypeAccessors$5","BondPicker","bondStore","prototypeAccessors$6","prototypeAccessors$7","center1","center2","ConePicker","prototypeAccessors$8","ClashPicker","validation","prototypeAccessors$9","clashArray","_getAtomProxyFromSele","getAtomIndices","sele1","sele2","DistancePicker","prototypeAccessors$10","EllipsoidPicker","prototypeAccessors$11","OctahedronPicker","prototypeAccessors$12","BoxPicker","prototypeAccessors$13","IgnorePicker","prototypeAccessors$14","MeshPicker","prototypeAccessors$15","__position","SpherePicker","prototypeAccessors$16","SurfacePicker","prototypeAccessors$17","TetrahedronPicker","prototypeAccessors$18","TorusPicker","prototypeAccessors$19","UnitcellPicker","prototypeAccessors$20","getCenter","VolumePicker","prototypeAccessors$22","vol","dp","SlicePicker","prototypeAccessors$23","PointPicker","prototypeAccessors$24","WidelinePicker","prototypeAccessors$25","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","wrap","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","qy","qz","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","bits","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","zOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_box","_contour","_wrap","vIndexLength","Matrix","cols","rows","At","nrows","ncols","Ai","Ati","pAt","ad","atd","multiplyABt","Ap","pA","pB","Cp","mrows","bd","cd","multiply3x3","Cd","Ad","Bd","m10","m11","m12","m13","m14","m15","m16","m17","m18","m20","m21","m22","m23","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","i0","i1","hypot","copyTo","svd","at","_m","amt","wmt","vmt","astep","_W","Vt","vstep","iter","maxIter","Aj","Vi","Vj","t0","t1","sd","beta","gamma","seed","val0","asum","Float64Array","EPSILON","JacobiSVDImpl","m4new","m4set","n11","n12","n13","n14","n21","n22","n23","n24","n31","n32","n33","n34","n41","n42","n43","n44","m4multiply","a11","a12","a13","a14","a21","a22","a23","a24","a31","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","m4makeScale","m4makeTranslation","m4makeRotationY","theta","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","jl","flagvert","tps","vertdeg","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","computeVertexNormals","nv3","ab","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","maxSize","tmpSize","tran","mroty","mscale","mtrans","Surface","Geometry","fromGeometry","setFromArray","VolumeSurface","mc","getSurface","smooth","normalMatrix","geo","getColor","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","include","getAtomindex","volsurf","Volume","Matrix3","inverseMatrix","setData","rms","getThreeSide","FrontSide","BackSide","DoubleSide","setAtomindex","_position","_min","_max","_mean","_rms","setStats","setMatrix","me","elements","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","setObjectMatrix","matrixWorldNeedsUpdate","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","property","uniform","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","isLine","dynamic","wireframeIndexCount","defaultParameters","UniformsUtils","merge","UniformsLib","common","emissive","lights","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","setUsage","DYNAMIC_DRAW","makeMaterial","vertexColors","derivatives","fragDepth","wm","pm","NoBlending","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","setDrawRange","checkEdge","drawRange","updateWireframeIndex","updateRange","getRenderOrder","renderOrder","_getMesh","materialName","frustumCulled","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","attribute","wu","isVector3","toJSON","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","zoomScroll","trackballControls","clipNearScroll","focusScroll","focus","getFocus","almostIdentity","setFocus","zoomFocusScroll","eachRepresentation","reprElem","comp","repr","panDrag","rotateDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","panAtomDrag","rotateComponentDrag","movePick","pickingProxy","animationControls","tooltipPick","tt","tooltip","mp","innerText","MouseActionPresets","default","measurePick","measureClear","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleAnimations","toggleRock","KeyActionPresets","toggleSpin","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","padding","fontFamily","_clientRect","getVisibility","vp","cr","depth","zIndex","ComponentControls","RadiusFactoryTypes","covalent","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","va","vb","vc","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","makeBasis","determinant","getRotationQuaternion","inverse","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dot","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredAtomindex","filteredData","filteredPosition","BondHash","al","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","code","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","cache","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","diff","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","_center","a1","getAtomIndexByType","a3","a4","acos","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","_end","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","parentN","parent","elemScore","child1Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","pivotIndex","pivotValue","storeIndex","arrMedian","currentDim","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityIndex","chainIndex","residue","atomType","partialCharge","aromatic","euclideanDistSq","euclideanDist","entityList","residueTypeId","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","aa","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","connectedAtomIndex","connectedAtomIndices","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","noResname","toObject","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","L","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","instanceCount","isIdentity","structureChainList","eachChain","getBoundingBox","partBox","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","assignSecondaryStructure","secStruct","chainnames","chainnamesSorted","chainnamesIndex","helices","h1","h2","helix","helixRun","chainChange","sheets","s1","s2","strandCharCode","sheet","sheetRun","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","zhangSkolnickSS","isHelical","calculateSecondaryStructure","distances","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","calculateChainnames","useExistingBonds","doAutoChainName","rStart","rEnd","chainData","mIndex","rCount","eachResidueN","newChain","bbType1","bbType2","backboneEndAtomIndex","backboneStartAtomIndex","fill","rOffset","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","spacegroup","encodedSymopList","matrixDict","symopList","symop","denominator","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","unitcellAssembly","unitcellMatrixList","getMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","setFromMatrixPosition","fracToCart","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","concatStructures","Structure","sb","atomIndexDict","modelCount","structures","finalizeAtoms","finalizeBonds","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","rungEndIndex","bbEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","prevIndex","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","residueEnd","getModelProxy","_rp","rNextIndex","first","ModelProxy","chainEnd","_cp","refreshed","extraData","atomSetCache","boxes","bondSet","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getMaxScaleOnAxis","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","radius2","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","seq","getChainnameCount","Set","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","sizeAttenuation","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","buffers","BufferRepresentation","GeometryBuffer","meshIndex","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","makeTranslation","applyPositionTransform","getNormalMatrix","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","IcosahedronBufferGeometry","_radius","MappedBuffer","mappingType","indexSize","mapping","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","PointBufferDefaultParameters","alphaTest","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","DataTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","flipY","pickingTex","pickingMap","mapSize","CUBIC_INTERPOLATION","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","NormalBlending","VolumeSlice","positionType","getPositionFromCoordinate","coord","vn","ms","setFromMatrixScale","dimLen","x0","y0","z0","setVec","tMin","tMax","pickingArray","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","Euler","setFromEuler","setScale","setTransform","getCenterUntransformed","makeScale","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","invA","t4","t5","t8","t9","t11","t13","t14","t15","t17","t18","t20","t21","t23","t26","md","mean1","mean2","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","det","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","frame","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","resetCache","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","_s1","_s2","_i","_j","ali","calc","ali1","aliIdx1","aliIdx2","ali2","_atoms1","_atoms2","initMatrices","score","gap","makeScoreFn","Vi1","Si1","Hi","Si","gap0","scoreFn","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","pointer","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","item","pickDict","del","values","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","Stage","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","assembly","sizeScore","backboneOnly","radiusScale","surfaceType","probeRadius","lineOnly","loadFile","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","lastFullscreenElement","getFullscreenElement","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","dataset","normalWidth","normalHeight","screen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","resizeElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","setSpin","setRock","pclamp","bbSize","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","sc","ShapeComponent","__decorate","decorators","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","c0","StructureRepresentation","radiusSize","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","xOffset","attachment","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","order","selected","_break","calcArcPoint","edt","edt1d","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","placeholder","CanvasTexture","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","iChar","nChar","iCharAll","textAtlas","txt","xadvance","xShift","yShift","inputMapping","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","toFixed","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","eye","CylinderGeometryBufferDefaultParameters","getGeo","makeRotationX","CylinderBufferGeometry","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","d3","addScaledVector","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","directional","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","normals","getNormals","tangent","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","NaN","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","unit","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","p4","v34","inPlane1","inPlane2","improperStart","improperEnd","v3angle","nLines","nPlanes","line1","line2","sector","plane","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","obj","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","createWideLineBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","createMeshBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","Float32Concat","arrays","lengths","accumulatedOffset","linesList","startPoints","endPoints","startColors","endColors","triangleColors","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","opaqueCircleSectorAngleStep","sectionIndex","startOffset","setOneSideHistogram","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","scalingFactor","discHistogram","binBorders","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","res","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","positionN","sizeN","colorN","labelFactory","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tx","ty","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","ngTorus","lastClip","_probePositions","rExt","surfGrid","fillGridDim","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","dd","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","ConeBufferGeometry","_position1","_position2","GeometryGroup","geometryList","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vFrom","vTo","vSplit","fullLength","coneLength","BoxBuffer","BoxBufferGeometry","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","OctahedronBufferGeometry","TetrahedronBuffer","TetrahedronBufferGeometry","TorusBufferDefaultParameters","radiusRatio","tubularSegments","TorusBuffer","TorusBufferGeometry","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","divideScalar","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","hex","isLegacy","headerLine","headerId","legacyId","currentCoord","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","currentEntityData","currentEntityKey","chainIdx","currentChainname","currentSeqresChainname","isPqr","isPdbqt","serialRadix","resnoRadix","doFrames","serialDict","unitcellDict","entityDataList","hetnameDict","modresDict","chainDict","seqresDict","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","ml","identityMatrix","covalentI","i$1","parseCore","begIcode","struct_conf","beg_auth_seq_id","pdbx_PDB_helix_class","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsName","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","experimentalMethods","GroParser","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","ctor","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","i2","decodeInt32","i4","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","MmtfParser","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","am","du","un","Mol2Parser","moleculeLineNo","modelAtomIdxStart","currentRecordType","PdbqtParser","PqrParser","reItem","SdfParser","headerLines","mItem","atomStart","bondStart","bondEnd","sdfData","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","atomNames","radii","pointersDict","pointers","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","PsfParser","lastSegid","segid","reField","TopParser","currentMoleculetype","molecules","moleculetypeDict","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","DcdParser","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","notNetcdf","statement","reason","readName","nameLength","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","version","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","TrrParser","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","num","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","mask","lastBB0","lastBB1","cnt","_tmpIntBytes","decodeInts","nums","XtcParser","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","zz","yy","xx","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","xmin","ymin","zmin","hx","hy","hz","DxbinParser","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","b1","b0","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","red","orange","gold","yellow","lime","green","sea","cyan","sky","blue","purple","magenta","hotpink","pink","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","white","gray","brown","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","lm","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","KinParser","currentGroupMasters","currentSubgroupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","ref$1","listMasters$1","listName$1","listColor$1","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","ref$2","listName$2","listColor$2","listMasters$2","radiusArray","ref$3","listMasters$3","listName$3","listColor$3","breakArray","ref$4","splitLine","ref$5","label$1","color$1","position$1","ref$6","label$2","color$2","position$2","ref$7","label$3","color$3","position$3","ref$8","dominant","ref$9","groupName$1","groupFlags$1","groupMasters$1","ref$10","groupName$2","groupFlags$2","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","objects","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","addFace","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","buffergeometry","ObjParser","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","colors","elementsNeedUpdate","elementName","setRGB","vertexIndices","vertex_indices","Face3","binaryRead","dataview","binaryReadElement","loc","PlyParser","CsvParser","table","reDelimiter","JsonParser","MsgpackParser","msgpack","NetcdfParser","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","child","re","prefix","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","ValidationParser","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","inflate_fast","strm","_in","last","_out","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","MAXBITS","offs","extra","extra_index","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","messages","ZStream","GZheader","Inflate","sources","source","raw","err","ended","_mode","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfFullUrl","mmtfBaseUrl","RcsbDatasource","pdbid","baseUrl","PubchemDatasource","PassThroughDatasource","AlphafoldDatasource","uniprotid","reProtocol","StaticDatasource","relativePath","pn","basePath","pathname","MdsrvDatasource","getListing","jsonData","frameIndex","getPathUrl","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","Version","_Promise"],"mappings":"itCA4TgB,IACRA,GACAC,GASAC,GACAC,GAqIEC,GCrcJ,SAAUC,GAAUC,GACxB,GAAsB,oBAAXC,OAAX,CAEAC,IACMC,EADI,IAAIC,OAAUJ,EAAc,cAC1BK,KAAKJ,OAAOK,SAASC,QAEjC,OAAIJ,EACKK,mBAAmBL,EAAE,SAE5B,CARiD,CAUrD,CAcgB,SAAAM,GAAUC,EAAYC,GACpC,YAAiBC,IAAVF,EAAsBA,EAAQC,CACvC,CAEgB,SAAAE,GAAiBC,EAAgCC,GAC/Db,IAAMc,EAASC,OAAOC,OAAO,CAAE,EAAEJ,GACjC,IAAKZ,IAAMiB,KAAKJ,EAAe,MAEfH,IADAE,EAAOK,KACIH,EAAEG,GAAKJ,EAAcI,GAC/C,CACD,OAAOH,CACT,CAEgB,SAAAI,GAAiBN,EAAWO,GAC1C,IAAKnB,IAAMiB,KAAKE,EAAW,CACzBnB,IAAMQ,EAAQW,EAAUF,QACVP,IAAVF,IAAqBI,EAAOK,GAAKT,EACtC,CACD,OAAOI,CACT,CAUgB,SAAAQ,GAASC,EAAcC,GACrCA,EAAMf,GAASe,EAAK,IACpB,IAAKC,IAAIC,EAAI,EAAGA,EAAIH,EAAMI,OAAQD,IAC5BE,MAAMC,QAAQN,EAAMG,IACtBJ,GAAQC,EAAMG,GAAIF,GAElBA,EAAIM,KAAKP,EAAMG,IAGnB,OAAOF,CACT,UAEgBO,KACd7B,IAAM8B,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AAA,EAAMF,OAAC,CAAA,GAAGG,GAAIA,QAAK,CAAA,GAChF,CAIa,IAAA48L,GAAiE,CAC5E//J,gBAzB8B,CAAEtzB,KAAM,SA0BtCC,QAASmzL,GAAY,OAAQ,MAAO,SAAU,QAC9CtjK,YAAaqjK,GAAW,EAAG,GAAI,GAC/B9xE,SA/BgC,CAAErhH,KAAM,WAgCxCshH,cAhCgC,CAAEthH,KAAM,WAiCxCuzC,YAAa2/I,GAAY,EAAG,GAAI,GAChC1/I,UAAW0/I,GAAY,EAAG,GAAI,GAC9Bz/I,SAAUy/I,GAAY,EAAG,GAAI,GAC7Br0J,SAAUs0J,GAAW,EAAG,IAAK,GAC7Br0J,QAASq0J,GAAW,EAAG,IAAK,GAC5Bp0J,SAAUk0J,GAAa,IAAK,GAC5Bj0J,SAAUo0J,GAAY,QAAS,UAC/Bn0J,UAAWm0J,GAAY,WAAY,YACnC70J,QAAS40J,GAAW,EAAG,IAAK,GAC5B30J,OAAQ20J,GAAW,EAAG,IAAK,GAC3B10J,WAAY20J,GAAY,cAAe,eAAgB,UACvDz0J,aAAcu0J,GAAY,EAAG,EAAK,KAClCx0J,UAAWy0J,GAAW,EAAG,IAAK,IAC9Bj0J,WA3C8B,CAAEl/B,KAAM,SA4CtCm/B,eAAgB+zJ,GAAY,EAAG,GAAI,GACnC9zJ,aA7C8B,CAAEp/B,KAAM,SA8CtCq/B,iBAAkB6zJ,GAAY,EAAG,GAAI,GACrC9iJ,aAAc6iJ,GAAa,KAAQ,GACnC7mG,QAnDgC,CAAEpsF,KAAM,WAoDxCixH,YAAamiE,GAAA34L,WAAe,EAAAlE,OAAO2L,KAAKqqF,MCjDpC+mG,WCgNA/9L,OAAe2pB,UAClB3pB,OAAe2pB,QAAUq0K"} \ No newline at end of file +{"version":3,"file":"ngl.esm.js","sources":["../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../src/writer/writer.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/utils/io-buffer.ts","../src/writer/stl-writer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/constants.ts","../src/stage/mouse-observer.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/datasource/mdsrv-datasource.ts","../src/ui/parameters.ts","../src/version.ts"],"sourcesContent":["/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#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!+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure) {\n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false) {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n const bonds = r.getBonds()\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const nn = atomIndices1.length\n\n for (let i = 0; i < nn; ++i) {\n const rai1 = atomIndices1[ i ]\n const rai2 = atomIndices2[ i ]\n const ai1 = rai1 + offset\n const ai2 = rai2 + offset\n const tmp = atomBondMap[ ai1 ]\n if (tmp !== undefined && tmp[ ai2 ] !== undefined) {\n bp.index = tmp[ ai2 ]\n const residueTypeBondIndex = r.residueType.getBondIndex(rai1, rai2)! // TODO\n // overwrite residueType bondOrder with value from existing bond\n bondOrders[ residueTypeBondIndex ] = bp.bondOrder\n } else {\n a1.index = ai1\n a2.index = ai2\n // only add bond if not already in bondStore\n bondStore.addBond(a1, a2, bondOrders[ i ])\n }\n }\n }\n\n // get RNA/DNA rung pseudo bonds\n const traceAtomIndex = r.residueType.traceAtomIndex\n const rungEndAtomIndex = r.residueType.rungEndAtomIndex\n if (traceAtomIndex !== -1 && rungEndAtomIndex !== -1) {\n a1.index = r.traceAtomIndex\n a2.index = r.rungEndAtomIndex\n rungBondStore.addBond(a1, a2)\n rungAtomSet.set(a1.index)\n rungAtomSet.set(a2.index)\n }\n })\n\n structure.atomSetDict.rung = rungAtomSet\n\n if (Debug) Log.timeEnd('calculateBondsWithin')\n}\n\nexport function calculateBondsBetween (structure: Structure, onlyAddBackbone = false, useExistingBonds = false) {\n if (Debug) Log.time('calculateBondsBetween')\n\n const bondStore = structure.bondStore\n const backboneBondStore = structure.backboneBondStore\n const backboneAtomSet = structure.getAtomSet(false)\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n if (backboneBondStore.count === 0) {\n backboneBondStore.resize(structure.residueStore.count)\n }\n\n function addBondIfConnected (rp1: ResidueProxy, rp2: ResidueProxy) {\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if ((useExistingBonds && ap1.hasBondTo(ap2)) || ap1.connectedTo(ap2)) {\n if (!onlyAddBackbone) {\n bondStore.addBond(ap1, ap2, 1) // assume single bond\n }\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n backboneBondStore.addBond(ap1, ap2)\n backboneAtomSet.set(ap1.index)\n backboneAtomSet.set(ap2.index)\n }\n }\n }\n\n structure.eachResidueN(2, addBondIfConnected)\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n\n // check for cyclic chains\n structure.eachChain(function (cp) {\n if (cp.residueCount === 0) return\n rp1.index = cp.residueOffset\n rp2.index = cp.residueOffset + cp.residueCount - 1\n addBondIfConnected(rp2, rp1)\n })\n\n structure.atomSetDict.backbone = backboneAtomSet\n\n if (!onlyAddBackbone) {\n if (Debug) Log.time('calculateBondsBetween inter')\n const spatialHash = structure.spatialHash\n structure.eachResidue(function (rp) {\n if (rp.backboneType === UnknownBackboneType && !rp.isWater()) {\n rp.eachAtom(function (ap) {\n if (ap.isMetal()) return\n spatialHash!.eachWithin(ap.x, ap.y, ap.z, 4, function (idx) { // TODO\n ap2.index = idx\n if (ap.modelIndex === ap2.modelIndex &&\n ap.residueIndex !== ap2.residueIndex &&\n !ap2.isMetal()\n ) {\n bondStore.addBondIfConnected(ap, ap2, 1) // assume single bond\n }\n })\n })\n }\n })\n if (Debug) Log.timeEnd('calculateBondsBetween inter')\n }\n\n if (Debug) Log.timeEnd('calculateBondsBetween')\n}\n\nexport function buildUnitcellAssembly (structure: Structure) {\n if (!structure.unitcell) return\n\n if (Debug) Log.time('buildUnitcellAssembly')\n\n const uc = structure.unitcell\n\n const structureCenterFrac = structure.center.clone().applyMatrix4(uc.cartToFrac)\n const centerFrac = structureCenterFrac.clone().floor()\n const symopDict: { [K: string]: Matrix4 } = getSymmetryOperations(uc.spacegroup)\n\n const centerFracSymop = new Vector3()\n const positionFracSymop = new Vector3()\n\n function getMatrixList (shift?: Vector3) {\n const matrixList: Matrix4[] = []\n\n Object.keys(symopDict).forEach(function (name) {\n const m = symopDict[ name ].clone()\n\n centerFracSymop.copy(structureCenterFrac).applyMatrix4(m).floor()\n positionFracSymop.setFromMatrixPosition(m)\n positionFracSymop.sub(centerFracSymop)\n positionFracSymop.add(centerFrac)\n\n if (shift) positionFracSymop.add(shift)\n\n m.setPosition(positionFracSymop)\n m.multiplyMatrices(uc.fracToCart, m)\n m.multiply(uc.cartToFrac)\n\n matrixList.push(m)\n })\n\n return matrixList\n }\n\n const unitcellAssembly = new Assembly('UNITCELL')\n const unitcellMatrixList = getMatrixList()\n const ncsMatrixList: Matrix4[] = []\n if (structure.biomolDict.NCS) {\n ncsMatrixList.push(\n new Matrix4(), ...structure.biomolDict.NCS.partList[ 0 ].matrixList\n )\n const ncsUnitcellMatrixList: Matrix4[] = []\n unitcellMatrixList.forEach(sm => {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n}\n\nclass PdbParser extends StructureParser {\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: number, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H') ? 1 : 0\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, 0, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, 1)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, 1)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file Version\n * @private\n * @author Alexander Rose \n */\n\nimport * as data from '../package.json'\n\n/**\n * Version name\n * @type {String}\n */\nconst Version = (data as any).version as string\n\nexport default Version\n"],"names":["getQuery","id","window","m","RegExp","exec","location","search","decodeURIComponent","defaults","value","defaultValue","undefined","createParams","params","defaultParams","o","Object","assign","k","updateParams","newParams","flatten","array","ret","i","length","Array","isArray","push","getProtocol","protocol","match","getBrowser","ua","navigator","userAgent","test","openUrl","url","open","href","download","data","downloadName","isSafari","isChromeIos","a","document","createElement","str","replace","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","result","readAsDataURL","objectUrlCreated","URL","createObjectURL","style","display","body","appendChild","target","click","removeChild","revokeObjectURL","throttle","func","wait","options","context","args","timeout","previous","later","leading","Date","now","apply","remaining","this","arguments","clearTimeout","trailing","setTimeout","lexicographicCompare","elm1","elm2","binarySearchIndexOf","element","compareFunction","low","high","mid","cmp","rangeInSortedArray","min","max","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sort","filter","index","sorted","uint8ToString","u8a","chunkSize","c","String","fromCharCode","subarray","join","getTypedArray","arrayType","arraySize","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Float32Array","Error","getUintArray","sizeOrArray","maxUint","ensureBuffer","buffer","ArrayBuffer","_ensureClassFromArray","constructor","fromArray","ensureVector3","v","Vector3","ensureMatrix4","Matrix4","ensureQuaternion","q","Quaternion","ensureFloat32Array","arg","toLowerCaseString","toString","toLowerCase","Registry","name","_dict","add","key","get","names","keys","degToRad","deg","chars","split","uuid","generateUUID","r","rnd","Math","random","clamp","lerp","start","stop","alpha","spline","p0","p1","p2","p3","t","tension","v0","v1","t2","smoothstep","x","normalize","colorSpace","ScaleDefaultParameters","scale","mode","domain","reverse","tmpColor","Color","manageColor","_target","_name","descriptor","originalMethod","fromTo","bind","set","convertSRGBToLinear","getHex","Colormaker","parameters","structure","atomProxy","getAtomProxy","getScale","p","slice","chroma","out","colorToArray","color","offset","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","s","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","error","rules","n","negate","f","subTests","hasOwnProperty","and","operator","na","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","string","signals","stringChanged","Signal","setString","type","silent","retSelection","newSelection","oldSelection","selectionStack","trim","charAt","substr","chunks","createNewContext","getPrevContext","pop","pushRule","rule","not","cu","toUpperCase","lastRule","indexOf","indexList","map","parseInt","b","console","resnameList","isNaN","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","e","message","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","dispatch","isAllSelection","isNoneSelection","SelectionColormaker","super","colormakerList","selectionList","dataList","forEach","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set1","Set2","Set3","Dark2","Paired","Pastel1","Pastel2","Accent","rainbow","rwb","ColormakerModes","rgb","hsv","hsl","hsi","lab","hcl","getWorkerDeps","vars","deps","sym","__deps","prototype","makeWorkerString","onmessage","__name","postId","__postId","self","callback","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","defineProperty","addEventListener","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","log","Function","call","info","warn","time","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","linewidth","opacity","labelUnit","arcVisible","planeVisible","setMeasurementDefaultParams","Debug","setDebug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","ListingDatasource","TrajectoryDatasource","setListingDatasource","setTrajectoryDatasource","Streamer","src","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","then","decompressFn","_chunk","end","chunk","peekLines","charCodeAt","count","chunkToLines","lines","chunkCount","floor","asText","partialLine","isLast","idx","lastIndexOf","str2","concat","nextChunk","nextChunkOfLines","d","eachChunk","round","eachChunkOfLines","chunkNo","dispose","FileStreamer","Promise","resolve","reject","file","onload","event","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","status","response","statusText","responseType","send","Loader","ext","dir","path","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","load","parse","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","Writer","getBlob","getData","mimeType","defaultName","defaultExt","PdbWriter","renumberSerial","remarks","ensureArray","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","sprintf","trajectory","frame","ia","im","charge","chargeSign","hasModels","modelStore","eachModel","eachAtom","formatString","hetero","serial","formalCharge","abs","toPrecision","y","z","occupancy","bfactor","getSelection","getString","SdfWriter","idString","titleString","title","countsString","atomCount","bondCount","chargeLines","pairs","ap","nCharges","j","formatAtom","line","formatBond","bp","bondOrder","_writeHeader","_writeCTab","_writeFooter","eachBond","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","reset","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","toArray","StlWriter","surface","triangles","output","vector","vectorNorm1","vectorNorm2","vectorNorm3","indices","normal","addVectors","position","Counter","countChanged","signalsWrapper","clear","change","delta","increment","decrement","listen","counter","unlisten","has","remove","onZeroOnce","Stats","updated","maxDuration","Infinity","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","update","startTime","currentTime","performance","reInclude","shaderCache","getShader","defines","hash","definesText","getDefines","shaderText","ShaderChunk","WebGLRenderingContext","wrcp","_getShaderParameter","getShaderParameter","_getShaderInfoLog","getShaderInfoLog","_getProgramParameter","getProgramParameter","program","pname","LINK_STATUS","_getProgramInfoLog","getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","renderer","camera","viewer","canvas","_viewer","_factor","factor","_antialias","antialias","_onProgress","onProgress","_onFinish","onFinish","_n","_width","width","_height","height","_ctx","getContext","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","offsetX","offsetY","setViewOffset","render","w","h","drawImage","domElement","ceil","_finalize","view","renderAsync","TwoPI","PI","RAD2DEG","circularMean","stride","cosMean","sinMean","angle","cos","sin","atan2","calculateCenterArray","array1","array2","center","calculateDirectionArray","direction","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","copyArray","dst","srcOffset","dstOffset","copyWithin","arrayMax","il","arrayMin","arraySum","sum","arrayMean","ImageDefaultParameters","transparent","makeImage","originalClearAlpha","getClearAlpha","backgroundColor","getClearColor","setLineWidthAndPixelSize","invert","scene","traverse","material","uniforms","size","__seen","trimCanvas","bg","g","canvasHeight","canvasWidth","pixels","getImageData","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","setClearAlpha","requestRender","vertex","matrix","modelViewProjectionMatrix","resolution","Vector2","projectionMatrixInverse","projectionMatrixTranspose","updateCameraUniforms","group","getInverse","projectionMatrix","copy","transpose","u","loadShader","gl","shaderSource","shaderType","shader","createShader","compileShader","COMPILE_STATUS","deleteShader","getExtension","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","createProgram","attachShader","attrib","bindAttribLocation","linkProgram","deleteProgram","useProgram","positionLocation","getAttribLocation","colorLoc","getUniformLocation","positionBuffer","createBuffer","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","enableVertexAttribArray","vertexAttribPointer","FLOAT","whiteTex","createTexture","whiteData","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","tex","texParameteri","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","uniform4fv","drawArrays","TRIANGLES","clearColor","COLOR_BUFFER_BIT","pixel","readPixels","floatPixel","getError","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","onBeforeRender","geometry","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","modelViewMatrix","multiplyMatrices","matrixWorldInverse","matrixWorld","materialProperties","properties","pu","getUniforms","setValue","Viewer","idOrElement","boundingBox","Box3","boundingBoxSize","boundingBoxLength","memory","programs","geometries","textures","calls","vertices","faces","points","distVector","ticked","rendered","elm","getElementById","container","HTMLElement","innerWidth","innerHeight","box","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","fogColor","fogNear","fogFar","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","LinearEncoding","lookAt","perspectiveCamera","PerspectiveCamera","orthographicCamera","OrthographicCamera","stereoCamera","StereoCamera","aspect","eyeSep","updateProjectionMatrix","stats","Scene","rotationGroup","Group","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","fog","Fog","spotLight","SpotLight","ambientLight","AmbientLight","dpr","devicePixelRatio","WebGLRenderer","preserveDrawingBuffer","innerHTML","setPixelRatio","setSize","autoClear","sortObjects","outputEncoding","capabilities","isWebGL2","extensions","supportsHalfFloat","dprWidth","dprHeight","JSON","stringify","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","WebGLRenderTarget","minFilter","NearestFilter","magFilter","stencilBuffer","format","RGBAFormat","FloatType","UnsignedByteType","texture","generateMipmaps","encoding","setRenderTarget","sampleTarget","LinearFilter","holdTarget","compositeUniforms","tForeground","Uniform","compositeMaterial","ShaderMaterial","vertexShader","fragmentShader","premultipliedAlpha","blending","AdditiveBlending","depthTest","depthWrite","compositeCamera","compositeScene","Mesh","PlaneGeometry","positions","bbGeometry","BufferGeometry","setIndex","BufferAttribute","setAttribute","bbMaterial","uColor","boundingBoxMesh","LineSegments","updateHelper","attributes","needsUpdate","isEmpty","computeBoundingSphere","cameraDistance","instanceList","instance","addBuffer","wireframeGroup","background","pickable","setUserData","object","children","userData","mesh","getMesh","applyMatrix4","wireframeMesh","getWireframeMesh","quaternion","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","instanceMatrix","updateGeometry","computeBoundingBox","geoBoundingBox","clone","equals","expandByScalar","union","updateNode","node","makeEmpty","getSize","getPickingPixels","imgBuffer","readRenderTargetPixels","getImage","picking","imgBuffer2","ctx","imgData","putImageData","setLight","intensity","near","far","setClearColor","getStyle","level","setOutputEncoding","setColorWorkflow","sRGBEncoding","setCamera","fov","up","updateZoom","setClip","dist","left","right","top","bottom","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","requestAnimationFrame","pick","pid","picker","pixelBuffer","oid","getObjectById","tan","zoom","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","getWorldPosition","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","updateMatrix","updateMatrixWorld","pixelRatio","getPixelRatio","ortho","nearClip","updateMaterialUniforms","traverseVisible","Points","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","ai","bi","arr","stack","tmp","sp","swap","tmp2","quicksortCmp","attr","itemSize","sortProjectedPosition","__setVisibility","helper","visible","__updateLights","setLength","__renderPickingGroup","__renderModelGroup","renderTarget","__renderSuperSample","baseSampleWeight","sampleWeight","clearViewOffset","__renderStereo","_renderTarget","setScissorTest","setScissor","setViewport","cameraL","__render","cameraR","lastRenderedPicking","rendering","cancelAnimationFrame","LeftMouseButton","MiddleMouseButton","RightMouseButton","getTouchDistance","dx","touches","pageX","dy","pageY","sqrt","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","preventDefault","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","detail","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","distanceTo","lastTouchDistance","touchDistance","removeEventListener","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","multiplyScalar","_getRotateXY","_getCameraRotation","extractRotation","multiply","makeRotationY","_transformPanVector","transform","premultiply","pan","translate","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","rotate","setFromAxisAngle","makeRotationFromQuaternion","applyMatrix","zRotate","dz","makeRotationZ","rotateComponent","makeRotationAxis","setFromRotationMatrix","tmpVec","PickingProxy","pickingData","getComponentsByObject","list","getObject","getPosition","closestBondAtom","atom1","v2","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","radius","getMaxRepresentationRadius","arrow","_objectIfType","axes","cone","clash","contact","cylinder","distance","ellipsoid","octahedron","point","sphere","tetrahedron","torus","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","shape","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","rotation","project","getCameraDistance","getOrientation","setPosition","orient","decompose","setRotationFromQuaternion","spin","axis","rotateOnAxis","align","basis","setRotationFromMatrix","Animation","duration","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","toggle","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","lerpVectors","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","slerp","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","animation","AnimationControls","animationList","finishedList","splice","rock","move","zoomMove","orientTo","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","next","shift","kill","Representation","lazy","step","clipRadius","precision","clipCenter","flatShaded","side","front","back","double","wireframe","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","roughness","metalness","diffuse","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","init","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","radialSegments","openEnded","disableImpostor","getColorParams","getBufferParams","val","prepare","cb","create","updateWhat","_make","manualAttach","disposed","attach","setVisibility","noRenderRequest","updateParameters","int","float","parseFloat","getParameters","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","origin","sub","projectOnVector","minX","minY","minZ","maxX","maxY","maxZ","l","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","ax","ay","az","bx","by","bz","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cx","cy","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","color2","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","col","rad","getFixedLengthWrappedDashData","drawing","k3","kprev","vl","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","expandByPoint","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","text","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","ix","iy","iz","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","index1","index2","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","intersection","intersects","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","indexArray","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","state","addFeature","features","groups","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","trace","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","A","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","Map","calcAngles","ap1","ap2","angles","d1","d2","subVectors","eachBondedAtom","number","angleTo","calcPlaneAngle","x1","v12","neighbours","ni","cross","ValenceModel","implicitH","totalH","idealGeometry","chg","implH","totH","geom","hydrogenCount","bondToElementCount","assignCharge","assignH","degree","valence","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","flag","a2","getOtherAtom","b2","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","addGroup","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","v3","n1","n2","getNormal","atoms","crossVectors","getOffset","projectOnPlane","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","c1","c2","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","distanceToSquared","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","setHex","contactColor","ContactPicker","getIndex","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","center1","center2","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","getCenter","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","wrap","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","qy","qz","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","bits","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","zOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_box","_contour","_wrap","vIndexLength","Matrix","cols","rows","copyTo","At","nrows","ncols","Ai","Ati","pAt","ad","atd","multiplyABt","Ap","pA","pB","Cp","mrows","bd","cd","multiply3x3","Cd","Ad","Bd","m10","m11","m12","m13","m14","m15","m16","m17","m18","m20","m21","m22","m23","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","i0","i1","hypot","EPSILON","FLT_MIN","svd","at","_m","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","t0","t1","sd","beta","gamma","seed","val0","asum","Float64Array","JacobiSVDImpl","m4new","m4set","n11","n12","n13","n14","n21","n22","n23","n24","n31","n32","n33","n34","n41","n42","n43","n44","m4multiply","a11","a12","a13","a14","a21","a22","a23","a24","a31","a32","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","m4makeScale","m4makeTranslation","m4makeRotationY","theta","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","jl","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","computeVertexNormals","nv3","ab","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","maxSize","pow","tmpSize","tran","mroty","mscale","mtrans","Surface","Geometry","fromGeometry","setFromArray","geo","getColor","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","include","getAtomindex","VolumeSurface","mc","getSurface","smooth","normalMatrix","volsurf","Volume","Matrix3","inverseMatrix","setData","setAtomindex","_position","_min","_max","_mean","_rms","setStats","rms","setMatrix","me","elements","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","FrontSide","BackSide","DoubleSide","setObjectMatrix","matrixWorldNeedsUpdate","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","property","uniform","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","isLine","dynamic","wireframeIndexCount","defaultParameters","UniformsUtils","merge","UniformsLib","common","emissive","lights","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","setUsage","DYNAMIC_DRAW","makeMaterial","vertexColors","derivatives","fragDepth","wm","pm","NoBlending","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","setDrawRange","checkEdge","drawRange","updateWireframeIndex","updateRange","getRenderOrder","renderOrder","_getMesh","materialName","frustumCulled","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","attribute","wu","isVector3","toJSON","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","focus","getFocus","sign","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","padding","fontFamily","_clientRect","getVisibility","vp","cr","depth","zIndex","ComponentControls","RadiusFactoryTypes","covalent","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","va","vb","vc","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","makeBasis","determinant","getRotationQuaternion","inverse","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dot","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","al","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","code","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","cache","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","diff","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","_center","a1","getAtomIndexByType","a3","a4","acos","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","_end","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","len","parentN","parent","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","aa","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","L","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","instanceCount","isIdentity","structureChainList","eachChain","getBoundingBox","partBox","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","chainnamesSorted","chainnamesIndex","helices","h1","h2","helix","helixRun","chainChange","sheets","s1","s2","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","denominator","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","setFromMatrixPosition","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","concatStructures","structures","Structure","sb","atomIndexDict","modelCount","finalizeAtoms","finalizeBonds","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","prevIndex","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","first","ModelProxy","chainEnd","_cp","refreshed","extraData","atomSetCache","boxes","bondSet","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getMaxScaleOnAxis","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","radius2","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","seq","getChainnameCount","Set","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","sizeAttenuation","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","buffers","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","makeTranslation","applyPositionTransform","getNormalMatrix","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","IcosahedronBufferGeometry","_radius","MappedBuffer","mappingType","indexSize","mapping","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","x0","y0","y1","PointBufferDefaultParameters","alphaTest","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","DataTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","flipY","pickingTex","pickingMap","mapSize","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","NormalBlending","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","setFromMatrixScale","vn","dimLen","z0","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","Euler","setFromEuler","setScale","setTransform","getCenterUntransformed","makeScale","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t11","t13","t14","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","det","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","resetCache","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","values","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","Stage","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","assembly","sizeScore","backboneOnly","radiusScale","surfaceType","probeRadius","lineOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","screen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","bbSize","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","sc","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","c0","StructureRepresentation","radiusSize","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","xOffset","attachment","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","order","selected","_break","Number","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","placeholder","CanvasTexture","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","toFixed","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","eye","CylinderGeometryBufferDefaultParameters","getGeo","makeRotationX","CylinderBufferGeometry","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","d3","addScaledVector","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","directional","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","normals","getNormals","tangent","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","NaN","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","unit","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","p4","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","nPlanes","line1","line2","sector","plane","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","obj","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","res","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tx","ty","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","dd","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","ConeBufferGeometry","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vFrom","vTo","vSplit","fullLength","coneLength","BoxBuffer","BoxBufferGeometry","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","OctahedronBufferGeometry","TetrahedronBuffer","TetrahedronBufferGeometry","TorusBufferDefaultParameters","radiusRatio","tubularSegments","TorusBuffer","TorusBufferGeometry","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","divideScalar","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","hex","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","ml","identityMatrix","covalentI","parseCore","begIcode","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","method","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","ctor","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","i2","decodeInt32","i4","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","am","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","TypeError","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","version","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","num","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","mask","lastBB0","lastBB1","cnt","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","zz","yy","xx","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","xmin","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","b1","b0","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","red","orange","gold","yellow","lime","green","sea","cyan","sky","blue","purple","magenta","hotpink","pink","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","white","gray","brown","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","lm","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","objects","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","addFace","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","buffergeometry","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","colors","elementsNeedUpdate","elementName","setRGB","vertexIndices","vertex_indices","Face3","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","child","re","prefix","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","_out","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","source","raw","err","ended","_mode","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","StaticDatasource","relativePath","pn","pathname","basePath","getAbsolutePath","MdsrvDatasource","getListing","jsonData","frameIndex","getPathUrl","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","Version"],"mappings":"grCAQM,SAAUA,GAAUC,GACxB,GAAsB,oBAAXC,OAAwB,OAEnC,MACMC,EADI,IAAIC,OAAO,GAAGH,eACZI,KAAKH,OAAOI,SAASC,QAEjC,OAAIJ,EACKK,mBAAmBL,EAAE,SAE5B,CAEJ,CAcgB,SAAAM,GAAUC,EAAYC,GACpC,YAAiBC,IAAVF,EAAsBA,EAAQC,CACvC,CAEgB,SAAAE,GAAiBC,EAAgCC,GAC/D,MAAMC,EAASC,OAAOC,OAAO,CAAE,EAAEJ,GACjC,IAAK,MAAMK,KAAKJ,EAAe,MAEfH,IADAE,EAAOK,KACIH,EAAEG,GAAKJ,EAAcI,GAC/C,CACD,OAAOH,CACT,CAEgB,SAAAI,GAAiBN,EAAWO,GAC1C,IAAK,MAAMF,KAAKE,EAAW,CACzB,MAAMX,EAAQW,EAAUF,QACVP,IAAVF,IAAqBI,EAAOK,GAAKT,EACtC,CACD,OAAOI,CACT,CAUgB,SAAAQ,GAASC,EAAcC,GACrCA,EAAMf,GAASe,EAAK,IACpB,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAMG,OAAQD,IAC5BE,MAAMC,QAAQL,EAAME,IACtBH,GAAQC,EAAME,GAAID,GAElBA,EAAIK,KAAKN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AI,GAC9B3+I,SAAU2+I,GAAY,EAAG,GAAI,GAC7B7zJ,SAAU8zJ,GAAW,EAAG,IAAK,GAC7B7zJ,QAAS6zJ,GAAW,EAAG,IAAK,GAC5B5zJ,SAAU0zJ,GAAa,IAAK,GAC5BzzJ,SAAU4zJ,GAAY,QAAS,UAC/B3zJ,UAAW2zJ,GAAY,WAAY,YACnCr0J,QAASo0J,GAAW,EAAG,IAAK,GAC5Bn0J,OAAQm0J,GAAW,EAAG,IAAK,GAC3Bl0J,WAAYm0J,GAAY,cAAe,eAAgB,UACvDj0J,aAAc+zJ,GAAY,EAAG,EAAK,KAClCh0J,UAAWi0J,GAAW,EAAG,IAAK,IAC9BzzJ,WA3C8B,CAAE3vB,KAAM,SA4CtC4vB,eAAgBuzJ,GAAY,EAAG,GAAI,GACnCtzJ,aA7C8B,CAAE7vB,KAAM,SA8CtC8vB,iBAAkBqzJ,GAAY,EAAG,GAAI,GACrChiJ,aAAc+hJ,GAAa,KAAQ,GACnCnoG,QAnDgC,CAAE/6E,KAAM,WAoDxCuhH,YAAa8hE,MAAez3L,OAAOgJ,KAAKwmF,MCjD1C,MAAMmoG"} \ No newline at end of file diff --git a/dist/ngl.js b/dist/ngl.js index d7db3af8..0d3fb3ae 100644 --- a/dist/ngl.js +++ b/dist/ngl.js @@ -1,91 +1,88 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).NGL={})}(this,(function(e){"use strict";var t,r,i,n,o;"undefined"!=typeof window&&function(){window.console=window.console||{};for(var e,t,r=window.console,i={},n=function(){},o="memory".split(","),a="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");e=o.pop();)r[e]||(r[e]=i);for(;t=a.pop();)r[t]||(r[t]=n)}(),"undefined"==typeof window||void 0===window.HTMLCanvasElement||window.HTMLCanvasElement.prototype.toBlob||Object.defineProperty(window.HTMLCanvasElement.prototype,"toBlob",{value:function(e,t,r){for(var i=window.atob(this.toDataURL(t,r).split(",")[1]),n=i.length,o=n>>2,a=new Uint8Array(n),s=new Uint32Array(a.buffer,0,o),c=0,u=0;c0?1:-1}),Number.isInteger||(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&e>-9007199254740992&&e<9007199254740992&&Math.floor(e)===e}),Number.isNaN||(Number.isNaN=function(e){return e!=e}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=arguments;if(null==e)throw new TypeError("Cannot convert first argument to object");for(var r,i=Object(e),n=!1,o=1;o1?arguments[1]:void 0,s=a?Number(a):0;Number.isNaN(s)&&(s=0);var c=Math.min(Math.max(s,0),i);if(o+c>i)return!1;for(var u=-1;++ur.length)&&(t=r.length),t-=e.length;var i=r.indexOf(e,t);return-1!==i&&i===t}),String.prototype.repeat||(String.prototype.repeat=function(e){if(null===this)throw new TypeError("can't convert "+this+" to object");var t=""+this;if(e=+e,Number.isNaN(e)&&(e=0),e<0)throw new RangeError("repeat count must be non-negative");if(e===1/0)throw new RangeError("repeat count must be less than infinity");if(e=Math.floor(e),0===t.length||0===e)return"";if(t.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&e)&&(r+=t),0!==(e>>>=1);)t+=t;return r}),String.prototype.includes||(String.prototype.includes=function(e,t){return"number"!=typeof t&&(t=0),!(t+e.length>this.length)&&-1!==this.indexOf(e,t)}),Array.prototype.includes||(Array.prototype.includes=function(e){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var t=Object(this),r=parseInt(t.length,10)||0;if(0===r)return!1;var i,n,o=parseInt(arguments[1],10)||0;for(o>=0?i=o:(i=r+o)<0&&(i=0);i0?1:-1)*Math.floor(Math.abs(t)):t}(e);return Math.min(Math.max(t,0),i)},function(e){var t=this,i=Object(e);if(null==e)throw new TypeError("Array.from requires an array-like object - not null or undefined");var o,a=arguments.length>1?arguments[1]:void 0;if(void 0!==a){if(!r(a))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(o=arguments[2])}for(var s,c=n(i.length),u=r(t)?Object(new t(c)):new Array(c),l=0;l>8&255]+k[e>>16&255]+k[e>>24&255]+"-"+k[255&t]+k[t>>8&255]+"-"+k[t>>16&15|64]+k[t>>24&255]+"-"+k[63&r|128]+k[r>>8&255]+"-"+k[r>>16&255]+k[r>>24&255]+k[255&i]+k[i>>8&255]+k[i>>16&255]+k[i>>24&255]).toUpperCase()},clamp:function(e,t,r){return Math.max(t,Math.min(r,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},lerp:function(e,t,r){return(1-r)*e+r*t},smoothstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*F.DEG2RAD},radToDeg:function(e){return e*F.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,r,i,n){var o=Math.cos,a=Math.sin,s=o(r/2),c=a(r/2),u=o((t+i)/2),l=a((t+i)/2),h=o((t-i)/2),p=a((t-i)/2),d=o((i-t)/2),f=a((i-t)/2);switch(n){case"XYX":e.set(s*l,c*h,c*p,s*u);break;case"YZY":e.set(c*p,s*l,c*h,s*u);break;case"ZXZ":e.set(c*h,c*p,s*l,s*u);break;case"XZX":e.set(s*l,c*f,c*d,s*u);break;case"YXY":e.set(c*d,s*l,c*f,s*u);break;case"ZYZ":e.set(c*f,c*d,s*l,s*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}};function z(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.x=e,this.y=t}function U(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(z.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(z.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},clampLength:function(e,t){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){return Math.atan2(-this.y,-this.x)+Math.PI},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y;return t*t+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var r=Math.cos(t),i=Math.sin(t),n=this.x-e.x,o=this.y-e.y;return this.x=n*r-o*i+e.x,this.y=n*i+o*r+e.y,this},random:function(){return this.x=Math.random(),this.y=Math.random(),this}}),Object.assign(U.prototype,{isMatrix3:!0,set:function(e,t,r,i,n,o,a,s,c){var u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=n,u[5]=s,u[6]=r,u[7]=o,u[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this},extractBasis:function(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,i=t.elements,n=this.elements,o=r[0],a=r[3],s=r[6],c=r[1],u=r[4],l=r[7],h=r[2],p=r[5],d=r[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],b=i[7],x=i[2],_=i[5],w=i[8];return n[0]=o*f+a*v+s*x,n[3]=o*m+a*y+s*_,n[6]=o*g+a*b+s*w,n[1]=c*f+u*v+l*x,n[4]=c*m+u*y+l*_,n[7]=c*g+u*b+l*w,n[2]=h*f+p*v+d*x,n[5]=h*m+p*y+d*_,n[8]=h*g+p*b+d*w,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],s=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-r*n*u+r*a*s+i*n*c-i*o*s},getInverse:function(e,t){void 0!==t&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");var r=e.elements,i=this.elements,n=r[0],o=r[1],a=r[2],s=r[3],c=r[4],u=r[5],l=r[6],h=r[7],p=r[8],d=p*c-u*h,f=u*l-p*s,m=h*s-c*l,g=n*d+o*f+a*m;if(0===g)return this.set(0,0,0,0,0,0,0,0,0);var v=1/g;return i[0]=d*v,i[1]=(a*h-p*o)*v,i[2]=(u*o-a*c)*v,i[3]=f*v,i[4]=(p*n-a*l)*v,i[5]=(a*s-u*n)*v,i[6]=m*v,i[7]=(o*l-h*n)*v,i[8]=(c*n-o*s)*v,this},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},setUvTransform:function(e,t,r,i,n,o,a){var s=Math.cos(n),c=Math.sin(n);this.set(r*s,r*c,-r*(s*o+c*a)+o+e,-i*c,i*s,-i*(-c*o+s*a)+a+t,0,0,1)},scale:function(e,t){var r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=t,r[4]*=t,r[7]*=t,this},rotate:function(e){var t=Math.cos(e),r=Math.sin(e),i=this.elements,n=i[0],o=i[3],a=i[6],s=i[1],c=i[4],u=i[7];return i[0]=t*n+r*s,i[3]=t*o+r*c,i[6]=t*a+r*u,i[1]=-r*n+t*s,i[4]=-r*o+t*c,i[7]=-r*a+t*u,this},translate:function(e,t){var r=this.elements;return r[0]+=e*r[2],r[3]+=e*r[5],r[6]+=e*r[8],r[1]+=t*r[2],r[4]+=t*r[5],r[7]+=t*r[8],this},equals:function(e){for(var t=this.elements,r=e.elements,i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(var r=0;r<9;r++)this.elements[r]=e[r+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}});var j=function(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;var t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===B&&(B=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),B.width=e.width,B.height=e.height;var r=B.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=B}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")},G=0;function V(e,t,r,i,n,o,a,s,c,u){Object.defineProperty(this,"id",{value:G++}),this.uuid=F.generateUUID(),this.name="",this.image=void 0!==e?e:V.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:V.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:y,this.wrapT=void 0!==i?i:y,this.magFilter=void 0!==n?n:_,this.minFilter=void 0!==o?o:1008,this.anisotropy=void 0!==c?c:1,this.format=void 0!==a?a:I,this.internalFormat=null,this.type=void 0!==s?s:w,this.offset=new z(0,0),this.repeat=new z(1,1),this.center=new z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new U,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:L,this.version=0,this.onUpdate=null}function $(e,t,r,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=1),this.x=e,this.y=t,this.z=r,this.w=i}function H(e,t,r){this.width=e,this.height=t,this.scissor=new $(0,0,e,t),this.scissorTest=!1,this.viewport=new $(0,0,e,t),r=r||{},this.texture=new V(void 0,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=void 0!==r.generateMipmaps&&r.generateMipmaps,this.texture.minFilter=void 0!==r.minFilter?r.minFilter:_,this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function W(e,t,r,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=1),this._x=e,this._y=t,this._z=r,this._w=i}V.DEFAULT_IMAGE=void 0,V.DEFAULT_MAPPING=300,V.prototype=Object.assign(Object.create(R.prototype),{constructor:V,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var r={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var i=this.image;if(void 0===i.uuid&&(i.uuid=F.generateUUID()),!t&&void 0===e.images[i.uuid]){var n;if(Array.isArray(i)){n=[];for(var o=0,a=i.length;o1)switch(this.wrapS){case v:e.x=e.x-Math.floor(e.x);break;case y:e.x=e.x<0?0:1;break;case b:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case v:e.y=e.y-Math.floor(e.y);break;case y:e.y=e.y<0?0:1;break;case b:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(V.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.defineProperties($.prototype,{width:{get:function(){return this.z},set:function(e){this.z=e}},height:{get:function(){return this.w},set:function(e){this.w=e}}}),Object.assign($.prototype,{isVector4:!0,set:function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=this.w,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*i+o[12]*n,this.y=o[1]*t+o[5]*r+o[9]*i+o[13]*n,this.z=o[2]*t+o[6]*r+o[10]*i+o[14]*n,this.w=o[3]*t+o[7]*r+o[11]*i+o[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,r,i,n,o=.01,a=.1,s=e.elements,c=s[0],u=s[4],l=s[8],h=s[1],p=s[5],d=s[9],f=s[2],m=s[6],g=s[10];if(Math.abs(u-h)y&&v>b?vb?y=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),x=Math.atan2(b,g*v);m=Math.sin(m*x)/b,a=Math.sin(a*x)/b}var _=a*v;if(s=s*m+h*_,c=c*m+p*_,u=u*m+d*_,l=l*m+f*_,m===1-a){var w=1/Math.sqrt(s*s+c*c+u*u+l*l);s*=w,c*=w,u*=w,l*=w}}e[t]=s,e[t+1]=c,e[t+2]=u,e[t+3]=l},multiplyQuaternionsFlat:function(e,t,r,i,n,o){var a=r[i],s=r[i+1],c=r[i+2],u=r[i+3],l=n[o],h=n[o+1],p=n[o+2],d=n[o+3];return e[t]=a*d+u*l+s*p-c*h,e[t+1]=s*d+u*h+c*l-a*p,e[t+2]=c*d+u*p+a*h-s*l,e[t+3]=u*d-a*l-s*h-c*p,e}}),Object.defineProperties(W.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}}}),Object.assign(W.prototype,{isQuaternion:!0,set:function(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=e._x,i=e._y,n=e._z,o=e.order,a=Math.cos,s=Math.sin,c=a(r/2),u=a(i/2),l=a(n/2),h=s(r/2),p=s(i/2),d=s(n/2);switch(o){case"XYZ":this._x=h*u*l+c*p*d,this._y=c*p*l-h*u*d,this._z=c*u*d+h*p*l,this._w=c*u*l-h*p*d;break;case"YXZ":this._x=h*u*l+c*p*d,this._y=c*p*l-h*u*d,this._z=c*u*d-h*p*l,this._w=c*u*l+h*p*d;break;case"ZXY":this._x=h*u*l-c*p*d,this._y=c*p*l+h*u*d,this._z=c*u*d+h*p*l,this._w=c*u*l-h*p*d;break;case"ZYX":this._x=h*u*l-c*p*d,this._y=c*p*l+h*u*d,this._z=c*u*d-h*p*l,this._w=c*u*l+h*p*d;break;case"YZX":this._x=h*u*l+c*p*d,this._y=c*p*l+h*u*d,this._z=c*u*d-h*p*l,this._w=c*u*l-h*p*d;break;case"XZY":this._x=h*u*l-c*p*d,this._y=c*p*l-h*u*d,this._z=c*u*d+h*p*l,this._w=c*u*l+h*p*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==t&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){var r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this},setFromRotationMatrix:function(e){var t=e.elements,r=t[0],i=t[4],n=t[8],o=t[1],a=t[5],s=t[9],c=t[2],u=t[6],l=t[10],h=r+a+l;if(h>0){var p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(u-s)*p,this._y=(n-c)*p,this._z=(o-i)*p}else if(r>a&&r>l){var d=2*Math.sqrt(1+r-a-l);this._w=(u-s)/d,this._x=.25*d,this._y=(i+o)/d,this._z=(n+c)/d}else if(a>l){var f=2*Math.sqrt(1+a-r-l);this._w=(n-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(s+u)/f}else{var m=2*Math.sqrt(1+l-r-a);this._w=(o-i)/m,this._x=(n+c)/m,this._y=(s+u)/m,this._z=.25*m}return this._onChangeCallback(),this},setFromUnitVectors:function(e,t){var r=e.dot(t)+1;return r<1e-6?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=r),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(F.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var r=this.angleTo(e);if(0===r)return this;var i=Math.min(1,t/r);return this.slerp(e,i),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var r=e._x,i=e._y,n=e._z,o=e._w,a=t._x,s=t._y,c=t._z,u=t._w;return this._x=r*u+o*a+i*c-n*s,this._y=i*u+o*s+n*a-r*c,this._z=n*u+o*c+r*s-i*a,this._w=o*u-r*a-i*s-n*c,this._onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var r=this._x,i=this._y,n=this._z,o=this._w,a=o*e._w+r*e._x+i*e._y+n*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=r,this._y=i,this._z=n,this;var s=1-a*a;if(s<=Number.EPSILON){var c=1-t;return this._w=c*o+t*this._w,this._x=c*r+t*this._x,this._y=c*i+t*this._y,this._z=c*n+t*this._z,this.normalize(),this._onChangeCallback(),this}var u=Math.sqrt(s),l=Math.atan2(u,a),h=Math.sin((1-t)*l)/u,p=Math.sin(t*l)/u;return this._w=o*h+this._w*p,this._x=r*h+this._x*p,this._y=i*h+this._y*p,this._z=n*h+this._z*p,this._onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},fromBufferAttribute:function(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});var q=new Y,X=new W;function Y(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),this.x=e,this.y=t,this.z=r}Object.assign(Y.prototype,{isVector3:!0,set:function(e,t,r){return this.x=e,this.y=t,this.z=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(X.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(X.setFromAxisAngle(e,t))},applyMatrix3:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[3]*r+n[6]*i,this.y=n[1]*t+n[4]*r+n[7]*i,this.z=n[2]*t+n[5]*r+n[8]*i,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements,o=1/(n[3]*t+n[7]*r+n[11]*i+n[15]);return this.x=(n[0]*t+n[4]*r+n[8]*i+n[12])*o,this.y=(n[1]*t+n[5]*r+n[9]*i+n[13])*o,this.z=(n[2]*t+n[6]*r+n[10]*i+n[14])*o,this},applyQuaternion:function(e){var t=this.x,r=this.y,i=this.z,n=e.x,o=e.y,a=e.z,s=e.w,c=s*t+o*i-a*r,u=s*r+a*t-n*i,l=s*i+n*r-o*t,h=-n*t-o*r-a*i;return this.x=c*s+h*-n+u*-a-l*-o,this.y=u*s+h*-o+l*-n-c*-a,this.z=l*s+h*-a+c*-o-u*-n,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*i,this.y=n[1]*t+n[5]*r+n[9]*i,this.z=n[2]*t+n[6]*r+n[10]*i,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},clampLength:function(e,t){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var r=e.x,i=e.y,n=e.z,o=t.x,a=t.y,s=t.z;return this.x=i*s-n*a,this.y=n*o-r*s,this.z=r*a-i*o,this},projectOnVector:function(e){var t=e.lengthSq();if(0===t)return this.set(0,0,0);var r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)},projectOnPlane:function(e){return q.copy(this).projectOnVector(e),this.sub(q)},reflect:function(e){return this.sub(q.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;var r=this.dot(e)/t;return Math.acos(F.clamp(r,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,r){var i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},setFromMatrix3Column:function(e,t){return this.fromArray(e.elements,3*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this},random:function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}});var Z=new Y,K=new ie,Q=new Y(0,0,0),J=new Y(1,1,1),ee=new Y,te=new Y,re=new Y;function ie(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(ie.prototype,{isMatrix4:!0,set:function(e,t,r,i,n,o,a,s,c,u,l,h,p,d,f,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=r,g[12]=i,g[1]=n,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=u,g[10]=l,g[14]=h,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new ie).fromArray(this.elements)},copy:function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this},copyPosition:function(e){var t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this},extractBasis:function(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this},extractRotation:function(e){var t=this.elements,r=e.elements,i=1/Z.setFromMatrixColumn(e,0).length(),n=1/Z.setFromMatrixColumn(e,1).length(),o=1/Z.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*n,t[5]=r[5]*n,t[6]=r[6]*n,t[7]=0,t[8]=r[8]*o,t[9]=r[9]*o,t[10]=r[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,r=e.x,i=e.y,n=e.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(i),c=Math.sin(i),u=Math.cos(n),l=Math.sin(n);if("XYZ"===e.order){var h=o*u,p=o*l,d=a*u,f=a*l;t[0]=s*u,t[4]=-s*l,t[8]=c,t[1]=p+d*c,t[5]=h-f*c,t[9]=-a*s,t[2]=f-h*c,t[6]=d+p*c,t[10]=o*s}else if("YXZ"===e.order){var m=s*u,g=s*l,v=c*u,y=c*l;t[0]=m+y*a,t[4]=v*a-g,t[8]=o*c,t[1]=o*l,t[5]=o*u,t[9]=-a,t[2]=g*a-v,t[6]=y+m*a,t[10]=o*s}else if("ZXY"===e.order){var b=s*u,x=s*l,_=c*u,w=c*l;t[0]=b-w*a,t[4]=-o*l,t[8]=_+x*a,t[1]=x+_*a,t[5]=o*u,t[9]=w-b*a,t[2]=-o*c,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){var S=o*u,A=o*l,M=a*u,C=a*l;t[0]=s*u,t[4]=M*c-A,t[8]=S*c+C,t[1]=s*l,t[5]=C*c+S,t[9]=A*c-M,t[2]=-c,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){var P=o*s,T=o*c,I=a*s,E=a*c;t[0]=s*u,t[4]=E-P*l,t[8]=I*l+T,t[1]=l,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=T*l+I,t[10]=P-E*l}else if("XZY"===e.order){var D=o*s,L=o*c,O=a*s,R=a*c;t[0]=s*u,t[4]=-l,t[8]=c*u,t[1]=D*l+R,t[5]=o*u,t[9]=L*l-O,t[2]=O*l-L,t[6]=a*u,t[10]=R*l+D}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(Q,e,J)},lookAt:function(e,t,r){var i=this.elements;return re.subVectors(e,t),0===re.lengthSq()&&(re.z=1),re.normalize(),ee.crossVectors(r,re),0===ee.lengthSq()&&(1===Math.abs(r.z)?re.x+=1e-4:re.z+=1e-4,re.normalize(),ee.crossVectors(r,re)),ee.normalize(),te.crossVectors(re,ee),i[0]=ee.x,i[4]=te.x,i[8]=re.x,i[1]=ee.y,i[5]=te.y,i[9]=re.y,i[2]=ee.z,i[6]=te.z,i[10]=re.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,i=t.elements,n=this.elements,o=r[0],a=r[4],s=r[8],c=r[12],u=r[1],l=r[5],h=r[9],p=r[13],d=r[2],f=r[6],m=r[10],g=r[14],v=r[3],y=r[7],b=r[11],x=r[15],_=i[0],w=i[4],S=i[8],A=i[12],M=i[1],C=i[5],P=i[9],T=i[13],I=i[2],E=i[6],D=i[10],L=i[14],O=i[3],R=i[7],k=i[11],N=i[15];return n[0]=o*_+a*M+s*I+c*O,n[4]=o*w+a*C+s*E+c*R,n[8]=o*S+a*P+s*D+c*k,n[12]=o*A+a*T+s*L+c*N,n[1]=u*_+l*M+h*I+p*O,n[5]=u*w+l*C+h*E+p*R,n[9]=u*S+l*P+h*D+p*k,n[13]=u*A+l*T+h*L+p*N,n[2]=d*_+f*M+m*I+g*O,n[6]=d*w+f*C+m*E+g*R,n[10]=d*S+f*P+m*D+g*k,n[14]=d*A+f*T+m*L+g*N,n[3]=v*_+y*M+b*I+x*O,n[7]=v*w+y*C+b*E+x*R,n[11]=v*S+y*P+b*D+x*k,n[15]=v*A+y*T+b*L+x*N,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},determinant:function(){var e=this.elements,t=e[0],r=e[4],i=e[8],n=e[12],o=e[1],a=e[5],s=e[9],c=e[13],u=e[2],l=e[6],h=e[10],p=e[14];return e[3]*(+n*s*l-i*c*l-n*a*h+r*c*h+i*a*p-r*s*p)+e[7]*(+t*s*p-t*c*h+n*o*h-i*o*p+i*c*u-n*s*u)+e[11]*(+t*c*l-t*a*p-n*o*l+r*o*p+n*a*u-r*c*u)+e[15]*(-i*a*u-t*s*l+t*a*h+i*o*l-r*o*h+r*s*u)},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},setPosition:function(e,t,r){var i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this},getInverse:function(e,t){void 0!==t&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");var r=this.elements,i=e.elements,n=i[0],o=i[1],a=i[2],s=i[3],c=i[4],u=i[5],l=i[6],h=i[7],p=i[8],d=i[9],f=i[10],m=i[11],g=i[12],v=i[13],y=i[14],b=i[15],x=d*y*h-v*f*h+v*l*m-u*y*m-d*l*b+u*f*b,_=g*f*h-p*y*h-g*l*m+c*y*m+p*l*b-c*f*b,w=p*v*h-g*d*h+g*u*m-c*v*m-p*u*b+c*d*b,S=g*d*l-p*v*l-g*u*f+c*v*f+p*u*y-c*d*y,A=n*x+o*_+a*w+s*S;if(0===A)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var M=1/A;return r[0]=x*M,r[1]=(v*f*s-d*y*s-v*a*m+o*y*m+d*a*b-o*f*b)*M,r[2]=(u*y*s-v*l*s+v*a*h-o*y*h-u*a*b+o*l*b)*M,r[3]=(d*l*s-u*f*s-d*a*h+o*f*h+u*a*m-o*l*m)*M,r[4]=_*M,r[5]=(p*y*s-g*f*s+g*a*m-n*y*m-p*a*b+n*f*b)*M,r[6]=(g*l*s-c*y*s-g*a*h+n*y*h+c*a*b-n*l*b)*M,r[7]=(c*f*s-p*l*s+p*a*h-n*f*h-c*a*m+n*l*m)*M,r[8]=w*M,r[9]=(g*d*s-p*v*s-g*o*m+n*v*m+p*o*b-n*d*b)*M,r[10]=(c*v*s-g*u*s+g*o*h-n*v*h-c*o*b+n*u*b)*M,r[11]=(p*u*s-c*d*s-p*o*h+n*d*h+c*o*m-n*u*m)*M,r[12]=S*M,r[13]=(p*v*a-g*d*a+g*o*f-n*v*f-p*o*y+n*d*y)*M,r[14]=(g*u*a-c*v*a-g*o*l+n*v*l+c*o*y-n*u*y)*M,r[15]=(c*d*a-p*u*a+p*o*l-n*d*l-c*o*f+n*u*f)*M,this},scale:function(e){var t=this.elements,r=e.x,i=e.y,n=e.z;return t[0]*=r,t[4]*=i,t[8]*=n,t[1]*=r,t[5]*=i,t[9]*=n,t[2]*=r,t[6]*=i,t[10]*=n,t[3]*=r,t[7]*=i,t[11]*=n,this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,i))},makeTranslation:function(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var r=Math.cos(t),i=Math.sin(t),n=1-r,o=e.x,a=e.y,s=e.z,c=n*o,u=n*a;return this.set(c*o+r,c*a-i*s,c*s+i*a,0,c*a+i*s,u*a+r,u*s-i*o,0,c*s-i*a,u*s+i*o,n*s*s+r,0,0,0,0,1),this},makeScale:function(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this},makeShear:function(e,t,r){return this.set(1,t,r,0,e,1,r,0,e,t,1,0,0,0,0,1),this},compose:function(e,t,r){var i=this.elements,n=t._x,o=t._y,a=t._z,s=t._w,c=n+n,u=o+o,l=a+a,h=n*c,p=n*u,d=n*l,f=o*u,m=o*l,g=a*l,v=s*c,y=s*u,b=s*l,x=r.x,_=r.y,w=r.z;return i[0]=(1-(f+g))*x,i[1]=(p+b)*x,i[2]=(d-y)*x,i[3]=0,i[4]=(p-b)*_,i[5]=(1-(h+g))*_,i[6]=(m+v)*_,i[7]=0,i[8]=(d+y)*w,i[9]=(m-v)*w,i[10]=(1-(h+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},decompose:function(e,t,r){var i=this.elements,n=Z.set(i[0],i[1],i[2]).length(),o=Z.set(i[4],i[5],i[6]).length(),a=Z.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),e.x=i[12],e.y=i[13],e.z=i[14],K.copy(this);var s=1/n,c=1/o,u=1/a;return K.elements[0]*=s,K.elements[1]*=s,K.elements[2]*=s,K.elements[4]*=c,K.elements[5]*=c,K.elements[6]*=c,K.elements[8]*=u,K.elements[9]*=u,K.elements[10]*=u,t.setFromRotationMatrix(K),r.x=n,r.y=o,r.z=a,this},makePerspective:function(e,t,r,i,n,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var a=this.elements,s=2*n/(t-e),c=2*n/(r-i),u=(t+e)/(t-e),l=(r+i)/(r-i),h=-(o+n)/(o-n),p=-2*o*n/(o-n);return a[0]=s,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=l,a[13]=0,a[2]=0,a[6]=0,a[10]=h,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makeOrthographic:function(e,t,r,i,n,o){var a=this.elements,s=1/(t-e),c=1/(r-i),u=1/(o-n),l=(t+e)*s,h=(r+i)*c,p=(o+n)*u;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-l,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-h,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},equals:function(e){for(var t=this.elements,r=e.elements,i=0;i<16;i++)if(t[i]!==r[i])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(var r=0;r<16;r++)this.elements[r]=e[r+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}});var ne=new ie,oe=new W;function ae(e,t,r,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=ae.DefaultOrder),this._x=e,this._y=t,this._z=r,this._order=i}function se(){this.mask=1}ae.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ae.DefaultOrder="XYZ",Object.defineProperties(ae.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this._onChangeCallback()}}}),Object.assign(ae.prototype,{isEuler:!0,set:function(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._order=i||this._order,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this},setFromRotationMatrix:function(e,t,r){var i=F.clamp,n=e.elements,o=n[0],a=n[4],s=n[8],c=n[1],u=n[5],l=n[9],h=n[2],p=n[6],d=n[10];switch(t=t||this._order){case"XYZ":this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-i(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,o),this._z=0);break;case"ZXY":this._x=Math.asin(i(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(c,o));break;case"ZYX":this._y=Math.asin(-i(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(i(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-l,u),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-i(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!1!==r&&this._onChangeCallback(),this},setFromQuaternion:function(e,t,r){return ne.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ne,t,r)},setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(e){return oe.setFromEuler(this),this.setFromQuaternion(oe,e)},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new Y(this._x,this._y,this._z)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}}),Object.assign(se.prototype,{set:function(e){this.mask=1<1){for(var r=0;r1){for(var r=0;r0){i.children=[];for(var d=0;d0&&(r.geometries=f),m.length>0&&(r.materials=m),g.length>0&&(r.textures=g),v.length>0&&(r.images=v),y.length>0&&(r.shapes=y)}return r.object=i,r;function b(e){var t=[];for(var r in e){var i=e[r];delete i.metadata,t.push(i)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var r=0;rs)return!1}return!0}Object.assign(Ne.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,r=1/0,i=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=e.length;sn&&(n=u),l>o&&(o=l),h>a&&(a=h)}return this.min.set(t,r,i),this.max.set(n,o,a),this},setFromBufferAttribute:function(e){for(var t=1/0,r=1/0,i=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=e.count;sn&&(n=u),l>o&&(o=l),h>a&&(a=h)}return this.min.set(t,r,i),this.max.set(n,o,a),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,r=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new Y),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(e){return this.clampPoint(e.center,Ae),Ae.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(Le),Oe.subVectors(this.max,Le),Ce.subVectors(e.a,Le),Pe.subVectors(e.b,Le),Te.subVectors(e.c,Le),Ie.subVectors(Pe,Ce),Ee.subVectors(Te,Pe),De.subVectors(Ce,Te);var t=[0,-Ie.z,Ie.y,0,-Ee.z,Ee.y,0,-De.z,De.y,Ie.z,0,-Ie.x,Ee.z,0,-Ee.x,De.z,0,-De.x,-Ie.y,Ie.x,0,-Ee.y,Ee.x,0,-De.y,De.x,0];return!!Be(t,Ce,Pe,Te,Oe)&&(!!Be(t=[1,0,0,0,1,0,0,0,1],Ce,Pe,Te,Oe)&&(Re.crossVectors(Ie,Ee),Be(t=[Re.x,Re.y,Re.z],Ce,Pe,Te,Oe)))},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new Y),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Ae.copy(e).clamp(this.min,this.max).sub(e).length()},getBoundingSphere:function(e){return void 0===e&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(Ae).length(),e},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){return this.isEmpty()||(Se[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Se[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Se[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Se[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Se[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Se[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Se[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Se[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Se)),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var Fe=new Ne;function ze(e,t){this.center=void 0!==e?e:new Y,this.radius=void 0!==t?t:-1}Object.assign(ze.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){var r=this.center;void 0!==t?r.copy(t):Fe.setFromPoints(e).getCenter(r);for(var i=0,n=0,o=e.length;nthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Ne),this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}});var Ue=new Y,je=new Y,Ge=new Y,Ve=new Y,$e=new Y,He=new Y,We=new Y;function qe(e,t){this.origin=void 0!==e?e:new Y,this.direction=void 0!==t?t:new Y(0,0,-1)}Object.assign(qe.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new Y),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,Ue)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new Y),t.subVectors(e,this.origin);var r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var t=Ue.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ue.copy(this.direction).multiplyScalar(t).add(this.origin),Ue.distanceToSquared(e))},distanceSqToSegment:function(e,t,r,i){je.copy(e).add(t).multiplyScalar(.5),Ge.copy(t).sub(e).normalize(),Ve.copy(this.origin).sub(je);var n,o,a,s,c=.5*e.distanceTo(t),u=-this.direction.dot(Ge),l=Ve.dot(this.direction),h=-Ve.dot(Ge),p=Ve.lengthSq(),d=Math.abs(1-u*u);if(d>0)if(o=u*l-h,s=c*d,(n=u*h-l)>=0)if(o>=-s)if(o<=s){var f=1/d;a=(n*=f)*(n+u*(o*=f)+2*l)+o*(u*n+o+2*h)+p}else o=c,a=-(n=Math.max(0,-(u*o+l)))*n+o*(o+2*h)+p;else o=-c,a=-(n=Math.max(0,-(u*o+l)))*n+o*(o+2*h)+p;else o<=-s?a=-(n=Math.max(0,-(-u*c+l)))*n+(o=n>0?-c:Math.min(Math.max(-c,-h),c))*(o+2*h)+p:o<=s?(n=0,a=(o=Math.min(Math.max(-c,-h),c))*(o+2*h)+p):a=-(n=Math.max(0,-(u*c+l)))*n+(o=n>0?c:Math.min(Math.max(-c,-h),c))*(o+2*h)+p;else o=u>0?-c:c,a=-(n=Math.max(0,-(u*o+l)))*n+o*(o+2*h)+p;return r&&r.copy(this.direction).multiplyScalar(n).add(this.origin),i&&i.copy(Ge).multiplyScalar(o).add(je),a},intersectSphere:function(e,t){Ue.subVectors(e.center,this.origin);var r=Ue.dot(this.direction),i=Ue.dot(Ue)-r*r,n=e.radius*e.radius;if(i>n)return null;var o=Math.sqrt(n-i),a=r-o,s=r+o;return a<0&&s<0?null:a<0?this.at(s,t):this.at(a,t)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null},intersectPlane:function(e,t){var r=this.distanceToPlane(e);return null===r?null:this.at(r,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var r,i,n,o,a,s,c=1/this.direction.x,u=1/this.direction.y,l=1/this.direction.z,h=this.origin;return c>=0?(r=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c):(r=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c),u>=0?(n=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(n=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),r>o||n>i?null:((n>r||r!=r)&&(r=n),(o=0?(a=(e.min.z-h.z)*l,s=(e.max.z-h.z)*l):(a=(e.max.z-h.z)*l,s=(e.min.z-h.z)*l),r>s||a>i?null:((a>r||r!=r)&&(r=a),(s=0?r:i,t)))},intersectsBox:function(e){return null!==this.intersectBox(e,Ue)},intersectTriangle:function(e,t,r,i,n){$e.subVectors(t,e),He.subVectors(r,e),We.crossVectors($e,He);var o,a=this.direction.dot(We);if(a>0){if(i)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}Ve.subVectors(this.origin,e);var s=o*this.direction.dot(He.crossVectors(Ve,He));if(s<0)return null;var c=o*this.direction.dot($e.cross(Ve));if(c<0)return null;if(s+c>a)return null;var u=-o*Ve.dot(We);return u<0?null:this.at(u/a,n)},applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}});var Xe=new Y,Ye=new Y,Ze=new U;function Ke(e,t){this.normal=void 0!==e?e:new Y(1,0,0),this.constant=void 0!==t?t:0}Object.assign(Ke.prototype,{isPlane:!0,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(e,t,r){var i=Xe.subVectors(r,t).cross(Ye.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new Y),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,t){void 0===t&&(console.warn("THREE.Plane: .intersectLine() target is now required"),t=new Y);var r=e.delta(Xe),i=this.normal.dot(r);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):void 0;var n=-(e.start.dot(this.normal)+this.constant)/i;return n<0||n>1?void 0:t.copy(r).multiplyScalar(n).add(e.start)},intersectsLine:function(e){var t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new Y),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,t){var r=t||Ze.getNormalMatrix(e),i=this.coplanarPoint(Xe).applyMatrix4(e),n=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(n),this},translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}});var Qe=new Y,Je=new Y,et=new Y,tt=new Y,rt=new Y,it=new Y,nt=new Y,ot=new Y,at=new Y,st=new Y;function ct(e,t,r){this.a=void 0!==e?e:new Y,this.b=void 0!==t?t:new Y,this.c=void 0!==r?r:new Y}Object.assign(ct,{getNormal:function(e,t,r,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new Y),i.subVectors(r,t),Qe.subVectors(e,t),i.cross(Qe);var n=i.lengthSq();return n>0?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)},getBarycoord:function(e,t,r,i,n){Qe.subVectors(i,t),Je.subVectors(r,t),et.subVectors(e,t);var o=Qe.dot(Qe),a=Qe.dot(Je),s=Qe.dot(et),c=Je.dot(Je),u=Je.dot(et),l=o*c-a*a;if(void 0===n&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),n=new Y),0===l)return n.set(-2,-1,-1);var h=1/l,p=(c*s-a*u)*h,d=(o*u-a*s)*h;return n.set(1-p-d,d,p)},containsPoint:function(e,t,r,i){return ct.getBarycoord(e,t,r,i,tt),tt.x>=0&&tt.y>=0&&tt.x+tt.y<=1},getUV:function(e,t,r,i,n,o,a,s){return this.getBarycoord(e,t,r,i,tt),s.set(0,0),s.addScaledVector(n,tt.x),s.addScaledVector(o,tt.y),s.addScaledVector(a,tt.z),s},isFrontFacing:function(e,t,r,i){return Qe.subVectors(r,t),Je.subVectors(e,t),Qe.cross(Je).dot(i)<0}}),Object.assign(ct.prototype,{set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this},setFromPointsAndIndices:function(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){return Qe.subVectors(this.c,this.b),Je.subVectors(this.a,this.b),.5*Qe.cross(Je).length()},getMidpoint:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new Y),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return ct.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new Ke),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return ct.getBarycoord(e,this.a,this.b,this.c,t)},getUV:function(e,t,r,i,n){return ct.getUV(e,this.a,this.b,this.c,t,r,i,n)},containsPoint:function(e){return ct.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return ct.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new Y);var r,i,n=this.a,o=this.b,a=this.c;rt.subVectors(o,n),it.subVectors(a,n),ot.subVectors(e,n);var s=rt.dot(ot),c=it.dot(ot);if(s<=0&&c<=0)return t.copy(n);at.subVectors(e,o);var u=rt.dot(at),l=it.dot(at);if(u>=0&&l<=u)return t.copy(o);var h=s*l-u*c;if(h<=0&&s>=0&&u<=0)return r=s/(s-u),t.copy(n).addScaledVector(rt,r);st.subVectors(e,a);var p=rt.dot(st),d=it.dot(st);if(d>=0&&p<=d)return t.copy(a);var f=p*c-s*d;if(f<=0&&c>=0&&d<=0)return i=c/(c-d),t.copy(n).addScaledVector(it,i);var m=u*d-p*l;if(m<=0&&l-u>=0&&p-d>=0)return nt.subVectors(a,o),i=(l-u)/(l-u+(p-d)),t.copy(o).addScaledVector(nt,i);var g=1/(m+f+h);return r=f*g,i=h*g,t.copy(n).addScaledVector(rt,r).addScaledVector(it,i)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var ut={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},lt={h:0,s:0,l:0},ht={h:0,s:0,l:0};function pt(e,t,r){return void 0===t&&void 0===r?this.set(e):this.setRGB(e,t,r)}function dt(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}function ft(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function mt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function gt(e,t,r,i,n,o){this.a=e,this.b=t,this.c=r,this.normal=i&&i.isVector3?i:new Y,this.vertexNormals=Array.isArray(i)?i:[],this.color=n&&n.isColor?n:new pt,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=void 0!==o?o:0}Object.assign(pt.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSL:function(e,t,r){if(e=F.euclideanModulo(e,1),t=F.clamp(t,0,1),r=F.clamp(r,0,1),0===t)this.r=this.g=this.b=r;else{var i=r<=.5?r*(1+t):r+t-r*t,n=2*r-i;this.r=dt(n,i,e+1/3),this.g=dt(n,i,e),this.b=dt(n,i,e-1/3)}return this},setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var i,n=r[1],o=r[2];switch(n){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(a,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(e)){var u=r[1],l=u.length;if(3===l)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){var t=ut[e];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var r=t>0?1/t:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(e){return this.r=ft(e.r),this.g=ft(e.g),this.b=ft(e.b),this},copyLinearToSRGB:function(e){return this.r=mt(e.r),this.g=mt(e.g),this.b=mt(e.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,r,i=this.r,n=this.g,o=this.b,a=Math.max(i,n,o),s=Math.min(i,n,o),c=(s+a)/2;if(s===a)t=0,r=0;else{var u=a-s;switch(r=c<=.5?u/(a+s):u/(2-a-s),a){case i:t=(n-o)/u+(n0&&(r.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(r.morphTargets=!0),!0===this.morphNormals&&(r.morphNormals=!0),!0===this.skinning&&(r.skinning=!0),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),t){var n=i(e.textures),o=i(e.images);n.length>0&&(r.textures=n),o.length>0&&(r.images=o)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;var t=e.clippingPlanes,r=null;if(null!==t){var i=t.length;r=new Array(i);for(var n=0;n!==i;++n)r[n]=t[n].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(yt.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),bt.prototype=Object.create(yt.prototype),bt.prototype.constructor=bt,bt.prototype.isMeshBasicMaterial=!0,bt.prototype.copy=function(e){return yt.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this};var xt=new Y,_t=new z;function wt(e,t,r){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===r,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0}function St(e,t,r){wt.call(this,new Int8Array(e),t,r)}function At(e,t,r){wt.call(this,new Uint8Array(e),t,r)}function Mt(e,t,r){wt.call(this,new Uint8ClampedArray(e),t,r)}function Ct(e,t,r){wt.call(this,new Int16Array(e),t,r)}function Pt(e,t,r){wt.call(this,new Uint16Array(e),t,r)}function Tt(e,t,r){wt.call(this,new Int32Array(e),t,r)}function It(e,t,r){wt.call(this,new Uint32Array(e),t,r)}function Et(e,t,r){wt.call(this,new Float32Array(e),t,r)}function Dt(e,t,r){wt.call(this,new Float64Array(e),t,r)}function Lt(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function Ot(e){if(0===e.length)return-1/0;for(var t=e[0],r=1,i=e.length;rt&&(t=e[r]);return t}Object.defineProperty(wt.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(wt.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,r){e*=this.itemSize,r*=t.itemSize;for(var i=0,n=this.itemSize;i0,a=n[1]&&n[1].length>0,s=e.morphTargets,c=s.length;if(c>0){t=[];for(var u=0;u0){l=[];for(var d=0;d0&&0===r.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var y=0;y65535?It:Pt)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,r){this.groups.push({start:e,count:t,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){var t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);var r=this.attributes.normal;if(void 0!==r){var i=(new U).getNormalMatrix(e);r.applyNormalMatrix(i),r.needsUpdate=!0}var n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(e){return kt.makeRotationX(e),this.applyMatrix4(kt),this},rotateY:function(e){return kt.makeRotationY(e),this.applyMatrix4(kt),this},rotateZ:function(e){return kt.makeRotationZ(e),this.applyMatrix4(kt),this},translate:function(e,t,r){return kt.makeTranslation(e,t,r),this.applyMatrix4(kt),this},scale:function(e,t,r){return kt.makeScale(e,t,r),this.applyMatrix4(kt),this},lookAt:function(e){return Nt.lookAt(e),Nt.updateMatrix(),this.applyMatrix4(Nt.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Bt).negate(),this.translate(Bt.x,Bt.y,Bt.z),this},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var r=new Et(3*t.vertices.length,3),i=new Et(3*t.colors.length,3);if(this.setAttribute("position",r.copyVector3sArray(t.vertices)),this.setAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var n=new Et(t.lineDistances.length,1);this.setAttribute("lineDistance",n.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],r=0,i=e.length;r0){var r=new Float32Array(3*e.normals.length);this.setAttribute("normal",new wt(r,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var i=new Float32Array(3*e.colors.length);this.setAttribute("color",new wt(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var n=new Float32Array(2*e.uvs.length);this.setAttribute("uv",new wt(n,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.setAttribute("uv2",new wt(o,2).copyVector2sArray(e.uvs2))}for(var a in this.groups=e.groups,e.morphTargets){for(var s=[],c=e.morphTargets[a],u=0,l=c.length;u0){var d=new Et(4*e.skinIndices.length,4);this.setAttribute("skinIndex",d.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var f=new Et(4*e.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ne);var e=this.attributes.position,t=this.morphAttributes.position;if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(var r=0,i=t.length;r0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var r in t)void 0!==t[r]&&(e[r]=t[r]);return e}e.data={attributes:{}};var i=this.index;null!==i&&(e.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});var n=this.attributes;for(var o in n){var a=n[o],s=a.toJSON(e.data);""!==a.name&&(s.name=a.name),e.data.attributes[o]=s}var c={},u=!1;for(var l in this.morphAttributes){for(var h=this.morphAttributes[l],p=[],d=0,f=h.length;d0&&(c[l]=p,u=!0)}u&&(e.data.morphAttributes=c,e.data.morphTargetsRelative=this.morphTargetsRelative);var v=this.groups;v.length>0&&(e.data.groups=JSON.parse(JSON.stringify(v)));var y=this.boundingSphere;return null!==y&&(e.data.boundingSphere={center:y.center.toArray(),radius:y.radius}),e},clone:function(){return(new jt).copy(this)},copy:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;var t={};this.name=e.name;var r=e.index;null!==r&&this.setIndex(r.clone(t));var i=e.attributes;for(var n in i){var o=i[n];this.setAttribute(n,o.clone(t))}var a=e.morphAttributes;for(var s in a){for(var c=[],u=a[s],l=0,h=u.length;lr.far?null:{distance:c,point:nr.clone(),object:e}}function sr(e,t,r,i,n,o,a,s,c,u,l,h){Ht.fromBufferAttribute(n,u),Wt.fromBufferAttribute(n,l),qt.fromBufferAttribute(n,h);var p=e.morphTargetInfluences;if(t.morphTargets&&o&&p){Kt.set(0,0,0),Qt.set(0,0,0),Jt.set(0,0,0);for(var d=0,f=o.length;d0){var i=t[r[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var n=0,o=i.length;n0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){var r,i=this.geometry,n=this.material,o=this.matrixWorld;if(void 0!==n&&(null===i.boundingSphere&&i.computeBoundingSphere(),$t.copy(i.boundingSphere),$t.applyMatrix4(o),!1!==e.ray.intersectsSphere($t)&&(Gt.getInverse(o),Vt.copy(e.ray).applyMatrix4(Gt),null===i.boundingBox||!1!==Vt.intersectsBox(i.boundingBox))))if(i.isBufferGeometry){var a=i.index,s=i.attributes.position,c=i.morphAttributes.position,u=i.morphTargetsRelative,l=i.attributes.uv,h=i.attributes.uv2,p=i.groups,d=i.drawRange;if(null!==a)if(Array.isArray(n))for(var f=0,m=p.length;f0&&(N=j);for(var G=0,V=U.length;G0)for(var p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){this.computeFaceNormals();for(var e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(var e=0,t=this.faces.length;e=0;f--){var m=c[f];this.faces.splice(m,1);for(var g=0,v=this.faceVertexUvs.length;g0,v=f.vertexNormals.length>0,y=1!==f.color.r||1!==f.color.g||1!==f.color.b,b=f.vertexColors.length>0,x=0;if(x=A(x,0,0),x=A(x,1,!0),x=A(x,2,!1),x=A(x,3,m),x=A(x,4,g),x=A(x,5,v),x=A(x,6,y),x=A(x,7,b),a.push(x),a.push(f.a,f.b,f.c),a.push(f.materialIndex),m){var _=this.faceVertexUvs[0][d];a.push(P(_[0]),P(_[1]),P(_[2]))}if(g&&a.push(M(f.normal)),v){var w=f.vertexNormals;a.push(M(w[0]),M(w[1]),M(w[2]))}if(y&&a.push(C(f.color)),b){var S=f.vertexColors;a.push(C(S[0]),C(S[1]),C(S[2]))}}function A(e,t,r){return r?e|1<0&&(e.data.colors=u),h.length>0&&(e.data.uvs=[h]),e.data.faces=a,e},clone:function(){return(new pr).copy(this)},copy:function(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;for(var t=e.vertices,r=0,i=t.length;r0?1:-1,l.push(P.x,P.y,P.z),h.push(E/m),h.push(1-T/g),M+=1}for(var L=0;L0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var n={};for(var o in this.extensions)!0===this.extensions[o]&&(n[o]=!0);return Object.keys(n).length>0&&(t.extensions=n),t},yr.prototype=Object.assign(Object.create(_e.prototype),{constructor:yr,isCamera:!0,copy:function(e,t){return _e.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new Y),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){_e.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(e,t){_e.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),br.prototype=Object.assign(Object.create(yr.prototype),{constructor:br,isPerspectiveCamera:!0,copy:function(e,t){return yr.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*F.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(.5*F.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*F.RAD2DEG*Math.atan(Math.tan(.5*F.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,r,i,n,o){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=n,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,t=e*Math.tan(.5*F.DEG2RAD*this.fov)/this.zoom,r=2*t,i=this.aspect*r,n=-.5*i,o=this.view;if(null!==this.view&&this.view.enabled){var a=o.fullWidth,s=o.fullHeight;n+=o.offsetX*i/a,t-=o.offsetY*r/s,i*=o.width/a,r*=o.height/s}var c=this.filmOffset;0!==c&&(n+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+i,t,t-r,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=_e.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}),xr.prototype=Object.create(V.prototype),xr.prototype.constructor=xr,xr.prototype.isDataTexture=!0;var _r=new ze,wr=new Y;function Sr(e,t,r,i,n,o){this.planes=[void 0!==e?e:new Ke,void 0!==t?t:new Ke,void 0!==r?r:new Ke,void 0!==i?i:new Ke,void 0!==n?n:new Ke,void 0!==o?o:new Ke]}Object.assign(Sr.prototype,{set:function(e,t,r,i,n,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,r=0;r<6;r++)t[r].copy(e.planes[r]);return this},setFromProjectionMatrix:function(e){var t=this.planes,r=e.elements,i=r[0],n=r[1],o=r[2],a=r[3],s=r[4],c=r[5],u=r[6],l=r[7],h=r[8],p=r[9],d=r[10],f=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return t[0].setComponents(a-i,l-s,f-h,y-m).normalize(),t[1].setComponents(a+i,l+s,f+h,y+m).normalize(),t[2].setComponents(a+n,l+c,f+p,y+g).normalize(),t[3].setComponents(a-n,l-c,f-p,y-g).normalize(),t[4].setComponents(a-o,l-u,f-d,y-v).normalize(),t[5].setComponents(a+o,l+u,f+d,y+v).normalize(),this},intersectsObject:function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),_r.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(_r)},intersectsSprite:function(e){return _r.center.set(0,0,0),_r.radius=.7071067811865476,_r.applyMatrix4(e.matrixWorld),this.intersectsSphere(_r)},intersectsSphere:function(e){for(var t=this.planes,r=e.center,i=-e.radius,n=0;n<6;n++){if(t[n].distanceToPoint(r)0?e.max.x:e.min.x,wr.y=i.normal.y>0?e.max.y:e.min.y,wr.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(wr)<0)return!1}return!0},containsPoint:function(e){for(var t=this.planes,r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}});var Ar={common:{diffuse:{value:new pt(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new U},uv2Transform:{value:new U},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new z(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new pt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new pt(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new U}},sprite:{diffuse:{value:new pt(15658734)},opacity:{value:1},center:{value:new z(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new U}}};function Mr(){var e=null,t=!1,r=null,i=null;function n(t,o){r(t,o),i=e.requestAnimationFrame(n)}return{start:function(){!0!==t&&null!==r&&(i=e.requestAnimationFrame(n),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){r=e},setContext:function(t){e=t}}}function Cr(e,t){var r=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);var r=i.get(t);r&&(e.deleteBuffer(r.buffer),i.delete(t))},update:function(t,n){t.isInterleavedBufferAttribute&&(t=t.data);var o=i.get(t);void 0===o?i.set(t,function(t,r){var i=t.array,n=t.usage,o=e.createBuffer();e.bindBuffer(r,o),e.bufferData(r,i,n),t.onUploadCallback();var a=5126;return i instanceof Float32Array?a=5126:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?a=5123:i instanceof Int16Array?a=5122:i instanceof Uint32Array?a=5125:i instanceof Int32Array?a=5124:i instanceof Int8Array?a=5120:i instanceof Uint8Array&&(a=5121),{buffer:o,type:a,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(t,n)):o.version0.0){distanceFalloff*=pow2(saturate(1.0-pow4(lightDistance/cutoffDistance)));}return distanceFalloff;\n#else\nif(cutoffDistance>0.0&&decayExponent>0.0){return pow(saturate(-lightDistance/cutoffDistance+1.0),decayExponent);}return 1.0;\n#endif\n}vec3 BRDF_Diffuse_Lambert(const in vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}vec3 F_Schlick(const in vec3 specularColor,const in float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}vec3 F_Schlick_RoughnessDependent(const in vec3 F0,const in float dotNV,const in float roughness){float fresnel=exp2((-5.55473*dotNV-6.98316)*dotNV);vec3 Fr=max(vec3(1.0-roughness),F0)-F0;return Fr*fresnel+F0;}float G_GGX_Smith(const in float alpha,const in float dotNL,const in float dotNV){float a2=pow2(alpha);float gl=dotNL+sqrt(a2+(1.0-a2)*pow2(dotNL));float gv=dotNV+sqrt(a2+(1.0-a2)*pow2(dotNV));return 1.0/(gl*gv);}float G_GGX_SmithCorrelated(const in float alpha,const in float dotNL,const in float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(const in float alpha,const in float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}vec3 BRDF_Specular_GGX(const in IncidentLight incidentLight,const in vec3 viewDir,const in vec3 normal,const in vec3 specularColor,const in float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentLight.direction+viewDir);float dotNL=saturate(dot(normal,incidentLight.direction));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentLight.direction,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec2 LTC_Uv(const in vec3 N,const in vec3 V,const in float roughness){const float LUT_SIZE=64.0;const float LUT_SCALE=(LUT_SIZE-1.0)/LUT_SIZE;const float LUT_BIAS=0.5/LUT_SIZE;float dotNV=saturate(dot(N,V));vec2 uv=vec2(roughness,sqrt(1.0-dotNV));uv=uv*LUT_SCALE+LUT_BIAS;return uv;}float LTC_ClippedSphereFormFactor(const in vec3 f){float l=length(f);return max((l*l+f.z)/(l+1.0),0.0);}vec3 LTC_EdgeVectorFormFactor(const in vec3 v1,const in vec3 v2){float x=dot(v1,v2);float y=abs(x);float a=0.8543985+(0.4965155+0.0145206*y)*y;float b=3.4175940+(4.1616724+y)*y;float v=a/b;float theta_sintheta=(x>0.0)?v:0.5*inversesqrt(max(1.0-x*x,1e-7))-v;return cross(v1,v2)*theta_sintheta;}vec3 LTC_Evaluate(const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[4]){vec3 v1=rectCoords[1]-rectCoords[0];vec3 v2=rectCoords[3]-rectCoords[0];vec3 lightNormal=cross(v1,v2);if(dot(lightNormal,P-rectCoords[0])<0.0)return vec3(0.0);vec3 T1,T2;T1=normalize(V-N*dot(V,N));T2=-cross(N,T1);mat3 mat=mInv*transposeMat3(mat3(T1,T2,N));vec3 coords[4];coords[0]=mat*(rectCoords[0]-P);coords[1]=mat*(rectCoords[1]-P);coords[2]=mat*(rectCoords[2]-P);coords[3]=mat*(rectCoords[3]-P);coords[0]=normalize(coords[0]);coords[1]=normalize(coords[1]);coords[2]=normalize(coords[2]);coords[3]=normalize(coords[3]);vec3 vectorFormFactor=vec3(0.0);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[0],coords[1]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[1],coords[2]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[2],coords[3]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[3],coords[0]);float result=LTC_ClippedSphereFormFactor(vectorFormFactor);return vec3(result);}vec3 BRDF_Specular_GGX_Environment(const in vec3 viewDir,const in vec3 normal,const in vec3 specularColor,const in float roughness){float dotNV=saturate(dot(normal,viewDir));vec2 brdf=integrateSpecularBRDF(dotNV,roughness);return specularColor*brdf.x+brdf.y;}void BRDF_Specular_Multiscattering_Environment(const in GeometricContext geometry,const in vec3 specularColor,const in float roughness,inout vec3 singleScatter,inout vec3 multiScatter){float dotNV=saturate(dot(geometry.normal,geometry.viewDir));vec3 F=F_Schlick_RoughnessDependent(specularColor,dotNV,roughness);vec2 brdf=integrateSpecularBRDF(dotNV,roughness);vec3 FssEss=F*brdf.x+brdf.y;float Ess=brdf.x+brdf.y;float Ems=1.0-Ess;vec3 Favg=specularColor+(1.0-specularColor)*0.047619;vec3 Fms=FssEss*Favg/(1.0-Ems*Favg);singleScatter+=FssEss;multiScatter+=Fms*Ems;}float G_BlinnPhong_Implicit(){return 0.25;}float D_BlinnPhong(const in float shininess,const in float dotNH){return RECIPROCAL_PI*(shininess*0.5+1.0)*pow(dotNH,shininess);}vec3 BRDF_Specular_BlinnPhong(const in IncidentLight incidentLight,const in GeometricContext geometry,const in vec3 specularColor,const in float shininess){vec3 halfDir=normalize(incidentLight.direction+geometry.viewDir);float dotNH=saturate(dot(geometry.normal,halfDir));float dotLH=saturate(dot(incidentLight.direction,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_BlinnPhong_Implicit();float D=D_BlinnPhong(shininess,dotNH);return F*(G*D);}float GGXRoughnessToBlinnExponent(const in float ggxRoughness){return(2.0/pow2(ggxRoughness+0.0001)-2.0);}float BlinnExponentToGGXRoughness(const in float blinnExponent){return sqrt(2.0/(blinnExponent+2.0));}\n#if defined(USE_SHEEN)\nfloat D_Charlie(float roughness,float NoH){float invAlpha=1.0/roughness;float cos2h=NoH*NoH;float sin2h=max(1.0-cos2h,0.0078125);return(2.0+invAlpha)*pow(sin2h,invAlpha*0.5)/(2.0*PI);}float V_Neubelt(float NoV,float NoL){return saturate(1.0/(4.0*(NoL+NoV-NoL*NoV)));}vec3 BRDF_Specular_Sheen(const in float roughness,const in vec3 L,const in GeometricContext geometry,vec3 specularColor){vec3 N=geometry.normal;vec3 V=geometry.viewDir;vec3 H=normalize(V+L);float dotNH=saturate(dot(N,H));return specularColor*D_Charlie(roughness,dotNH)*V_Neubelt(dot(N,V),dot(N,L));}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;uniform float bumpScale;vec2 dHdxy_fwd(){vec2 dSTdx=dFdx(vUv);vec2 dSTdy=dFdy(vUv);float Hll=bumpScale*texture2D(bumpMap,vUv).x;float dBx=bumpScale*texture2D(bumpMap,vUv+dSTdx).x-Hll;float dBy=bumpScale*texture2D(bumpMap,vUv+dSTdy).x-Hll;return vec2(dBx,dBy);}vec3 perturbNormalArb(vec3 surf_pos,vec3 surf_norm,vec2 dHdxy){vec3 vSigmaX=vec3(dFdx(surf_pos.x),dFdx(surf_pos.y),dFdx(surf_pos.z));vec3 vSigmaY=vec3(dFdy(surf_pos.x),dFdy(surf_pos.y),dFdy(surf_pos.z));vec3 vN=surf_norm;vec3 R1=cross(vSigmaY,vN);vec3 R2=cross(vN,vSigmaX);float fDet=dot(vSigmaX,R1);fDet*=(float(gl_FrontFacing)*2.0-1.0);vec3 vGrad=sign(fDet)*(dHdxy.x*R1+dHdxy.y*R2);return normalize(abs(fDet)*surf_norm-vGrad);}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES>0\nvec4 plane;\n#pragma unroll_loop_start\nfor(int i=0;iplane.w)discard;}\n#pragma unroll_loop_end\n#if UNION_CLIPPING_PLANESplane.w)&&clipped;}\n#pragma unroll_loop_end\nif(clipped)discard;\n#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES>0\nvarying vec3 vClipPosition;uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES>0\nvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES>0\nvClipPosition=-mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\ndiffuseColor.rgb*=vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor.xyz=color.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a)clamp(a,0.0,1.0)\n#endif\n#define whiteComplement(a)(1.0-saturate(a))\nfloat pow2(const in float x){return x*x;}float pow3(const in float x){return x*x*x;}float pow4(const in float x){float x2=x*x;return x2*x2;}float average(const in vec3 color){return dot(color,vec3(0.3333));}highp float rand(const in vec2 uv){const highp float a=12.9898,b=78.233,c=43758.5453;highp float dt=dot(uv.xy,vec2(a,b)),sn=mod(dt,PI);return fract(sin(sn)*c);}\n#ifdef HIGH_PRECISION\nfloat precisionSafeLength(vec3 v){return length(v);}\n#else\nfloat max3(vec3 v){return max(max(v.x,v.y),v.z);}float precisionSafeLength(vec3 v){float maxComponent=max3(abs(v));return length(v/maxComponent)*maxComponent;}\n#endif\nstruct IncidentLight{vec3 color;vec3 direction;bool visible;};struct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct GeometricContext{vec3 position;vec3 normal;vec3 viewDir;\n#ifdef CLEARCOAT\nvec3 clearcoatNormal;\n#endif\n};vec3 transformDirection(in vec3 dir,in mat4 matrix){return normalize((matrix*vec4(dir,0.0)).xyz);}vec3 inverseTransformDirection(in vec3 dir,in mat4 matrix){return normalize((vec4(dir,0.0)*matrix).xyz);}vec3 projectOnPlane(in vec3 point,in vec3 pointOnPlane,in vec3 planeNormal){float distance=dot(planeNormal,point-pointOnPlane);return-distance*planeNormal+point;}float sideOfPlane(in vec3 point,in vec3 pointOnPlane,in vec3 planeNormal){return sign(dot(point-pointOnPlane,planeNormal));}vec3 linePlaneIntersect(in vec3 pointOnLine,in vec3 lineDirection,in vec3 pointOnPlane,in vec3 planeNormal){return lineDirection*(dot(planeNormal,pointOnPlane-pointOnLine)/dot(planeNormal,lineDirection))+pointOnLine;}mat3 transposeMat3(const in mat3 m){mat3 tmp;tmp[0]=vec3(m[0].x,m[1].x,m[2].x);tmp[1]=vec3(m[0].y,m[1].y,m[2].y);tmp[2]=vec3(m[0].z,m[1].z,m[2].z);return tmp;}float linearToRelativeLuminance(const in vec3 color){vec3 weights=vec3(0.2126,0.7152,0.0722);return dot(weights,color.rgb);}bool isPerspectiveMatrix(mat4 m){return m[2][3]==-1.0;}vec2 equirectUv(in vec3 dir){float u=atan(dir.z,dir.x)*RECIPROCAL_PI2+0.5;float v=asin(clamp(dir.y,-1.0,1.0))*RECIPROCAL_PI+0.5;return vec2(u,v);}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction){vec3 absDirection=abs(direction);float face=-1.0;if(absDirection.x>absDirection.z){if(absDirection.x>absDirection.y)face=direction.x>0.0?0.0:3.0;else face=direction.y>0.0?1.0:4.0;}else{if(absDirection.z>absDirection.y)face=direction.z>0.0?2.0:5.0;else face=direction.y>0.0?1.0:4.0;}return face;}vec2 getUV(vec3 direction,float face){vec2 uv;if(face==0.0){uv=vec2(direction.z,direction.y)/abs(direction.x);}else if(face==1.0){uv=vec2(-direction.x,-direction.z)/abs(direction.y);}else if(face==2.0){uv=vec2(-direction.x,direction.y)/abs(direction.z);}else if(face==3.0){uv=vec2(-direction.z,direction.y)/abs(direction.x);}else if(face==4.0){uv=vec2(-direction.x,direction.z)/abs(direction.y);}else{uv=vec2(direction.x,direction.y)/abs(direction.z);}return 0.5*(uv+1.0);}vec3 bilinearCubeUV(sampler2D envMap,vec3 direction,float mipInt){float face=getFace(direction);float filterInt=max(cubeUV_minMipLevel-mipInt,0.0);mipInt=max(mipInt,cubeUV_minMipLevel);float faceSize=exp2(mipInt);float texelSize=1.0/(3.0*cubeUV_maxTileSize);vec2 uv=getUV(direction,face)*(faceSize-1.0);vec2 f=fract(uv);uv+=0.5-f;if(face>2.0){uv.y+=faceSize;face-=3.0;}uv.x+=face*faceSize;if(mipInt=r1){mip=(r0-roughness)*(m1-m0)/(r0-r1)+m0;}else if(roughness>=r4){mip=(r1-roughness)*(m4-m1)/(r1-r4)+m1;}else if(roughness>=r5){mip=(r4-roughness)*(m5-m4)/(r4-r5)+m4;}else if(roughness>=r6){mip=(r5-roughness)*(m6-m5)/(r5-r6)+m5;}else{mip=-2.0*log2(1.16*roughness);}return mip;}vec4 textureCubeUV(sampler2D envMap,vec3 sampleDir,float roughness){float mip=clamp(roughnessToMip(roughness),m0,cubeUV_maxMipLevel);float mipF=fract(mip);float mipInt=floor(mip);vec3 color0=bilinearCubeUV(envMap,sampleDir,mipInt);if(mipF==0.0){return vec4(color0,1.0);}else{vec3 color1=bilinearCubeUV(envMap,sampleDir,mipInt+1.0);return vec4(mix(color0,color1,mipF),1.0);}}\n#endif",defaultnormal_vertex:"vec3 transformedNormal=objectNormal;\n#ifdef USE_INSTANCING\nmat3 m=mat3(instanceMatrix);transformedNormal/=vec3(dot(m[0],m[0]),dot(m[1],m[1]),dot(m[2],m[2]));transformedNormal=m*transformedNormal;\n#endif\ntransformedNormal=normalMatrix*transformedNormal;\n#ifdef FLIP_SIDED\ntransformedNormal=-transformedNormal;\n#endif\n#ifdef USE_TANGENT\nvec3 transformedTangent=(modelViewMatrix*vec4(objectTangent,0.0)).xyz;\n#ifdef FLIP_SIDED\ntransformedTangent=-transformedTangent;\n#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\nuniform sampler2D displacementMap;uniform float displacementScale;uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\ntransformed+=normalize(objectNormal)*(texture2D(displacementMap,vUv).x*displacementScale+displacementBias);\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\nvec4 emissiveColor=texture2D(emissiveMap,vUv);emissiveColor.rgb=emissiveMapTexelToLinear(emissiveColor).rgb;totalEmissiveRadiance*=emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\nuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor=linearToOutputTexel(gl_FragColor);",encodings_pars_fragment:"vec4 LinearToLinear(in vec4 value){return value;}vec4 GammaToLinear(in vec4 value,in float gammaFactor){return vec4(pow(value.rgb,vec3(gammaFactor)),value.a);}vec4 LinearToGamma(in vec4 value,in float gammaFactor){return vec4(pow(value.rgb,vec3(1.0/gammaFactor)),value.a);}vec4 sRGBToLinear(in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}vec4 LinearTosRGB(in vec4 value){return vec4(mix(pow(value.rgb,vec3(0.41666))*1.055-vec3(0.055),value.rgb*12.92,vec3(lessThanEqual(value.rgb,vec3(0.0031308)))),value.a);}vec4 RGBEToLinear(in vec4 value){return vec4(value.rgb*exp2(value.a*255.0-128.0),1.0);}vec4 LinearToRGBE(in vec4 value){float maxComponent=max(max(value.r,value.g),value.b);float fExp=clamp(ceil(log2(maxComponent)),-128.0,127.0);return vec4(value.rgb/exp2(fExp),(fExp+128.0)/255.0);}vec4 RGBMToLinear(in vec4 value,in float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 LinearToRGBM(in vec4 value,in float maxRange){float maxRGB=max(value.r,max(value.g,value.b));float M=clamp(maxRGB/maxRange,0.0,1.0);M=ceil(M*255.0)/255.0;return vec4(value.rgb/(M*maxRange),M);}vec4 RGBDToLinear(in vec4 value,in float maxRange){return vec4(value.rgb*((maxRange/255.0)/value.a),1.0);}vec4 LinearToRGBD(in vec4 value,in float maxRange){float maxRGB=max(value.r,max(value.g,value.b));float D=max(maxRange/maxRGB,1.0);D=clamp(floor(D)/255.0,0.0,1.0);return vec4(value.rgb*(D*(255.0/maxRange)),D);}const mat3 cLogLuvM=mat3(0.2209,0.3390,0.4184,0.1138,0.6780,0.7319,0.0102,0.1130,0.2969);vec4 LinearToLogLuv(in vec4 value){vec3 Xp_Y_XYZp=cLogLuvM*value.rgb;Xp_Y_XYZp=max(Xp_Y_XYZp,vec3(1e-6,1e-6,1e-6));vec4 vResult;vResult.xy=Xp_Y_XYZp.xy/Xp_Y_XYZp.z;float Le=2.0*log2(Xp_Y_XYZp.y)+127.0;vResult.w=fract(Le);vResult.z=(Le-(floor(vResult.w*255.0))/255.0)/255.0;return vResult;}const mat3 cLogLuvInverseM=mat3(6.0014,-2.7008,-1.7996,-1.3320,3.1029,-5.7721,0.3008,-1.0882,5.6268);vec4 LogLuvToLinear(in vec4 value){float Le=value.z*255.0+value.w;vec3 Xp_Y_XYZp;Xp_Y_XYZp.y=exp2((Le-127.0)/2.0);Xp_Y_XYZp.z=Xp_Y_XYZp.y/value.y;Xp_Y_XYZp.x=value.x*Xp_Y_XYZp.z;vec3 vRGB=cLogLuvInverseM*Xp_Y_XYZp.rgb;return vec4(max(vRGB,0.0),1.0);}",envmap_fragment:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvec3 cameraToFrag;if(isOrthographic){cameraToFrag=normalize(vec3(-viewMatrix[0][2],-viewMatrix[1][2],-viewMatrix[2][2]));}else{cameraToFrag=normalize(vWorldPosition-cameraPosition);}vec3 worldNormal=inverseTransformDirection(normal,viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 reflectVec=reflect(cameraToFrag,worldNormal);\n#else\nvec3 reflectVec=refract(cameraToFrag,worldNormal,refractionRatio);\n#endif\n#else\nvec3 reflectVec=vReflect;\n#endif\n#ifdef ENVMAP_TYPE_CUBE\nvec4 envColor=textureCube(envMap,vec3(flipEnvMap*reflectVec.x,reflectVec.yz));\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envColor=textureCubeUV(envMap,reflectVec,0.0);\n#elif defined(ENVMAP_TYPE_EQUIREC)\nreflectVec=normalize(reflectVec);vec2 sampleUV=equirectUv(reflectVec);vec4 envColor=texture2D(envMap,sampleUV);\n#else\nvec4 envColor=vec4(0.0);\n#endif\n#ifndef ENVMAP_TYPE_CUBE_UV\nenvColor=envMapTexelToLinear(envColor);\n#endif\n#ifdef ENVMAP_BLENDING_MULTIPLY\noutgoingLight=mix(outgoingLight,outgoingLight*envColor.xyz,specularStrength*reflectivity);\n#elif defined(ENVMAP_BLENDING_MIX)\noutgoingLight=mix(outgoingLight,envColor.xyz,specularStrength*reflectivity);\n#elif defined(ENVMAP_BLENDING_ADD)\noutgoingLight+=envColor.xyz*specularStrength*reflectivity;\n#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\nuniform float envMapIntensity;uniform float flipEnvMap;uniform int maxMipLevel;\n#ifdef ENVMAP_TYPE_CUBE\nuniform samplerCube envMap;\n#else\nuniform sampler2D envMap;\n#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\n#if defined(USE_BUMPMAP)||defined(USE_NORMALMAP)||defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\nvarying vec3 vWorldPosition;uniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n#if defined(USE_BUMPMAP)||defined(USE_NORMALMAP)||defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\nvarying vec3 vWorldPosition;\n#else\nvarying vec3 vReflect;uniform float refractionRatio;\n#endif\n#endif",envmap_physical_pars_fragment:"#if defined(USE_ENVMAP)\n#ifdef ENVMAP_MODE_REFRACTION\nuniform float refractionRatio;\n#endif\nvec3 getLightProbeIndirectIrradiance(const in GeometricContext geometry,const in int maxMIPLevel){vec3 worldNormal=inverseTransformDirection(geometry.normal,viewMatrix);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec=vec3(flipEnvMap*worldNormal.x,worldNormal.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor=textureCubeLodEXT(envMap,queryVec,float(maxMIPLevel));\n#else\nvec4 envMapColor=textureCube(envMap,queryVec,float(maxMIPLevel));\n#endif\nenvMapColor.rgb=envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envMapColor=textureCubeUV(envMap,worldNormal,1.0);\n#else\nvec4 envMapColor=vec4(0.0);\n#endif\nreturn PI*envMapColor.rgb*envMapIntensity;}float getSpecularMIPLevel(const in float roughness,const in int maxMIPLevel){float maxMIPLevelScalar=float(maxMIPLevel);float sigma=PI*roughness*roughness/(1.0+roughness);float desiredMIPLevel=maxMIPLevelScalar+log2(sigma);return clamp(desiredMIPLevel,0.0,maxMIPLevelScalar);}vec3 getLightProbeIndirectRadiance(const in vec3 viewDir,const in vec3 normal,const in float roughness,const in int maxMIPLevel){\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec=normalize(mix(reflectVec,normal,roughness*roughness));\n#else\nvec3 reflectVec=refract(-viewDir,normal,refractionRatio);\n#endif\nreflectVec=inverseTransformDirection(reflectVec,viewMatrix);float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryReflectVec=vec3(flipEnvMap*reflectVec.x,reflectVec.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor=textureCubeLodEXT(envMap,queryReflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(envMap,queryReflectVec,specularMIPLevel);\n#endif\nenvMapColor.rgb=envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envMapColor=textureCubeUV(envMap,reflectVec,roughness);\n#elif defined(ENVMAP_TYPE_EQUIREC)\nvec2 sampleUV=equirectUv(reflectVec);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor=texture2DLodEXT(envMap,sampleUV,specularMIPLevel);\n#else\nvec4 envMapColor=texture2D(envMap,sampleUV,specularMIPLevel);\n#endif\nenvMapColor.rgb=envMapTexelToLinear(envMapColor).rgb;\n#endif\nreturn envMapColor.rgb*envMapIntensity;}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvWorldPosition=worldPosition.xyz;\n#else\nvec3 cameraToVertex;if(isOrthographic){cameraToVertex=normalize(vec3(-viewMatrix[0][2],-viewMatrix[1][2],-viewMatrix[2][2]));}else{cameraToVertex=normalize(worldPosition.xyz-cameraPosition);}vec3 worldNormal=inverseTransformDirection(transformedNormal,viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvReflect=reflect(cameraToVertex,worldNormal);\n#else\nvReflect=refract(cameraToVertex,worldNormal,refractionRatio);\n#endif\n#endif\n#endif",fog_vertex:"#ifdef USE_FOG\nfogDepth=-mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\nvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n#ifdef FOG_EXP2\nfloat fogFactor=1.0-exp(-fogDensity*fogDensity*fogDepth*fogDepth);\n#else\nfloat fogFactor=smoothstep(fogNear,fogFar,fogDepth);\n#endif\ngl_FragColor.rgb=mix(gl_FragColor.rgb,fogColor,fogFactor);\n#endif",fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;varying float fogDepth;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;uniform float fogFar;\n#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\nuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance(vec3 normal,vec3 lightDirection){float dotNL=dot(normal,lightDirection);vec2 coord=vec2(dotNL*0.5+0.5,0.0);\n#ifdef USE_GRADIENTMAP\nreturn texture2D(gradientMap,coord).rgb;\n#else\nreturn(coord.x<0.7)?vec3(0.7):vec3(1.0);\n#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\nvec4 lightMapTexel=texture2D(lightMap,vUv2);reflectedLight.indirectDiffuse+=PI*lightMapTexelToLinear(lightMapTexel).rgb*lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nuniform sampler2D lightMap;uniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse=vec3(1.0);GeometricContext geometry;geometry.position=mvPosition.xyz;geometry.normal=normalize(transformedNormal);geometry.viewDir=(isOrthographic)?vec3(0,0,1):normalize(-mvPosition.xyz);GeometricContext backGeometry;backGeometry.position=geometry.position;backGeometry.normal=-geometry.normal;backGeometry.viewDir=geometry.viewDir;vLightFront=vec3(0.0);vIndirectFront=vec3(0.0);\n#ifdef DOUBLE_SIDED\nvLightBack=vec3(0.0);vIndirectBack=vec3(0.0);\n#endif\nIncidentLight directLight;float dotNL;vec3 directLightColor_Diffuse;vIndirectFront+=getAmbientLightIrradiance(ambientLightColor);vIndirectFront+=getLightProbeIrradiance(lightProbe,geometry);\n#ifdef DOUBLE_SIDED\nvIndirectBack+=getAmbientLightIrradiance(ambientLightColor);vIndirectBack+=getLightProbeIrradiance(lightProbe,backGeometry);\n#endif\n#if NUM_POINT_LIGHTS>0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\nstruct DirectionalLight{vec3 direction;vec3 color;};uniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];void getDirectionalDirectLightIrradiance(const in DirectionalLight directionalLight,const in GeometricContext geometry,out IncidentLight directLight){directLight.color=directionalLight.color;directLight.direction=directionalLight.direction;directLight.visible=true;}\n#endif\n#if NUM_POINT_LIGHTS>0\nstruct PointLight{vec3 position;vec3 color;float distance;float decay;};uniform PointLight pointLights[NUM_POINT_LIGHTS];void getPointDirectLightIrradiance(const in PointLight pointLight,const in GeometricContext geometry,out IncidentLight directLight){vec3 lVector=pointLight.position-geometry.position;directLight.direction=normalize(lVector);float lightDistance=length(lVector);directLight.color=pointLight.color;directLight.color*=punctualLightIntensityToIrradianceFactor(lightDistance,pointLight.distance,pointLight.decay);directLight.visible=(directLight.color!=vec3(0.0));}\n#endif\n#if NUM_SPOT_LIGHTS>0\nstruct SpotLight{vec3 position;vec3 direction;vec3 color;float distance;float decay;float coneCos;float penumbraCos;};uniform SpotLight spotLights[NUM_SPOT_LIGHTS];void getSpotDirectLightIrradiance(const in SpotLight spotLight,const in GeometricContext geometry,out IncidentLight directLight){vec3 lVector=spotLight.position-geometry.position;directLight.direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(directLight.direction,spotLight.direction);if(angleCos>spotLight.coneCos){float spotEffect=smoothstep(spotLight.coneCos,spotLight.penumbraCos,angleCos);directLight.color=spotLight.color;directLight.color*=spotEffect*punctualLightIntensityToIrradianceFactor(lightDistance,spotLight.distance,spotLight.decay);directLight.visible=true;}else{directLight.color=vec3(0.0);directLight.visible=false;}}\n#endif\n#if NUM_RECT_AREA_LIGHTS>0\nstruct RectAreaLight{vec3 color;vec3 position;vec3 halfWidth;vec3 halfHeight;};uniform sampler2D ltc_1;uniform sampler2D ltc_2;uniform RectAreaLight rectAreaLights[NUM_RECT_AREA_LIGHTS];\n#endif\n#if NUM_HEMI_LIGHTS>0\nstruct HemisphereLight{vec3 direction;vec3 skyColor;vec3 groundColor;};uniform HemisphereLight hemisphereLights[NUM_HEMI_LIGHTS];vec3 getHemisphereLightIrradiance(const in HemisphereLight hemiLight,const in GeometricContext geometry){float dotNL=dot(geometry.normal,hemiLight.direction);float hemiDiffuseWeight=0.5*dotNL+0.5;vec3 irradiance=mix(hemiLight.groundColor,hemiLight.skyColor,hemiDiffuseWeight);\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance*=PI;\n#endif\nreturn irradiance;}\n#endif",lights_toon_fragment:"ToonMaterial material;material.diffuseColor=diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct ToonMaterial{vec3 diffuseColor;};void RE_Direct_Toon(const in IncidentLight directLight,const in GeometricContext geometry,const in ToonMaterial material,inout ReflectedLight reflectedLight){vec3 irradiance=getGradientIrradiance(geometry.normal,directLight.direction)*directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance*=PI;\n#endif\nreflectedLight.directDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Toon(const in vec3 irradiance,const in GeometricContext geometry,const in ToonMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD(material)(0)",lights_phong_fragment:"BlinnPhongMaterial material;material.diffuseColor=diffuseColor.rgb;material.specularColor=specular;material.specularShininess=shininess;material.specularStrength=specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial{vec3 diffuseColor;vec3 specularColor;float specularShininess;float specularStrength;};void RE_Direct_BlinnPhong(const in IncidentLight directLight,const in GeometricContext geometry,const in BlinnPhongMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance*=PI;\n#endif\nreflectedLight.directDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);reflectedLight.directSpecular+=irradiance*BRDF_Specular_BlinnPhong(directLight,geometry,material.specularColor,material.specularShininess)*material.specularStrength;}void RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance,const in GeometricContext geometry,const in BlinnPhongMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD(material)(0)",lights_physical_fragment:"PhysicalMaterial material;material.diffuseColor=diffuseColor.rgb*(1.0-metalnessFactor);vec3 dxy=max(abs(dFdx(geometryNormal)),abs(dFdy(geometryNormal)));float geometryRoughness=max(max(dxy.x,dxy.y),dxy.z);material.specularRoughness=max(roughnessFactor,0.0525);material.specularRoughness+=geometryRoughness;material.specularRoughness=min(material.specularRoughness,1.0);\n#ifdef REFLECTIVITY\nmaterial.specularColor=mix(vec3(MAXIMUM_SPECULAR_COEFFICIENT*pow2(reflectivity)),diffuseColor.rgb,metalnessFactor);\n#else\nmaterial.specularColor=mix(vec3(DEFAULT_SPECULAR_COEFFICIENT),diffuseColor.rgb,metalnessFactor);\n#endif\n#ifdef CLEARCOAT\nmaterial.clearcoat=clearcoat;material.clearcoatRoughness=clearcoatRoughness;\n#ifdef USE_CLEARCOATMAP\nmaterial.clearcoat*=texture2D(clearcoatMap,vUv).x;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\nmaterial.clearcoatRoughness*=texture2D(clearcoatRoughnessMap,vUv).y;\n#endif\nmaterial.clearcoat=saturate(material.clearcoat);material.clearcoatRoughness=max(material.clearcoatRoughness,0.0525);material.clearcoatRoughness+=geometryRoughness;material.clearcoatRoughness=min(material.clearcoatRoughness,1.0);\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor=sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial{vec3 diffuseColor;float specularRoughness;vec3 specularColor;\n#ifdef CLEARCOAT\nfloat clearcoat;float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox(const in float roughness,const in float dotNL){return DEFAULT_SPECULAR_COEFFICIENT+(1.0-DEFAULT_SPECULAR_COEFFICIENT)*(pow(1.0-dotNL,5.0)*pow(1.0-roughness,2.0));}\n#if NUM_RECT_AREA_LIGHTS>0\nvoid RE_Direct_RectArea_Physical(const in RectAreaLight rectAreaLight,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){vec3 normal=geometry.normal;vec3 viewDir=geometry.viewDir;vec3 position=geometry.position;vec3 lightPos=rectAreaLight.position;vec3 halfWidth=rectAreaLight.halfWidth;vec3 halfHeight=rectAreaLight.halfHeight;vec3 lightColor=rectAreaLight.color;float roughness=material.specularRoughness;vec3 rectCoords[4];rectCoords[0]=lightPos+halfWidth-halfHeight;rectCoords[1]=lightPos-halfWidth-halfHeight;rectCoords[2]=lightPos-halfWidth+halfHeight;rectCoords[3]=lightPos+halfWidth+halfHeight;vec2 uv=LTC_Uv(normal,viewDir,roughness);vec4 t1=texture2D(ltc_1,uv);vec4 t2=texture2D(ltc_2,uv);mat3 mInv=mat3(vec3(t1.x,0,t1.y),vec3(0,1,0),vec3(t1.z,0,t1.w));vec3 fresnel=(material.specularColor*t2.x+(vec3(1.0)-material.specularColor)*t2.y);reflectedLight.directSpecular+=lightColor*fresnel*LTC_Evaluate(normal,viewDir,position,mInv,rectCoords);reflectedLight.directDiffuse+=lightColor*material.diffuseColor*LTC_Evaluate(normal,viewDir,position,mat3(1.0),rectCoords);}\n#endif\nvoid RE_Direct_Physical(const in IncidentLight directLight,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance*=PI;\n#endif\n#ifdef CLEARCOAT\nfloat ccDotNL=saturate(dot(geometry.clearcoatNormal,directLight.direction));vec3 ccIrradiance=ccDotNL*directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nccIrradiance*=PI;\n#endif\nfloat clearcoatDHR=material.clearcoat*clearcoatDHRApprox(material.clearcoatRoughness,ccDotNL);reflectedLight.directSpecular+=ccIrradiance*material.clearcoat*BRDF_Specular_GGX(directLight,geometry.viewDir,geometry.clearcoatNormal,vec3(DEFAULT_SPECULAR_COEFFICIENT),material.clearcoatRoughness);\n#else\nfloat clearcoatDHR=0.0;\n#endif\n#ifdef USE_SHEEN\nreflectedLight.directSpecular+=(1.0-clearcoatDHR)*irradiance*BRDF_Specular_Sheen(material.specularRoughness,directLight.direction,geometry,material.sheenColor);\n#else\nreflectedLight.directSpecular+=(1.0-clearcoatDHR)*irradiance*BRDF_Specular_GGX(directLight,geometry.viewDir,geometry.normal,material.specularColor,material.specularRoughness);\n#endif\nreflectedLight.directDiffuse+=(1.0-clearcoatDHR)*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Physical(const in vec3 irradiance,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}void RE_IndirectSpecular_Physical(const in vec3 radiance,const in vec3 irradiance,const in vec3 clearcoatRadiance,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){\n#ifdef CLEARCOAT\nfloat ccDotNV=saturate(dot(geometry.clearcoatNormal,geometry.viewDir));reflectedLight.indirectSpecular+=clearcoatRadiance*material.clearcoat*BRDF_Specular_GGX_Environment(geometry.viewDir,geometry.clearcoatNormal,vec3(DEFAULT_SPECULAR_COEFFICIENT),material.clearcoatRoughness);float ccDotNL=ccDotNV;float clearcoatDHR=material.clearcoat*clearcoatDHRApprox(material.clearcoatRoughness,ccDotNL);\n#else\nfloat clearcoatDHR=0.0;\n#endif\nfloat clearcoatInv=1.0-clearcoatDHR;vec3 singleScattering=vec3(0.0);vec3 multiScattering=vec3(0.0);vec3 cosineWeightedIrradiance=irradiance*RECIPROCAL_PI;BRDF_Specular_Multiscattering_Environment(geometry,material.specularColor,material.specularRoughness,singleScattering,multiScattering);vec3 diffuse=material.diffuseColor*(1.0-(singleScattering+multiScattering));reflectedLight.indirectSpecular+=clearcoatInv*radiance*singleScattering;reflectedLight.indirectSpecular+=multiScattering*cosineWeightedIrradiance;reflectedLight.indirectDiffuse+=diffuse*cosineWeightedIrradiance;}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion(const in float dotNV,const in float ambientOcclusion,const in float roughness){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}",lights_fragment_begin:"GeometricContext geometry;geometry.position=-vViewPosition;geometry.normal=normal;geometry.viewDir=(isOrthographic)?vec3(0,0,1):normalize(vViewPosition);\n#ifdef CLEARCOAT\ngeometry.clearcoatNormal=clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if (NUM_POINT_LIGHTS>0)&&defined(RE_Direct)\nPointLight pointLight;\n#if defined(USE_SHADOWMAP)&&NUM_POINT_LIGHT_SHADOWS>0\nPointLightShadow pointLightShadow;\n#endif\n#pragma unroll_loop_start\nfor(int i=0;i0)&&defined(RE_Direct)\nSpotLight spotLight;\n#if defined(USE_SHADOWMAP)&&NUM_SPOT_LIGHT_SHADOWS>0\nSpotLightShadow spotLightShadow;\n#endif\n#pragma unroll_loop_start\nfor(int i=0;i0)&&defined(RE_Direct)\nDirectionalLight directionalLight;\n#if defined(USE_SHADOWMAP)&&NUM_DIR_LIGHT_SHADOWS>0\nDirectionalLightShadow directionalLightShadow;\n#endif\n#pragma unroll_loop_start\nfor(int i=0;i0)&&defined(RE_Direct_RectArea)\nRectAreaLight rectAreaLight;\n#pragma unroll_loop_start\nfor(int i=0;i0)\n#pragma unroll_loop_start\nfor(int i=0;i0\nuniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];struct DirectionalLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS>0\nuniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];varying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];struct SpotLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS>0\nuniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];struct PointLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;float shadowCameraNear;float shadowCameraFar;};uniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];\n#endif\nfloat texture2DCompare(sampler2D depths,vec2 uv,float compare){return step(compare,unpackRGBAToDepth(texture2D(depths,uv)));}vec2 texture2DDistribution(sampler2D shadow,vec2 uv){return unpackRGBATo2Half(texture2D(shadow,uv));}float VSMShadow(sampler2D shadow,vec2 uv,float compare){float occlusion=1.0;vec2 distribution=texture2DDistribution(shadow,uv);float hard_shadow=step(compare,distribution.x);if(hard_shadow!=1.0){float distance=compare-distribution.x;float variance=max(0.00000,distribution.y*distribution.y);float softness_probability=variance/(variance+distance*distance);softness_probability=clamp((softness_probability-0.3)/(0.95-0.3),0.0,1.0);occlusion=clamp(max(hard_shadow,softness_probability),0.0,1.0);}return occlusion;}float getShadow(sampler2D shadowMap,vec2 shadowMapSize,float shadowBias,float shadowRadius,vec4 shadowCoord){float shadow=1.0;shadowCoord.xyz/=shadowCoord.w;shadowCoord.z+=shadowBias;bvec4 inFrustumVec=bvec4(shadowCoord.x>=0.0,shadowCoord.x<=1.0,shadowCoord.y>=0.0,shadowCoord.y<=1.0);bool inFrustum=all(inFrustumVec);bvec2 frustumTestVec=bvec2(inFrustum,shadowCoord.z<=1.0);bool frustumTest=all(frustumTestVec);if(frustumTest){\n#if defined(SHADOWMAP_TYPE_PCF)\nvec2 texelSize=vec2(1.0)/shadowMapSize;float dx0=-texelSize.x*shadowRadius;float dy0=-texelSize.y*shadowRadius;float dx1=+texelSize.x*shadowRadius;float dy1=+texelSize.y*shadowRadius;float dx2=dx0/2.0;float dy2=dy0/2.0;float dx3=dx1/2.0;float dy3=dy1/2.0;shadow=(texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy,shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,dy1),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy1),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,dy1),shadowCoord.z))*(1.0/17.0);\n#elif defined(SHADOWMAP_TYPE_PCF_SOFT)\nvec2 texelSize=vec2(1.0)/shadowMapSize;float dx=texelSize.x;float dy=texelSize.y;vec2 uv=shadowCoord.xy;vec2 f=fract(uv*shadowMapSize+0.5);uv-=f*texelSize;shadow=(texture2DCompare(shadowMap,uv,shadowCoord.z)+texture2DCompare(shadowMap,uv+vec2(dx,0.0),shadowCoord.z)+texture2DCompare(shadowMap,uv+vec2(0.0,dy),shadowCoord.z)+texture2DCompare(shadowMap,uv+texelSize,shadowCoord.z)+mix(texture2DCompare(shadowMap,uv+vec2(-dx,0.0),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,0.0),shadowCoord.z),f.x)+mix(texture2DCompare(shadowMap,uv+vec2(-dx,dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,dy),shadowCoord.z),f.x)+mix(texture2DCompare(shadowMap,uv+vec2(0.0,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(0.0,2.0*dy),shadowCoord.z),f.y)+mix(texture2DCompare(shadowMap,uv+vec2(dx,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(dx,2.0*dy),shadowCoord.z),f.y)+mix(mix(texture2DCompare(shadowMap,uv+vec2(-dx,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,-dy),shadowCoord.z),f.x),mix(texture2DCompare(shadowMap,uv+vec2(-dx,2.0*dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,2.0*dy),shadowCoord.z),f.x),f.y))*(1.0/9.0);\n#elif defined(SHADOWMAP_TYPE_VSM)\nshadow=VSMShadow(shadowMap,shadowCoord.xy,shadowCoord.z);\n#else\nshadow=texture2DCompare(shadowMap,shadowCoord.xy,shadowCoord.z);\n#endif\n}return shadow;}vec2 cubeToUV(vec3 v,float texelSizeY){vec3 absV=abs(v);float scaleToCube=1.0/max(absV.x,max(absV.y,absV.z));absV*=scaleToCube;v*=scaleToCube*(1.0-2.0*texelSizeY);vec2 planar=v.xy;float almostATexel=1.5*texelSizeY;float almostOne=1.0-almostATexel;if(absV.z>=almostOne){if(v.z>0.0)planar.x=4.0-v.x;}else if(absV.x>=almostOne){float signX=sign(v.x);planar.x=v.z*signX+2.0*signX;}else if(absV.y>=almostOne){float signY=sign(v.y);planar.x=v.x+2.0*signY+2.0;planar.y=v.z*signY-2.0;}return vec2(0.125,0.25)*planar+vec2(0.375,0.75);}float getPointShadow(sampler2D shadowMap,vec2 shadowMapSize,float shadowBias,float shadowRadius,vec4 shadowCoord,float shadowCameraNear,float shadowCameraFar){vec2 texelSize=vec2(1.0)/(shadowMapSize*vec2(4.0,2.0));vec3 lightToPosition=shadowCoord.xyz;float dp=(length(lightToPosition)-shadowCameraNear)/(shadowCameraFar-shadowCameraNear);dp+=shadowBias;vec3 bd3D=normalize(lightToPosition);\n#if defined(SHADOWMAP_TYPE_PCF)||defined(SHADOWMAP_TYPE_PCF_SOFT)||defined(SHADOWMAP_TYPE_VSM)\nvec2 offset=vec2(-1,1)*shadowRadius*texelSize.y;return(texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xyy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yyy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xyx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yyx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xxy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yxy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xxx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yxx,texelSize.y),dp))*(1.0/9.0);\n#else\nreturn texture2DCompare(shadowMap,cubeToUV(bd3D,texelSize.y),dp);\n#endif\n}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS>0\nuniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];struct DirectionalLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS>0\nuniform mat4 spotShadowMatrix[NUM_SPOT_LIGHT_SHADOWS];varying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];struct SpotLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS>0\nuniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];struct PointLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;float shadowCameraNear;float shadowCameraFar;};uniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];\n#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS>0||NUM_SPOT_LIGHT_SHADOWS>0||NUM_POINT_LIGHT_SHADOWS>0\nvec3 shadowWorldNormal=inverseTransformDirection(transformedNormal,viewMatrix);vec4 shadowWorldPosition;\n#endif\n#if NUM_DIR_LIGHT_SHADOWS>0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\nDirectionalLightShadow directionalLight;\n#pragma unroll_loop_start\nfor(int i=0;i0\nSpotLightShadow spotLight;\n#pragma unroll_loop_start\nfor(int i=0;i0\nPointLightShadow pointLight;\n#pragma unroll_loop_start\nfor(int i=0;i\n#include \n}",background_vert:"varying vec2 vUv;uniform mat3 uvTransform;void main(){vUv=(uvTransform*vec3(uv,1)).xy;gl_Position=vec4(position.xy,1.0,1.0);}",cube_frag:"#include \nuniform float opacity;varying vec3 vWorldDirection;\n#include \nvoid main(){vec3 vReflect=vWorldDirection;\n#include \ngl_FragColor=envColor;gl_FragColor.a*=opacity;\n#include \n#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main(){vWorldDirection=transformDirection(position,modelMatrix);\n#include \n#include \ngl_Position.z=gl_Position.w;}",depth_frag:"#if DEPTH_PACKING==3200\nuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;void main(){\n#include \nvec4 diffuseColor=vec4(1.0);\n#if DEPTH_PACKING==3200\ndiffuseColor.a=opacity;\n#endif\n#include \n#include \n#include \n#include \nfloat fragCoordZ=0.5*vHighPrecisionZW[0]/vHighPrecisionZW[1]+0.5;\n#if DEPTH_PACKING==3200\ngl_FragColor=vec4(vec3(1.0-fragCoordZ),opacity);\n#elif DEPTH_PACKING==3201\ngl_FragColor=packDepthToRGBA(fragCoordZ);\n#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;void main(){\n#include \n#include \n#ifdef USE_DISPLACEMENTMAP\n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvHighPrecisionZW=gl_Position.zw;}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;uniform float nearDistance;uniform float farDistance;varying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(1.0);\n#include \n#include \n#include \nfloat dist=length(vWorldPosition-referencePosition);dist=(dist-nearDistance)/(farDistance-nearDistance);dist=saturate(dist);gl_FragColor=packDepthToRGBA(dist);}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#ifdef USE_DISPLACEMENTMAP\n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvWorldPosition=worldPosition.xyz;}",equirect_frag:"uniform sampler2D tEquirect;varying vec3 vWorldDirection;\n#include \nvoid main(){vec3 direction=normalize(vWorldDirection);vec2 sampleUV=equirectUv(direction);vec4 texColor=texture2D(tEquirect,sampleUV);gl_FragColor=mapTexelToLinear(texColor);\n#include \n#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main(){vWorldDirection=transformDirection(position,modelMatrix);\n#include \n#include \n}",linedashed_frag:"uniform vec3 diffuse;uniform float opacity;uniform float dashSize;uniform float totalSize;varying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nif(mod(vLineDistance,totalSize)>dashSize){discard;}vec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \noutgoingLight=diffuseColor.rgb;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n}",linedashed_vert:"uniform float scale;attribute float lineDistance;varying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){vLineDistance=scale*lineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshbasic_frag:"uniform vec3 diffuse;uniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \n#include \n#include \n#include \n#include \nReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel=texture2D(lightMap,vUv2);reflectedLight.indirectDiffuse+=lightMapTexelToLinear(lightMapTexel).rgb*lightMapIntensity;\n#else\nreflectedLight.indirectDiffuse+=vec3(1.0);\n#endif\n#include \nreflectedLight.indirectDiffuse*=diffuseColor.rgb;vec3 outgoingLight=reflectedLight.indirectDiffuse;\n#include \ngl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#ifdef USE_ENVMAP\n#include \n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshlambert_frag:"uniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;varying vec3 vLightFront;varying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef DOUBLE_SIDED\nreflectedLight.indirectDiffuse+=(gl_FrontFacing)?vIndirectFront:vIndirectBack;\n#else\nreflectedLight.indirectDiffuse+=vIndirectFront;\n#endif\n#include \nreflectedLight.indirectDiffuse*=BRDF_Diffuse_Lambert(diffuseColor.rgb);\n#ifdef DOUBLE_SIDED\nreflectedLight.directDiffuse=(gl_FrontFacing)?vLightFront:vLightBack;\n#else\nreflectedLight.directDiffuse=vLightFront;\n#endif\nreflectedLight.directDiffuse*=BRDF_Diffuse_Lambert(diffuseColor.rgb)*getShadowMask();\n#include \nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+totalEmissiveRadiance;\n#include \ngl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;varying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;uniform float opacity;uniform sampler2D matcap;varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 viewDir=normalize(vViewPosition);vec3 x=normalize(vec3(viewDir.z,0.0,-viewDir.x));vec3 y=cross(viewDir,x);vec2 uv=vec2(dot(x,normal),dot(y,normal))*0.495+0.5;\n#ifdef USE_MATCAP\nvec4 matcapColor=texture2D(matcap,uv);matcapColor=matcapTexelToLinear(matcapColor);\n#else\nvec4 matcapColor=vec4(1.0);\n#endif\nvec3 outgoingLight=diffuseColor.rgb*matcapColor.rgb;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition=-mvPosition.xyz;}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+totalEmissiveRadiance;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition=-mvPosition.xyz;\n#include \n#include \n#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;uniform vec3 emissive;uniform vec3 specular;uniform float shininess;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+totalEmissiveRadiance;\n#include \ngl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition=-mvPosition.xyz;\n#include \n#include \n#include \n#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n#define REFLECTIVITY\n#define CLEARCOAT\n#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;uniform vec3 emissive;uniform float roughness;uniform float metalness;uniform float opacity;\n#ifdef TRANSPARENCY\nuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\nuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\nuniform float clearcoat;uniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+totalEmissiveRadiance;\n#ifdef TRANSPARENCY\ndiffuseColor.a*=saturate(1.-transparency+linearToRelativeLuminance(reflectedLight.directSpecular+reflectedLight.indirectSpecular));\n#endif\ngl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent=normalize(transformedTangent);vBitangent=normalize(cross(vNormal,vTangent)*tangent.w);\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition=-mvPosition.xyz;\n#include \n#include \n#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \ngl_FragColor=vec4(packNormalToRGB(normal),opacity);}",normal_vert:"#define NORMAL\n#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent=normalize(transformedTangent);vBitangent=normalize(cross(vNormal,vTangent)*tangent.w);\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(TANGENTSPACE_NORMALMAP)\nvViewPosition=-mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \n#include \n#include \noutgoingLight=diffuseColor.rgb;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n}",points_vert:"uniform float size;uniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \ngl_PointSize=size;\n#ifdef USE_SIZEATTENUATION\nbool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)gl_PointSize*=(scale/-mvPosition.z);\n#endif\n#include \n#include \n#include \n#include \n}",shadow_frag:"uniform vec3 color;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){gl_FragColor=vec4(color,opacity*(1.0-getShadowMask()));\n#include \n#include \n#include \n}",shadow_vert:"#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",sprite_frag:"uniform vec3 diffuse;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \n#include \n#include \noutgoingLight=diffuseColor.rgb;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n}",sprite_vert:"uniform float rotation;uniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 mvPosition=modelViewMatrix*vec4(0.0,0.0,0.0,1.0);vec2 scale;scale.x=length(vec3(modelMatrix[0].x,modelMatrix[0].y,modelMatrix[0].z));scale.y=length(vec3(modelMatrix[1].x,modelMatrix[1].y,modelMatrix[1].z));\n#ifndef USE_SIZEATTENUATION\nbool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)scale*=-mvPosition.z;\n#endif\nvec2 alignedPosition=(position.xy-(center-vec2(0.5)))*scale;vec2 rotatedPosition;rotatedPosition.x=cos(rotation)*alignedPosition.x-sin(rotation)*alignedPosition.y;rotatedPosition.y=sin(rotation)*alignedPosition.x+cos(rotation)*alignedPosition.y;mvPosition.xy+=rotatedPosition;gl_Position=projectionMatrix*mvPosition;\n#include \n#include \n#include \n}"},Er={basic:{uniforms:mr([Ar.common,Ar.specularmap,Ar.envmap,Ar.aomap,Ar.lightmap,Ar.fog]),vertexShader:Ir.meshbasic_vert,fragmentShader:Ir.meshbasic_frag},lambert:{uniforms:mr([Ar.common,Ar.specularmap,Ar.envmap,Ar.aomap,Ar.lightmap,Ar.emissivemap,Ar.fog,Ar.lights,{emissive:{value:new pt(0)}}]),vertexShader:Ir.meshlambert_vert,fragmentShader:Ir.meshlambert_frag},phong:{uniforms:mr([Ar.common,Ar.specularmap,Ar.envmap,Ar.aomap,Ar.lightmap,Ar.emissivemap,Ar.bumpmap,Ar.normalmap,Ar.displacementmap,Ar.fog,Ar.lights,{emissive:{value:new pt(0)},specular:{value:new pt(1118481)},shininess:{value:30}}]),vertexShader:Ir.meshphong_vert,fragmentShader:Ir.meshphong_frag},standard:{uniforms:mr([Ar.common,Ar.envmap,Ar.aomap,Ar.lightmap,Ar.emissivemap,Ar.bumpmap,Ar.normalmap,Ar.displacementmap,Ar.roughnessmap,Ar.metalnessmap,Ar.fog,Ar.lights,{emissive:{value:new pt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ir.meshphysical_vert,fragmentShader:Ir.meshphysical_frag},toon:{uniforms:mr([Ar.common,Ar.aomap,Ar.lightmap,Ar.emissivemap,Ar.bumpmap,Ar.normalmap,Ar.displacementmap,Ar.gradientmap,Ar.fog,Ar.lights,{emissive:{value:new pt(0)}}]),vertexShader:Ir.meshtoon_vert,fragmentShader:Ir.meshtoon_frag},matcap:{uniforms:mr([Ar.common,Ar.bumpmap,Ar.normalmap,Ar.displacementmap,Ar.fog,{matcap:{value:null}}]),vertexShader:Ir.meshmatcap_vert,fragmentShader:Ir.meshmatcap_frag},points:{uniforms:mr([Ar.points,Ar.fog]),vertexShader:Ir.points_vert,fragmentShader:Ir.points_frag},dashed:{uniforms:mr([Ar.common,Ar.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ir.linedashed_vert,fragmentShader:Ir.linedashed_frag},depth:{uniforms:mr([Ar.common,Ar.displacementmap]),vertexShader:Ir.depth_vert,fragmentShader:Ir.depth_frag},normal:{uniforms:mr([Ar.common,Ar.bumpmap,Ar.normalmap,Ar.displacementmap,{opacity:{value:1}}]),vertexShader:Ir.normal_vert,fragmentShader:Ir.normal_frag},sprite:{uniforms:mr([Ar.sprite,Ar.fog]),vertexShader:Ir.sprite_vert,fragmentShader:Ir.sprite_frag},background:{uniforms:{uvTransform:{value:new U},t2D:{value:null}},vertexShader:Ir.background_vert,fragmentShader:Ir.background_frag},cube:{uniforms:mr([Ar.envmap,{opacity:{value:1}}]),vertexShader:Ir.cube_vert,fragmentShader:Ir.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ir.equirect_vert,fragmentShader:Ir.equirect_frag},distanceRGBA:{uniforms:mr([Ar.common,Ar.displacementmap,{referencePosition:{value:new Y},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ir.distanceRGBA_vert,fragmentShader:Ir.distanceRGBA_frag},shadow:{uniforms:mr([Ar.lights,Ar.fog,{color:{value:new pt(0)},opacity:{value:1}}]),vertexShader:Ir.shadow_vert,fragmentShader:Ir.shadow_frag}};function Dr(e,t,r,i){var n,o,a=new pt(0),s=0,c=null,u=0,l=null;function h(e,r){t.buffers.color.setClear(e.r,e.g,e.b,r,i)}return{getClearColor:function(){return a},setClearColor:function(e,t){a.set(e),h(a,s=void 0!==t?t:1)},getClearAlpha:function(){return s},setClearAlpha:function(e){h(a,s=e)},render:function(t,i,p,d){var f=!0===i.isScene?i.background:null,m=e.xr,g=m.getSession&&m.getSession();if(g&&"additive"===g.environmentBlendMode&&(f=null),null===f?h(a,s):f&&f.isColor&&(h(f,1),d=!0),(e.autoClear||d)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),f&&(f.isCubeTexture||f.isWebGLCubeRenderTarget||306===f.mapping)){void 0===o&&((o=new or(new dr(1,1,1),new vr({name:"BackgroundCubeMaterial",uniforms:fr(Er.cube.uniforms),vertexShader:Er.cube.vertexShader,fragmentShader:Er.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),o.geometry.deleteAttribute("uv"),o.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},Object.defineProperty(o.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(o));var v=f.isWebGLCubeRenderTarget?f.texture:f;o.material.uniforms.envMap.value=v,o.material.uniforms.flipEnvMap.value=v.isCubeTexture?-1:1,c===f&&u===v.version&&l===e.toneMapping||(o.material.needsUpdate=!0,c=f,u=v.version,l=e.toneMapping),t.unshift(o,o.geometry,o.material,0,0,null)}else f&&f.isTexture&&(void 0===n&&((n=new or(new Tr(2,2),new vr({name:"BackgroundMaterial",uniforms:fr(Er.background.uniforms),vertexShader:Er.background.vertexShader,fragmentShader:Er.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(n.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(n)),n.material.uniforms.t2D.value=f,!0===f.matrixAutoUpdate&&f.updateMatrix(),n.material.uniforms.uvTransform.value.copy(f.matrix),c===f&&u===f.version&&l===e.toneMapping||(n.material.needsUpdate=!0,c=f,u=f.version,l=e.toneMapping),t.unshift(n,n.geometry,n.material,0,0,null))}}}function Lr(e,t,r,i){var n=e.getParameter(34921),o=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==o,s={},c=p(null),u=c;function l(t){return i.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function h(t){return i.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function p(e){for(var t=[],r=[],i=[],o=0;o=0){var y=c[h];if(void 0!==y){var b=y.normalized,x=y.itemSize,_=r.get(y);if(void 0===_)continue;var w=_.buffer,S=_.type,A=_.bytesPerElement;if(y.isInterleavedBufferAttribute){var M=y.data,C=M.stride,P=y.offset;M&&M.isInstancedInterleavedBuffer?(m(p,M.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=M.meshPerAttribute*M.count)):f(p),e.bindBuffer(34962,w),v(p,x,S,b,C*A,P*A)}else y.isInstancedBufferAttribute?(m(p,y.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=y.meshPerAttribute*y.count)):f(p),e.bindBuffer(34962,w),v(p,x,S,b,0,0)}else if("instanceMatrix"===h){var T=r.get(n.instanceMatrix);if(void 0===T)continue;var I=T.buffer,E=T.type;m(p+0,1),m(p+1,1),m(p+2,1),m(p+3,1),e.bindBuffer(34962,I),e.vertexAttribPointer(p+0,4,E,!1,64,0),e.vertexAttribPointer(p+1,4,E,!1,64,16),e.vertexAttribPointer(p+2,4,E,!1,64,32),e.vertexAttribPointer(p+3,4,E,!1,64,48)}else if(void 0!==l){var D=l[h];if(void 0!==D)switch(D.length){case 2:e.vertexAttrib2fv(p,D);break;case 3:e.vertexAttrib3fv(p,D);break;case 4:e.vertexAttrib4fv(p,D);break;default:e.vertexAttrib1fv(p,D)}}}}g()}(n,c,h,y),null!==b&&e.bindBuffer(34963,r.get(b).buffer))},reset:y,resetDefaultState:b,dispose:function(){for(var e in y(),s){var t=s[e];for(var r in t){var i=t[r];for(var n in i)h(i[n].object),delete i[n];delete t[r]}delete s[e]}},releaseStatesOfGeometry:function(e){if(void 0!==s[e.id]){var t=s[e.id];for(var r in t){var i=t[r];for(var n in i)h(i[n].object),delete i[n];delete t[r]}delete s[e.id]}},releaseStatesOfProgram:function(e){for(var t in s){var r=s[t];if(void 0!==r[e.id]){var i=r[e.id];for(var n in i)h(i[n].object),delete i[n];delete r[e.id]}}},initAttributes:d,enableAttribute:f,disableUnusedAttributes:g}}function Or(e,t,r,i){var n,o=i.isWebGL2;this.setMode=function(e){n=e},this.render=function(t,i){e.drawArrays(n,t,i),r.update(i,n)},this.renderInstances=function(i,a,s,c){if(0!==c){var u,l;if(o)u=e,l="drawArraysInstanced";else if(l="drawArraysInstancedANGLE",null===(u=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[l](n,a,s,c),r.update(s,n,c)}}}function Rr(e,t,r){var i;function n(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext,a=void 0!==r.precision?r.precision:"highp",s=n(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);var c=!0===r.logarithmicDepthBuffer,u=e.getParameter(34930),l=e.getParameter(35660),h=e.getParameter(3379),p=e.getParameter(34076),d=e.getParameter(34921),f=e.getParameter(36347),m=e.getParameter(36348),g=e.getParameter(36349),v=l>0,y=o||!!t.get("OES_texture_float");return{isWebGL2:o,getMaxAnisotropy:function(){if(void 0!==i)return i;var r=t.get("EXT_texture_filter_anisotropic");return i=null!==r?e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:l,maxTextureSize:h,maxCubemapSize:p,maxAttributes:d,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:o?e.getParameter(36183):0}}function kr(){var e=this,t=null,r=0,i=!1,n=!1,o=new Ke,a=new U,s={value:null,needsUpdate:!1};function c(){s.value!==t&&(s.value=t,s.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(t,r,i,n){var c=null!==t?t.length:0,u=null;if(0!==c){if(u=s.value,!0!==n||null===u){var l=i+4*c,h=r.matrixWorldInverse;a.getNormalMatrix(h),(null===u||u.length65535?It:Pt)(r,1);b.version=a;var x=o.get(e);x&&t.remove(x),o.set(e,b)}return{get:function(e,t){var i=n.get(t);return i||(t.addEventListener("dispose",a),t.isBufferGeometry?i=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new jt).setFromObject(e)),i=t._bufferGeometry),n.set(t,i),r.memory.geometries++,i)},update:function(e){var r=e.attributes;for(var i in r)t.update(r[i],34962);var n=e.morphAttributes;for(var o in n)for(var a=n[o],s=0,c=a.length;s0)return e;var n=t*r,o=Kr[n];if(void 0===o&&(o=new Float32Array(n),Kr[n]=o),0!==t){i.toArray(o,0);for(var a=1,s=0;a!==t;++a)s+=r,e[a].toArray(o,s)}return o}function ii(e,t){if(e.length!==t.length)return!1;for(var r=0,i=e.length;r/gm;function Qi(e){return e.replace(Ki,Ji)}function Ji(e,t){var r=Ir[t];if(void 0===r)throw new Error("Can not resolve #include <"+t+">");return Qi(r)}var en=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,tn=/#pragma unroll_loop_start[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}[\s]+?#pragma unroll_loop_end/g;function rn(e){return e.replace(tn,on).replace(en,nn)}function nn(e,t,r,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),on(e,t,r,i)}function on(e,t,r,i){for(var n="",o=parseInt(t);o0?e.gammaFactor:1,y=r.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Xi).join("\n")}(r),b=function(e){var t=[];for(var r in e){var i=e[r];!1!==i&&t.push("#define "+r+" "+i)}return t.join("\n")}(l),x=u.createProgram();if(r.isRawShaderMaterial?((n=[b].filter(Xi).join("\n")).length>0&&(n+="\n"),(o=[y,b].filter(Xi).join("\n")).length>0&&(o+="\n")):(n=[an(r),"#define SHADER_NAME "+r.shaderName,b,r.instancing?"#define USE_INSTANCING":"",r.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+v,"#define MAX_BONES "+r.maxBones,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+m:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMap&&r.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",r.normalMap&&r.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.displacementMap&&r.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.vertexTangents?"#define USE_TANGENT":"",r.vertexColors?"#define USE_COLOR":"",r.vertexUvs?"#define USE_UV":"",r.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",r.flatShading?"#define FLAT_SHADED":"",r.skinning?"#define USE_SKINNING":"",r.useVertexTexture?"#define BONE_TEXTURE":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.morphNormals&&!1===r.flatShading?"#define USE_MORPHNORMALS":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+d:"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Xi).join("\n"),o=[y,an(r),"#define SHADER_NAME "+r.shaderName,b,r.alphaTest?"#define ALPHATEST "+r.alphaTest+(r.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+v,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.matcap?"#define USE_MATCAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+f:"",r.envMap?"#define "+m:"",r.envMap?"#define "+g:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMap&&r.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",r.normalMap&&r.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.sheen?"#define USE_SHEEN":"",r.vertexTangents?"#define USE_TANGENT":"",r.vertexColors?"#define USE_COLOR":"",r.vertexUvs?"#define USE_UV":"",r.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+d:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensionShaderTextureLOD||r.envMap)&&r.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==r.toneMapping?"#define TONE_MAPPING":"",0!==r.toneMapping?Ir.tonemapping_pars_fragment:"",0!==r.toneMapping?qi("toneMapping",r.toneMapping):"",r.dithering?"#define DITHERING":"",Ir.encodings_pars_fragment,r.map?Wi("mapTexelToLinear",r.mapEncoding):"",r.matcap?Wi("matcapTexelToLinear",r.matcapEncoding):"",r.envMap?Wi("envMapTexelToLinear",r.envMapEncoding):"",r.emissiveMap?Wi("emissiveMapTexelToLinear",r.emissiveMapEncoding):"",r.lightMap?Wi("lightMapTexelToLinear",r.lightMapEncoding):"",(a="linearToOutputTexel",s=r.outputEncoding,c=$i(s),"vec4 "+a+"( vec4 value ) { return LinearTo"+c[0]+c[1]+"; }"),r.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Xi).join("\n")),h=Zi(h=Yi(h=Qi(h),r),r),p=Zi(p=Yi(p=Qi(p),r),r),h=rn(h),p=rn(p),r.isWebGL2&&!r.isRawShaderMaterial){var _=!1,w=/^\s*#version\s+300\s+es\s*\n/;r.isShaderMaterial&&null!==h.match(w)&&null!==p.match(w)&&(_=!0,h=h.replace(w,""),p=p.replace(w,"")),n=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+n,o=["#version 300 es\n","#define varying in",_?"":"out highp vec4 pc_fragColor;",_?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+o}var S,A,M=o+p,C=Gi(u,35633,n+h),P=Gi(u,35632,M);if(u.attachShader(x,C),u.attachShader(x,P),void 0!==r.index0AttributeName?u.bindAttribLocation(x,0,r.index0AttributeName):!0===r.morphTargets&&u.bindAttribLocation(x,0,"position"),u.linkProgram(x),e.debug.checkShaderErrors){var T=u.getProgramInfoLog(x).trim(),I=u.getShaderInfoLog(C).trim(),E=u.getShaderInfoLog(P).trim(),D=!0,L=!0;if(!1===u.getProgramParameter(x,35714)){D=!1;var O=Hi(u,C,"vertex"),R=Hi(u,P,"fragment");console.error("THREE.WebGLProgram: shader error: ",u.getError(),"gl.VALIDATE_STATUS",u.getProgramParameter(x,35715),"gl.getProgramInfoLog",T,O,R)}else""!==T?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",T):""!==I&&""!==E||(L=!1);L&&(this.diagnostics={runnable:D,programLog:T,vertexShader:{log:I,prefix:n},fragmentShader:{log:E,prefix:o}})}return u.deleteShader(C),u.deleteShader(P),this.getUniforms=function(){return void 0===S&&(S=new ji(u,x)),S},this.getAttributes=function(){return void 0===A&&(A=function(e,t){for(var r={},i=e.getProgramParameter(t,35721),n=0;n0,maxBones:w,useVertexTexture:s,morphTargets:i.morphTargets,morphNormals:i.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:n.directional.length,numPointLights:n.point.length,numSpotLights:n.spot.length,numRectAreaLights:n.rectArea.length,numHemiLights:n.hemi.length,numDirLightShadows:n.directionalShadowMap.length,numPointLightShadows:n.pointShadowMap.length,numSpotLightShadows:n.spotShadowMap.length,numClippingPlanes:m,numClipIntersection:g,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&p.length>0,shadowMapType:e.shadowMap.type,toneMapping:i.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:2===i.side,flipSided:1===i.side,depthPacking:void 0!==i.depthPacking&&i.depthPacking,index0AttributeName:i.index0AttributeName,extensionDerivatives:i.extensions&&i.extensions.derivatives,extensionFragDepth:i.extensions&&i.extensions.fragDepth,extensionDrawBuffers:i.extensions&&i.extensions.drawBuffers,extensionShaderTextureLOD:i.extensions&&i.extensions.shaderTextureLOD,rendererExtensionFragDepth:o||null!==t.get("EXT_frag_depth"),rendererExtensionDrawBuffers:o||null!==t.get("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:o||null!==t.get("EXT_shader_texture_lod"),customProgramCacheKey:i.customProgramCacheKey()}},getProgramCacheKey:function(t){var r=[];if(t.shaderID?r.push(t.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var i in t.defines)r.push(i),r.push(t.defines[i]);if(void 0===t.isRawShaderMaterial){for(var n=0;n1&&r.sort(e||ln),i.length>1&&i.sort(t||hn)}}}function dn(){var e=new WeakMap;function t(r){var i=r.target;i.removeEventListener("dispose",t),e.delete(i)}return{get:function(r,i){var n,o=e.get(r);return void 0===o?(n=new pn,e.set(r,new WeakMap),e.get(r).set(i,n),r.addEventListener("dispose",t)):void 0===(n=o.get(i))&&(n=new pn,o.set(i,n)),n},dispose:function(){e=new WeakMap}}}function fn(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var r;switch(t.type){case"DirectionalLight":r={direction:new Y,color:new pt};break;case"SpotLight":r={position:new Y,direction:new Y,color:new pt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new Y,color:new pt,distance:0,decay:0};break;case"HemisphereLight":r={direction:new Y,skyColor:new pt,groundColor:new pt};break;case"RectAreaLight":r={color:new pt,position:new Y,halfWidth:new Y,halfHeight:new Y}}return e[t.id]=r,r}}}var mn=0;function gn(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function vn(){for(var e,t=new fn,r=(e={},{get:function(t){if(void 0!==e[t.id])return e[t.id];var r;switch(t.type){case"DirectionalLight":case"SpotLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z};break;case"PointLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=r,r}}),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},n=0;n<9;n++)i.probe.push(new Y);var o=new Y,a=new ie,s=new ie;return{setup:function(e,n,c){for(var u=0,l=0,h=0,p=0;p<9;p++)i.probe[p].set(0,0,0);var d=0,f=0,m=0,g=0,v=0,y=0,b=0,x=0,_=c.matrixWorldInverse;e.sort(gn);for(var w=0,S=e.length;w\nvoid main(){float mean=0.0;float squared_mean=0.0;float depth=unpackRGBAToDepth(texture2D(shadow_pass,(gl_FragCoord.xy)/resolution));for(float i=-1.0;i<1.0;i+=SAMPLE_RATE){\n#ifdef HORIZONAL_PASS\nvec2 distribution=unpackRGBATo2Half(texture2D(shadow_pass,(gl_FragCoord.xy+vec2(i,0.0)*radius)/resolution));mean+=distribution.x;squared_mean+=distribution.y*distribution.y+distribution.x*distribution.x;\n#else\nfloat depth=unpackRGBAToDepth(texture2D(shadow_pass,(gl_FragCoord.xy+vec2(0.0,i)*radius)/resolution));mean+=depth;squared_mean+=depth*depth;\n#endif\n}mean=mean*HALF_SAMPLE_RATE;squared_mean=squared_mean*HALF_SAMPLE_RATE;float std_dev=sqrt(squared_mean-mean*mean);gl_FragColor=pack2HalfToRGBA(vec2(mean,std_dev));}"}),p=h.clone();p.defines.HORIZONAL_PASS=1;var d=new jt;d.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var f=new or(d,h),m=this;function g(r,i){var n=t.update(f);h.uniforms.shadow_pass.value=r.map.texture,h.uniforms.resolution.value=r.mapSize,h.uniforms.radius.value=r.radius,e.setRenderTarget(r.mapPass),e.clear(),e.renderBufferDirect(i,null,n,h,f,null),p.uniforms.shadow_pass.value=r.mapPass.texture,p.uniforms.resolution.value=r.mapSize,p.uniforms.radius.value=r.radius,e.setRenderTarget(r.map),e.clear(),e.renderBufferDirect(i,null,n,p,f,null)}function v(e,t,r){var i=e<<0|t<<1|r<<2,n=s[i];return void 0===n&&(n=new xn({depthPacking:3201,morphTargets:e,skinning:t}),s[i]=n),n}function y(e,t,r){var i=e<<0|t<<1|r<<2,n=c[i];return void 0===n&&(n=new _n({morphTargets:e,skinning:t}),c[i]=n),n}function b(t,r,i,n,o,a,s){var c=null,h=v,p=t.customDepthMaterial;if(!0===n.isPointLight&&(h=y,p=t.customDistanceMaterial),void 0===p){var d=!1;!0===i.morphTargets&&(d=r.morphAttributes&&r.morphAttributes.position&&r.morphAttributes.position.length>0);var f=!1;!0===t.isSkinnedMesh&&(!0===i.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t)),c=h(d,f,!0===t.isInstancedMesh)}else c=p;if(e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var m=c.uuid,g=i.uuid,b=u[m];void 0===b&&(b={},u[m]=b);var x=b[g];void 0===x&&(x=c.clone(),b[g]=x),c=x}return c.visible=i.visible,c.wireframe=i.wireframe,c.side=3===s?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:l[i.side],c.clipShadows=i.clipShadows,c.clippingPlanes=i.clippingPlanes,c.clipIntersection=i.clipIntersection,c.wireframeLinewidth=i.wireframeLinewidth,c.linewidth=i.linewidth,!0===n.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(n.matrixWorld),c.nearDistance=o,c.farDistance=a),c}function w(r,n,o,a,s){if(!1!==r.visible){if(r.layers.test(n.layers)&&(r.isMesh||r.isLine||r.isPoints)&&(r.castShadow||r.receiveShadow&&3===s)&&(!r.frustumCulled||i.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,r.matrixWorld);var c=t.update(r),u=r.material;if(Array.isArray(u))for(var l=c.groups,h=0,p=l.length;hr||n.y>r)&&(n.x>r&&(o.x=Math.floor(r/b.x),n.x=o.x*b.x,y.mapSize.x=o.x),n.y>r&&(o.y=Math.floor(r/b.y),n.y=o.y*b.y,y.mapSize.y=o.y)),null===y.map&&!y.isPointLightShadow&&3===this.type){var S={minFilter:_,magFilter:_,format:I};y.map=new H(n.x,n.y,S),y.map.texture.name=v.name+".shadowMap",y.mapPass=new H(n.x,n.y,S),y.camera.updateProjectionMatrix()}if(null===y.map){var A={minFilter:x,magFilter:x,format:I};y.map=new H(n.x,n.y,A),y.map.texture.name=v.name+".shadowMap",y.camera.updateProjectionMatrix()}e.setRenderTarget(y.map),e.clear();for(var M=y.getViewportCount(),C=0;C=1):-1!==P.indexOf("OpenGL ES")&&(C=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(P)[1]),M=C>=2);var T=null,I={},E=new $,D=new $;function L(t,r,i){var n=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(var a=0;ai||e.height>i)&&(n=i/Math.max(e.width,e.height)),n<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){var o=t?F.floorPowerOfTwo:Math.floor,a=o(n*e.width),c=o(n*e.height);void 0===s&&(s=m(a,c));var u=r?m(a,c):s;return u.width=a,u.height=c,u.getContext("2d").drawImage(e,0,0,a,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+c+")."),u}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function v(e){return F.isPowerOfTwo(e.width)&&F.isPowerOfTwo(e.height)}function b(e,t){return e.generateMipmaps&&t&&e.minFilter!==x&&e.minFilter!==_}function w(t,r,n,o){e.generateMipmap(t),i.get(r).__maxMipLevel=Math.log(Math.max(n,o))*Math.LOG2E}function L(r,i,n){if(!1===c)return i;if(null!==r){if(void 0!==e[r])return e[r];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+r+"'")}var o=i;return 6403===i&&(5126===n&&(o=33326),5131===n&&(o=33325),5121===n&&(o=33321)),6407===i&&(5126===n&&(o=34837),5131===n&&(o=34843),5121===n&&(o=32849)),6408===i&&(5126===n&&(o=34836),5131===n&&(o=34842),5121===n&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||t.get("EXT_color_buffer_float"),o}function O(e){return e===x||1004===e||1005===e?9728:9729}function R(t){var r=t.target;r.removeEventListener("dispose",R),function(t){var r=i.get(t);if(void 0===r.__webglInit)return;e.deleteTexture(r.__webglTexture),i.remove(t)}(r),r.isVideoTexture&&d.delete(r),a.memory.textures--}function k(t){var r=t.target;r.removeEventListener("dispose",k),function(t){var r=i.get(t),n=i.get(t.texture);if(!t)return;void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(var o=0;o<6;o++)e.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[o]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);i.remove(t.texture),i.remove(t)}(r),a.memory.textures--}var N=0;function B(e,t){var n=i.get(e);if(e.isVideoTexture&&function(e){var t=a.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())}(e),e.version>0&&n.__version!==e.version){var o=e.image;if(void 0===o)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==o.complete)return void H(n,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}r.activeTexture(33984+t),r.bindTexture(3553,n.__webglTexture)}function z(t,n){if(6===t.image.length){var a=i.get(t);if(t.version>0&&a.__version!==t.version){$(a,t),r.activeTexture(33984+n),r.bindTexture(34067,a.__webglTexture),e.pixelStorei(37440,t.flipY);for(var s=t&&(t.isCompressedTexture||t.image[0].isCompressedTexture),u=t.image[0]&&t.image[0].isDataTexture,h=[],p=0;p<6;p++)h[p]=s||u?u?t.image[p].image:t.image[p]:g(t.image[p],!1,!0,l);var d,f=h[0],m=v(f)||c,y=o.convert(t.format),x=o.convert(t.type),_=L(t.internalFormat,y,x);if(V(34067,t,m),s){for(var S=0;S<6;S++){d=h[S].mipmaps;for(var A=0;A1||i.get(o).__currentAnisotropy)&&(e.texParameterf(r,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,n.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function $(t,r){void 0===t.__webglInit&&(t.__webglInit=!0,r.addEventListener("dispose",R),t.__webglTexture=e.createTexture(),a.memory.textures++)}function H(t,i,n){var a=3553;i.isDataTexture2DArray&&(a=35866),i.isDataTexture3D&&(a=32879),$(t,i),r.activeTexture(33984+n),r.bindTexture(a,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment);var s,u=function(e){return!c&&(e.wrapS!==y||e.wrapT!==y||e.minFilter!==x&&e.minFilter!==_)}(i)&&!1===v(i.image),l=g(i.image,u,!1,h),p=v(l)||c,d=o.convert(i.format),f=o.convert(i.type),m=L(i.internalFormat,d,f);V(a,i,p);var C=i.mipmaps;if(i.isDepthTexture)m=6402,c?m=i.type===M?36012:i.type===A?33190:i.type===P?35056:33189:i.type===M&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===E&&6402===m&&i.type!==S&&i.type!==A&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=S,f=o.convert(i.type)),i.format===D&&6402===m&&(m=34041,i.type!==P&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=P,f=o.convert(i.type))),r.texImage2D(3553,0,m,l.width,l.height,0,d,f,null);else if(i.isDataTexture)if(C.length>0&&p){for(var O=0,R=C.length;O0&&p){for(var B=0,F=C.length;B=u&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+u),N+=1,e},this.resetTextureUnits=function(){N=0},this.setTexture2D=B,this.setTexture2DArray=function(e,t){var n=i.get(e);e.version>0&&n.__version!==e.version?H(n,e,t):(r.activeTexture(33984+t),r.bindTexture(35866,n.__webglTexture))},this.setTexture3D=function(e,t){var n=i.get(e);e.version>0&&n.__version!==e.version?H(n,e,t):(r.activeTexture(33984+t),r.bindTexture(32879,n.__webglTexture))},this.setTextureCube=z,this.setTextureCubeDynamic=U,this.setupRenderTarget=function(t){var n=i.get(t),s=i.get(t.texture);t.addEventListener("dispose",k),s.__webglTexture=e.createTexture(),a.memory.textures++;var u=!0===t.isWebGLCubeRenderTarget,l=!0===t.isWebGLMultisampleRenderTarget,h=v(t)||c;if(!c||t.texture.format!==T||t.texture.type!==M&&t.texture.type!==C||(t.texture.format=I,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),u){n.__webglFramebuffer=[];for(var p=0;p<6;p++)n.__webglFramebuffer[p]=e.createFramebuffer()}else if(n.__webglFramebuffer=e.createFramebuffer(),l)if(c){n.__webglMultisampledFramebuffer=e.createFramebuffer(),n.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,n.__webglColorRenderbuffer);var d=o.convert(t.texture.format),f=o.convert(t.texture.type),m=L(t.texture.internalFormat,d,f),g=Y(t);e.renderbufferStorageMultisample(36161,g,m,t.width,t.height),e.bindFramebuffer(36160,n.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,n.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(n.__webglDepthRenderbuffer=e.createRenderbuffer(),q(n.__webglDepthRenderbuffer,t,!0)),e.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(u){r.bindTexture(34067,s.__webglTexture),V(34067,t.texture,h);for(var y=0;y<6;y++)W(n.__webglFramebuffer[y],t,36064,34069+y);b(t.texture,h)&&w(34067,t.texture,t.width,t.height),r.bindTexture(34067,null)}else r.bindTexture(3553,s.__webglTexture),V(3553,t.texture,h),W(n.__webglFramebuffer,t,36064,3553),b(t.texture,h)&&w(3553,t.texture,t.width,t.height),r.bindTexture(3553,null);t.depthBuffer&&X(t)},this.updateRenderTargetMipmap=function(e){var t=e.texture;if(b(t,v(e)||c)){var n=e.isWebGLCubeRenderTarget?34067:3553,o=i.get(t).__webglTexture;r.bindTexture(n,o),w(n,t,e.width,e.height),r.bindTexture(n,null)}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(c){var r=i.get(t);e.bindFramebuffer(36008,r.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,r.__webglFramebuffer);var n=t.width,o=t.height,a=16384;t.depthBuffer&&(a|=256),t.stencilBuffer&&(a|=1024),e.blitFramebuffer(0,0,n,o,0,0,n,o,a,9728),e.bindFramebuffer(36160,r.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===Z&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),Z=!0),e=e.texture),B(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===K&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),K=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?z(e,t):U(e,t)}}function Mn(e,t,r){var i=r.isWebGL2;return{convert:function(e){var r;if(e===w)return 5121;if(1017===e)return 32819;if(1018===e)return 32820;if(1019===e)return 33635;if(1010===e)return 5120;if(1011===e)return 5122;if(e===S)return 5123;if(1013===e)return 5124;if(e===A)return 5125;if(e===M)return 5126;if(e===C)return i?5131:null!==(r=t.get("OES_texture_half_float"))?r.HALF_FLOAT_OES:null;if(1021===e)return 6406;if(e===T)return 6407;if(e===I)return 6408;if(1024===e)return 6409;if(1025===e)return 6410;if(e===E)return 6402;if(e===D)return 34041;if(1028===e)return 6403;if(1029===e)return 36244;if(1030===e)return 33319;if(1031===e)return 33320;if(1032===e)return 36248;if(1033===e)return 36249;if(33776===e||33777===e||33778===e||33779===e){if(null===(r=t.get("WEBGL_compressed_texture_s3tc")))return null;if(33776===e)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===e)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===e)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===e)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===e||35841===e||35842===e||35843===e){if(null===(r=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(35840===e)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===e)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===e)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===e)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e)return null!==(r=t.get("WEBGL_compressed_texture_etc1"))?r.COMPRESSED_RGB_ETC1_WEBGL:null;if((37492===e||37496===e)&&null!==(r=t.get("WEBGL_compressed_texture_etc"))){if(37492===e)return r.COMPRESSED_RGB8_ETC2;if(37496===e)return r.COMPRESSED_RGBA8_ETC2_EAC}return 37808===e||37809===e||37810===e||37811===e||37812===e||37813===e||37814===e||37815===e||37816===e||37817===e||37818===e||37819===e||37820===e||37821===e||37840===e||37841===e||37842===e||37843===e||37844===e||37845===e||37846===e||37847===e||37848===e||37849===e||37850===e||37851===e||37852===e||37853===e?null!==(r=t.get("WEBGL_compressed_texture_astc"))?e:null:36492===e?null!==(r=t.get("EXT_texture_compression_bptc"))?e:null:e===P?i?34042:null!==(r=t.get("WEBGL_depth_texture"))?r.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}function Cn(e){br.call(this),this.cameras=e||[]}function Pn(){_e.call(this),this.type="Group"}function Tn(){this._targetRay=null,this._grip=null}function In(e,t){var r=this,i=null,n=1,o=null,a="local-floor",s=null,c=[],u=new Map,l=new br;l.layers.enable(1),l.viewport=new $;var h=new br;h.layers.enable(2),h.viewport=new $;var p=[l,h],d=new Cn;d.layers.enable(1),d.layers.enable(2);var f=null,m=null;function g(e){var t=u.get(e.inputSource);t&&t.dispatchEvent({type:e.type})}function v(){u.forEach((function(e,t){e.disconnect(t)})),u.clear(),e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),A.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}function y(e){o=e,A.setContext(i),A.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}function b(e){for(var t=i.inputSources,r=0;r=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var m=0;m=0&&e.numSupportedMorphNormals++}var g=i.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=G.numPlanes,i.numIntersection=G.numIntersection,g.clippingPlanes=G.uniform),i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=a,i.needsLights&&(g.ambientLightColor.value=n.state.ambient,g.lightProbe.value=n.state.probe,g.directionalLights.value=n.state.directional,g.directionalLightShadows.value=n.state.directionalShadow,g.spotLights.value=n.state.spot,g.spotLightShadows.value=n.state.spotShadow,g.rectAreaLights.value=n.state.rectArea,g.pointLights.value=n.state.point,g.pointLightShadows.value=n.state.pointShadow,g.hemisphereLights.value=n.state.hemi,g.directionalShadowMap.value=n.state.directionalShadowMap,g.directionalShadowMatrix.value=n.state.directionalShadowMatrix,g.spotShadowMap.value=n.state.spotShadowMap,g.spotShadowMatrix.value=n.state.spotShadowMatrix,g.pointShadowMap.value=n.state.pointShadowMap,g.pointShadowMatrix.value=n.state.pointShadowMatrix);var v=i.program.getUniforms(),y=ji.seqWithValue(v.seq,g);i.uniformsList=y}function Re(e,t,r,i){!0!==t.isScene&&(t=X),re.resetTextureUnits();var n=t.fog,o=r.isMeshStandardMaterial?t.environment:null,a=null===y?d.outputEncoding:y.texture.encoding,s=te.get(r),c=p.state.lights;if(!0===V&&(!0===H||e!==_)){var u=e===_&&r.id===x;G.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,e,s,u)}r.version===s.__version?void 0===s.program||r.fog&&s.fog!==n||s.environment!==o||s.needsLights&&s.lightsStateVersion!==c.state.version?Oe(r,t,i):void 0===s.numClippingPlanes||s.numClippingPlanes===G.numPlanes&&s.numIntersection===G.numIntersection?s.outputEncoding!==a&&Oe(r,t,i):Oe(r,t,i):(Oe(r,t,i),s.__version=r.version);var l,h,f=!1,m=!1,g=!1,v=s.program,b=v.getUniforms(),w=s.uniforms;if(J.useProgram(v.program)&&(f=!0,m=!0,g=!0),r.id!==x&&(x=r.id,m=!0),f||_!==e){if(b.setValue(ve,"projectionMatrix",e.projectionMatrix),Q.logarithmicDepthBuffer&&b.setValue(ve,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),_!==e&&(_=e,m=!0,g=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){var S=b.map.cameraPosition;void 0!==S&&S.setValue(ve,q.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&b.setValue(ve,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||r.skinning)&&b.setValue(ve,"viewMatrix",e.matrixWorldInverse)}if(r.skinning){b.setOptional(ve,i,"bindMatrix"),b.setOptional(ve,i,"bindMatrixInverse");var A=i.skeleton;if(A){var C=A.bones;if(Q.floatVertexTextures){if(void 0===A.boneTexture){var P=Math.sqrt(4*C.length);P=F.ceilPowerOfTwo(P),P=Math.max(P,4);var T=new Float32Array(P*P*4);T.set(A.boneMatrices);var E=new xr(T,P,P,I,M);A.boneMatrices=T,A.boneTexture=E,A.boneTextureSize=P}b.setValue(ve,"boneTexture",A.boneTexture,re),b.setValue(ve,"boneTextureSize",A.boneTextureSize)}else b.setOptional(ve,A,"boneMatrices")}}return(m||s.receiveShadow!==i.receiveShadow)&&(s.receiveShadow=i.receiveShadow,b.setValue(ve,"receiveShadow",i.receiveShadow)),m&&(b.setValue(ve,"toneMappingExposure",d.toneMappingExposure),s.needsLights&&(h=g,(l=w).ambientLightColor.needsUpdate=h,l.lightProbe.needsUpdate=h,l.directionalLights.needsUpdate=h,l.directionalLightShadows.needsUpdate=h,l.pointLights.needsUpdate=h,l.pointLightShadows.needsUpdate=h,l.spotLights.needsUpdate=h,l.spotLightShadows.needsUpdate=h,l.rectAreaLights.needsUpdate=h,l.hemisphereLights.needsUpdate=h),n&&r.fog&&ce.refreshFogUniforms(w,n),ce.refreshMaterialUniforms(w,r,o,O,D),void 0!==w.ltc_1&&(w.ltc_1.value=Ar.LTC_1),void 0!==w.ltc_2&&(w.ltc_2.value=Ar.LTC_2),ji.upload(ve,s.uniformsList,w,re)),r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(ji.upload(ve,s.uniformsList,w,re),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&b.setValue(ve,"center",i.center),b.setValue(ve,"modelViewMatrix",i.modelViewMatrix),b.setValue(ve,"normalMatrix",i.normalMatrix),b.setValue(ve,"modelMatrix",i.matrixWorld),v}Ie.setAnimationLoop((function(e){we.isPresenting||Te&&Te(e)})),"undefined"!=typeof window&&Ie.setContext(window),this.setAnimationLoop=function(e){Te=e,we.setAnimationLoop(e),null===e?Ie.stop():Ie.start()},this.render=function(e,t){var r,i;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),r=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),i=arguments[3]),void 0===t||!0===t.isCamera){if(!0!==f){ge.resetDefaultState(),x=-1,_=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===we.enabled&&!0===we.isPresenting&&(t=we.getCamera(t)),!0===e.isScene&&e.onBeforeRender(d,e,t,r||y),(p=le.get(e,t)).init(),W.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),j.setFromProjectionMatrix(W),H=this.localClippingEnabled,V=G.init(this.clippingPlanes,H,t),(h=ue.get(e,t)).init(),Ee(e,t,0,d.sortObjects),h.finish(),!0===d.sortObjects&&h.sort(R,k),!0===V&&G.beginShadows();var n=p.state.shadowsArray;Se.render(n,e,t),p.setupLights(t),!0===V&&G.endShadows(),!0===this.info.autoReset&&this.info.reset(),void 0!==r&&this.setRenderTarget(r),he.render(h,e,t,i);var o=h.opaque,a=h.transparent;o.length>0&&De(o,e,t),a.length>0&&De(a,e,t),!0===e.isScene&&e.onAfterRender(d,e,t),null!==y&&(re.updateRenderTargetMipmap(y),re.updateMultisampleRenderTarget(y)),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1),h=null,p=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(e){m!==e&&null===y&&ve.bindFramebuffer(36160,e),m=e},this.getActiveCubeFace=function(){return g},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return y},this.setRenderTarget=function(e,t,r){y=e,g=t,v=r,e&&void 0===te.get(e).__webglFramebuffer&&re.setupRenderTarget(e);var i=m,n=!1;if(e){var o=te.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=o[t||0],n=!0):i=e.isWebGLMultisampleRenderTarget?te.get(e).__webglMultisampledFramebuffer:o,A.copy(e.viewport),P.copy(e.scissor),T=e.scissorTest}else A.copy(N).multiplyScalar(O).floor(),P.copy(B).multiplyScalar(O).floor(),T=U;if(b!==i&&(ve.bindFramebuffer(36160,i),b=i),J.viewport(A),J.scissor(P),J.setScissorTest(T),n){var a=te.get(e.texture);ve.framebufferTexture2D(36160,36064,34069+(t||0),a.__webglTexture,r||0)}},this.readRenderTargetPixels=function(e,t,r,i,n,o,a){if(e&&e.isWebGLRenderTarget){var s=te.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){var c=!1;s!==b&&(ve.bindFramebuffer(36160,s),c=!0);try{var u=e.texture,l=u.format,h=u.type;if(l!==I&&me.convert(l)!==ve.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===w||me.convert(h)===ve.getParameter(35738)||h===M&&(Q.isWebGL2||K.get("OES_texture_float")||K.get("WEBGL_color_buffer_float"))||h===C&&(Q.isWebGL2?K.get("EXT_color_buffer_float"):K.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ve.checkFramebufferStatus(36160)?t>=0&&t<=e.width-i&&r>=0&&r<=e.height-n&&ve.readPixels(t,r,i,n,me.convert(l),me.convert(h),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&ve.bindFramebuffer(36160,b)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,r){void 0===r&&(r=0);var i=Math.pow(2,-r),n=Math.floor(t.image.width*i),o=Math.floor(t.image.height*i),a=me.convert(t.format);re.setTexture2D(t,0),ve.copyTexImage2D(3553,r,a,e.x,e.y,n,o,0),J.unbindTexture()},this.copyTextureToTexture=function(e,t,r,i){void 0===i&&(i=0);var n=t.image.width,o=t.image.height,a=me.convert(r.format),s=me.convert(r.type);re.setTexture2D(r,0),ve.pixelStorei(37440,r.flipY),ve.pixelStorei(37441,r.premultiplyAlpha),ve.pixelStorei(3317,r.unpackAlignment),t.isDataTexture?ve.texSubImage2D(3553,i,e.x,e.y,n,o,a,s,t.image.data):t.isCompressedTexture?ve.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):ve.texSubImage2D(3553,i,e.x,e.y,a,s,t.image),0===i&&r.generateMipmaps&&ve.generateMipmap(3553),J.unbindTexture()},this.initTexture=function(e){re.setTexture2D(e,0),J.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Ln(e,t,r){this.name="",this.color=new pt(e),this.near=void 0!==t?t:1,this.far=void 0!==r?r:1e3}function On(e){yt.call(this),this.type="LineBasicMaterial",this.color=new pt(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(e)}Cn.prototype=Object.assign(Object.create(br.prototype),{constructor:Cn,isArrayCamera:!0}),Pn.prototype=Object.assign(Object.create(_e.prototype),{constructor:Pn,isGroup:!0}),Object.assign(Tn.prototype,{constructor:Tn,getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new Pn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new Pn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),this},disconnect:function(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),this},update:function(e,t,r){var i=null,n=null,o=this._targetRay,a=this._grip;return e&&(null!==o&&null!==(i=t.getPose(e.targetRaySpace,r))&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale)),null!==a&&e.gripSpace&&null!==(n=t.getPose(e.gripSpace,r))&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale))),null!==o&&(o.visible=null!==i),null!==a&&(a.visible=null!==n),this}}),Object.assign(In.prototype,R.prototype),Object.assign(Ln.prototype,{isFog:!0,clone:function(){return new Ln(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),On.prototype=Object.create(yt.prototype),On.prototype.constructor=On,On.prototype.isLineBasicMaterial=!0,On.prototype.copy=function(e){return yt.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.morphTargets=e.morphTargets,this};var Rn=new Y,kn=new Y,Nn=new ie,Bn=new qe,Fn=new ze;function zn(e,t,r){1===r&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),_e.call(this),this.type="Line",this.geometry=void 0!==e?e:new jt,this.material=void 0!==t?t:new On,this.updateMorphTargets()}zn.prototype=Object.assign(Object.create(_e.prototype),{constructor:zn,isLine:!0,copy:function(e){return _e.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,r=[0],i=1,n=t.count;ia)){l.applyMatrix4(this.matrixWorld);var b=e.ray.origin.distanceTo(l);be.far||t.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else for(var x=0,_=d.length/3-1;x<_;x+=h){if(s.fromArray(d,3*x),c.fromArray(d,3*x+3),!(Bn.distanceSqToSegment(s,c,l,u)>a)){l.applyMatrix4(this.matrixWorld);var w=e.ray.origin.distanceTo(l);we.far||t.push({distance:w,point:u.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}else if(r.isGeometry)for(var S=r.vertices,A=S.length,M=0;Ma)){l.applyMatrix4(this.matrixWorld);var C=e.ray.origin.distanceTo(l);Ce.far||t.push({distance:C,point:u.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}}},updateMorphTargets:function(){var e=this.geometry;if(e.isBufferGeometry){var t=e.morphAttributes,r=Object.keys(t);if(r.length>0){var i=t[r[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var n=0,o=i.length;n0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});var Un=new Y,jn=new Y;function Gn(e,t){zn.call(this,e,t),this.type="LineSegments"}function Vn(e){yt.call(this),this.type="PointsMaterial",this.color=new pt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}Gn.prototype=Object.assign(Object.create(zn.prototype),{constructor:Gn,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,r=[],i=0,n=t.count;in.far)return;o.push({distance:u,distanceToRay:Math.sqrt(s),point:c,index:t,face:null,object:a})}}function Zn(e,t,r,i,n,o,a,s,c){V.call(this,e,t,r,i,n,o,a,s,c),this.needsUpdate=!0}function Kn(e,t,r,i){pr.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:r,detail:i},this.fromBufferGeometry(new Qn(e,t,r,i)),this.mergeVertices()}function Qn(e,t,r,i){jt.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:e,indices:t,radius:r,detail:i},r=r||1;var n=[],o=[];function a(e,t,r,i){for(var n=Math.pow(2,i),o=[],a=0;a<=n;a++){o[a]=[];for(var c=e.clone().lerp(r,a/n),u=t.clone().lerp(r,a/n),l=n-a,h=0;h<=l;h++)o[a][h]=0===h&&a===n?c:c.clone().lerp(u,h/l)}for(var p=0;p.9&&a<.1&&(t<.2&&(o[e+0]+=1),r<.2&&(o[e+2]+=1),i<.2&&(o[e+4]+=1))}}()}(),this.setAttribute("position",new Et(n,3)),this.setAttribute("normal",new Et(n.slice(),3)),this.setAttribute("uv",new Et(o,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}function Jn(e,t){pr.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new eo(e,t)),this.mergeVertices()}function eo(e,t){Qn.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function to(e,t){pr.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new ro(e,t)),this.mergeVertices()}function ro(e,t){Qn.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function io(e,t){pr.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new no(e,t)),this.mergeVertices()}function no(e,t){var r=(1+Math.sqrt(5))/2,i=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1];Qn.call(this,i,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function oo(e,t,r,i,n){pr.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:r,tubularSegments:i,arc:n},this.fromBufferGeometry(new ao(e,t,r,i,n)),this.mergeVertices()}function ao(e,t,r,i,n){jt.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:r,tubularSegments:i,arc:n},e=e||1,t=t||.4,r=Math.floor(r)||8,i=Math.floor(i)||6,n=n||2*Math.PI;for(var o=[],a=[],s=[],c=[],u=new Y,l=new Y,h=new Y,p=0;p<=r;p++)for(var d=0;d<=i;d++){var f=d/i*n,m=p/r*Math.PI*2;l.x=(e+t*Math.cos(m))*Math.cos(f),l.y=(e+t*Math.cos(m))*Math.sin(f),l.z=t*Math.sin(m),a.push(l.x,l.y,l.z),u.x=e*Math.cos(f),u.y=e*Math.sin(f),h.subVectors(l,u).normalize(),s.push(h.x,h.y,h.z),c.push(d/i),c.push(p/r)}for(var g=1;g<=r;g++)for(var v=1;v<=i;v++){var y=(i+1)*g+v-1,b=(i+1)*(g-1)+v-1,x=(i+1)*(g-1)+v,_=(i+1)*g+v;o.push(y,b,_),o.push(b,x,_)}this.setIndex(o),this.setAttribute("position",new Et(a,3)),this.setAttribute("normal",new Et(s,3)),this.setAttribute("uv",new Et(c,2))}function so(e,t,r,i,n,o,a,s){pr.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:n,openEnded:o,thetaStart:a,thetaLength:s},this.fromBufferGeometry(new co(e,t,r,i,n,o,a,s)),this.mergeVertices()}function co(e,t,r,i,n,o,a,s){jt.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:n,openEnded:o,thetaStart:a,thetaLength:s};var c=this;e=void 0!==e?e:1,t=void 0!==t?t:1,r=r||1,i=Math.floor(i)||8,n=Math.floor(n)||1,o=void 0!==o&&o,a=void 0!==a?a:0,s=void 0!==s?s:2*Math.PI;var u=[],l=[],h=[],p=[],d=0,f=[],m=r/2,g=0;function v(r){var n,o,f=new z,v=new Y,y=0,b=!0===r?e:t,x=!0===r?1:-1;n=d;for(var _=1;_<=i;_++)l.push(0,m*x,0),h.push(0,x,0),p.push(.5,.5),d++;o=d;for(var w=0;w<=i;w++){var S=w/i*s+a,A=Math.cos(S),M=Math.sin(S);v.x=b*M,v.y=m*x,v.z=b*A,l.push(v.x,v.y,v.z),h.push(0,x,0),f.x=.5*A+.5,f.y=.5*M*x+.5,p.push(f.x,f.y),d++}for(var C=0;C0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new Et(l,3)),this.setAttribute("normal",new Et(h,3)),this.setAttribute("uv",new Et(p,2))}function uo(e,t,r,i,n,o,a){so.call(this,0,e,t,r,i,n,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:o,thetaLength:a}}function lo(e,t,r,i,n,o,a){co.call(this,0,e,t,r,i,n,o,a),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:o,thetaLength:a}}function ho(e,t){_e.call(this),this.type="Light",this.color=new pt(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function po(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new z(512,512),this.map=null,this.mapPass=null,this.matrix=new ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Sr,this._frameExtents=new z(1,1),this._viewportCount=1,this._viewports=[new $(0,0,1,1)]}function fo(){po.call(this,new br(50,1,.5,500))}function mo(e,t,r,i,n,o){ho.call(this,e,t),this.type="SpotLight",this.position.copy(_e.DefaultUp),this.updateMatrix(),this.target=new _e,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==o?o:1,this.shadow=new fo}function go(e,t,r,i,n,o){yr.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=void 0!==e?e:-1,this.right=void 0!==t?t:1,this.top=void 0!==r?r:1,this.bottom=void 0!==i?i:-1,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function vo(e,t){ho.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}Xn.prototype=Object.assign(Object.create(_e.prototype),{constructor:Xn,isPoints:!0,copy:function(e){return _e.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},raycast:function(e,t){var r=this.geometry,i=this.matrixWorld,n=e.params.Points.threshold;if(null===r.boundingSphere&&r.computeBoundingSphere(),Wn.copy(r.boundingSphere),Wn.applyMatrix4(i),Wn.radius+=n,!1!==e.ray.intersectsSphere(Wn)){$n.getInverse(i),Hn.copy(e.ray).applyMatrix4($n);var o=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o;if(r.isBufferGeometry){var s=r.index,c=r.attributes.position.array;if(null!==s)for(var u=s.array,l=0,h=u.length;l0){var i=t[r[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var n=0,o=i.length;n0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}),Zn.prototype=Object.create(V.prototype),Zn.prototype.constructor=Zn,Zn.prototype.isCanvasTexture=!0,Kn.prototype=Object.create(pr.prototype),Kn.prototype.constructor=Kn,Qn.prototype=Object.create(jt.prototype),Qn.prototype.constructor=Qn,Jn.prototype=Object.create(pr.prototype),Jn.prototype.constructor=Jn,eo.prototype=Object.create(Qn.prototype),eo.prototype.constructor=eo,to.prototype=Object.create(pr.prototype),to.prototype.constructor=to,ro.prototype=Object.create(Qn.prototype),ro.prototype.constructor=ro,io.prototype=Object.create(pr.prototype),io.prototype.constructor=io,no.prototype=Object.create(Qn.prototype),no.prototype.constructor=no,oo.prototype=Object.create(pr.prototype),oo.prototype.constructor=oo,ao.prototype=Object.create(jt.prototype),ao.prototype.constructor=ao,so.prototype=Object.create(pr.prototype),so.prototype.constructor=so,co.prototype=Object.create(jt.prototype),co.prototype.constructor=co,uo.prototype=Object.create(so.prototype),uo.prototype.constructor=uo,lo.prototype=Object.create(co.prototype),lo.prototype.constructor=lo,ho.prototype=Object.assign(Object.create(_e.prototype),{constructor:ho,isLight:!0,copy:function(e){return _e.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=_e.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),Object.assign(po.prototype,{_projScreenMatrix:new ie,_lightPositionWorld:new Y,_lookTarget:new Y,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){var t=this.camera,r=this.matrix,i=this._projScreenMatrix,n=this._lookTarget,o=this._lightPositionWorld;o.setFromMatrixPosition(e.matrixWorld),t.position.copy(o),n.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(n),t.updateMatrixWorld(),i.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(i),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(t.projectionMatrix),r.multiply(t.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),fo.prototype=Object.assign(Object.create(po.prototype),{constructor:fo,isSpotLightShadow:!0,updateMatrices:function(e){var t=this.camera,r=2*F.RAD2DEG*e.angle,i=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;r===t.fov&&i===t.aspect&&n===t.far||(t.fov=r,t.aspect=i,t.far=n,t.updateProjectionMatrix()),po.prototype.updateMatrices.call(this,e)}}),mo.prototype=Object.assign(Object.create(ho.prototype),{constructor:mo,isSpotLight:!0,copy:function(e){return ho.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),go.prototype=Object.assign(Object.create(yr.prototype),{constructor:go,isOrthographicCamera:!0,copy:function(e,t){return yr.prototype.copy.call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this},setViewOffset:function(e,t,r,i,n,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=n,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2,n=r-e,o=r+e,a=i+t,s=i-t;if(null!==this.view&&this.view.enabled){var c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o=(n+=c*this.view.offsetX)+c*this.view.width,s=(a-=u*this.view.offsetY)-u*this.view.height}this.projectionMatrix.makeOrthographic(n,o,a,s,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=_e.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}),vo.prototype=Object.assign(Object.create(ho.prototype),{constructor:vo,isAmbientLight:!0});var yo=new ie,bo=new ie;function xo(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new br,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new br,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}function _o(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function wo(e){if("undefined"!=typeof window){var t=new RegExp(e+"=([^&#=]*)").exec(window.location.search);return t?decodeURIComponent(t[1]):void 0}}function So(e,t){return void 0!==e?e:t}function Ao(e,t){var r=Object.assign({},e);for(var i in t){void 0===e[i]&&(r[i]=t[i])}return r}function Mo(e,t){for(var r in t){var i=t[r];void 0!==i&&(e[r]=i)}return e}function Co(){var e=window.location.protocol;return null===e.match(/http(s)?:/gi)?"http:":e}function Po(){if("undefined"==typeof window)return!1;var e=window.navigator.userAgent;return/Opera|OPR/.test(e)?"Opera":/Chrome/i.test(e)?"Chrome":/Firefox/i.test(e)?"Firefox":/Mobile(\/.*)? Safari/i.test(e)?"Mobile Safari":/MSIE/i.test(e)?"Internet Explorer":!!/Safari/i.test(e)&&"Safari"}function To(e){window.open(e,"_blank")||(window.location.href=e)}function Io(e,t){if(void 0===t&&(t="download"),e){var r="Safari"===Po(),i=/CriOS\/[\d]+/.test(window.navigator.userAgent),n=document.createElement("a");if("undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(e,t);else if((r||i)&&FileReader)if(e instanceof Blob){var o=new FileReader;o.onloadend=function(){s(o.result)},o.readAsDataURL(e)}else s(e);else{var a=!1;e instanceof Blob&&(e=URL.createObjectURL(e),a=!0),"download"in n?(n.style.display="hidden",document.body.appendChild(n),n.href=e,n.download=t,n.target="_blank",n.click(),document.body.removeChild(n)):To(e),a&&window.URL.revokeObjectURL(e)}}function s(e){To(i?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"))}}function Eo(e,t){return et?1:0}function Do(e,t,r){void 0===r&&(r=Eo);for(var i=0,n=e.length-1;i<=n;){var o=i+n>>1,a=r(t,e[o]);if(a>0)i=o+1;else{if(!(a<0))return o;n=o-1}}return-i-1}function Lo(e,t,r){var i=function(e,t){var r=e.length-1;if(e[r]>1;e[n]>=t?r=n-1:i=n+1}return r+1}(e,t),n=function(e,t){if(e[0]>t)return-1;for(var r=0,i=e.length-1;r<=i;){var n=r+i>>1;e[n]>t?i=n-1:r=n+1}return r-1}(e,r);return-1===i||-1===n||i>n?0:n-i+1}function Oo(e){return e.sort().filter((function(e,t,r){return 0===t||e!==r[t-1]}))}function Ro(e){var t=28672;if(e.length>t){for(var r=[],i=0;i65535?Uint32Array:Uint16Array)(e)}function Bo(e){return e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e}function Fo(e,t){return void 0===e?e=new t:Array.isArray(e)&&(e=(new t).fromArray(e)),e}function zo(e){return Fo(e,Y)}function Uo(e){return Fo(e,ie)}function jo(e){return Fo(e,W)}function Go(e){return t=e,r=Float32Array,t instanceof r?t:new r(t);var t,r}function Vo(e){return So(e,"").toString().toLowerCase()}Object.assign(xo.prototype,{update:function(e){var t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep;var r,i,n=e.projectionMatrix.clone(),o=t.eyeSep/2,a=o*t.near/t.focus,s=t.near*Math.tan(F.DEG2RAD*t.fov*.5)/t.zoom;bo.elements[12]=-o,yo.elements[12]=o,r=-s*t.aspect+a,i=s*t.aspect+a,n.elements[0]=2*t.near/(i-r),n.elements[8]=(i+r)/(i-r),this.cameraL.projectionMatrix.copy(n),r=-s*t.aspect-a,i=s*t.aspect-a,n.elements[0]=2*t.near/(i-r),n.elements[8]=(i+r)/(i-r),this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(bo),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(yo)}}),_o.prototype.clone=function(){return new _o(void 0===this.value.clone?this.value:this.value.clone())};var $o=function(e){this.name=e,this._dict={}},Ho={names:{configurable:!0}};function Wo(e){return.01745*e}$o.prototype.add=function(e,t){this._dict[Vo(e)]=t},$o.prototype.get=function(e){return this._dict[Vo(e)]},Ho.names.get=function(){return Object.keys(this._dict)},Object.defineProperties($o.prototype,Ho);var qo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Xo=new Array(36);function Yo(){for(var e,t=0,r=0;r<36;r++)8===r||13===r||18===r||23===r?Xo[r]="-":14===r?Xo[r]="4":(t<=2&&(t=33554432+16777216*Math.random()|0),e=15&t,t>>=4,Xo[r]=qo[19===r?3&e|8:e]);return Xo.join("")}function Zo(e,t,r){return Math.max(t,Math.min(r,e))}function Ko(e,t,r){return e+(t-e)*r}function Qo(e,t,r,i,n,o){var a=(r-e)*o,s=(i-t)*o,c=n*n;return(2*t-2*r+a+s)*(n*c)+(-3*t+3*r-2*a-s)*c+a*n+t}function Jo(e,t,r){var i;return i=function(e,t,r){return(e-t)/(r-t)}(r,e,t),(r=Zo(i,0,1))*r*(3-2*r)}var ea="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ta(e){var t={exports:{}};return e(t,t.exports),t.exports}var ra=ta((function(e,t){ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).NGL={})}(this,(function(e){"use strict";const t=0,i=1,n=2,r=1,s=2,o=3,a=0,c=1,l=2,h=0,u=1,d=2,f=3,m=4,p=5,g=100,v=101,y=102,x=103,b=104,_=200,w=201,S=202,A=203,M=204,C=205,P=206,T=207,I=208,E=209,D=210,L=0,R=1,k=2,O=3,B=4,N=5,F=6,z=7,U=0,$=1,G=2,V=0,H=1,j=2,W=3,q=4,X=5,Y=301,Z=302,K=303,Q=304,J=306,ee=307,te=1e3,ie=1001,ne=1002,re=1003,se=1004,oe=1005,ae=1006,ce=1007,le=1008,he=1009,ue=1010,de=1011,fe=1012,me=1013,pe=1014,ge=1015,ve=1016,ye=1017,xe=1018,be=1019,_e=1020,we=1021,Se=1022,Ae=1023,Me=1024,Ce=1025,Pe=1026,Te=1027,Ie=1028,Ee=1029,De=1030,Le=1031,Re=1032,ke=1033,Oe=33776,Be=33777,Ne=33778,Fe=33779,ze=35840,Ue=35841,$e=35842,Ge=35843,Ve=36196,He=37492,je=37496,We=37808,qe=37809,Xe=37810,Ye=37811,Ze=37812,Ke=37813,Qe=37814,Je=37815,et=37816,tt=37817,it=37818,nt=37819,rt=37820,st=37821,ot=36492,at=37840,ct=37841,lt=37842,ht=37843,ut=37844,dt=37845,ft=37846,mt=37847,pt=37848,gt=37849,vt=37850,yt=37851,xt=37852,bt=37853,_t=3e3,wt=3001,St=3007,At=3002,Mt=3003,Ct=3004,Pt=3005,Tt=3006,It=3200,Et=3201,Dt=0,Lt=1,Rt=7680,kt=519,Ot=35044;function Bt(){}Object.assign(Bt.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)},removeEventListener:function(e,t){if(void 0===this._listeners)return;const i=this._listeners[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}},dispatchEvent:function(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const i=t.slice(0);for(let t=0,n=i.length;t>8&255]+Nt[e>>16&255]+Nt[e>>24&255]+"-"+Nt[255&t]+Nt[t>>8&255]+"-"+Nt[t>>16&15|64]+Nt[t>>24&255]+"-"+Nt[63&i|128]+Nt[i>>8&255]+"-"+Nt[i>>16&255]+Nt[i>>24&255]+Nt[255&n]+Nt[n>>8&255]+Nt[n>>16&255]+Nt[n>>24&255]).toUpperCase()},clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*Ft.DEG2RAD},radToDeg:function(e){return e*Ft.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,i,n,r){const s=Math.cos,o=Math.sin,a=s(i/2),c=o(i/2),l=s((t+n)/2),h=o((t+n)/2),u=s((t-n)/2),d=o((t-n)/2),f=s((n-t)/2),m=o((n-t)/2);switch(r){case"XYX":e.set(a*h,c*u,c*d,a*l);break;case"YZY":e.set(c*d,a*h,c*u,a*l);break;case"ZXZ":e.set(c*u,c*d,a*h,a*l);break;case"XZX":e.set(a*h,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*h,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*h,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};function zt(e=0,t=0){this.x=e,this.y=t}function Ut(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}let $t;Object.defineProperties(zt.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(zt.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},clampLength:function(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){return Math.atan2(-this.y,-this.x)+Math.PI},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*i-s*n+e.x,this.y=r*n+s*i+e.y,this},random:function(){return this.x=Math.random(),this.y=Math.random(),this}}),Object.assign(Ut.prototype,{isMatrix3:!0,set:function(e,t,i,n,r,s,o,a,c){const l=this.elements;return l[0]=e,l[1]=n,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=i,l[7]=s,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this},extractBasis:function(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this},setFromMatrix4:function(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){const i=e.elements,n=t.elements,r=this.elements,s=i[0],o=i[3],a=i[6],c=i[1],l=i[4],h=i[7],u=i[2],d=i[5],f=i[8],m=n[0],p=n[3],g=n[6],v=n[1],y=n[4],x=n[7],b=n[2],_=n[5],w=n[8];return r[0]=s*m+o*v+a*b,r[3]=s*p+o*y+a*_,r[6]=s*g+o*x+a*w,r[1]=c*m+l*v+h*b,r[4]=c*p+l*y+h*_,r[7]=c*g+l*x+h*w,r[2]=u*m+d*v+f*b,r[5]=u*p+d*y+f*_,r[8]=u*g+d*x+f*w,this},multiplyScalar:function(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-i*r*l+i*o*a+n*r*c-n*s*a},getInverse:function(e,t){void 0!==t&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");const i=e.elements,n=this.elements,r=i[0],s=i[1],o=i[2],a=i[3],c=i[4],l=i[5],h=i[6],u=i[7],d=i[8],f=d*c-l*u,m=l*h-d*a,p=u*a-c*h,g=r*f+s*m+o*p;if(0===g)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return n[0]=f*v,n[1]=(o*u-d*s)*v,n[2]=(l*s-o*c)*v,n[3]=m*v,n[4]=(d*r-o*h)*v,n[5]=(o*a-l*r)*v,n[6]=p*v,n[7]=(s*h-u*r)*v,n[8]=(c*r-s*a)*v,this},transpose:function(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},setUvTransform:function(e,t,i,n,r,s,o){const a=Math.cos(r),c=Math.sin(r);this.set(i*a,i*c,-i*(a*s+c*o)+s+e,-n*c,n*a,-n*(-c*s+a*o)+o+t,0,0,1)},scale:function(e,t){const i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this},rotate:function(e){const t=Math.cos(e),i=Math.sin(e),n=this.elements,r=n[0],s=n[3],o=n[6],a=n[1],c=n[4],l=n[7];return n[0]=t*r+i*a,n[3]=t*s+i*c,n[6]=t*o+i*l,n[1]=-i*r+t*a,n[4]=-i*s+t*c,n[7]=-i*o+t*l,this},translate:function(e,t){const i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this},equals:function(e){const t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}});const Gt=function(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===$t&&($t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),$t.width=e.width,$t.height=e.height;const i=$t.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=$t}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")};let Vt=0;function Ht(e,t,i,n,r,s,o,a,c,l){Object.defineProperty(this,"id",{value:Vt++}),this.uuid=Ft.generateUUID(),this.name="",this.image=void 0!==e?e:Ht.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:Ht.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:ie,this.wrapT=void 0!==n?n:ie,this.magFilter=void 0!==r?r:ae,this.minFilter=void 0!==s?s:le,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:Ae,this.internalFormat=null,this.type=void 0!==a?a:he,this.offset=new zt(0,0),this.repeat=new zt(1,1),this.center=new zt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ut,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:_t,this.version=0,this.onUpdate=null}function jt(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}function Wt(e,t,i){this.width=e,this.height=t,this.scissor=new jt(0,0,e,t),this.scissorTest=!1,this.viewport=new jt(0,0,e,t),i=i||{},this.texture=new Ht(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:ae,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0===i.stencilBuffer||i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}function qt(e=0,t=0,i=0,n=1){this._x=e,this._y=t,this._z=i,this._w=n}Ht.DEFAULT_IMAGE=void 0,Ht.DEFAULT_MAPPING=300,Ht.prototype=Object.assign(Object.create(Bt.prototype),{constructor:Ht,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=Ft.generateUUID()),!t&&void 0===e.images[n.uuid]){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e1)switch(this.wrapS){case te:e.x=e.x-Math.floor(e.x);break;case ie:e.x=e.x<0?0:1;break;case ne:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case te:e.y=e.y-Math.floor(e.y);break;case ie:e.y=e.y<0?0:1;break;case ne:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(Ht.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.defineProperties(jt.prototype,{width:{get:function(){return this.z},set:function(e){this.z=e}},height:{get:function(){return this.w},set:function(e){this.w=e}}}),Object.assign(jt.prototype,{isVector4:!0,set:function(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){const t=this.x,i=this.y,n=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*t+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*t+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*t+s[7]*i+s[11]*n+s[15]*r,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){let t,i,n,r;const s=.01,o=.1,a=e.elements,c=a[0],l=a[4],h=a[8],u=a[1],d=a[5],f=a[9],m=a[2],p=a[6],g=a[10];if(Math.abs(l-u)a&&e>v?ev?a=0?1:-1,n=1-t*t;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,t*i);e=Math.sin(e*s)/r,o=Math.sin(o*s)/r}const r=o*i;if(a=a*e+u*r,c=c*e+d*r,l=l*e+f*r,h=h*e+m*r,e===1-o){const e=1/Math.sqrt(a*a+c*c+l*l+h*h);a*=e,c*=e,l*=e,h*=e}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=h},multiplyQuaternionsFlat:function(e,t,i,n,r,s){const o=i[n],a=i[n+1],c=i[n+2],l=i[n+3],h=r[s],u=r[s+1],d=r[s+2],f=r[s+3];return e[t]=o*f+l*h+a*d-c*u,e[t+1]=a*f+l*u+c*h-o*d,e[t+2]=c*f+l*d+o*u-a*h,e[t+3]=l*f-o*h-a*u-c*d,e}}),Object.defineProperties(qt.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}}}),Object.assign(qt.prototype,{isQuaternion:!0,set:function(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=e._x,n=e._y,r=e._z,s=e.order,o=Math.cos,a=Math.sin,c=o(i/2),l=o(n/2),h=o(r/2),u=a(i/2),d=a(n/2),f=a(r/2);switch(s){case"XYZ":this._x=u*l*h+c*d*f,this._y=c*d*h-u*l*f,this._z=c*l*f+u*d*h,this._w=c*l*h-u*d*f;break;case"YXZ":this._x=u*l*h+c*d*f,this._y=c*d*h-u*l*f,this._z=c*l*f-u*d*h,this._w=c*l*h+u*d*f;break;case"ZXY":this._x=u*l*h-c*d*f,this._y=c*d*h+u*l*f,this._z=c*l*f+u*d*h,this._w=c*l*h-u*d*f;break;case"ZYX":this._x=u*l*h-c*d*f,this._y=c*d*h+u*l*f,this._z=c*l*f-u*d*h,this._w=c*l*h+u*d*f;break;case"YZX":this._x=u*l*h+c*d*f,this._y=c*d*h+u*l*f,this._z=c*l*f-u*d*h,this._w=c*l*h-u*d*f;break;case"XZY":this._x=u*l*h-c*d*f,this._y=c*d*h-u*l*f,this._z=c*l*f+u*d*h,this._w=c*l*h+u*d*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this},setFromRotationMatrix:function(e){const t=e.elements,i=t[0],n=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],h=t[10],u=i+o+h;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(l-a)*e,this._y=(r-c)*e,this._z=(s-n)*e}else if(i>o&&i>h){const e=2*Math.sqrt(1+i-o-h);this._w=(l-a)/e,this._x=.25*e,this._y=(n+s)/e,this._z=(r+c)/e}else if(o>h){const e=2*Math.sqrt(1+o-i-h);this._w=(r-c)/e,this._x=(n+s)/e,this._y=.25*e,this._z=(a+l)/e}else{const e=2*Math.sqrt(1+h-i-o);this._w=(s-n)/e,this._x=(r+c)/e,this._y=(a+l)/e,this._z=.25*e}return this._onChangeCallback(),this},setFromUnitVectors:function(e,t){let i=e.dot(t)+1;return i<1e-6?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(Ft.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){const i=this.angleTo(e);if(0===i)return this;const n=Math.min(1,t/i);return this.slerp(e,n),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){const i=e._x,n=e._y,r=e._z,s=e._w,o=t._x,a=t._y,c=t._z,l=t._w;return this._x=i*l+s*o+n*c-r*a,this._y=n*l+s*a+r*o-i*c,this._z=r*l+s*c+i*a-n*o,this._w=s*l-i*o-n*a-r*c,this._onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);const i=this._x,n=this._y,r=this._z,s=this._w;let o=s*e._w+i*e._x+n*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;const a=1-o*o;if(a<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*i+t*this._x,this._y=e*n+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(a),l=Math.atan2(c,o),h=Math.sin((1-t)*l)/c,u=Math.sin(t*l)/c;return this._w=s*h+this._w*u,this._x=i*h+this._x*u,this._y=n*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},fromBufferAttribute:function(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});const Xt=new Zt,Yt=new qt;function Zt(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}Object.assign(Zt.prototype,{isVector3:!0,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Yt.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(Yt.setFromAxisAngle(e,t))},applyMatrix3:function(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){const t=this.x,i=this.y,n=this.z,r=e.elements,s=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*s,this},applyQuaternion:function(e){const t=this.x,i=this.y,n=this.z,r=e.x,s=e.y,o=e.z,a=e.w,c=a*t+s*n-o*i,l=a*i+o*t-r*n,h=a*n+r*i-s*t,u=-r*t-s*i-o*n;return this.x=c*a+u*-r+l*-o-h*-s,this.y=l*a+u*-s+h*-r-c*-o,this.z=h*a+u*-o+c*-s-l*-r,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},clampLength:function(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){const i=e.x,n=e.y,r=e.z,s=t.x,o=t.y,a=t.z;return this.x=n*a-r*o,this.y=r*s-i*a,this.z=i*o-n*s,this},projectOnVector:function(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)},projectOnPlane:function(e){return Xt.copy(this).projectOnVector(e),this.sub(Xt)},reflect:function(e){return this.sub(Xt.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Ft.clamp(i,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},setFromMatrix3Column:function(e,t){return this.fromArray(e.elements,3*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this},random:function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}});const Kt=new Zt,Qt=new ri,Jt=new Zt(0,0,0),ei=new Zt(1,1,1),ti=new Zt,ii=new Zt,ni=new Zt;function ri(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(ri.prototype,{isMatrix4:!0,set:function(e,t,i,n,r,s,o,a,c,l,h,u,d,f,m,p){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=o,g[13]=a,g[2]=c,g[6]=l,g[10]=h,g[14]=u,g[3]=d,g[7]=f,g[11]=m,g[15]=p,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new ri).fromArray(this.elements)},copy:function(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this},copyPosition:function(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:function(e){const t=this.elements,i=e.elements,n=1/Kt.setFromMatrixColumn(e,0).length(),r=1/Kt.setFromMatrixColumn(e,1).length(),s=1/Kt.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,i=e.x,n=e.y,r=e.z,s=Math.cos(i),o=Math.sin(i),a=Math.cos(n),c=Math.sin(n),l=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=s*l,i=s*h,n=o*l,r=o*h;t[0]=a*l,t[4]=-a*h,t[8]=c,t[1]=i+n*c,t[5]=e-r*c,t[9]=-o*a,t[2]=r-e*c,t[6]=n+i*c,t[10]=s*a}else if("YXZ"===e.order){const e=a*l,i=a*h,n=c*l,r=c*h;t[0]=e+r*o,t[4]=n*o-i,t[8]=s*c,t[1]=s*h,t[5]=s*l,t[9]=-o,t[2]=i*o-n,t[6]=r+e*o,t[10]=s*a}else if("ZXY"===e.order){const e=a*l,i=a*h,n=c*l,r=c*h;t[0]=e-r*o,t[4]=-s*h,t[8]=n+i*o,t[1]=i+n*o,t[5]=s*l,t[9]=r-e*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if("ZYX"===e.order){const e=s*l,i=s*h,n=o*l,r=o*h;t[0]=a*l,t[4]=n*c-i,t[8]=e*c+r,t[1]=a*h,t[5]=r*c+e,t[9]=i*c-n,t[2]=-c,t[6]=o*a,t[10]=s*a}else if("YZX"===e.order){const e=s*a,i=s*c,n=o*a,r=o*c;t[0]=a*l,t[4]=r-e*h,t[8]=n*h+i,t[1]=h,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=i*h+n,t[10]=e-r*h}else if("XZY"===e.order){const e=s*a,i=s*c,n=o*a,r=o*c;t[0]=a*l,t[4]=-h,t[8]=c*l,t[1]=e*h+r,t[5]=s*l,t[9]=i*h-n,t[2]=n*h-i,t[6]=o*l,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(Jt,e,ei)},lookAt:function(e,t,i){const n=this.elements;return ni.subVectors(e,t),0===ni.lengthSq()&&(ni.z=1),ni.normalize(),ti.crossVectors(i,ni),0===ti.lengthSq()&&(1===Math.abs(i.z)?ni.x+=1e-4:ni.z+=1e-4,ni.normalize(),ti.crossVectors(i,ni)),ti.normalize(),ii.crossVectors(ni,ti),n[0]=ti.x,n[4]=ii.x,n[8]=ni.x,n[1]=ti.y,n[5]=ii.y,n[9]=ni.y,n[2]=ti.z,n[6]=ii.z,n[10]=ni.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){const i=e.elements,n=t.elements,r=this.elements,s=i[0],o=i[4],a=i[8],c=i[12],l=i[1],h=i[5],u=i[9],d=i[13],f=i[2],m=i[6],p=i[10],g=i[14],v=i[3],y=i[7],x=i[11],b=i[15],_=n[0],w=n[4],S=n[8],A=n[12],M=n[1],C=n[5],P=n[9],T=n[13],I=n[2],E=n[6],D=n[10],L=n[14],R=n[3],k=n[7],O=n[11],B=n[15];return r[0]=s*_+o*M+a*I+c*R,r[4]=s*w+o*C+a*E+c*k,r[8]=s*S+o*P+a*D+c*O,r[12]=s*A+o*T+a*L+c*B,r[1]=l*_+h*M+u*I+d*R,r[5]=l*w+h*C+u*E+d*k,r[9]=l*S+h*P+u*D+d*O,r[13]=l*A+h*T+u*L+d*B,r[2]=f*_+m*M+p*I+g*R,r[6]=f*w+m*C+p*E+g*k,r[10]=f*S+m*P+p*D+g*O,r[14]=f*A+m*T+p*L+g*B,r[3]=v*_+y*M+x*I+b*R,r[7]=v*w+y*C+x*E+b*k,r[11]=v*S+y*P+x*D+b*O,r[15]=v*A+y*T+x*L+b*B,this},multiplyScalar:function(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},determinant:function(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],h=e[6],u=e[10],d=e[14];return e[3]*(+r*a*h-n*c*h-r*o*u+i*c*u+n*o*d-i*a*d)+e[7]*(+t*a*d-t*c*u+r*s*u-n*s*d+n*c*l-r*a*l)+e[11]*(+t*c*h-t*o*d-r*s*h+i*s*d+r*o*l-i*c*l)+e[15]*(-n*o*l-t*a*h+t*o*u+n*s*h-i*s*u+i*a*l)},transpose:function(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this},getInverse:function(e,t){void 0!==t&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");const i=this.elements,n=e.elements,r=n[0],s=n[1],o=n[2],a=n[3],c=n[4],l=n[5],h=n[6],u=n[7],d=n[8],f=n[9],m=n[10],p=n[11],g=n[12],v=n[13],y=n[14],x=n[15],b=f*y*u-v*m*u+v*h*p-l*y*p-f*h*x+l*m*x,_=g*m*u-d*y*u-g*h*p+c*y*p+d*h*x-c*m*x,w=d*v*u-g*f*u+g*l*p-c*v*p-d*l*x+c*f*x,S=g*f*h-d*v*h-g*l*m+c*v*m+d*l*y-c*f*y,A=r*b+s*_+o*w+a*S;if(0===A)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/A;return i[0]=b*M,i[1]=(v*m*a-f*y*a-v*o*p+s*y*p+f*o*x-s*m*x)*M,i[2]=(l*y*a-v*h*a+v*o*u-s*y*u-l*o*x+s*h*x)*M,i[3]=(f*h*a-l*m*a-f*o*u+s*m*u+l*o*p-s*h*p)*M,i[4]=_*M,i[5]=(d*y*a-g*m*a+g*o*p-r*y*p-d*o*x+r*m*x)*M,i[6]=(g*h*a-c*y*a-g*o*u+r*y*u+c*o*x-r*h*x)*M,i[7]=(c*m*a-d*h*a+d*o*u-r*m*u-c*o*p+r*h*p)*M,i[8]=w*M,i[9]=(g*f*a-d*v*a-g*s*p+r*v*p+d*s*x-r*f*x)*M,i[10]=(c*v*a-g*l*a+g*s*u-r*v*u-c*s*x+r*l*x)*M,i[11]=(d*l*a-c*f*a-d*s*u+r*f*u+c*s*p-r*l*p)*M,i[12]=S*M,i[13]=(d*v*o-g*f*o+g*s*m-r*v*m-d*s*y+r*f*y)*M,i[14]=(g*l*o-c*v*o-g*s*h+r*v*h+c*s*y-r*l*y)*M,i[15]=(c*f*o-d*l*o+d*s*h-r*f*h-c*s*m+r*l*m)*M,this},scale:function(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this},getMaxScaleOnAxis:function(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))},makeTranslation:function(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this},makeRotationY:function(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this},makeRotationZ:function(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,s=e.x,o=e.y,a=e.z,c=r*s,l=r*o;return this.set(c*s+i,c*o-n*a,c*a+n*o,0,c*o+n*a,l*o+i,l*a-n*s,0,c*a-n*o,l*a+n*s,r*a*a+i,0,0,0,0,1),this},makeScale:function(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(e,t,i){return this.set(1,t,i,0,e,1,i,0,e,t,1,0,0,0,0,1),this},compose:function(e,t,i){const n=this.elements,r=t._x,s=t._y,o=t._z,a=t._w,c=r+r,l=s+s,h=o+o,u=r*c,d=r*l,f=r*h,m=s*l,p=s*h,g=o*h,v=a*c,y=a*l,x=a*h,b=i.x,_=i.y,w=i.z;return n[0]=(1-(m+g))*b,n[1]=(d+x)*b,n[2]=(f-y)*b,n[3]=0,n[4]=(d-x)*_,n[5]=(1-(u+g))*_,n[6]=(p+v)*_,n[7]=0,n[8]=(f+y)*w,n[9]=(p-v)*w,n[10]=(1-(u+m))*w,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this},decompose:function(e,t,i){const n=this.elements;let r=Kt.set(n[0],n[1],n[2]).length(),s=Kt.set(n[4],n[5],n[6]).length(),o=Kt.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],Qt.copy(this);const a=1/r,c=1/s,l=1/o;return Qt.elements[0]*=a,Qt.elements[1]*=a,Qt.elements[2]*=a,Qt.elements[4]*=c,Qt.elements[5]*=c,Qt.elements[6]*=c,Qt.elements[8]*=l,Qt.elements[9]*=l,Qt.elements[10]*=l,t.setFromRotationMatrix(Qt),i.x=r,i.y=s,i.z=o,this},makePerspective:function(e,t,i,n,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,a=2*r/(t-e),c=2*r/(i-n),l=(t+e)/(t-e),h=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return o[0]=a,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=c,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makeOrthographic:function(e,t,i,n,r,s){const o=this.elements,a=1/(t-e),c=1/(i-n),l=1/(s-r),h=(t+e)*a,u=(i+n)*c,d=(s+r)*l;return o[0]=2*a,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(e){const t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}});const si=new ri,oi=new qt;function ai(e=0,t=0,i=0,n=ai.DefaultOrder){this._x=e,this._y=t,this._z=i,this._order=n}function ci(){this.mask=1}ai.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ai.DefaultOrder="XYZ",Object.defineProperties(ai.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this._onChangeCallback()}}}),Object.assign(ai.prototype,{isEuler:!0,set:function(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._order=n||this._order,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this},setFromRotationMatrix:function(e,t,i){const n=Ft.clamp,r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],h=r[9],u=r[2],d=r[6],f=r[10];switch(t=t||this._order){case"XYZ":this._y=Math.asin(n(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-n(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-n(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-n(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!1!==i&&this._onChangeCallback(),this},setFromQuaternion:function(e,t,i){return si.makeRotationFromQuaternion(e),this.setFromRotationMatrix(si,t,i)},setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(e){return oi.setFromEuler(this),this.setFromQuaternion(oi,e)},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new Zt(this._x,this._y,this._z)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}}),Object.assign(ci.prototype,{set:function(e){this.mask=1<1){for(let e=0;e1){for(let e=0;e0){n.children=[];for(let t=0;t0&&(i.geometries=t),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),o.length>0&&(i.images=o),a.length>0&&(i.shapes=a)}return i.object=n,i;function s(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;to)return!1}return!0}Object.assign(Ni.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){let t=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0;for(let a=0,c=e.length;ar&&(r=c),l>s&&(s=l),h>o&&(o=h)}return this.min.set(t,i,n),this.max.set(r,s,o),this},setFromBufferAttribute:function(e){let t=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0;for(let a=0,c=e.count;ar&&(r=c),l>s&&(s=l),h>o&&(o=h)}return this.min.set(t,i,n),this.max.set(r,s,o),this},setFromPoints:function(e){this.makeEmpty();for(let t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new Zt),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(e){return this.clampPoint(e.center,Mi),Mi.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(Ri),ki.subVectors(this.max,Ri),Pi.subVectors(e.a,Ri),Ti.subVectors(e.b,Ri),Ii.subVectors(e.c,Ri),Ei.subVectors(Ti,Pi),Di.subVectors(Ii,Ti),Li.subVectors(Pi,Ii);let t=[0,-Ei.z,Ei.y,0,-Di.z,Di.y,0,-Li.z,Li.y,Ei.z,0,-Ei.x,Di.z,0,-Di.x,Li.z,0,-Li.x,-Ei.y,Ei.x,0,-Di.y,Di.x,0,-Li.y,Li.x,0];return!!Fi(t,Pi,Ti,Ii,ki)&&(t=[1,0,0,0,1,0,0,0,1],!!Fi(t,Pi,Ti,Ii,ki)&&(Oi.crossVectors(Ei,Di),t=[Oi.x,Oi.y,Oi.z],Fi(t,Pi,Ti,Ii,ki)))},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new Zt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Mi.copy(e).clamp(this.min,this.max).sub(e).length()},getBoundingSphere:function(e){return void 0===e&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(Mi).length(),e},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){return this.isEmpty()||(Ai[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ai[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ai[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ai[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ai[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ai[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ai[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ai[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ai)),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});const zi=new Ni;function Ui(e,t){this.center=void 0!==e?e:new Zt,this.radius=void 0!==t?t:-1}Object.assign(Ui.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){const i=this.center;void 0!==t?i.copy(t):zi.setFromPoints(e).getCenter(i);let n=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Ni),this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}});const $i=new Zt,Gi=new Zt,Vi=new Zt,Hi=new Zt,ji=new Zt,Wi=new Zt,qi=new Zt;function Xi(e,t){this.origin=void 0!==e?e:new Zt,this.direction=void 0!==t?t:new Zt(0,0,-1)}Object.assign(Xi.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new Zt),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,$i)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new Zt),t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){const t=$i.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):($i.copy(this.direction).multiplyScalar(t).add(this.origin),$i.distanceToSquared(e))},distanceSqToSegment:function(e,t,i,n){Gi.copy(e).add(t).multiplyScalar(.5),Vi.copy(t).sub(e).normalize(),Hi.copy(this.origin).sub(Gi);const r=.5*e.distanceTo(t),s=-this.direction.dot(Vi),o=Hi.dot(this.direction),a=-Hi.dot(Vi),c=Hi.lengthSq(),l=Math.abs(1-s*s);let h,u,d,f;if(l>0)if(h=s*a-o,u=s*o-a,f=r*l,h>=0)if(u>=-f)if(u<=f){const e=1/l;h*=e,u*=e,d=h*(h+s*u+2*o)+u*(s*h+u+2*a)+c}else u=r,h=Math.max(0,-(s*u+o)),d=-h*h+u*(u+2*a)+c;else u=-r,h=Math.max(0,-(s*u+o)),d=-h*h+u*(u+2*a)+c;else u<=-f?(h=Math.max(0,-(-s*r+o)),u=h>0?-r:Math.min(Math.max(-r,-a),r),d=-h*h+u*(u+2*a)+c):u<=f?(h=0,u=Math.min(Math.max(-r,-a),r),d=u*(u+2*a)+c):(h=Math.max(0,-(s*r+o)),u=h>0?r:Math.min(Math.max(-r,-a),r),d=-h*h+u*(u+2*a)+c);else u=s>0?-r:r,h=Math.max(0,-(s*u+o)),d=-h*h+u*(u+2*a)+c;return i&&i.copy(this.direction).multiplyScalar(h).add(this.origin),n&&n.copy(Vi).multiplyScalar(u).add(Gi),d},intersectSphere:function(e,t){$i.subVectors(e.center,this.origin);const i=$i.dot(this.direction),n=$i.dot($i)-i*i,r=e.radius*e.radius;if(n>r)return null;const s=Math.sqrt(r-n),o=i-s,a=i+s;return o<0&&a<0?null:o<0?this.at(a,t):this.at(o,t)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){const i=this.distanceToPlane(e);return null===i?null:this.at(i,t)},intersectsPlane:function(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){let i,n,r,s,o,a;const c=1/this.direction.x,l=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,n=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,n=(e.min.x-u.x)*c),l>=0?(r=(e.min.y-u.y)*l,s=(e.max.y-u.y)*l):(r=(e.max.y-u.y)*l,s=(e.min.y-u.y)*l),i>s||r>n?null:((r>i||i!=i)&&(i=r),(s=0?(o=(e.min.z-u.z)*h,a=(e.max.z-u.z)*h):(o=(e.max.z-u.z)*h,a=(e.min.z-u.z)*h),i>a||o>n?null:((o>i||i!=i)&&(i=o),(a=0?i:n,t)))},intersectsBox:function(e){return null!==this.intersectBox(e,$i)},intersectTriangle:function(e,t,i,n,r){ji.subVectors(t,e),Wi.subVectors(i,e),qi.crossVectors(ji,Wi);let s,o=this.direction.dot(qi);if(o>0){if(n)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}Hi.subVectors(this.origin,e);const a=s*this.direction.dot(Wi.crossVectors(Hi,Wi));if(a<0)return null;const c=s*this.direction.dot(ji.cross(Hi));if(c<0)return null;if(a+c>o)return null;const l=-s*Hi.dot(qi);return l<0?null:this.at(l/o,r)},applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}});const Yi=new Zt,Zi=new Zt,Ki=new Ut;function Qi(e,t){this.normal=void 0!==e?e:new Zt(1,0,0),this.constant=void 0!==t?t:0}Object.assign(Qi.prototype,{isPlane:!0,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(e,t,i){const n=Yi.subVectors(i,t).cross(Zi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new Zt),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,t){void 0===t&&(console.warn("THREE.Plane: .intersectLine() target is now required"),t=new Zt);const i=e.delta(Yi),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(e.start)?t.copy(e.start):void 0;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?void 0:t.copy(i).multiplyScalar(r).add(e.start)},intersectsLine:function(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new Zt),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,t){const i=t||Ki.getNormalMatrix(e),n=this.coplanarPoint(Yi).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this},translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}});const Ji=new Zt,en=new Zt,tn=new Zt,nn=new Zt,rn=new Zt,sn=new Zt,on=new Zt,an=new Zt,cn=new Zt,ln=new Zt;function hn(e,t,i){this.a=void 0!==e?e:new Zt,this.b=void 0!==t?t:new Zt,this.c=void 0!==i?i:new Zt}Object.assign(hn,{getNormal:function(e,t,i,n){void 0===n&&(console.warn("THREE.Triangle: .getNormal() target is now required"),n=new Zt),n.subVectors(i,t),Ji.subVectors(e,t),n.cross(Ji);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)},getBarycoord:function(e,t,i,n,r){Ji.subVectors(n,t),en.subVectors(i,t),tn.subVectors(e,t);const s=Ji.dot(Ji),o=Ji.dot(en),a=Ji.dot(tn),c=en.dot(en),l=en.dot(tn),h=s*c-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new Zt),0===h)return r.set(-2,-1,-1);const u=1/h,d=(c*a-o*l)*u,f=(s*l-o*a)*u;return r.set(1-d-f,f,d)},containsPoint:function(e,t,i,n){return hn.getBarycoord(e,t,i,n,nn),nn.x>=0&&nn.y>=0&&nn.x+nn.y<=1},getUV:function(e,t,i,n,r,s,o,a){return this.getBarycoord(e,t,i,n,nn),a.set(0,0),a.addScaledVector(r,nn.x),a.addScaledVector(s,nn.y),a.addScaledVector(o,nn.z),a},isFrontFacing:function(e,t,i,n){return Ji.subVectors(i,t),en.subVectors(e,t),Ji.cross(en).dot(n)<0}}),Object.assign(hn.prototype,{set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){return Ji.subVectors(this.c,this.b),en.subVectors(this.a,this.b),.5*Ji.cross(en).length()},getMidpoint:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new Zt),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return hn.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new Qi),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return hn.getBarycoord(e,this.a,this.b,this.c,t)},getUV:function(e,t,i,n,r){return hn.getUV(e,this.a,this.b,this.c,t,i,n,r)},containsPoint:function(e){return hn.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return hn.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new Zt);const i=this.a,n=this.b,r=this.c;let s,o;rn.subVectors(n,i),sn.subVectors(r,i),an.subVectors(e,i);const a=rn.dot(an),c=sn.dot(an);if(a<=0&&c<=0)return t.copy(i);cn.subVectors(e,n);const l=rn.dot(cn),h=sn.dot(cn);if(l>=0&&h<=l)return t.copy(n);const u=a*h-l*c;if(u<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(i).addScaledVector(rn,s);ln.subVectors(e,r);const d=rn.dot(ln),f=sn.dot(ln);if(f>=0&&d<=f)return t.copy(r);const m=d*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(i).addScaledVector(sn,o);const p=l*f-d*h;if(p<=0&&h-l>=0&&d-f>=0)return on.subVectors(r,n),o=(h-l)/(h-l+(d-f)),t.copy(n).addScaledVector(on,o);const g=1/(p+m+u);return s=m*g,o=u*g,t.copy(i).addScaledVector(rn,s).addScaledVector(sn,o)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});const un={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dn={h:0,s:0,l:0},fn={h:0,s:0,l:0};function mn(e,t,i){return void 0===t&&void 0===i?this.set(e):this.setRGB(e,t,i)}function pn(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}function gn(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function vn(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function yn(e,t,i,n,r,s){this.a=e,this.b=t,this.c=i,this.normal=n&&n.isVector3?n:new Zt,this.vertexNormals=Array.isArray(n)?n:[],this.color=r&&r.isColor?r:new mn,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==s?s:0}Object.assign(mn.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(e,t,i){if(e=Ft.euclideanModulo(e,1),t=Ft.clamp(t,0,1),i=Ft.clamp(i,0,1),0===t)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,r=2*i-n;this.r=pn(r,n,e+1/3),this.g=pn(r,n,e),this.b=pn(r,n,e-1/3)}return this},setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){let e;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(e=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[5]),this;if(e=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[5]),this;break;case"hsl":case"hsla":if(e=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r)){const i=parseFloat(e[1])/360,n=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[5]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){const e=i[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){const t=un[e];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);const i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(e){return this.r=gn(e.r),this.g=gn(e.g),this.b=gn(e.b),this},copyLinearToSRGB:function(e){return this.r=vn(e.r),this.g=vn(e.g),this.b=vn(e.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});const t=this.r,i=this.g,n=this.b,r=Math.max(t,i,n),s=Math.min(t,i,n);let o,a;const c=(s+r)/2;if(s===r)o=0,a=0;else{const e=r-s;switch(a=c<=.5?e/(r+s):e/(2-r-s),r){case t:o=(i-n)/e+(i0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.morphNormals&&(i.morphNormals=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){const t=n(e.textures),r=n(e.images);t.length>0&&(i.textures=t),r.length>0&&(i.images=r)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(null!==t){const e=t.length;i=new Array(e);for(let n=0;n!==e;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(bn.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),_n.prototype=Object.create(bn.prototype),_n.prototype.constructor=_n,_n.prototype.isMeshBasicMaterial=!0,_n.prototype.copy=function(e){return bn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this};const wn=new Zt,Sn=new zt;function An(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===i,this.usage=Ot,this.updateRange={offset:0,count:-1},this.version=0}function Mn(e,t,i){An.call(this,new Int8Array(e),t,i)}function Cn(e,t,i){An.call(this,new Uint8Array(e),t,i)}function Pn(e,t,i){An.call(this,new Uint8ClampedArray(e),t,i)}function Tn(e,t,i){An.call(this,new Int16Array(e),t,i)}function In(e,t,i){An.call(this,new Uint16Array(e),t,i)}function En(e,t,i){An.call(this,new Int32Array(e),t,i)}function Dn(e,t,i){An.call(this,new Uint32Array(e),t,i)}function Ln(e,t,i){An.call(this,new Float32Array(e),t,i)}function Rn(e,t,i){An.call(this,new Float64Array(e),t,i)}function kn(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function On(e){if(0===e.length)return-1/0;let t=e[0];for(let i=1,n=e.length;it&&(t=e[i]);return t}Object.defineProperty(An.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(An.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n0,s=n[1]&&n[1].length>0,o=e.morphTargets,a=o.length;let c;if(a>0){c=[];for(let e=0;e0){u=[];for(let e=0;e0&&0===t.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let e=0;e65535?Dn:In)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const t=(new Ut).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(e){return Nn.makeRotationX(e),this.applyMatrix4(Nn),this},rotateY:function(e){return Nn.makeRotationY(e),this.applyMatrix4(Nn),this},rotateZ:function(e){return Nn.makeRotationZ(e),this.applyMatrix4(Nn),this},translate:function(e,t,i){return Nn.makeTranslation(e,t,i),this.applyMatrix4(Nn),this},scale:function(e,t,i){return Nn.makeScale(e,t,i),this.applyMatrix4(Nn),this},lookAt:function(e){return Fn.lookAt(e),Fn.updateMatrix(),this.applyMatrix4(Fn.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(zn).negate(),this.translate(zn.x,zn.y,zn.z),this},setFromObject:function(e){const t=e.geometry;if(e.isPoints||e.isLine){const e=new Ln(3*t.vertices.length,3),i=new Ln(3*t.colors.length,3);if(this.setAttribute("position",e.copyVector3sArray(t.vertices)),this.setAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){const e=new Ln(t.lineDistances.length,1);this.setAttribute("lineDistance",e.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){const t=[];for(let i=0,n=e.length;i0){const t=new Float32Array(3*e.normals.length);this.setAttribute("normal",new An(t,3).copyVector3sArray(e.normals))}if(e.colors.length>0){const t=new Float32Array(3*e.colors.length);this.setAttribute("color",new An(t,3).copyColorsArray(e.colors))}if(e.uvs.length>0){const t=new Float32Array(2*e.uvs.length);this.setAttribute("uv",new An(t,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){const t=new Float32Array(2*e.uvs2.length);this.setAttribute("uv2",new An(t,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(const t in e.morphTargets){const i=[],n=e.morphTargets[t];for(let e=0,t=n.length;e0){const t=new Ln(4*e.skinIndices.length,4);this.setAttribute("skinIndex",t.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){const t=new Ln(4*e.skinWeights.length,4);this.setAttribute("skinWeight",t.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ni);const e=this.attributes.position,t=this.morphAttributes.position;if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const t in i){const n=i[t],r=n.toJSON(e.data);""!==n.name&&(r.name=n.name),e.data.attributes[t]=r}const n={};let r=!1;for(const t in this.morphAttributes){const i=this.morphAttributes[t],s=[];for(let t=0,n=i.length;t0&&(n[t]=s,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e},clone:function(){return(new Vn).copy(this)},copy:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;null!==i&&this.setIndex(i.clone(t));const n=e.attributes;for(const e in n){const i=n[e];this.setAttribute(e,i.clone(t))}const r=e.morphAttributes;for(const e in r){const i=[],n=r[e];for(let e=0,r=n.length;ei.far?null:{distance:u,point:or.clone(),object:e}}function lr(e,t,i,n,r,s,o,a,c,l,h,u){qn.fromBufferAttribute(r,l),Xn.fromBufferAttribute(r,h),Yn.fromBufferAttribute(r,u);const d=e.morphTargetInfluences;if(t.morphTargets&&s&&d){Jn.set(0,0,0),er.set(0,0,0),tr.set(0,0,0);for(let e=0,t=s.length;e0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),Wn.copy(i.boundingSphere),Wn.applyMatrix4(r),!1===e.ray.intersectsSphere(Wn))return;if(Hn.getInverse(r),jn.copy(e.ray).applyMatrix4(Hn),null!==i.boundingBox&&!1===jn.intersectsBox(i.boundingBox))return;let s;if(i.isBufferGeometry){const r=i.index,o=i.attributes.position,a=i.morphAttributes.position,c=i.morphTargetsRelative,l=i.attributes.uv,h=i.attributes.uv2,u=i.groups,d=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,f=u.length;i0&&(c=l);for(let i=0,l=a.length;i0)for(let e=0;e0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,t=this.faces.length;e=0;e--){const t=r[e];this.faces.splice(t,1);for(let e=0,i=this.faceVertexUvs.length;e0,a=t.vertexNormals.length>0,c=1!==t.color.r||1!==t.color.g||1!==t.color.b,f=t.vertexColors.length>0;let m=0;if(m=l(m,0,0),m=l(m,1,n),m=l(m,2,r),m=l(m,3,s),m=l(m,4,o),m=l(m,5,a),m=l(m,6,c),m=l(m,7,f),i.push(m),i.push(t.a,t.b,t.c),i.push(t.materialIndex),s){const t=this.faceVertexUvs[0][e];i.push(d(t[0]),d(t[1]),d(t[2]))}if(o&&i.push(h(t.normal)),a){const e=t.vertexNormals;i.push(h(e[0]),h(e[1]),h(e[2]))}if(c&&i.push(u(t.color)),f){const e=t.vertexColors;i.push(u(e[0]),u(e[1]),u(e[2]))}}function l(e,t,i){return i?e|1<0&&(e.data.colors=s),a.length>0&&(e.data.uvs=[a]),e.data.faces=i,e},clone:function(){return(new mr).copy(this)},copy:function(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;const t=e.vertices;for(let e=0,i=t.length;e0?1:-1,l.push(P.x,P.y,P.z),h.push(a/p),h.push(1-s/g),M+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t},wr.prototype=Object.assign(Object.create(wi.prototype),{constructor:wr,isCamera:!0,copy:function(e,t){return wi.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new Zt),this.updateMatrixWorld(!0);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){wi.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(e,t){wi.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),Sr.prototype=Object.assign(Object.create(wr.prototype),{constructor:Sr,isPerspectiveCamera:!0,copy:function(e,t){return wr.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){const t=.5*this.getFilmHeight()/e;this.fov=2*Ft.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){const e=Math.tan(.5*Ft.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*Ft.RAD2DEG*Math.atan(Math.tan(.5*Ft.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,i,n,r,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let e=this.near,t=e*Math.tan(.5*Ft.DEG2RAD*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n,s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,o=s.fullHeight;r+=s.offsetX*n/e,t-=s.offsetY*i/o,n*=s.width/e,i*=s.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){const t=wi.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}),Ar.prototype=Object.create(Ht.prototype),Ar.prototype.constructor=Ar,Ar.prototype.isDataTexture=!0;const Mr=new Ui,Cr=new Zt;function Pr(e,t,i,n,r,s){this.planes=[void 0!==e?e:new Qi,void 0!==t?t:new Qi,void 0!==i?i:new Qi,void 0!==n?n:new Qi,void 0!==r?r:new Qi,void 0!==s?s:new Qi]}Object.assign(Pr.prototype,{set:function(e,t,i,n,r,s){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(s),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this},setFromProjectionMatrix:function(e){const t=this.planes,i=e.elements,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],c=i[5],l=i[6],h=i[7],u=i[8],d=i[9],f=i[10],m=i[11],p=i[12],g=i[13],v=i[14],y=i[15];return t[0].setComponents(o-n,h-a,m-u,y-p).normalize(),t[1].setComponents(o+n,h+a,m+u,y+p).normalize(),t[2].setComponents(o+r,h+c,m+d,y+g).normalize(),t[3].setComponents(o-r,h-c,m-d,y-g).normalize(),t[4].setComponents(o-s,h-l,m-f,y-v).normalize(),t[5].setComponents(o+s,h+l,m+f,y+v).normalize(),this},intersectsObject:function(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Mr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Mr)},intersectsSprite:function(e){return Mr.center.set(0,0,0),Mr.radius=.7071067811865476,Mr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mr)},intersectsSphere:function(e){const t=this.planes,i=e.center,n=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(i)0?e.max.x:e.min.x,Cr.y=n.normal.y>0?e.max.y:e.min.y,Cr.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Cr)<0)return!1}return!0},containsPoint:function(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}});const Tr={common:{diffuse:{value:new mn(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Ut},uv2Transform:{value:new Ut},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new zt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new mn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new mn(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ut}},sprite:{diffuse:{value:new mn(15658734)},opacity:{value:1},center:{value:new zt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ut}}};function Ir(){let e=null,t=!1,i=null,n=null;function r(t,s){i(t,s),n=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==i&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function Er(e,t){const i=t.isWebGL2,n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const i=n.get(t);i&&(e.deleteBuffer(i.buffer),n.delete(t))},update:function(t,r){t.isInterleavedBufferAttribute&&(t=t.data);const s=n.get(t);void 0===s?n.set(t,function(t,i){const n=t.array,r=t.usage,s=e.createBuffer();e.bindBuffer(i,s),e.bufferData(i,n,r),t.onUploadCallback();let o=5126;return n instanceof Float32Array?o=5126:n instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):n instanceof Uint16Array?o=5123:n instanceof Int16Array?o=5122:n instanceof Uint32Array?o=5125:n instanceof Int32Array?o=5124:n instanceof Int8Array?o=5120:n instanceof Uint8Array&&(o=5121),{buffer:s,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:t.version}}(t,r)):s.version0.0){distanceFalloff*=pow2(saturate(1.0-pow4(lightDistance/cutoffDistance)));}return distanceFalloff;\n#else\nif(cutoffDistance>0.0&&decayExponent>0.0){return pow(saturate(-lightDistance/cutoffDistance+1.0),decayExponent);}return 1.0;\n#endif\n}vec3 BRDF_Diffuse_Lambert(const in vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}vec3 F_Schlick(const in vec3 specularColor,const in float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}vec3 F_Schlick_RoughnessDependent(const in vec3 F0,const in float dotNV,const in float roughness){float fresnel=exp2((-5.55473*dotNV-6.98316)*dotNV);vec3 Fr=max(vec3(1.0-roughness),F0)-F0;return Fr*fresnel+F0;}float G_GGX_Smith(const in float alpha,const in float dotNL,const in float dotNV){float a2=pow2(alpha);float gl=dotNL+sqrt(a2+(1.0-a2)*pow2(dotNL));float gv=dotNV+sqrt(a2+(1.0-a2)*pow2(dotNV));return 1.0/(gl*gv);}float G_GGX_SmithCorrelated(const in float alpha,const in float dotNL,const in float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(const in float alpha,const in float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}vec3 BRDF_Specular_GGX(const in IncidentLight incidentLight,const in vec3 viewDir,const in vec3 normal,const in vec3 specularColor,const in float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentLight.direction+viewDir);float dotNL=saturate(dot(normal,incidentLight.direction));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentLight.direction,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec2 LTC_Uv(const in vec3 N,const in vec3 V,const in float roughness){const float LUT_SIZE=64.0;const float LUT_SCALE=(LUT_SIZE-1.0)/LUT_SIZE;const float LUT_BIAS=0.5/LUT_SIZE;float dotNV=saturate(dot(N,V));vec2 uv=vec2(roughness,sqrt(1.0-dotNV));uv=uv*LUT_SCALE+LUT_BIAS;return uv;}float LTC_ClippedSphereFormFactor(const in vec3 f){float l=length(f);return max((l*l+f.z)/(l+1.0),0.0);}vec3 LTC_EdgeVectorFormFactor(const in vec3 v1,const in vec3 v2){float x=dot(v1,v2);float y=abs(x);float a=0.8543985+(0.4965155+0.0145206*y)*y;float b=3.4175940+(4.1616724+y)*y;float v=a/b;float theta_sintheta=(x>0.0)?v:0.5*inversesqrt(max(1.0-x*x,1e-7))-v;return cross(v1,v2)*theta_sintheta;}vec3 LTC_Evaluate(const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[4]){vec3 v1=rectCoords[1]-rectCoords[0];vec3 v2=rectCoords[3]-rectCoords[0];vec3 lightNormal=cross(v1,v2);if(dot(lightNormal,P-rectCoords[0])<0.0)return vec3(0.0);vec3 T1,T2;T1=normalize(V-N*dot(V,N));T2=-cross(N,T1);mat3 mat=mInv*transposeMat3(mat3(T1,T2,N));vec3 coords[4];coords[0]=mat*(rectCoords[0]-P);coords[1]=mat*(rectCoords[1]-P);coords[2]=mat*(rectCoords[2]-P);coords[3]=mat*(rectCoords[3]-P);coords[0]=normalize(coords[0]);coords[1]=normalize(coords[1]);coords[2]=normalize(coords[2]);coords[3]=normalize(coords[3]);vec3 vectorFormFactor=vec3(0.0);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[0],coords[1]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[1],coords[2]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[2],coords[3]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[3],coords[0]);float result=LTC_ClippedSphereFormFactor(vectorFormFactor);return vec3(result);}vec3 BRDF_Specular_GGX_Environment(const in vec3 viewDir,const in vec3 normal,const in vec3 specularColor,const in float roughness){float dotNV=saturate(dot(normal,viewDir));vec2 brdf=integrateSpecularBRDF(dotNV,roughness);return specularColor*brdf.x+brdf.y;}void BRDF_Specular_Multiscattering_Environment(const in GeometricContext geometry,const in vec3 specularColor,const in float roughness,inout vec3 singleScatter,inout vec3 multiScatter){float dotNV=saturate(dot(geometry.normal,geometry.viewDir));vec3 F=F_Schlick_RoughnessDependent(specularColor,dotNV,roughness);vec2 brdf=integrateSpecularBRDF(dotNV,roughness);vec3 FssEss=F*brdf.x+brdf.y;float Ess=brdf.x+brdf.y;float Ems=1.0-Ess;vec3 Favg=specularColor+(1.0-specularColor)*0.047619;vec3 Fms=FssEss*Favg/(1.0-Ems*Favg);singleScatter+=FssEss;multiScatter+=Fms*Ems;}float G_BlinnPhong_Implicit(){return 0.25;}float D_BlinnPhong(const in float shininess,const in float dotNH){return RECIPROCAL_PI*(shininess*0.5+1.0)*pow(dotNH,shininess);}vec3 BRDF_Specular_BlinnPhong(const in IncidentLight incidentLight,const in GeometricContext geometry,const in vec3 specularColor,const in float shininess){vec3 halfDir=normalize(incidentLight.direction+geometry.viewDir);float dotNH=saturate(dot(geometry.normal,halfDir));float dotLH=saturate(dot(incidentLight.direction,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_BlinnPhong_Implicit();float D=D_BlinnPhong(shininess,dotNH);return F*(G*D);}float GGXRoughnessToBlinnExponent(const in float ggxRoughness){return(2.0/pow2(ggxRoughness+0.0001)-2.0);}float BlinnExponentToGGXRoughness(const in float blinnExponent){return sqrt(2.0/(blinnExponent+2.0));}\n#if defined(USE_SHEEN)\nfloat D_Charlie(float roughness,float NoH){float invAlpha=1.0/roughness;float cos2h=NoH*NoH;float sin2h=max(1.0-cos2h,0.0078125);return(2.0+invAlpha)*pow(sin2h,invAlpha*0.5)/(2.0*PI);}float V_Neubelt(float NoV,float NoL){return saturate(1.0/(4.0*(NoL+NoV-NoL*NoV)));}vec3 BRDF_Specular_Sheen(const in float roughness,const in vec3 L,const in GeometricContext geometry,vec3 specularColor){vec3 N=geometry.normal;vec3 V=geometry.viewDir;vec3 H=normalize(V+L);float dotNH=saturate(dot(N,H));return specularColor*D_Charlie(roughness,dotNH)*V_Neubelt(dot(N,V),dot(N,L));}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;uniform float bumpScale;vec2 dHdxy_fwd(){vec2 dSTdx=dFdx(vUv);vec2 dSTdy=dFdy(vUv);float Hll=bumpScale*texture2D(bumpMap,vUv).x;float dBx=bumpScale*texture2D(bumpMap,vUv+dSTdx).x-Hll;float dBy=bumpScale*texture2D(bumpMap,vUv+dSTdy).x-Hll;return vec2(dBx,dBy);}vec3 perturbNormalArb(vec3 surf_pos,vec3 surf_norm,vec2 dHdxy){vec3 vSigmaX=vec3(dFdx(surf_pos.x),dFdx(surf_pos.y),dFdx(surf_pos.z));vec3 vSigmaY=vec3(dFdy(surf_pos.x),dFdy(surf_pos.y),dFdy(surf_pos.z));vec3 vN=surf_norm;vec3 R1=cross(vSigmaY,vN);vec3 R2=cross(vN,vSigmaX);float fDet=dot(vSigmaX,R1);fDet*=(float(gl_FrontFacing)*2.0-1.0);vec3 vGrad=sign(fDet)*(dHdxy.x*R1+dHdxy.y*R2);return normalize(abs(fDet)*surf_norm-vGrad);}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES>0\nvec4 plane;\n#pragma unroll_loop_start\nfor(int i=0;iplane.w)discard;}\n#pragma unroll_loop_end\n#if UNION_CLIPPING_PLANESplane.w)&&clipped;}\n#pragma unroll_loop_end\nif(clipped)discard;\n#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES>0\nvarying vec3 vClipPosition;uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES>0\nvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES>0\nvClipPosition=-mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\ndiffuseColor.rgb*=vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor.xyz=color.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a)clamp(a,0.0,1.0)\n#endif\n#define whiteComplement(a)(1.0-saturate(a))\nfloat pow2(const in float x){return x*x;}float pow3(const in float x){return x*x*x;}float pow4(const in float x){float x2=x*x;return x2*x2;}float average(const in vec3 color){return dot(color,vec3(0.3333));}highp float rand(const in vec2 uv){const highp float a=12.9898,b=78.233,c=43758.5453;highp float dt=dot(uv.xy,vec2(a,b)),sn=mod(dt,PI);return fract(sin(sn)*c);}\n#ifdef HIGH_PRECISION\nfloat precisionSafeLength(vec3 v){return length(v);}\n#else\nfloat max3(vec3 v){return max(max(v.x,v.y),v.z);}float precisionSafeLength(vec3 v){float maxComponent=max3(abs(v));return length(v/maxComponent)*maxComponent;}\n#endif\nstruct IncidentLight{vec3 color;vec3 direction;bool visible;};struct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct GeometricContext{vec3 position;vec3 normal;vec3 viewDir;\n#ifdef CLEARCOAT\nvec3 clearcoatNormal;\n#endif\n};vec3 transformDirection(in vec3 dir,in mat4 matrix){return normalize((matrix*vec4(dir,0.0)).xyz);}vec3 inverseTransformDirection(in vec3 dir,in mat4 matrix){return normalize((vec4(dir,0.0)*matrix).xyz);}vec3 projectOnPlane(in vec3 point,in vec3 pointOnPlane,in vec3 planeNormal){float distance=dot(planeNormal,point-pointOnPlane);return-distance*planeNormal+point;}float sideOfPlane(in vec3 point,in vec3 pointOnPlane,in vec3 planeNormal){return sign(dot(point-pointOnPlane,planeNormal));}vec3 linePlaneIntersect(in vec3 pointOnLine,in vec3 lineDirection,in vec3 pointOnPlane,in vec3 planeNormal){return lineDirection*(dot(planeNormal,pointOnPlane-pointOnLine)/dot(planeNormal,lineDirection))+pointOnLine;}mat3 transposeMat3(const in mat3 m){mat3 tmp;tmp[0]=vec3(m[0].x,m[1].x,m[2].x);tmp[1]=vec3(m[0].y,m[1].y,m[2].y);tmp[2]=vec3(m[0].z,m[1].z,m[2].z);return tmp;}float linearToRelativeLuminance(const in vec3 color){vec3 weights=vec3(0.2126,0.7152,0.0722);return dot(weights,color.rgb);}bool isPerspectiveMatrix(mat4 m){return m[2][3]==-1.0;}vec2 equirectUv(in vec3 dir){float u=atan(dir.z,dir.x)*RECIPROCAL_PI2+0.5;float v=asin(clamp(dir.y,-1.0,1.0))*RECIPROCAL_PI+0.5;return vec2(u,v);}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction){vec3 absDirection=abs(direction);float face=-1.0;if(absDirection.x>absDirection.z){if(absDirection.x>absDirection.y)face=direction.x>0.0?0.0:3.0;else face=direction.y>0.0?1.0:4.0;}else{if(absDirection.z>absDirection.y)face=direction.z>0.0?2.0:5.0;else face=direction.y>0.0?1.0:4.0;}return face;}vec2 getUV(vec3 direction,float face){vec2 uv;if(face==0.0){uv=vec2(direction.z,direction.y)/abs(direction.x);}else if(face==1.0){uv=vec2(-direction.x,-direction.z)/abs(direction.y);}else if(face==2.0){uv=vec2(-direction.x,direction.y)/abs(direction.z);}else if(face==3.0){uv=vec2(-direction.z,direction.y)/abs(direction.x);}else if(face==4.0){uv=vec2(-direction.x,direction.z)/abs(direction.y);}else{uv=vec2(direction.x,direction.y)/abs(direction.z);}return 0.5*(uv+1.0);}vec3 bilinearCubeUV(sampler2D envMap,vec3 direction,float mipInt){float face=getFace(direction);float filterInt=max(cubeUV_minMipLevel-mipInt,0.0);mipInt=max(mipInt,cubeUV_minMipLevel);float faceSize=exp2(mipInt);float texelSize=1.0/(3.0*cubeUV_maxTileSize);vec2 uv=getUV(direction,face)*(faceSize-1.0);vec2 f=fract(uv);uv+=0.5-f;if(face>2.0){uv.y+=faceSize;face-=3.0;}uv.x+=face*faceSize;if(mipInt=r1){mip=(r0-roughness)*(m1-m0)/(r0-r1)+m0;}else if(roughness>=r4){mip=(r1-roughness)*(m4-m1)/(r1-r4)+m1;}else if(roughness>=r5){mip=(r4-roughness)*(m5-m4)/(r4-r5)+m4;}else if(roughness>=r6){mip=(r5-roughness)*(m6-m5)/(r5-r6)+m5;}else{mip=-2.0*log2(1.16*roughness);}return mip;}vec4 textureCubeUV(sampler2D envMap,vec3 sampleDir,float roughness){float mip=clamp(roughnessToMip(roughness),m0,cubeUV_maxMipLevel);float mipF=fract(mip);float mipInt=floor(mip);vec3 color0=bilinearCubeUV(envMap,sampleDir,mipInt);if(mipF==0.0){return vec4(color0,1.0);}else{vec3 color1=bilinearCubeUV(envMap,sampleDir,mipInt+1.0);return vec4(mix(color0,color1,mipF),1.0);}}\n#endif",defaultnormal_vertex:"vec3 transformedNormal=objectNormal;\n#ifdef USE_INSTANCING\nmat3 m=mat3(instanceMatrix);transformedNormal/=vec3(dot(m[0],m[0]),dot(m[1],m[1]),dot(m[2],m[2]));transformedNormal=m*transformedNormal;\n#endif\ntransformedNormal=normalMatrix*transformedNormal;\n#ifdef FLIP_SIDED\ntransformedNormal=-transformedNormal;\n#endif\n#ifdef USE_TANGENT\nvec3 transformedTangent=(modelViewMatrix*vec4(objectTangent,0.0)).xyz;\n#ifdef FLIP_SIDED\ntransformedTangent=-transformedTangent;\n#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\nuniform sampler2D displacementMap;uniform float displacementScale;uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\ntransformed+=normalize(objectNormal)*(texture2D(displacementMap,vUv).x*displacementScale+displacementBias);\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\nvec4 emissiveColor=texture2D(emissiveMap,vUv);emissiveColor.rgb=emissiveMapTexelToLinear(emissiveColor).rgb;totalEmissiveRadiance*=emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\nuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor=linearToOutputTexel(gl_FragColor);",encodings_pars_fragment:"vec4 LinearToLinear(in vec4 value){return value;}vec4 GammaToLinear(in vec4 value,in float gammaFactor){return vec4(pow(value.rgb,vec3(gammaFactor)),value.a);}vec4 LinearToGamma(in vec4 value,in float gammaFactor){return vec4(pow(value.rgb,vec3(1.0/gammaFactor)),value.a);}vec4 sRGBToLinear(in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}vec4 LinearTosRGB(in vec4 value){return vec4(mix(pow(value.rgb,vec3(0.41666))*1.055-vec3(0.055),value.rgb*12.92,vec3(lessThanEqual(value.rgb,vec3(0.0031308)))),value.a);}vec4 RGBEToLinear(in vec4 value){return vec4(value.rgb*exp2(value.a*255.0-128.0),1.0);}vec4 LinearToRGBE(in vec4 value){float maxComponent=max(max(value.r,value.g),value.b);float fExp=clamp(ceil(log2(maxComponent)),-128.0,127.0);return vec4(value.rgb/exp2(fExp),(fExp+128.0)/255.0);}vec4 RGBMToLinear(in vec4 value,in float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 LinearToRGBM(in vec4 value,in float maxRange){float maxRGB=max(value.r,max(value.g,value.b));float M=clamp(maxRGB/maxRange,0.0,1.0);M=ceil(M*255.0)/255.0;return vec4(value.rgb/(M*maxRange),M);}vec4 RGBDToLinear(in vec4 value,in float maxRange){return vec4(value.rgb*((maxRange/255.0)/value.a),1.0);}vec4 LinearToRGBD(in vec4 value,in float maxRange){float maxRGB=max(value.r,max(value.g,value.b));float D=max(maxRange/maxRGB,1.0);D=clamp(floor(D)/255.0,0.0,1.0);return vec4(value.rgb*(D*(255.0/maxRange)),D);}const mat3 cLogLuvM=mat3(0.2209,0.3390,0.4184,0.1138,0.6780,0.7319,0.0102,0.1130,0.2969);vec4 LinearToLogLuv(in vec4 value){vec3 Xp_Y_XYZp=cLogLuvM*value.rgb;Xp_Y_XYZp=max(Xp_Y_XYZp,vec3(1e-6,1e-6,1e-6));vec4 vResult;vResult.xy=Xp_Y_XYZp.xy/Xp_Y_XYZp.z;float Le=2.0*log2(Xp_Y_XYZp.y)+127.0;vResult.w=fract(Le);vResult.z=(Le-(floor(vResult.w*255.0))/255.0)/255.0;return vResult;}const mat3 cLogLuvInverseM=mat3(6.0014,-2.7008,-1.7996,-1.3320,3.1029,-5.7721,0.3008,-1.0882,5.6268);vec4 LogLuvToLinear(in vec4 value){float Le=value.z*255.0+value.w;vec3 Xp_Y_XYZp;Xp_Y_XYZp.y=exp2((Le-127.0)/2.0);Xp_Y_XYZp.z=Xp_Y_XYZp.y/value.y;Xp_Y_XYZp.x=value.x*Xp_Y_XYZp.z;vec3 vRGB=cLogLuvInverseM*Xp_Y_XYZp.rgb;return vec4(max(vRGB,0.0),1.0);}",envmap_fragment:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvec3 cameraToFrag;if(isOrthographic){cameraToFrag=normalize(vec3(-viewMatrix[0][2],-viewMatrix[1][2],-viewMatrix[2][2]));}else{cameraToFrag=normalize(vWorldPosition-cameraPosition);}vec3 worldNormal=inverseTransformDirection(normal,viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 reflectVec=reflect(cameraToFrag,worldNormal);\n#else\nvec3 reflectVec=refract(cameraToFrag,worldNormal,refractionRatio);\n#endif\n#else\nvec3 reflectVec=vReflect;\n#endif\n#ifdef ENVMAP_TYPE_CUBE\nvec4 envColor=textureCube(envMap,vec3(flipEnvMap*reflectVec.x,reflectVec.yz));\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envColor=textureCubeUV(envMap,reflectVec,0.0);\n#elif defined(ENVMAP_TYPE_EQUIREC)\nreflectVec=normalize(reflectVec);vec2 sampleUV=equirectUv(reflectVec);vec4 envColor=texture2D(envMap,sampleUV);\n#else\nvec4 envColor=vec4(0.0);\n#endif\n#ifndef ENVMAP_TYPE_CUBE_UV\nenvColor=envMapTexelToLinear(envColor);\n#endif\n#ifdef ENVMAP_BLENDING_MULTIPLY\noutgoingLight=mix(outgoingLight,outgoingLight*envColor.xyz,specularStrength*reflectivity);\n#elif defined(ENVMAP_BLENDING_MIX)\noutgoingLight=mix(outgoingLight,envColor.xyz,specularStrength*reflectivity);\n#elif defined(ENVMAP_BLENDING_ADD)\noutgoingLight+=envColor.xyz*specularStrength*reflectivity;\n#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\nuniform float envMapIntensity;uniform float flipEnvMap;uniform int maxMipLevel;\n#ifdef ENVMAP_TYPE_CUBE\nuniform samplerCube envMap;\n#else\nuniform sampler2D envMap;\n#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\n#if defined(USE_BUMPMAP)||defined(USE_NORMALMAP)||defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\nvarying vec3 vWorldPosition;uniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n#if defined(USE_BUMPMAP)||defined(USE_NORMALMAP)||defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\nvarying vec3 vWorldPosition;\n#else\nvarying vec3 vReflect;uniform float refractionRatio;\n#endif\n#endif",envmap_physical_pars_fragment:"#if defined(USE_ENVMAP)\n#ifdef ENVMAP_MODE_REFRACTION\nuniform float refractionRatio;\n#endif\nvec3 getLightProbeIndirectIrradiance(const in GeometricContext geometry,const in int maxMIPLevel){vec3 worldNormal=inverseTransformDirection(geometry.normal,viewMatrix);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec=vec3(flipEnvMap*worldNormal.x,worldNormal.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor=textureCubeLodEXT(envMap,queryVec,float(maxMIPLevel));\n#else\nvec4 envMapColor=textureCube(envMap,queryVec,float(maxMIPLevel));\n#endif\nenvMapColor.rgb=envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envMapColor=textureCubeUV(envMap,worldNormal,1.0);\n#else\nvec4 envMapColor=vec4(0.0);\n#endif\nreturn PI*envMapColor.rgb*envMapIntensity;}float getSpecularMIPLevel(const in float roughness,const in int maxMIPLevel){float maxMIPLevelScalar=float(maxMIPLevel);float sigma=PI*roughness*roughness/(1.0+roughness);float desiredMIPLevel=maxMIPLevelScalar+log2(sigma);return clamp(desiredMIPLevel,0.0,maxMIPLevelScalar);}vec3 getLightProbeIndirectRadiance(const in vec3 viewDir,const in vec3 normal,const in float roughness,const in int maxMIPLevel){\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec=normalize(mix(reflectVec,normal,roughness*roughness));\n#else\nvec3 reflectVec=refract(-viewDir,normal,refractionRatio);\n#endif\nreflectVec=inverseTransformDirection(reflectVec,viewMatrix);float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryReflectVec=vec3(flipEnvMap*reflectVec.x,reflectVec.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor=textureCubeLodEXT(envMap,queryReflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(envMap,queryReflectVec,specularMIPLevel);\n#endif\nenvMapColor.rgb=envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envMapColor=textureCubeUV(envMap,reflectVec,roughness);\n#elif defined(ENVMAP_TYPE_EQUIREC)\nvec2 sampleUV=equirectUv(reflectVec);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor=texture2DLodEXT(envMap,sampleUV,specularMIPLevel);\n#else\nvec4 envMapColor=texture2D(envMap,sampleUV,specularMIPLevel);\n#endif\nenvMapColor.rgb=envMapTexelToLinear(envMapColor).rgb;\n#endif\nreturn envMapColor.rgb*envMapIntensity;}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvWorldPosition=worldPosition.xyz;\n#else\nvec3 cameraToVertex;if(isOrthographic){cameraToVertex=normalize(vec3(-viewMatrix[0][2],-viewMatrix[1][2],-viewMatrix[2][2]));}else{cameraToVertex=normalize(worldPosition.xyz-cameraPosition);}vec3 worldNormal=inverseTransformDirection(transformedNormal,viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvReflect=reflect(cameraToVertex,worldNormal);\n#else\nvReflect=refract(cameraToVertex,worldNormal,refractionRatio);\n#endif\n#endif\n#endif",fog_vertex:"#ifdef USE_FOG\nfogDepth=-mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\nvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n#ifdef FOG_EXP2\nfloat fogFactor=1.0-exp(-fogDensity*fogDensity*fogDepth*fogDepth);\n#else\nfloat fogFactor=smoothstep(fogNear,fogFar,fogDepth);\n#endif\ngl_FragColor.rgb=mix(gl_FragColor.rgb,fogColor,fogFactor);\n#endif",fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;varying float fogDepth;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;uniform float fogFar;\n#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\nuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance(vec3 normal,vec3 lightDirection){float dotNL=dot(normal,lightDirection);vec2 coord=vec2(dotNL*0.5+0.5,0.0);\n#ifdef USE_GRADIENTMAP\nreturn texture2D(gradientMap,coord).rgb;\n#else\nreturn(coord.x<0.7)?vec3(0.7):vec3(1.0);\n#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\nvec4 lightMapTexel=texture2D(lightMap,vUv2);reflectedLight.indirectDiffuse+=PI*lightMapTexelToLinear(lightMapTexel).rgb*lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nuniform sampler2D lightMap;uniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse=vec3(1.0);GeometricContext geometry;geometry.position=mvPosition.xyz;geometry.normal=normalize(transformedNormal);geometry.viewDir=(isOrthographic)?vec3(0,0,1):normalize(-mvPosition.xyz);GeometricContext backGeometry;backGeometry.position=geometry.position;backGeometry.normal=-geometry.normal;backGeometry.viewDir=geometry.viewDir;vLightFront=vec3(0.0);vIndirectFront=vec3(0.0);\n#ifdef DOUBLE_SIDED\nvLightBack=vec3(0.0);vIndirectBack=vec3(0.0);\n#endif\nIncidentLight directLight;float dotNL;vec3 directLightColor_Diffuse;vIndirectFront+=getAmbientLightIrradiance(ambientLightColor);vIndirectFront+=getLightProbeIrradiance(lightProbe,geometry);\n#ifdef DOUBLE_SIDED\nvIndirectBack+=getAmbientLightIrradiance(ambientLightColor);vIndirectBack+=getLightProbeIrradiance(lightProbe,backGeometry);\n#endif\n#if NUM_POINT_LIGHTS>0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\nstruct DirectionalLight{vec3 direction;vec3 color;};uniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];void getDirectionalDirectLightIrradiance(const in DirectionalLight directionalLight,const in GeometricContext geometry,out IncidentLight directLight){directLight.color=directionalLight.color;directLight.direction=directionalLight.direction;directLight.visible=true;}\n#endif\n#if NUM_POINT_LIGHTS>0\nstruct PointLight{vec3 position;vec3 color;float distance;float decay;};uniform PointLight pointLights[NUM_POINT_LIGHTS];void getPointDirectLightIrradiance(const in PointLight pointLight,const in GeometricContext geometry,out IncidentLight directLight){vec3 lVector=pointLight.position-geometry.position;directLight.direction=normalize(lVector);float lightDistance=length(lVector);directLight.color=pointLight.color;directLight.color*=punctualLightIntensityToIrradianceFactor(lightDistance,pointLight.distance,pointLight.decay);directLight.visible=(directLight.color!=vec3(0.0));}\n#endif\n#if NUM_SPOT_LIGHTS>0\nstruct SpotLight{vec3 position;vec3 direction;vec3 color;float distance;float decay;float coneCos;float penumbraCos;};uniform SpotLight spotLights[NUM_SPOT_LIGHTS];void getSpotDirectLightIrradiance(const in SpotLight spotLight,const in GeometricContext geometry,out IncidentLight directLight){vec3 lVector=spotLight.position-geometry.position;directLight.direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(directLight.direction,spotLight.direction);if(angleCos>spotLight.coneCos){float spotEffect=smoothstep(spotLight.coneCos,spotLight.penumbraCos,angleCos);directLight.color=spotLight.color;directLight.color*=spotEffect*punctualLightIntensityToIrradianceFactor(lightDistance,spotLight.distance,spotLight.decay);directLight.visible=true;}else{directLight.color=vec3(0.0);directLight.visible=false;}}\n#endif\n#if NUM_RECT_AREA_LIGHTS>0\nstruct RectAreaLight{vec3 color;vec3 position;vec3 halfWidth;vec3 halfHeight;};uniform sampler2D ltc_1;uniform sampler2D ltc_2;uniform RectAreaLight rectAreaLights[NUM_RECT_AREA_LIGHTS];\n#endif\n#if NUM_HEMI_LIGHTS>0\nstruct HemisphereLight{vec3 direction;vec3 skyColor;vec3 groundColor;};uniform HemisphereLight hemisphereLights[NUM_HEMI_LIGHTS];vec3 getHemisphereLightIrradiance(const in HemisphereLight hemiLight,const in GeometricContext geometry){float dotNL=dot(geometry.normal,hemiLight.direction);float hemiDiffuseWeight=0.5*dotNL+0.5;vec3 irradiance=mix(hemiLight.groundColor,hemiLight.skyColor,hemiDiffuseWeight);\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance*=PI;\n#endif\nreturn irradiance;}\n#endif",lights_toon_fragment:"ToonMaterial material;material.diffuseColor=diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct ToonMaterial{vec3 diffuseColor;};void RE_Direct_Toon(const in IncidentLight directLight,const in GeometricContext geometry,const in ToonMaterial material,inout ReflectedLight reflectedLight){vec3 irradiance=getGradientIrradiance(geometry.normal,directLight.direction)*directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance*=PI;\n#endif\nreflectedLight.directDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Toon(const in vec3 irradiance,const in GeometricContext geometry,const in ToonMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD(material)(0)",lights_phong_fragment:"BlinnPhongMaterial material;material.diffuseColor=diffuseColor.rgb;material.specularColor=specular;material.specularShininess=shininess;material.specularStrength=specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial{vec3 diffuseColor;vec3 specularColor;float specularShininess;float specularStrength;};void RE_Direct_BlinnPhong(const in IncidentLight directLight,const in GeometricContext geometry,const in BlinnPhongMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance*=PI;\n#endif\nreflectedLight.directDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);reflectedLight.directSpecular+=irradiance*BRDF_Specular_BlinnPhong(directLight,geometry,material.specularColor,material.specularShininess)*material.specularStrength;}void RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance,const in GeometricContext geometry,const in BlinnPhongMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD(material)(0)",lights_physical_fragment:"PhysicalMaterial material;material.diffuseColor=diffuseColor.rgb*(1.0-metalnessFactor);vec3 dxy=max(abs(dFdx(geometryNormal)),abs(dFdy(geometryNormal)));float geometryRoughness=max(max(dxy.x,dxy.y),dxy.z);material.specularRoughness=max(roughnessFactor,0.0525);material.specularRoughness+=geometryRoughness;material.specularRoughness=min(material.specularRoughness,1.0);\n#ifdef REFLECTIVITY\nmaterial.specularColor=mix(vec3(MAXIMUM_SPECULAR_COEFFICIENT*pow2(reflectivity)),diffuseColor.rgb,metalnessFactor);\n#else\nmaterial.specularColor=mix(vec3(DEFAULT_SPECULAR_COEFFICIENT),diffuseColor.rgb,metalnessFactor);\n#endif\n#ifdef CLEARCOAT\nmaterial.clearcoat=clearcoat;material.clearcoatRoughness=clearcoatRoughness;\n#ifdef USE_CLEARCOATMAP\nmaterial.clearcoat*=texture2D(clearcoatMap,vUv).x;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\nmaterial.clearcoatRoughness*=texture2D(clearcoatRoughnessMap,vUv).y;\n#endif\nmaterial.clearcoat=saturate(material.clearcoat);material.clearcoatRoughness=max(material.clearcoatRoughness,0.0525);material.clearcoatRoughness+=geometryRoughness;material.clearcoatRoughness=min(material.clearcoatRoughness,1.0);\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor=sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial{vec3 diffuseColor;float specularRoughness;vec3 specularColor;\n#ifdef CLEARCOAT\nfloat clearcoat;float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox(const in float roughness,const in float dotNL){return DEFAULT_SPECULAR_COEFFICIENT+(1.0-DEFAULT_SPECULAR_COEFFICIENT)*(pow(1.0-dotNL,5.0)*pow(1.0-roughness,2.0));}\n#if NUM_RECT_AREA_LIGHTS>0\nvoid RE_Direct_RectArea_Physical(const in RectAreaLight rectAreaLight,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){vec3 normal=geometry.normal;vec3 viewDir=geometry.viewDir;vec3 position=geometry.position;vec3 lightPos=rectAreaLight.position;vec3 halfWidth=rectAreaLight.halfWidth;vec3 halfHeight=rectAreaLight.halfHeight;vec3 lightColor=rectAreaLight.color;float roughness=material.specularRoughness;vec3 rectCoords[4];rectCoords[0]=lightPos+halfWidth-halfHeight;rectCoords[1]=lightPos-halfWidth-halfHeight;rectCoords[2]=lightPos-halfWidth+halfHeight;rectCoords[3]=lightPos+halfWidth+halfHeight;vec2 uv=LTC_Uv(normal,viewDir,roughness);vec4 t1=texture2D(ltc_1,uv);vec4 t2=texture2D(ltc_2,uv);mat3 mInv=mat3(vec3(t1.x,0,t1.y),vec3(0,1,0),vec3(t1.z,0,t1.w));vec3 fresnel=(material.specularColor*t2.x+(vec3(1.0)-material.specularColor)*t2.y);reflectedLight.directSpecular+=lightColor*fresnel*LTC_Evaluate(normal,viewDir,position,mInv,rectCoords);reflectedLight.directDiffuse+=lightColor*material.diffuseColor*LTC_Evaluate(normal,viewDir,position,mat3(1.0),rectCoords);}\n#endif\nvoid RE_Direct_Physical(const in IncidentLight directLight,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance*=PI;\n#endif\n#ifdef CLEARCOAT\nfloat ccDotNL=saturate(dot(geometry.clearcoatNormal,directLight.direction));vec3 ccIrradiance=ccDotNL*directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nccIrradiance*=PI;\n#endif\nfloat clearcoatDHR=material.clearcoat*clearcoatDHRApprox(material.clearcoatRoughness,ccDotNL);reflectedLight.directSpecular+=ccIrradiance*material.clearcoat*BRDF_Specular_GGX(directLight,geometry.viewDir,geometry.clearcoatNormal,vec3(DEFAULT_SPECULAR_COEFFICIENT),material.clearcoatRoughness);\n#else\nfloat clearcoatDHR=0.0;\n#endif\n#ifdef USE_SHEEN\nreflectedLight.directSpecular+=(1.0-clearcoatDHR)*irradiance*BRDF_Specular_Sheen(material.specularRoughness,directLight.direction,geometry,material.sheenColor);\n#else\nreflectedLight.directSpecular+=(1.0-clearcoatDHR)*irradiance*BRDF_Specular_GGX(directLight,geometry.viewDir,geometry.normal,material.specularColor,material.specularRoughness);\n#endif\nreflectedLight.directDiffuse+=(1.0-clearcoatDHR)*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Physical(const in vec3 irradiance,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}void RE_IndirectSpecular_Physical(const in vec3 radiance,const in vec3 irradiance,const in vec3 clearcoatRadiance,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){\n#ifdef CLEARCOAT\nfloat ccDotNV=saturate(dot(geometry.clearcoatNormal,geometry.viewDir));reflectedLight.indirectSpecular+=clearcoatRadiance*material.clearcoat*BRDF_Specular_GGX_Environment(geometry.viewDir,geometry.clearcoatNormal,vec3(DEFAULT_SPECULAR_COEFFICIENT),material.clearcoatRoughness);float ccDotNL=ccDotNV;float clearcoatDHR=material.clearcoat*clearcoatDHRApprox(material.clearcoatRoughness,ccDotNL);\n#else\nfloat clearcoatDHR=0.0;\n#endif\nfloat clearcoatInv=1.0-clearcoatDHR;vec3 singleScattering=vec3(0.0);vec3 multiScattering=vec3(0.0);vec3 cosineWeightedIrradiance=irradiance*RECIPROCAL_PI;BRDF_Specular_Multiscattering_Environment(geometry,material.specularColor,material.specularRoughness,singleScattering,multiScattering);vec3 diffuse=material.diffuseColor*(1.0-(singleScattering+multiScattering));reflectedLight.indirectSpecular+=clearcoatInv*radiance*singleScattering;reflectedLight.indirectSpecular+=multiScattering*cosineWeightedIrradiance;reflectedLight.indirectDiffuse+=diffuse*cosineWeightedIrradiance;}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion(const in float dotNV,const in float ambientOcclusion,const in float roughness){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}",lights_fragment_begin:"GeometricContext geometry;geometry.position=-vViewPosition;geometry.normal=normal;geometry.viewDir=(isOrthographic)?vec3(0,0,1):normalize(vViewPosition);\n#ifdef CLEARCOAT\ngeometry.clearcoatNormal=clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if (NUM_POINT_LIGHTS>0)&&defined(RE_Direct)\nPointLight pointLight;\n#if defined(USE_SHADOWMAP)&&NUM_POINT_LIGHT_SHADOWS>0\nPointLightShadow pointLightShadow;\n#endif\n#pragma unroll_loop_start\nfor(int i=0;i0)&&defined(RE_Direct)\nSpotLight spotLight;\n#if defined(USE_SHADOWMAP)&&NUM_SPOT_LIGHT_SHADOWS>0\nSpotLightShadow spotLightShadow;\n#endif\n#pragma unroll_loop_start\nfor(int i=0;i0)&&defined(RE_Direct)\nDirectionalLight directionalLight;\n#if defined(USE_SHADOWMAP)&&NUM_DIR_LIGHT_SHADOWS>0\nDirectionalLightShadow directionalLightShadow;\n#endif\n#pragma unroll_loop_start\nfor(int i=0;i0)&&defined(RE_Direct_RectArea)\nRectAreaLight rectAreaLight;\n#pragma unroll_loop_start\nfor(int i=0;i0)\n#pragma unroll_loop_start\nfor(int i=0;i0\nuniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];struct DirectionalLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS>0\nuniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];varying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];struct SpotLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS>0\nuniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];struct PointLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;float shadowCameraNear;float shadowCameraFar;};uniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];\n#endif\nfloat texture2DCompare(sampler2D depths,vec2 uv,float compare){return step(compare,unpackRGBAToDepth(texture2D(depths,uv)));}vec2 texture2DDistribution(sampler2D shadow,vec2 uv){return unpackRGBATo2Half(texture2D(shadow,uv));}float VSMShadow(sampler2D shadow,vec2 uv,float compare){float occlusion=1.0;vec2 distribution=texture2DDistribution(shadow,uv);float hard_shadow=step(compare,distribution.x);if(hard_shadow!=1.0){float distance=compare-distribution.x;float variance=max(0.00000,distribution.y*distribution.y);float softness_probability=variance/(variance+distance*distance);softness_probability=clamp((softness_probability-0.3)/(0.95-0.3),0.0,1.0);occlusion=clamp(max(hard_shadow,softness_probability),0.0,1.0);}return occlusion;}float getShadow(sampler2D shadowMap,vec2 shadowMapSize,float shadowBias,float shadowRadius,vec4 shadowCoord){float shadow=1.0;shadowCoord.xyz/=shadowCoord.w;shadowCoord.z+=shadowBias;bvec4 inFrustumVec=bvec4(shadowCoord.x>=0.0,shadowCoord.x<=1.0,shadowCoord.y>=0.0,shadowCoord.y<=1.0);bool inFrustum=all(inFrustumVec);bvec2 frustumTestVec=bvec2(inFrustum,shadowCoord.z<=1.0);bool frustumTest=all(frustumTestVec);if(frustumTest){\n#if defined(SHADOWMAP_TYPE_PCF)\nvec2 texelSize=vec2(1.0)/shadowMapSize;float dx0=-texelSize.x*shadowRadius;float dy0=-texelSize.y*shadowRadius;float dx1=+texelSize.x*shadowRadius;float dy1=+texelSize.y*shadowRadius;float dx2=dx0/2.0;float dy2=dy0/2.0;float dx3=dx1/2.0;float dy3=dy1/2.0;shadow=(texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy,shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,dy1),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy1),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,dy1),shadowCoord.z))*(1.0/17.0);\n#elif defined(SHADOWMAP_TYPE_PCF_SOFT)\nvec2 texelSize=vec2(1.0)/shadowMapSize;float dx=texelSize.x;float dy=texelSize.y;vec2 uv=shadowCoord.xy;vec2 f=fract(uv*shadowMapSize+0.5);uv-=f*texelSize;shadow=(texture2DCompare(shadowMap,uv,shadowCoord.z)+texture2DCompare(shadowMap,uv+vec2(dx,0.0),shadowCoord.z)+texture2DCompare(shadowMap,uv+vec2(0.0,dy),shadowCoord.z)+texture2DCompare(shadowMap,uv+texelSize,shadowCoord.z)+mix(texture2DCompare(shadowMap,uv+vec2(-dx,0.0),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,0.0),shadowCoord.z),f.x)+mix(texture2DCompare(shadowMap,uv+vec2(-dx,dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,dy),shadowCoord.z),f.x)+mix(texture2DCompare(shadowMap,uv+vec2(0.0,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(0.0,2.0*dy),shadowCoord.z),f.y)+mix(texture2DCompare(shadowMap,uv+vec2(dx,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(dx,2.0*dy),shadowCoord.z),f.y)+mix(mix(texture2DCompare(shadowMap,uv+vec2(-dx,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,-dy),shadowCoord.z),f.x),mix(texture2DCompare(shadowMap,uv+vec2(-dx,2.0*dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,2.0*dy),shadowCoord.z),f.x),f.y))*(1.0/9.0);\n#elif defined(SHADOWMAP_TYPE_VSM)\nshadow=VSMShadow(shadowMap,shadowCoord.xy,shadowCoord.z);\n#else\nshadow=texture2DCompare(shadowMap,shadowCoord.xy,shadowCoord.z);\n#endif\n}return shadow;}vec2 cubeToUV(vec3 v,float texelSizeY){vec3 absV=abs(v);float scaleToCube=1.0/max(absV.x,max(absV.y,absV.z));absV*=scaleToCube;v*=scaleToCube*(1.0-2.0*texelSizeY);vec2 planar=v.xy;float almostATexel=1.5*texelSizeY;float almostOne=1.0-almostATexel;if(absV.z>=almostOne){if(v.z>0.0)planar.x=4.0-v.x;}else if(absV.x>=almostOne){float signX=sign(v.x);planar.x=v.z*signX+2.0*signX;}else if(absV.y>=almostOne){float signY=sign(v.y);planar.x=v.x+2.0*signY+2.0;planar.y=v.z*signY-2.0;}return vec2(0.125,0.25)*planar+vec2(0.375,0.75);}float getPointShadow(sampler2D shadowMap,vec2 shadowMapSize,float shadowBias,float shadowRadius,vec4 shadowCoord,float shadowCameraNear,float shadowCameraFar){vec2 texelSize=vec2(1.0)/(shadowMapSize*vec2(4.0,2.0));vec3 lightToPosition=shadowCoord.xyz;float dp=(length(lightToPosition)-shadowCameraNear)/(shadowCameraFar-shadowCameraNear);dp+=shadowBias;vec3 bd3D=normalize(lightToPosition);\n#if defined(SHADOWMAP_TYPE_PCF)||defined(SHADOWMAP_TYPE_PCF_SOFT)||defined(SHADOWMAP_TYPE_VSM)\nvec2 offset=vec2(-1,1)*shadowRadius*texelSize.y;return(texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xyy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yyy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xyx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yyx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xxy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yxy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xxx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yxx,texelSize.y),dp))*(1.0/9.0);\n#else\nreturn texture2DCompare(shadowMap,cubeToUV(bd3D,texelSize.y),dp);\n#endif\n}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS>0\nuniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];struct DirectionalLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS>0\nuniform mat4 spotShadowMatrix[NUM_SPOT_LIGHT_SHADOWS];varying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];struct SpotLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS>0\nuniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];struct PointLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;float shadowCameraNear;float shadowCameraFar;};uniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];\n#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS>0||NUM_SPOT_LIGHT_SHADOWS>0||NUM_POINT_LIGHT_SHADOWS>0\nvec3 shadowWorldNormal=inverseTransformDirection(transformedNormal,viewMatrix);vec4 shadowWorldPosition;\n#endif\n#if NUM_DIR_LIGHT_SHADOWS>0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\n#pragma unroll_loop_start\nfor(int i=0;i0\nDirectionalLightShadow directionalLight;\n#pragma unroll_loop_start\nfor(int i=0;i0\nSpotLightShadow spotLight;\n#pragma unroll_loop_start\nfor(int i=0;i0\nPointLightShadow pointLight;\n#pragma unroll_loop_start\nfor(int i=0;i\n#include \n}",background_vert:"varying vec2 vUv;uniform mat3 uvTransform;void main(){vUv=(uvTransform*vec3(uv,1)).xy;gl_Position=vec4(position.xy,1.0,1.0);}",cube_frag:"#include \nuniform float opacity;varying vec3 vWorldDirection;\n#include \nvoid main(){vec3 vReflect=vWorldDirection;\n#include \ngl_FragColor=envColor;gl_FragColor.a*=opacity;\n#include \n#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main(){vWorldDirection=transformDirection(position,modelMatrix);\n#include \n#include \ngl_Position.z=gl_Position.w;}",depth_frag:"#if DEPTH_PACKING==3200\nuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;void main(){\n#include \nvec4 diffuseColor=vec4(1.0);\n#if DEPTH_PACKING==3200\ndiffuseColor.a=opacity;\n#endif\n#include \n#include \n#include \n#include \nfloat fragCoordZ=0.5*vHighPrecisionZW[0]/vHighPrecisionZW[1]+0.5;\n#if DEPTH_PACKING==3200\ngl_FragColor=vec4(vec3(1.0-fragCoordZ),opacity);\n#elif DEPTH_PACKING==3201\ngl_FragColor=packDepthToRGBA(fragCoordZ);\n#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;void main(){\n#include \n#include \n#ifdef USE_DISPLACEMENTMAP\n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvHighPrecisionZW=gl_Position.zw;}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;uniform float nearDistance;uniform float farDistance;varying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(1.0);\n#include \n#include \n#include \nfloat dist=length(vWorldPosition-referencePosition);dist=(dist-nearDistance)/(farDistance-nearDistance);dist=saturate(dist);gl_FragColor=packDepthToRGBA(dist);}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#ifdef USE_DISPLACEMENTMAP\n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvWorldPosition=worldPosition.xyz;}",equirect_frag:"uniform sampler2D tEquirect;varying vec3 vWorldDirection;\n#include \nvoid main(){vec3 direction=normalize(vWorldDirection);vec2 sampleUV=equirectUv(direction);vec4 texColor=texture2D(tEquirect,sampleUV);gl_FragColor=mapTexelToLinear(texColor);\n#include \n#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main(){vWorldDirection=transformDirection(position,modelMatrix);\n#include \n#include \n}",linedashed_frag:"uniform vec3 diffuse;uniform float opacity;uniform float dashSize;uniform float totalSize;varying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nif(mod(vLineDistance,totalSize)>dashSize){discard;}vec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \noutgoingLight=diffuseColor.rgb;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n}",linedashed_vert:"uniform float scale;attribute float lineDistance;varying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){vLineDistance=scale*lineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshbasic_frag:"uniform vec3 diffuse;uniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \n#include \n#include \n#include \n#include \nReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel=texture2D(lightMap,vUv2);reflectedLight.indirectDiffuse+=lightMapTexelToLinear(lightMapTexel).rgb*lightMapIntensity;\n#else\nreflectedLight.indirectDiffuse+=vec3(1.0);\n#endif\n#include \nreflectedLight.indirectDiffuse*=diffuseColor.rgb;vec3 outgoingLight=reflectedLight.indirectDiffuse;\n#include \ngl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#ifdef USE_ENVMAP\n#include \n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshlambert_frag:"uniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;varying vec3 vLightFront;varying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef DOUBLE_SIDED\nreflectedLight.indirectDiffuse+=(gl_FrontFacing)?vIndirectFront:vIndirectBack;\n#else\nreflectedLight.indirectDiffuse+=vIndirectFront;\n#endif\n#include \nreflectedLight.indirectDiffuse*=BRDF_Diffuse_Lambert(diffuseColor.rgb);\n#ifdef DOUBLE_SIDED\nreflectedLight.directDiffuse=(gl_FrontFacing)?vLightFront:vLightBack;\n#else\nreflectedLight.directDiffuse=vLightFront;\n#endif\nreflectedLight.directDiffuse*=BRDF_Diffuse_Lambert(diffuseColor.rgb)*getShadowMask();\n#include \nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+totalEmissiveRadiance;\n#include \ngl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;varying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;uniform float opacity;uniform sampler2D matcap;varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 viewDir=normalize(vViewPosition);vec3 x=normalize(vec3(viewDir.z,0.0,-viewDir.x));vec3 y=cross(viewDir,x);vec2 uv=vec2(dot(x,normal),dot(y,normal))*0.495+0.5;\n#ifdef USE_MATCAP\nvec4 matcapColor=texture2D(matcap,uv);matcapColor=matcapTexelToLinear(matcapColor);\n#else\nvec4 matcapColor=vec4(1.0);\n#endif\nvec3 outgoingLight=diffuseColor.rgb*matcapColor.rgb;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition=-mvPosition.xyz;}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+totalEmissiveRadiance;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition=-mvPosition.xyz;\n#include \n#include \n#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;uniform vec3 emissive;uniform vec3 specular;uniform float shininess;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+totalEmissiveRadiance;\n#include \ngl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition=-mvPosition.xyz;\n#include \n#include \n#include \n#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n#define REFLECTIVITY\n#define CLEARCOAT\n#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;uniform vec3 emissive;uniform float roughness;uniform float metalness;uniform float opacity;\n#ifdef TRANSPARENCY\nuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\nuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\nuniform float clearcoat;uniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+totalEmissiveRadiance;\n#ifdef TRANSPARENCY\ndiffuseColor.a*=saturate(1.-transparency+linearToRelativeLuminance(reflectedLight.directSpecular+reflectedLight.indirectSpecular));\n#endif\ngl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent=normalize(transformedTangent);vBitangent=normalize(cross(vNormal,vTangent)*tangent.w);\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition=-mvPosition.xyz;\n#include \n#include \n#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \ngl_FragColor=vec4(packNormalToRGB(normal),opacity);}",normal_vert:"#define NORMAL\n#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal=normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent=normalize(transformedTangent);vBitangent=normalize(cross(vNormal,vTangent)*tangent.w);\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(TANGENTSPACE_NORMALMAP)\nvViewPosition=-mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \n#include \n#include \noutgoingLight=diffuseColor.rgb;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n#include \n}",points_vert:"uniform float size;uniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \ngl_PointSize=size;\n#ifdef USE_SIZEATTENUATION\nbool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)gl_PointSize*=(scale/-mvPosition.z);\n#endif\n#include \n#include \n#include \n#include \n}",shadow_frag:"uniform vec3 color;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){gl_FragColor=vec4(color,opacity*(1.0-getShadowMask()));\n#include \n#include \n#include \n}",shadow_vert:"#include \n#include \n#include \nvoid main(){\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",sprite_frag:"uniform vec3 diffuse;uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);\n#include \n#include \n#include \n#include \noutgoingLight=diffuseColor.rgb;gl_FragColor=vec4(outgoingLight,diffuseColor.a);\n#include \n#include \n#include \n}",sprite_vert:"uniform float rotation;uniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main(){\n#include \nvec4 mvPosition=modelViewMatrix*vec4(0.0,0.0,0.0,1.0);vec2 scale;scale.x=length(vec3(modelMatrix[0].x,modelMatrix[0].y,modelMatrix[0].z));scale.y=length(vec3(modelMatrix[1].x,modelMatrix[1].y,modelMatrix[1].z));\n#ifndef USE_SIZEATTENUATION\nbool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)scale*=-mvPosition.z;\n#endif\nvec2 alignedPosition=(position.xy-(center-vec2(0.5)))*scale;vec2 rotatedPosition;rotatedPosition.x=cos(rotation)*alignedPosition.x-sin(rotation)*alignedPosition.y;rotatedPosition.y=sin(rotation)*alignedPosition.x+cos(rotation)*alignedPosition.y;mvPosition.xy+=rotatedPosition;gl_Position=projectionMatrix*mvPosition;\n#include \n#include \n#include \n}"},kr={basic:{uniforms:vr([Tr.common,Tr.specularmap,Tr.envmap,Tr.aomap,Tr.lightmap,Tr.fog]),vertexShader:Rr.meshbasic_vert,fragmentShader:Rr.meshbasic_frag},lambert:{uniforms:vr([Tr.common,Tr.specularmap,Tr.envmap,Tr.aomap,Tr.lightmap,Tr.emissivemap,Tr.fog,Tr.lights,{emissive:{value:new mn(0)}}]),vertexShader:Rr.meshlambert_vert,fragmentShader:Rr.meshlambert_frag},phong:{uniforms:vr([Tr.common,Tr.specularmap,Tr.envmap,Tr.aomap,Tr.lightmap,Tr.emissivemap,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.fog,Tr.lights,{emissive:{value:new mn(0)},specular:{value:new mn(1118481)},shininess:{value:30}}]),vertexShader:Rr.meshphong_vert,fragmentShader:Rr.meshphong_frag},standard:{uniforms:vr([Tr.common,Tr.envmap,Tr.aomap,Tr.lightmap,Tr.emissivemap,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.roughnessmap,Tr.metalnessmap,Tr.fog,Tr.lights,{emissive:{value:new mn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Rr.meshphysical_vert,fragmentShader:Rr.meshphysical_frag},toon:{uniforms:vr([Tr.common,Tr.aomap,Tr.lightmap,Tr.emissivemap,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.gradientmap,Tr.fog,Tr.lights,{emissive:{value:new mn(0)}}]),vertexShader:Rr.meshtoon_vert,fragmentShader:Rr.meshtoon_frag},matcap:{uniforms:vr([Tr.common,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.fog,{matcap:{value:null}}]),vertexShader:Rr.meshmatcap_vert,fragmentShader:Rr.meshmatcap_frag},points:{uniforms:vr([Tr.points,Tr.fog]),vertexShader:Rr.points_vert,fragmentShader:Rr.points_frag},dashed:{uniforms:vr([Tr.common,Tr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Rr.linedashed_vert,fragmentShader:Rr.linedashed_frag},depth:{uniforms:vr([Tr.common,Tr.displacementmap]),vertexShader:Rr.depth_vert,fragmentShader:Rr.depth_frag},normal:{uniforms:vr([Tr.common,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,{opacity:{value:1}}]),vertexShader:Rr.normal_vert,fragmentShader:Rr.normal_frag},sprite:{uniforms:vr([Tr.sprite,Tr.fog]),vertexShader:Rr.sprite_vert,fragmentShader:Rr.sprite_frag},background:{uniforms:{uvTransform:{value:new Ut},t2D:{value:null}},vertexShader:Rr.background_vert,fragmentShader:Rr.background_frag},cube:{uniforms:vr([Tr.envmap,{opacity:{value:1}}]),vertexShader:Rr.cube_vert,fragmentShader:Rr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Rr.equirect_vert,fragmentShader:Rr.equirect_frag},distanceRGBA:{uniforms:vr([Tr.common,Tr.displacementmap,{referencePosition:{value:new Zt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Rr.distanceRGBA_vert,fragmentShader:Rr.distanceRGBA_frag},shadow:{uniforms:vr([Tr.lights,Tr.fog,{color:{value:new mn(0)},opacity:{value:1}}]),vertexShader:Rr.shadow_vert,fragmentShader:Rr.shadow_frag}};function Or(e,t,i,n){const r=new mn(0);let s,o,l=0,h=null,u=0,d=null;function f(e,i){t.buffers.color.setClear(e.r,e.g,e.b,i,n)}return{getClearColor:function(){return r},setClearColor:function(e,t){r.set(e),l=void 0!==t?t:1,f(r,l)},getClearAlpha:function(){return l},setClearAlpha:function(e){l=e,f(r,l)},render:function(t,n,m,p){let g=!0===n.isScene?n.background:null;const v=e.xr,y=v.getSession&&v.getSession();if(y&&"additive"===y.environmentBlendMode&&(g=null),null===g?f(r,l):g&&g.isColor&&(f(g,1),p=!0),(e.autoClear||p)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),g&&(g.isCubeTexture||g.isWebGLCubeRenderTarget||g.mapping===J)){void 0===o&&(o=new ar(new pr(1,1,1),new _r({name:"BackgroundCubeMaterial",uniforms:gr(kr.cube.uniforms),vertexShader:kr.cube.vertexShader,fragmentShader:kr.cube.fragmentShader,side:c,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),o.geometry.deleteAttribute("uv"),o.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(o.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(o));const n=g.isWebGLCubeRenderTarget?g.texture:g;o.material.uniforms.envMap.value=n,o.material.uniforms.flipEnvMap.value=n.isCubeTexture?-1:1,h===g&&u===n.version&&d===e.toneMapping||(o.material.needsUpdate=!0,h=g,u=n.version,d=e.toneMapping),t.unshift(o,o.geometry,o.material,0,0,null)}else g&&g.isTexture&&(void 0===s&&(s=new ar(new Lr(2,2),new _r({name:"BackgroundMaterial",uniforms:gr(kr.background.uniforms),vertexShader:kr.background.vertexShader,fragmentShader:kr.background.fragmentShader,side:a,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(s)),s.material.uniforms.t2D.value=g,!0===g.matrixAutoUpdate&&g.updateMatrix(),s.material.uniforms.uvTransform.value.copy(g.matrix),h===g&&u===g.version&&d===e.toneMapping||(s.material.needsUpdate=!0,h=g,u=g.version,d=e.toneMapping),t.unshift(s,s.geometry,s.material,0,0,null))}}}function Br(e,t,i,n){const r=e.getParameter(34921),s=n.isWebGL2?null:t.get("OES_vertex_array_object"),o=n.isWebGL2||null!==s,a={},c=d(null);let l=c;function h(t){return n.isWebGL2?e.bindVertexArray(t):s.bindVertexArrayOES(t)}function u(t){return n.isWebGL2?e.deleteVertexArray(t):s.deleteVertexArrayOES(t)}function d(e){const t=[],i=[],n=[];for(let e=0;e=0){const s=c[t];if(void 0!==s){const t=s.normalized,r=s.itemSize,o=i.get(s);if(void 0===o)continue;const c=o.buffer,l=o.type,h=o.bytesPerElement;if(s.isInterleavedBufferAttribute){const i=s.data,o=i.stride,u=s.offset;i&&i.isInstancedInterleavedBuffer?(p(n,i.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=i.meshPerAttribute*i.count)):m(n),e.bindBuffer(34962,c),v(n,r,l,t,o*h,u*h)}else s.isInstancedBufferAttribute?(p(n,s.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=s.meshPerAttribute*s.count)):m(n),e.bindBuffer(34962,c),v(n,r,l,t,0,0)}else if("instanceMatrix"===t){const t=i.get(r.instanceMatrix);if(void 0===t)continue;const s=t.buffer,o=t.type;p(n+0,1),p(n+1,1),p(n+2,1),p(n+3,1),e.bindBuffer(34962,s),e.vertexAttribPointer(n+0,4,o,!1,64,0),e.vertexAttribPointer(n+1,4,o,!1,64,16),e.vertexAttribPointer(n+2,4,o,!1,64,32),e.vertexAttribPointer(n+3,4,o,!1,64,48)}else if(void 0!==h){const i=h[t];if(void 0!==i)switch(i.length){case 2:e.vertexAttrib2fv(n,i);break;case 3:e.vertexAttrib3fv(n,i);break;case 4:e.vertexAttrib4fv(n,i);break;default:e.vertexAttrib1fv(n,i)}}}}g()}(r,c,u,y),null!==x&&e.bindBuffer(34963,i.get(x).buffer))},reset:y,resetDefaultState:x,dispose:function(){y();for(const e in a){const t=a[e];for(const e in t){const i=t[e];for(const e in i)u(i[e].object),delete i[e];delete t[e]}delete a[e]}},releaseStatesOfGeometry:function(e){if(void 0===a[e.id])return;const t=a[e.id];for(const e in t){const i=t[e];for(const e in i)u(i[e].object),delete i[e];delete t[e]}delete a[e.id]},releaseStatesOfProgram:function(e){for(const t in a){const i=a[t];if(void 0===i[e.id])continue;const n=i[e.id];for(const e in n)u(n[e].object),delete n[e];delete i[e.id]}},initAttributes:f,enableAttribute:m,disableUnusedAttributes:g}}function Nr(e,t,i,n){const r=n.isWebGL2;let s;this.setMode=function(e){s=e},this.render=function(t,n){e.drawArrays(s,t,n),i.update(n,s)},this.renderInstances=function(n,o,a,c){if(0===c)return;let l,h;if(r)l=e,h="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[h](s,o,a,c),i.update(a,s,c)}}function Fr(e,t,i){let n;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let o=void 0!==i.precision?i.precision:"highp";const a=r(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);const c=!0===i.logarithmicDepthBuffer,l=e.getParameter(34930),h=e.getParameter(35660),u=e.getParameter(3379),d=e.getParameter(34076),f=e.getParameter(34921),m=e.getParameter(36347),p=e.getParameter(36348),g=e.getParameter(36349),v=h>0,y=s||!!t.get("OES_texture_float");return{isWebGL2:s,getMaxAnisotropy:function(){if(void 0!==n)return n;const i=t.get("EXT_texture_filter_anisotropic");return n=null!==i?e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,n},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:h,maxTextureSize:u,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:m,maxVaryings:p,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:s?e.getParameter(36183):0}}function zr(){const e=this;let t=null,i=0,n=!1,r=!1;const s=new Qi,o=new Ut,a={value:null,needsUpdate:!1};function c(){a.value!==t&&(a.value=t,a.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function l(t,i,n,r){let c=null!==t?t.length:0,l=null;if(0!==c){if(l=a.value,!0!==r||null===l){const e=n+4*c,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===l||l.length65535?Dn:In)(i,1);a.version=o;const c=s.get(e);c&&t.remove(c),s.set(e,a)}return{get:function(e,t){let n=r.get(t);return n||(t.addEventListener("dispose",o),t.isBufferGeometry?n=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new Vn).setFromObject(e)),n=t._bufferGeometry),r.set(t,n),i.memory.geometries++,n)},update:function(e){const i=e.attributes;for(const e in i)t.update(i[e],34962);const n=e.morphAttributes;for(const e in n){const i=n[e];for(let e=0,n=i.length;e0)return e;let r=t*i,s=ts[r];if(void 0===s&&(s=new Float32Array(r),ts[r]=s),0!==t){n.toArray(s,0);for(let n=1,r=0;n!==t;++n)r+=i,e[n].toArray(s,r)}return s}function as(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i/gm;function no(e){return e.replace(io,ro)}function ro(e,t){const i=Rr[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return no(i)}const so=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,oo=/#pragma unroll_loop_start[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}[\s]+?#pragma unroll_loop_end/g;function ao(e){return e.replace(oo,lo).replace(so,co)}function co(e,t,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),lo(e,t,i,n)}function lo(e,t,i,n){let r="";for(let e=parseInt(t);e0?e.gammaFactor:1,g=i.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Js).join("\n")}(i),v=function(e){const t=[];for(const i in e){const n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}(c),y=a.createProgram();let x,b;if(i.isRawShaderMaterial?(x=[v].filter(Js).join("\n"),x.length>0&&(x+="\n"),b=[g,v].filter(Js).join("\n"),b.length>0&&(b+="\n")):(x=[ho(i),"#define SHADER_NAME "+i.shaderName,v,i.instancing?"#define USE_INSTANCING":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+p,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+f:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+u:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Js).join("\n"),b=[g,ho(i),"#define SHADER_NAME "+i.shaderName,v,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+p,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+d:"",i.envMap?"#define "+f:"",i.envMap?"#define "+m:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+u:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==V?"#define TONE_MAPPING":"",i.toneMapping!==V?Rr.tonemapping_pars_fragment:"",i.toneMapping!==V?Qs("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",Rr.encodings_pars_fragment,i.map?Zs("mapTexelToLinear",i.mapEncoding):"",i.matcap?Zs("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?Zs("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?Zs("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMap?Zs("lightMapTexelToLinear",i.lightMapEncoding):"",Ks("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Js).join("\n")),l=no(l),l=eo(l,i),l=to(l,i),h=no(h),h=eo(h,i),h=to(h,i),l=ao(l),h=ao(h),i.isWebGL2&&!i.isRawShaderMaterial){let e=!1;const t=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&null!==l.match(t)&&null!==h.match(t)&&(e=!0,l=l.replace(t,""),h=h.replace(t,"")),x=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,b=["#version 300 es\n","#define varying in",e?"":"out highp vec4 pc_fragColor;",e?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+b}const _=b+h,w=Ws(a,35633,x+l),S=Ws(a,35632,_);if(a.attachShader(y,w),a.attachShader(y,S),void 0!==i.index0AttributeName?a.bindAttribLocation(y,0,i.index0AttributeName):!0===i.morphTargets&&a.bindAttribLocation(y,0,"position"),a.linkProgram(y),e.debug.checkShaderErrors){const e=a.getProgramInfoLog(y).trim(),t=a.getShaderInfoLog(w).trim(),i=a.getShaderInfoLog(S).trim();let n=!0,r=!0;if(!1===a.getProgramParameter(y,35714)){n=!1;const t=Ys(a,w,"vertex"),i=Ys(a,S,"fragment");console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(y,35715),"gl.getProgramInfoLog",e,t,i)}else""!==e?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",e):""!==t&&""!==i||(r=!1);r&&(this.diagnostics={runnable:n,programLog:e,vertexShader:{log:t,prefix:x},fragmentShader:{log:i,prefix:b}})}let A,M;return a.deleteShader(w),a.deleteShader(S),this.getUniforms=function(){return void 0===A&&(A=new js(a,y)),A},this.getAttributes=function(){return void 0===M&&(M=function(e,t){const i={},n=e.getProgramParameter(t,35721);for(let r=0;r0,maxBones:A,useVertexTexture:a,morphTargets:n.morphTargets,morphNormals:n.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numDirLightShadows:r.directionalShadowMap.length,numPointLightShadows:r.pointShadowMap.length,numSpotLightShadows:r.spotShadowMap.length,numClippingPlanes:v,numClipIntersection:y,dithering:n.dithering,shadowMapEnabled:e.shadowMap.enabled&&m.length>0,shadowMapType:e.shadowMap.type,toneMapping:n.toneMapped?e.toneMapping:V,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:n.premultipliedAlpha,alphaTest:n.alphaTest,doubleSided:n.side===l,flipSided:n.side===c,depthPacking:void 0!==n.depthPacking&&n.depthPacking,index0AttributeName:n.index0AttributeName,extensionDerivatives:n.extensions&&n.extensions.derivatives,extensionFragDepth:n.extensions&&n.extensions.fragDepth,extensionDrawBuffers:n.extensions&&n.extensions.drawBuffers,extensionShaderTextureLOD:n.extensions&&n.extensions.shaderTextureLOD,rendererExtensionFragDepth:s||null!==t.get("EXT_frag_depth"),rendererExtensionDrawBuffers:s||null!==t.get("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:s||null!==t.get("EXT_shader_texture_lod"),customProgramCacheKey:n.customProgramCacheKey()}},getProgramCacheKey:function(t){const i=[];if(t.shaderID?i.push(t.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(const e in t.defines)i.push(e),i.push(t.defines[e]);if(void 0===t.isRawShaderMaterial){for(let e=0;e1&&i.sort(e||po),n.length>1&&n.sort(t||go)}}}function yo(){let e=new WeakMap;function t(i){const n=i.target;n.removeEventListener("dispose",t),e.delete(n)}return{get:function(i,n){const r=e.get(i);let s;return void 0===r?(s=new vo,e.set(i,new WeakMap),e.get(i).set(n,s),i.addEventListener("dispose",t)):(s=r.get(n),void 0===s&&(s=new vo,r.set(n,s))),s},dispose:function(){e=new WeakMap}}}function xo(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new Zt,color:new mn};break;case"SpotLight":i={position:new Zt,direction:new Zt,color:new mn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Zt,color:new mn,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Zt,skyColor:new mn,groundColor:new mn};break;case"RectAreaLight":i={color:new mn,position:new Zt,halfWidth:new Zt,halfHeight:new Zt}}return e[t.id]=i,i}}}let bo=0;function _o(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function wo(){const e=new xo,t=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new zt};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new zt,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)i.probe.push(new Zt);const n=new Zt,r=new ri,s=new ri;return{setup:function(o,a,c){let l=0,h=0,u=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let d=0,f=0,m=0,p=0,g=0,v=0,y=0,x=0;const b=c.matrixWorldInverse;o.sort(_o);for(let a=0,c=o.length;a0);let r=!1;!0===t.isSkinnedMesh&&(!0===n.skinning?r=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t));l=h(e,r,!0===t.isInstancedMesh)}else l=u;if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){const e=l.uuid,t=n.uuid;let i=p[e];void 0===i&&(i={},p[e]=i);let r=i[t];void 0===r&&(r=l.clone(),i[t]=r),l=r}return l.visible=n.visible,l.wireframe=n.wireframe,l.side=c===o?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:g[n.side],l.clipShadows=n.clipShadows,l.clippingPlanes=n.clippingPlanes,l.clipIntersection=n.clipIntersection,l.wireframeLinewidth=n.wireframeLinewidth,l.linewidth=n.linewidth,!0===r.isPointLight&&!0===l.isMeshDistanceMaterial&&(l.referencePosition.setFromMatrixPosition(r.matrixWorld),l.nearDistance=s,l.farDistance=a),l}function C(i,r,s,a,c){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&c===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=t.update(i),r=i.material;if(Array.isArray(r)){const t=n.groups;for(let o=0,l=t.length;oi||s.y>i)&&(s.x>i&&(u.x=Math.floor(i/f.x),s.x=u.x*f.x,h.mapSize.x=u.x),s.y>i&&(u.y=Math.floor(i/f.y),s.y=u.y*f.y,h.mapSize.y=u.y)),null===h.map&&!h.isPointLightShadow&&this.type===o){const e={minFilter:ae,magFilter:ae,format:Ae};h.map=new Wt(s.x,s.y,e),h.map.texture.name=l.name+".shadowMap",h.mapPass=new Wt(s.x,s.y,e),h.camera.updateProjectionMatrix()}if(null===h.map){const e={minFilter:re,magFilter:re,format:Ae};h.map=new Wt(s.x,s.y,e),h.map.texture.name=l.name+".shadowMap",h.camera.updateProjectionMatrix()}e.setRenderTarget(h.map),e.clear();const p=h.getViewportCount();for(let e=0;e=1):-1!==ae.indexOf("OpenGL ES")&&(oe=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ae)[1]),se=oe>=2);let ce=null,le={};const he=new jt,ue=new jt;function de(t,i,n){const r=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;tn||e.height>n)&&(r=n/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const n=t?Ft.floorPowerOfTwo:Math.floor,s=n(r*e.width),o=n(r*e.height);void 0===f&&(f=p(s,o));const a=i?p(s,o):f;a.width=s,a.height=o;return a.getContext("2d").drawImage(e,0,0,s,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+o+")."),a}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function v(e){return Ft.isPowerOfTwo(e.width)&&Ft.isPowerOfTwo(e.height)}function y(e,t){return e.generateMipmaps&&t&&e.minFilter!==re&&e.minFilter!==ae}function x(t,i,r,s){e.generateMipmap(t);n.get(i).__maxMipLevel=Math.log(Math.max(r,s))*Math.LOG2E}function b(i,n,r){if(!1===a)return n;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let s=n;return 6403===n&&(5126===r&&(s=33326),5131===r&&(s=33325),5121===r&&(s=33321)),6407===n&&(5126===r&&(s=34837),5131===r&&(s=34843),5121===r&&(s=32849)),6408===n&&(5126===r&&(s=34836),5131===r&&(s=34842),5121===r&&(s=32856)),33325!==s&&33326!==s&&34842!==s&&34836!==s||t.get("EXT_color_buffer_float"),s}function _(e){return e===re||e===se||e===oe?9728:9729}function w(t){const i=t.target;i.removeEventListener("dispose",w),function(t){const i=n.get(t);if(void 0===i.__webglInit)return;e.deleteTexture(i.__webglTexture),n.remove(t)}(i),i.isVideoTexture&&d.delete(i),o.memory.textures--}function S(t){const i=t.target;i.removeEventListener("dispose",S),function(t){const i=n.get(t),r=n.get(t.texture);if(!t)return;void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(i.__webglFramebuffer[t]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[t]);else e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&e.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&e.deleteRenderbuffer(i.__webglDepthRenderbuffer);n.remove(t.texture),n.remove(t)}(i),o.memory.textures--}let A=0;function M(e,t){const r=n.get(e);if(e.isVideoTexture&&function(e){const t=o.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())}(e),e.version>0&&r.__version!==e.version){const i=e.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void L(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+t),i.bindTexture(3553,r.__webglTexture)}function C(t,r){if(6!==t.image.length)return;const o=n.get(t);if(t.version>0&&o.__version!==t.version){D(o,t),i.activeTexture(33984+r),i.bindTexture(34067,o.__webglTexture),e.pixelStorei(37440,t.flipY);const n=t&&(t.isCompressedTexture||t.image[0].isCompressedTexture),c=t.image[0]&&t.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=n||c?c?t.image[e].image:t.image[e]:g(t.image[e],!1,!0,l);const u=h[0],d=v(u)||a,f=s.convert(t.format),m=s.convert(t.type),p=b(t.internalFormat,f,m);let _;if(E(34067,t,d),n){for(let e=0;e<6;e++){_=h[e].mipmaps;for(let n=0;n<_.length;n++){const r=_[n];t.format!==Ae&&t.format!==Se?null!==f?i.compressedTexImage2D(34069+e,n,p,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+e,n,p,r.width,r.height,0,f,m,r.data)}}o.__maxMipLevel=_.length-1}else{_=t.mipmaps;for(let e=0;e<6;e++)if(c){i.texImage2D(34069+e,0,p,h[e].width,h[e].height,0,f,m,h[e].data);for(let t=0;t<_.length;t++){const n=_[t].image[e].image;i.texImage2D(34069+e,t+1,p,n.width,n.height,0,f,m,n.data)}}else{i.texImage2D(34069+e,0,p,f,m,h[e]);for(let t=0;t<_.length;t++){const n=_[t];i.texImage2D(34069+e,t+1,p,f,m,n.image[e])}}o.__maxMipLevel=_.length}y(t,d)&&x(34067,t,u.width,u.height),o.__version=t.version,t.onUpdate&&t.onUpdate(t)}else i.activeTexture(33984+r),i.bindTexture(34067,o.__webglTexture)}function P(e,t){i.activeTexture(33984+t),i.bindTexture(34067,n.get(e).__webglTexture)}const T={[te]:10497,[ie]:33071,[ne]:33648},I={[re]:9728,[se]:9984,[oe]:9986,[ae]:9729,[ce]:9985,[le]:9987};function E(i,s,o){o?(e.texParameteri(i,10242,T[s.wrapS]),e.texParameteri(i,10243,T[s.wrapT]),32879!==i&&35866!==i||e.texParameteri(i,32882,T[s.wrapR]),e.texParameteri(i,10240,I[s.magFilter]),e.texParameteri(i,10241,I[s.minFilter])):(e.texParameteri(i,10242,33071),e.texParameteri(i,10243,33071),32879!==i&&35866!==i||e.texParameteri(i,32882,33071),s.wrapS===ie&&s.wrapT===ie||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,10240,_(s.magFilter)),e.texParameteri(i,10241,_(s.minFilter)),s.minFilter!==re&&s.minFilter!==ae&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));const c=t.get("EXT_texture_filter_anisotropic");if(c){if(s.type===ge&&null===t.get("OES_texture_float_linear"))return;if(s.type===ve&&null===(a||t.get("OES_texture_half_float_linear")))return;(s.anisotropy>1||n.get(s).__currentAnisotropy)&&(e.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy)}}function D(t,i){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",w),t.__webglTexture=e.createTexture(),o.memory.textures++)}function L(t,n,r){let o=3553;n.isDataTexture2DArray&&(o=35866),n.isDataTexture3D&&(o=32879),D(t,n),i.activeTexture(33984+r),i.bindTexture(o,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment);const c=function(e){return!a&&(e.wrapS!==ie||e.wrapT!==ie||e.minFilter!==re&&e.minFilter!==ae)}(n)&&!1===v(n.image),l=g(n.image,c,!1,h),u=v(l)||a,d=s.convert(n.format);let f,m=s.convert(n.type),p=b(n.internalFormat,d,m);E(o,n,u);const _=n.mipmaps;if(n.isDepthTexture)p=6402,a?p=n.type===ge?36012:n.type===pe?33190:n.type===_e?35056:33189:n.type===ge&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===Pe&&6402===p&&n.type!==fe&&n.type!==pe&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=fe,m=s.convert(n.type)),n.format===Te&&6402===p&&(p=34041,n.type!==_e&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=_e,m=s.convert(n.type))),i.texImage2D(3553,0,p,l.width,l.height,0,d,m,null);else if(n.isDataTexture)if(_.length>0&&u){for(let e=0,t=_.length;e0&&u){for(let e=0,t=_.length;e=c&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+c),A+=1,e},this.resetTextureUnits=function(){A=0},this.setTexture2D=M,this.setTexture2DArray=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?L(r,e,t):(i.activeTexture(33984+t),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?L(r,e,t):(i.activeTexture(33984+t),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=C,this.setTextureCubeDynamic=P,this.setupRenderTarget=function(t){const r=n.get(t),c=n.get(t.texture);t.addEventListener("dispose",S),c.__webglTexture=e.createTexture(),o.memory.textures++;const l=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultisampleRenderTarget,u=v(t)||a;if(!a||t.texture.format!==Se||t.texture.type!==ge&&t.texture.type!==ve||(t.texture.format=Ae,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),l){r.__webglFramebuffer=[];for(let t=0;t<6;t++)r.__webglFramebuffer[t]=e.createFramebuffer()}else if(r.__webglFramebuffer=e.createFramebuffer(),h)if(a){r.__webglMultisampledFramebuffer=e.createFramebuffer(),r.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,r.__webglColorRenderbuffer);const i=s.convert(t.texture.format),n=s.convert(t.texture.type),o=b(t.texture.internalFormat,i,n),a=B(t);e.renderbufferStorageMultisample(36161,a,o,t.width,t.height),e.bindFramebuffer(36160,r.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,r.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(r.__webglDepthRenderbuffer=e.createRenderbuffer(),k(r.__webglDepthRenderbuffer,t,!0)),e.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(l){i.bindTexture(34067,c.__webglTexture),E(34067,t.texture,u);for(let e=0;e<6;e++)R(r.__webglFramebuffer[e],t,36064,34069+e);y(t.texture,u)&&x(34067,t.texture,t.width,t.height),i.bindTexture(34067,null)}else i.bindTexture(3553,c.__webglTexture),E(3553,t.texture,u),R(r.__webglFramebuffer,t,36064,3553),y(t.texture,u)&&x(3553,t.texture,t.width,t.height),i.bindTexture(3553,null);t.depthBuffer&&O(t)},this.updateRenderTargetMipmap=function(e){const t=e.texture;if(y(t,v(e)||a)){const r=e.isWebGLCubeRenderTarget?34067:3553,s=n.get(t).__webglTexture;i.bindTexture(r,s),x(r,t,e.width,e.height),i.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(a){const i=n.get(t);e.bindFramebuffer(36008,i.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,i.__webglFramebuffer);const r=t.width,s=t.height;let o=16384;t.depthBuffer&&(o|=256),t.stencilBuffer&&(o|=1024),e.blitFramebuffer(0,0,r,s,0,0,r,s,o,9728),e.bindFramebuffer(36160,i.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===N&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),N=!0),e=e.texture),M(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===F&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),F=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?C(e,t):P(e,t)}}function Lo(e,t,i){const n=i.isWebGL2;return{convert:function(e){let i;if(e===he)return 5121;if(e===ye)return 32819;if(e===xe)return 32820;if(e===be)return 33635;if(e===ue)return 5120;if(e===de)return 5122;if(e===fe)return 5123;if(e===me)return 5124;if(e===pe)return 5125;if(e===ge)return 5126;if(e===ve)return n?5131:(i=t.get("OES_texture_half_float"),null!==i?i.HALF_FLOAT_OES:null);if(e===we)return 6406;if(e===Se)return 6407;if(e===Ae)return 6408;if(e===Me)return 6409;if(e===Ce)return 6410;if(e===Pe)return 6402;if(e===Te)return 34041;if(e===Ie)return 6403;if(e===Ee)return 36244;if(e===De)return 33319;if(e===Le)return 33320;if(e===Re)return 36248;if(e===ke)return 36249;if(e===Oe||e===Be||e===Ne||e===Fe){if(i=t.get("WEBGL_compressed_texture_s3tc"),null===i)return null;if(e===Oe)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Be)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===Ne)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Fe)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===ze||e===Ue||e===$e||e===Ge){if(i=t.get("WEBGL_compressed_texture_pvrtc"),null===i)return null;if(e===ze)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Ue)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===$e)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===Ge)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===Ve)return i=t.get("WEBGL_compressed_texture_etc1"),null!==i?i.COMPRESSED_RGB_ETC1_WEBGL:null;if((e===He||e===je)&&(i=t.get("WEBGL_compressed_texture_etc"),null!==i)){if(e===He)return i.COMPRESSED_RGB8_ETC2;if(e===je)return i.COMPRESSED_RGBA8_ETC2_EAC}return e===We||e===qe||e===Xe||e===Ye||e===Ze||e===Ke||e===Qe||e===Je||e===et||e===tt||e===it||e===nt||e===rt||e===st||e===at||e===ct||e===lt||e===ht||e===ut||e===dt||e===ft||e===mt||e===pt||e===gt||e===vt||e===yt||e===xt||e===bt?(i=t.get("WEBGL_compressed_texture_astc"),null!==i?e:null):e===ot?(i=t.get("EXT_texture_compression_bptc"),null!==i?e:null):e===_e?n?34042:(i=t.get("WEBGL_depth_texture"),null!==i?i.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}function Ro(e){Sr.call(this),this.cameras=e||[]}function ko(){wi.call(this),this.type="Group"}function Oo(){this._targetRay=null,this._grip=null}function Bo(e,t){const i=this;let n=null,r=1,s=null,o="local-floor",a=null;const c=[],l=new Map,h=new Sr;h.layers.enable(1),h.viewport=new jt;const u=new Sr;u.layers.enable(2),u.viewport=new jt;const d=[h,u],f=new Ro;f.layers.enable(1),f.layers.enable(2);let m=null,p=null;function g(e){const t=l.get(e.inputSource);t&&t.dispatchEvent({type:e.type})}function v(){l.forEach((function(e,t){e.disconnect(t)})),l.clear(),e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),A.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function y(e){s=e,A.setContext(n),A.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}function x(e){const t=n.inputSources;for(let e=0;e=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(let t=0;t=0&&e.numSupportedMorphNormals++}const m=n.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(n.numClippingPlanes=O.numPlanes,n.numIntersection=O.numIntersection,m.clippingPlanes=O.uniform),n.environment=e.isMeshStandardMaterial?t.environment:null,n.fog=t.fog,n.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),n.lightsStateVersion=o,n.needsLights&&(m.ambientLightColor.value=r.state.ambient,m.lightProbe.value=r.state.probe,m.directionalLights.value=r.state.directional,m.directionalLightShadows.value=r.state.directionalShadow,m.spotLights.value=r.state.spot,m.spotLightShadows.value=r.state.spotShadow,m.rectAreaLights.value=r.state.rectArea,m.pointLights.value=r.state.point,m.pointLightShadows.value=r.state.pointShadow,m.hemisphereLights.value=r.state.hemi,m.directionalShadowMap.value=r.state.directionalShadowMap,m.directionalShadowMatrix.value=r.state.directionalShadowMatrix,m.spotShadowMap.value=r.state.spotShadowMap,m.spotShadowMatrix.value=r.state.spotShadowMatrix,m.pointShadowMap.value=r.state.pointShadowMap,m.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=n.program.getUniforms(),g=js.seqWithValue(p.seq,m);n.uniformsList=g}function Pe(e,t,i,n){!0!==t.isScene&&(t=U),X.resetTextureUnits();const r=t.fog,s=i.isMeshStandardMaterial?t.environment:null,o=null===y?f.outputEncoding:y.texture.encoding,a=q.get(i),c=d.state.lights;if(!0===B&&(!0===N||e!==_)){const t=e===_&&i.id===b;O.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,e,a,t)}i.version===a.__version?void 0===a.program||i.fog&&a.fog!==r||a.environment!==s||a.needsLights&&a.lightsStateVersion!==c.state.version?Ce(i,t,n):void 0===a.numClippingPlanes||a.numClippingPlanes===O.numPlanes&&a.numIntersection===O.numIntersection?a.outputEncoding!==o&&Ce(i,t,n):Ce(i,t,n):(Ce(i,t,n),a.__version=i.version);let l=!1,h=!1,u=!1;const m=a.program,p=m.getUniforms(),g=a.uniforms;if(j.useProgram(m.program)&&(l=!0,h=!0,u=!0),i.id!==b&&(b=i.id,h=!0),l||_!==e){if(p.setValue(ce,"projectionMatrix",e.projectionMatrix),H.logarithmicDepthBuffer&&p.setValue(ce,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),_!==e&&(_=e,h=!0,u=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const t=p.map.cameraPosition;void 0!==t&&t.setValue(ce,z.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&p.setValue(ce,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||i.skinning)&&p.setValue(ce,"viewMatrix",e.matrixWorldInverse)}if(i.skinning){p.setOptional(ce,n,"bindMatrix"),p.setOptional(ce,n,"bindMatrixInverse");const e=n.skeleton;if(e){const t=e.bones;if(H.floatVertexTextures){if(void 0===e.boneTexture){let i=Math.sqrt(4*t.length);i=Ft.ceilPowerOfTwo(i),i=Math.max(i,4);const n=new Float32Array(i*i*4);n.set(e.boneMatrices);const r=new Ar(n,i,i,Ae,ge);e.boneMatrices=n,e.boneTexture=r,e.boneTextureSize=i}p.setValue(ce,"boneTexture",e.boneTexture,X),p.setValue(ce,"boneTextureSize",e.boneTextureSize)}else p.setOptional(ce,e,"boneMatrices")}}var v,x;return(h||a.receiveShadow!==n.receiveShadow)&&(a.receiveShadow=n.receiveShadow,p.setValue(ce,"receiveShadow",n.receiveShadow)),h&&(p.setValue(ce,"toneMappingExposure",f.toneMappingExposure),a.needsLights&&(x=u,(v=g).ambientLightColor.needsUpdate=x,v.lightProbe.needsUpdate=x,v.directionalLights.needsUpdate=x,v.directionalLightShadows.needsUpdate=x,v.pointLights.needsUpdate=x,v.pointLightShadows.needsUpdate=x,v.spotLights.needsUpdate=x,v.spotLightShadows.needsUpdate=x,v.rectAreaLights.needsUpdate=x,v.hemisphereLights.needsUpdate=x),r&&i.fog&&J.refreshFogUniforms(g,r),J.refreshMaterialUniforms(g,i,s,T,P),void 0!==g.ltc_1&&(g.ltc_1.value=Tr.LTC_1),void 0!==g.ltc_2&&(g.ltc_2.value=Tr.LTC_2),js.upload(ce,a.uniformsList,g,X)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(js.upload(ce,a.uniformsList,g,X),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&p.setValue(ce,"center",n.center),p.setValue(ce,"modelViewMatrix",n.modelViewMatrix),p.setValue(ce,"normalMatrix",n.normalMatrix),p.setValue(ce,"modelMatrix",n.matrixWorld),m}_e.setAnimationLoop((function(e){de.isPresenting||be&&be(e)})),"undefined"!=typeof window&&_e.setContext(window),this.setAnimationLoop=function(e){be=e,de.setAnimationLoop(e),null===e?_e.stop():_e.start()},this.render=function(e,t){let i,n;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),i=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),n=arguments[3]),void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===m)return;ae.resetDefaultState(),b=-1,_=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===de.enabled&&!0===de.isPresenting&&(t=de.getCamera(t)),!0===e.isScene&&e.onBeforeRender(f,e,t,i||y),d=te.get(e,t),d.init(),F.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),k.setFromProjectionMatrix(F),N=this.localClippingEnabled,B=O.init(this.clippingPlanes,N,t),u=ee.get(e,t),u.init(),we(e,t,0,f.sortObjects),u.finish(),!0===f.sortObjects&&u.sort(I,E),!0===B&&O.beginShadows();const r=d.state.shadowsArray;fe.render(r,e,t),d.setupLights(t),!0===B&&O.endShadows(),!0===this.info.autoReset&&this.info.reset(),void 0!==i&&this.setRenderTarget(i),ie.render(u,e,t,n);const s=u.opaque,o=u.transparent;s.length>0&&Se(s,e,t),o.length>0&&Se(o,e,t),!0===e.isScene&&e.onAfterRender(f,e,t),null!==y&&(X.updateRenderTargetMipmap(y),X.updateMultisampleRenderTarget(y)),j.buffers.depth.setTest(!0),j.buffers.depth.setMask(!0),j.buffers.color.setMask(!0),j.setPolygonOffset(!1),u=null,d=null},this.setFramebuffer=function(e){p!==e&&null===y&&ce.bindFramebuffer(36160,e),p=e},this.getActiveCubeFace=function(){return g},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return y},this.setRenderTarget=function(e,t,i){y=e,g=t,v=i,e&&void 0===q.get(e).__webglFramebuffer&&X.setupRenderTarget(e);let n=p,r=!1;if(e){const i=q.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(n=i[t||0],r=!0):n=e.isWebGLMultisampleRenderTarget?q.get(e).__webglMultisampledFramebuffer:i,S.copy(e.viewport),A.copy(e.scissor),M=e.scissorTest}else S.copy(D).multiplyScalar(T).floor(),A.copy(L).multiplyScalar(T).floor(),M=R;if(x!==n&&(ce.bindFramebuffer(36160,n),x=n),j.viewport(S),j.scissor(A),j.setScissorTest(M),r){const n=q.get(e.texture);ce.framebufferTexture2D(36160,36064,34069+(t||0),n.__webglTexture,i||0)}},this.readRenderTargetPixels=function(e,t,i,n,r,s,o){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=q.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(a=a[o]),a){let o=!1;a!==x&&(ce.bindFramebuffer(36160,a),o=!0);try{const o=e.texture,a=o.format,c=o.type;if(a!==Ae&&oe.convert(a)!==ce.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(c===he||oe.convert(c)===ce.getParameter(35738)||c===ge&&(H.isWebGL2||G.get("OES_texture_float")||G.get("WEBGL_color_buffer_float"))||c===ve&&(H.isWebGL2?G.get("EXT_color_buffer_float"):G.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ce.checkFramebufferStatus(36160)?t>=0&&t<=e.width-n&&i>=0&&i<=e.height-r&&ce.readPixels(t,i,n,r,oe.convert(a),oe.convert(c),s):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{o&&ce.bindFramebuffer(36160,x)}}},this.copyFramebufferToTexture=function(e,t,i){void 0===i&&(i=0);const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n),o=oe.convert(t.format);X.setTexture2D(t,0),ce.copyTexImage2D(3553,i,o,e.x,e.y,r,s,0),j.unbindTexture()},this.copyTextureToTexture=function(e,t,i,n){void 0===n&&(n=0);const r=t.image.width,s=t.image.height,o=oe.convert(i.format),a=oe.convert(i.type);X.setTexture2D(i,0),ce.pixelStorei(37440,i.flipY),ce.pixelStorei(37441,i.premultiplyAlpha),ce.pixelStorei(3317,i.unpackAlignment),t.isDataTexture?ce.texSubImage2D(3553,n,e.x,e.y,r,s,o,a,t.image.data):t.isCompressedTexture?ce.compressedTexSubImage2D(3553,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):ce.texSubImage2D(3553,n,e.x,e.y,o,a,t.image),0===n&&i.generateMipmaps&&ce.generateMipmap(3553),j.unbindTexture()},this.initTexture=function(e){X.setTexture2D(e,0),j.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function zo(e,t,i){this.name="",this.color=new mn(e),this.near=void 0!==t?t:1,this.far=void 0!==i?i:1e3}function Uo(e){bn.call(this),this.type="LineBasicMaterial",this.color=new mn(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(e)}Ro.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Ro,isArrayCamera:!0}),ko.prototype=Object.assign(Object.create(wi.prototype),{constructor:ko,isGroup:!0}),Object.assign(Oo.prototype,{constructor:Oo,getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new ko,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new ko,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),this},disconnect:function(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),this},update:function(e,t,i){let n=null,r=null;const s=this._targetRay,o=this._grip;return e&&(null!==s&&(n=t.getPose(e.targetRaySpace,i),null!==n&&(s.matrix.fromArray(n.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale))),null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale)))),null!==s&&(s.visible=null!==n),null!==o&&(o.visible=null!==r),this}}),Object.assign(Bo.prototype,Bt.prototype),Object.assign(zo.prototype,{isFog:!0,clone:function(){return new zo(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Uo.prototype=Object.create(bn.prototype),Uo.prototype.constructor=Uo,Uo.prototype.isLineBasicMaterial=!0,Uo.prototype.copy=function(e){return bn.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.morphTargets=e.morphTargets,this};const $o=new Zt,Go=new Zt,Vo=new ri,Ho=new Xi,jo=new Ui;function Wo(e,t,i){1===i&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),wi.call(this),this.type="Line",this.geometry=void 0!==e?e:new Vn,this.material=void 0!==t?t:new Uo,this.updateMorphTargets()}Wo.prototype=Object.assign(Object.create(wi.prototype),{constructor:Wo,isLine:!0,copy:function(e){return wi.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[0];for(let e=1,n=t.count;eo)continue;h.applyMatrix4(this.matrixWorld);const d=e.ray.origin.distanceTo(h);de.far||t.push({distance:d,point:l.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else for(let i=0,n=r.length/3-1;io)continue;h.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(h);ne.far||t.push({distance:n,point:l.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else if(i.isGeometry){const n=i.vertices,r=n.length;for(let i=0;io)continue;h.applyMatrix4(this.matrixWorld);const r=e.ray.origin.distanceTo(h);re.far||t.push({distance:r,point:l.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const qo=new Zt,Xo=new Zt;function Yo(e,t){Wo.call(this,e,t),this.type="LineSegments"}function Zo(e){bn.call(this),this.type="PointsMaterial",this.color=new mn(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}Yo.prototype=Object.assign(Object.create(Wo.prototype),{constructor:Yo,isLineSegments:!0,computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[];for(let e=0,n=t.count;er.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:i,index:t,face:null,object:o})}}function na(e,t,i,n,r,s,o,a,c){Ht.call(this,e,t,i,n,r,s,o,a,c),this.needsUpdate=!0}function ra(e,t,i,n){mr.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n},this.fromBufferGeometry(new sa(e,t,i,n)),this.mergeVertices()}function sa(e,t,i,n){Vn.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n},i=i||1;const r=[],s=[];function o(e,t,i,n){const r=Math.pow(2,n),s=[];for(let n=0;n<=r;n++){s[n]=[];const o=e.clone().lerp(i,n/r),a=t.clone().lerp(i,n/r),c=r-n;for(let e=0;e<=c;e++)s[n][e]=0===e&&n===r?o:o.clone().lerp(a,e/c)}for(let e=0;e.9&&o<.1&&(t<.2&&(s[e+0]+=1),i<.2&&(s[e+2]+=1),n<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new Ln(r,3)),this.setAttribute("normal",new Ln(r.slice(),3)),this.setAttribute("uv",new Ln(s,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}function oa(e,t){mr.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new aa(e,t)),this.mergeVertices()}function aa(e,t){sa.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function ca(e,t){mr.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new la(e,t)),this.mergeVertices()}function la(e,t){sa.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function ha(e,t){mr.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new ua(e,t)),this.mergeVertices()}function ua(e,t){const i=(1+Math.sqrt(5))/2,n=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];sa.call(this,n,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function da(e,t,i,n,r){mr.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:r},this.fromBufferGeometry(new fa(e,t,i,n,r)),this.mergeVertices()}function fa(e,t,i,n,r){Vn.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:r},e=e||1,t=t||.4,i=Math.floor(i)||8,n=Math.floor(n)||6,r=r||2*Math.PI;const s=[],o=[],a=[],c=[],l=new Zt,h=new Zt,u=new Zt;for(let s=0;s<=i;s++)for(let d=0;d<=n;d++){const f=d/n*r,m=s/i*Math.PI*2;h.x=(e+t*Math.cos(m))*Math.cos(f),h.y=(e+t*Math.cos(m))*Math.sin(f),h.z=t*Math.sin(m),o.push(h.x,h.y,h.z),l.x=e*Math.cos(f),l.y=e*Math.sin(f),u.subVectors(h,l).normalize(),a.push(u.x,u.y,u.z),c.push(d/n),c.push(s/i)}for(let e=1;e<=i;e++)for(let t=1;t<=n;t++){const i=(n+1)*e+t-1,r=(n+1)*(e-1)+t-1,o=(n+1)*(e-1)+t,a=(n+1)*e+t;s.push(i,r,a),s.push(r,o,a)}this.setIndex(s),this.setAttribute("position",new Ln(o,3)),this.setAttribute("normal",new Ln(a,3)),this.setAttribute("uv",new Ln(c,2))}function ma(e,t,i,n,r,s,o,a){mr.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new pa(e,t,i,n,r,s,o,a)),this.mergeVertices()}function pa(e,t,i,n,r,s,o,a){Vn.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a};const c=this;e=void 0!==e?e:1,t=void 0!==t?t:1,i=i||1,n=Math.floor(n)||8,r=Math.floor(r)||1,s=void 0!==s&&s,o=void 0!==o?o:0,a=void 0!==a?a:2*Math.PI;const l=[],h=[],u=[],d=[];let f=0;const m=[],p=i/2;let g=0;function v(i){let r,s;const m=new zt,v=new Zt;let y=0;const x=!0===i?e:t,b=!0===i?1:-1;r=f;for(let e=1;e<=n;e++)h.push(0,p*b,0),u.push(0,b,0),d.push(.5,.5),f++;s=f;for(let e=0;e<=n;e++){const t=e/n*a+o,i=Math.cos(t),r=Math.sin(t);v.x=x*r,v.y=p*b,v.z=x*i,h.push(v.x,v.y,v.z),u.push(0,b,0),m.x=.5*i+.5,m.y=.5*r*b+.5,d.push(m.x,m.y),f++}for(let e=0;e0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute("position",new Ln(h,3)),this.setAttribute("normal",new Ln(u,3)),this.setAttribute("uv",new Ln(d,2))}function ga(e,t,i,n,r,s,o){ma.call(this,0,e,t,i,n,r,s,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:s,thetaLength:o}}function va(e,t,i,n,r,s,o){pa.call(this,0,e,t,i,n,r,s,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:s,thetaLength:o}}function ya(e,t){wi.call(this),this.type="Light",this.color=new mn(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function xa(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new zt(512,512),this.map=null,this.mapPass=null,this.matrix=new ri,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Pr,this._frameExtents=new zt(1,1),this._viewportCount=1,this._viewports=[new jt(0,0,1,1)]}function ba(){xa.call(this,new Sr(50,1,.5,500))}function _a(e,t,i,n,r,s){ya.call(this,e,t),this.type="SpotLight",this.position.copy(wi.DefaultUp),this.updateMatrix(),this.target=new wi,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==s?s:1,this.shadow=new ba}function wa(e,t,i,n,r,s){wr.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=void 0!==e?e:-1,this.right=void 0!==t?t:1,this.top=void 0!==i?i:1,this.bottom=void 0!==n?n:-1,this.near=void 0!==r?r:.1,this.far=void 0!==s?s:2e3,this.updateProjectionMatrix()}function Sa(e,t){ya.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}ta.prototype=Object.assign(Object.create(wi.prototype),{constructor:ta,isPoints:!0,copy:function(e){return wi.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},raycast:function(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold;if(null===i.boundingSphere&&i.computeBoundingSphere(),Jo.copy(i.boundingSphere),Jo.applyMatrix4(n),Jo.radius+=r,!1===e.ray.intersectsSphere(Jo))return;Ko.getInverse(n),Qo.copy(e.ray).applyMatrix4(Ko);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position.array;if(null!==r){const i=r.array;for(let r=0,a=i.length;r0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}),na.prototype=Object.create(Ht.prototype),na.prototype.constructor=na,na.prototype.isCanvasTexture=!0,ra.prototype=Object.create(mr.prototype),ra.prototype.constructor=ra,sa.prototype=Object.create(Vn.prototype),sa.prototype.constructor=sa,oa.prototype=Object.create(mr.prototype),oa.prototype.constructor=oa,aa.prototype=Object.create(sa.prototype),aa.prototype.constructor=aa,ca.prototype=Object.create(mr.prototype),ca.prototype.constructor=ca,la.prototype=Object.create(sa.prototype),la.prototype.constructor=la,ha.prototype=Object.create(mr.prototype),ha.prototype.constructor=ha,ua.prototype=Object.create(sa.prototype),ua.prototype.constructor=ua,da.prototype=Object.create(mr.prototype),da.prototype.constructor=da,fa.prototype=Object.create(Vn.prototype),fa.prototype.constructor=fa,ma.prototype=Object.create(mr.prototype),ma.prototype.constructor=ma,pa.prototype=Object.create(Vn.prototype),pa.prototype.constructor=pa,ga.prototype=Object.create(ma.prototype),ga.prototype.constructor=ga,va.prototype=Object.create(pa.prototype),va.prototype.constructor=va,ya.prototype=Object.assign(Object.create(wi.prototype),{constructor:ya,isLight:!0,copy:function(e){return wi.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){const t=wi.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),Object.assign(xa.prototype,{_projScreenMatrix:new ri,_lightPositionWorld:new Zt,_lookTarget:new Zt,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){const t=this.camera,i=this.matrix,n=this._projScreenMatrix,r=this._lookTarget,s=this._lightPositionWorld;s.setFromMatrixPosition(e.matrixWorld),t.position.copy(s),r.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(r),t.updateMatrixWorld(),n.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(n),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.multiply(t.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),ba.prototype=Object.assign(Object.create(xa.prototype),{constructor:ba,isSpotLightShadow:!0,updateMatrices:function(e){const t=this.camera,i=2*Ft.RAD2DEG*e.angle,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;i===t.fov&&n===t.aspect&&r===t.far||(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),xa.prototype.updateMatrices.call(this,e)}}),_a.prototype=Object.assign(Object.create(ya.prototype),{constructor:_a,isSpotLight:!0,copy:function(e){return ya.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),wa.prototype=Object.assign(Object.create(wr.prototype),{constructor:wa,isOrthographicCamera:!0,copy:function(e,t){return wr.prototype.copy.call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this},setViewOffset:function(e,t,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,s=i+e,o=n+t,a=n-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,o-=t*this.view.offsetY,a=o-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){const t=wi.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}),Sa.prototype=Object.assign(Object.create(ya.prototype),{constructor:Sa,isAmbientLight:!0});const Aa=new ri,Ma=new ri;function Ca(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Sr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Sr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}function Pa(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function Ta(e){if("undefined"==typeof window)return;const t=new RegExp(`${e}=([^&#=]*)`).exec(window.location.search);return t?decodeURIComponent(t[1]):void 0}function Ia(e,t){return void 0!==e?e:t}function Ea(e,t){const i=Object.assign({},e);for(const n in t){void 0===e[n]&&(i[n]=t[n])}return i}function Da(e,t){for(const i in t){const n=t[i];void 0!==n&&(e[i]=n)}return e}function La(){const e=window.location.protocol;return null===e.match(/http(s)?:/gi)?"http:":e}function Ra(){if("undefined"==typeof window)return!1;const e=window.navigator.userAgent;return/Opera|OPR/.test(e)?"Opera":/Chrome/i.test(e)?"Chrome":/Firefox/i.test(e)?"Firefox":/Mobile(\/.*)? Safari/i.test(e)?"Mobile Safari":/MSIE/i.test(e)?"Internet Explorer":!!/Safari/i.test(e)&&"Safari"}function ka(e){window.open(e,"_blank")||(window.location.href=e)}function Oa(e,t="download"){if(!e)return;const i="Safari"===Ra(),n=/CriOS\/[\d]+/.test(window.navigator.userAgent),r=document.createElement("a");function s(e){ka(n?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"))}if("undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(e,t);else if((i||n)&&FileReader)if(e instanceof Blob){var o=new FileReader;o.onloadend=function(){s(o.result)},o.readAsDataURL(e)}else s(e);else{let i=!1;e instanceof Blob&&(e=URL.createObjectURL(e),i=!0),"download"in r?(r.style.display="hidden",document.body.appendChild(r),r.href=e,r.download=t,r.target="_blank",r.click(),document.body.removeChild(r)):ka(e),i&&window.URL.revokeObjectURL(e)}}function Ba(e,t){return et?1:0}function Na(e,t,i=Ba){let n=0,r=e.length-1;for(;n<=r;){const s=n+r>>1,o=i(t,e[s]);if(o>0)n=s+1;else{if(!(o<0))return s;r=s-1}}return-n-1}function Fa(e,t,i){const n=function(e,t){let i=e.length-1;if(e[i]>1;e[r]>=t?i=r-1:n=r+1}return i+1}(e,t),r=function(e,t){if(e[0]>t)return-1;let i=0,n=e.length-1;for(;i<=n;){const r=i+n>>1;e[r]>t?n=r-1:i=r+1}return i-1}(e,i);return-1===n||-1===r||n>r?0:r-n+1}function za(e){return e.sort().filter((function(e,t,i){return 0===t||e!==i[t-1]}))}function Ua(e){const t=28672;if(e.length>t){const i=[];for(let n=0;n65535?Uint32Array:Uint16Array)(e)}function Va(e){return e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e}function Ha(e,t){return void 0===e?e=new t:Array.isArray(e)&&(e=(new t).fromArray(e)),e}function ja(e){return Ha(e,Zt)}function Wa(e){return Ha(e,ri)}function qa(e){return Ha(e,qt)}function Xa(e){return t=e,i=Float32Array,t instanceof i?t:new i(t);var t,i}function Ya(e){return Ia(e,"").toString().toLowerCase()}Object.assign(Ca.prototype,{update:function(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep;const i=e.projectionMatrix.clone(),n=t.eyeSep/2,r=n*t.near/t.focus,s=t.near*Math.tan(Ft.DEG2RAD*t.fov*.5)/t.zoom;let o,a;Ma.elements[12]=-n,Aa.elements[12]=n,o=-s*t.aspect+r,a=s*t.aspect+r,i.elements[0]=2*t.near/(a-o),i.elements[8]=(a+o)/(a-o),this.cameraL.projectionMatrix.copy(i),o=-s*t.aspect-r,a=s*t.aspect-r,i.elements[0]=2*t.near/(a-o),i.elements[8]=(a+o)/(a-o),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Ma),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Aa)}}),Pa.prototype.clone=function(){return new Pa(void 0===this.value.clone?this.value:this.value.clone())};class Za{constructor(e){this.name=e,this._dict={}}add(e,t){this._dict[Ya(e)]=t}get(e){return this._dict[Ya(e)]}get names(){return Object.keys(this._dict)}}function Ka(e){return.01745*e}const Qa="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Ja=new Array(36);function ec(){let e,t=0;for(let i=0;i<36;i++)8===i||13===i||18===i||23===i?Ja[i]="-":14===i?Ja[i]="4":(t<=2&&(t=33554432+16777216*Math.random()|0),e=15&t,t>>=4,Ja[i]=Qa[19===i?3&e|8:e]);return Ja.join("")}function tc(e,t,i){return Math.max(t,Math.min(i,e))}function ic(e,t,i){return e+(t-e)*i}function nc(e,t,i,n,r,s){const o=(i-e)*s,a=(n-t)*s,c=r*r;return(2*t-2*i+o+a)*(r*c)+(-3*t+3*i-2*o-a)*c+o*r+t}function rc(e,t,i){var n;return n=function(e,t,i){return(e-t)/(i-t)}(i,e,t),(i=tc(n,0,1))*i*(3-2*i)}var sc="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function oc(e){var t={exports:{}};return e(t,t.exports),t.exports}var ac=oc((function(e,t){ /** - * @license - * - * chroma.js - JavaScript library for color conversions - * - * Copyright (c) 2011-2017, Gregor Aisch - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name Gregor Aisch may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -(function(){var r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b,x,_,w,S,A,M,C,P,T,I,E,D,L,O,R,k,N,B,F,z,U,j,G,V,$,H,W,q,X,Y,Z,K,Q,J,ee,te,re,ie,ne,oe,ae,se,ce,ue,le,he,pe,de,fe,me,ge,ve,ye,be,xe,_e,we,Se,Ae,Me,Ce,Pe,Te=[].slice;Se=function(){var e,t,r,i,n;for(e={},i=0,t=(n="Boolean Number String Function Array Date RegExp Undefined Null".split(" ")).length;ir&&(e=r),e},Ae=function(e){return e.length>=3?Array.prototype.slice.call(e):e[0]},w=function(e){var t,r;for(e._clipped=!1,e._unclipped=e.slice(0),t=r=0;r<3;t=++r)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]<0&&(e[t]=0),e[t]>255&&(e[t]=255)):3===t&&(e[t]<0&&(e[t]=0),e[t]>1&&(e[t]=1));return e._clipped||delete e._unclipped,e},o=Math.PI,ye=Math.round,A=Math.cos,I=Math.floor,re=Math.pow,Y=Math.log,xe=Math.sin,_e=Math.sqrt,m=Math.atan2,Q=Math.max,f=Math.abs,c=2*o,a=o/3,i=o/180,s=180/o,_=function(){return arguments[0]instanceof r?arguments[0]:function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,arguments,(function(){}))},_.default=_,d=[],null!==e&&null!=e.exports&&(e.exports=_),(null!==t?t:this).chroma=_,_.version="1.4.1",p={},l=[],h=!1,r=function(){function e(){var e,t,r,i,n,o,a,s,c,u=arguments;for(o=this,t=[],s=0,i=arguments.length;s1&&(a=t[t.length-1]),null!=p[a])o._rgb=w(p[a](Ae(t.slice(0,-1))));else{for(h||(l=l.sort((function(e,t){return t.p-e.p})),h=!0),c=0,n=l.length;ci&&(e=i),e},Ae=function(e){return e.length>=3?Array.prototype.slice.call(e):e[0]},w=function(e){var t,i;for(e._clipped=!1,e._unclipped=e.slice(0),t=i=0;i<3;t=++i)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]<0&&(e[t]=0),e[t]>255&&(e[t]=255)):3===t&&(e[t]<0&&(e[t]=0),e[t]>1&&(e[t]=1));return e._clipped||delete e._unclipped,e},s=Math.PI,ye=Math.round,A=Math.cos,I=Math.floor,ie=Math.pow,Y=Math.log,be=Math.sin,_e=Math.sqrt,p=Math.atan2,Q=Math.max,m=Math.abs,c=2*s,o=s/3,n=s/180,a=180/s,_=function(){return arguments[0]instanceof i?arguments[0]:function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,arguments,(function(){}))},_.default=_,f=[],null!==e&&null!=e.exports&&(e.exports=_),(null!==t?t:this).chroma=_,_.version="1.4.1",d={},h=[],u=!1,i=function(){function e(){var e,t,i,n,r,s,o,a,c;for(s=this,t=[],a=0,n=arguments.length;a1&&(o=t[t.length-1]),null!=d[o])s._rgb=w(d[o](Ae(t.slice(0,-1))));else{for(u||(h=h.sort((function(e,t){return t.p-e.p})),u=!0),c=0,r=h.length;c3?t[3]:1]},Pe=function(e){return 255*(e<=.00304?12.92*e:1.055*re(e,1/2.4)-.055)},$=function(e){return e>n.t1?e*e*e:n.t2*(e-n.t0)},n={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},le=function(){var e,t,r,i,n,o,a;return r=(i=Ae(arguments))[0],t=i[1],e=i[2],o=(n=me(r,t,e))[0],[116*(a=n[1])-16,500*(o-a),200*(a-n[2])]},ge=function(e){return(e/=255)<=.04045?e/12.92:re((e+.055)/1.055,2.4)},Ce=function(e){return e>n.t3?re(e,1/3):e/n.t2+n.t0},me=function(){var e,t,r,i;return r=(i=Ae(arguments))[0],t=i[1],e=i[2],r=ge(r),t=ge(t),e=ge(e),[Ce((.4124564*r+.3575761*t+.1804375*e)/n.Xn),Ce((.2126729*r+.7151522*t+.072175*e)/n.Yn),Ce((.0193339*r+.119192*t+.9503041*e)/n.Zn)]},_.lab=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["lab"]),(function(){}))},p.lab=V,r.prototype.lab=function(){return le(this._rgb)},g=function(e){var t,r,i,n,o,a,s,c,u,l,h;return 2===(e=function(){var t,r,i;for(i=[],r=0,t=e.length;r=0&&t[3]<=1?"rgb":void 0}}),p.lrgb=p.rgb,z=function(e,t,i,n){var o,a;return o=e._rgb,a=t._rgb,new r(_e(re(o[0],2)*(1-i)+re(a[0],2)*i),_e(re(o[1],2)*(1-i)+re(a[1],2)*i),_e(re(o[2],2)*(1-i)+re(a[2],2)*i),n)},u=function(e){var t,i,n,o,a;for(t=1/e.length,a=[0,0,0,0],n=0,i=e.length;n1&&(a[3]=1),new r(w(a))},d.push(["lrgb",z]),_.average=function(e,t){var r,i,n,a,s,c,l,h,p,d,f,g,v;if(null==t&&(t="rgb"),p=e.length,e=e.map((function(e){return _(e)})),l=e.splice(0,1)[0],"lrgb"===t)return u(e);for(h in a=[],s=0,c=0,g=l.get(t))g[h]=g[h]||0,a.push(isNaN(g[h])?0:1),"h"!==t.charAt(h)||isNaN(g[h])||(r=g[h]/180*o,s+=A(r),c+=xe(r));for(i=l.alpha(),f=0,d=e.length;f=360;)r-=360;g[h]=r}else g[h]=g[h]/a[h];return _(g,t).alpha(i/p)},D=function(e){var t,r;if(e.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return 4!==e.length&&7!==e.length||(e=e.substr(1)),3===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]),[(r=parseInt(e,16))>>16,r>>8&255,255&r,1];if(e.match(/^#?([A-Fa-f0-9]{8})$/))return 9===e.length&&(e=e.substr(1)),[(r=parseInt(e,16))>>24&255,r>>16&255,r>>8&255,ye((255&r)/255*100)/100];if(null!=p.css&&(t=p.css(e)))return t;throw"unknown color: "+e},ae=function(e,t){var r,i,n,o,a,s;return null==t&&(t="auto"),a=e[0],n=e[1],i=e[2],r=e[3],"auto"===t&&(t=r<1?"rgba":"rgb"),a=Math.round(a),n=Math.round(n),i=Math.round(i),s=(s="000000"+(a<<16|n<<8|i).toString(16)).substr(s.length-6),o=(o="0"+ye(255*r).toString(16)).substr(o.length-2),"#"+function(){switch(t.toLowerCase()){case"rgba":return s+o;case"argb":return o+s;default:return s}}()},p.hex=function(e){return D(e)},_.hex=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["hex"]),(function(){}))},r.prototype.hex=function(e){return null==e&&(e="auto"),ae(this._rgb,e)},l.push({p:4,test:function(e){if(1===arguments.length&&"string"===Se(e))return"hex"}}),R=function(){var e,t,r,i,n,o,a,s,c,u,l,h,p,d;if(n=(e=Ae(arguments))[0],l=e[1],a=e[2],0===l)c=i=t=255*a;else{for(r=[0,0,0],h=2*a-(p=a<.5?a*(1+l):a+l-a*l),(d=[0,0,0])[0]=(n/=360)+1/3,d[1]=n,d[2]=n-1/3,o=s=0;s<=2;o=++s)d[o]<0&&(d[o]+=1),d[o]>1&&(d[o]-=1),6*d[o]<1?r[o]=h+6*(p-h)*d[o]:2*d[o]<1?r[o]=p:3*d[o]<2?r[o]=h+(p-h)*(2/3-d[o])*6:r[o]=h;c=(u=[ye(255*r[0]),ye(255*r[1]),ye(255*r[2])])[0],i=u[1],t=u[2]}return e.length>3?[c,i,t,e[3]]:[c,i,t]},ce=function(e,t,r){var i,n,o,a,s;return void 0!==e&&e.length>=3&&(e=(a=e)[0],t=a[1],r=a[2]),e/=255,t/=255,r/=255,o=Math.min(e,t,r),n=((Q=Math.max(e,t,r))+o)/2,Q===o?(s=0,i=Number.NaN):s=n<.5?(Q-o)/(Q+o):(Q-o)/(2-Q-o),e===Q?i=(t-r)/(Q-o):t===Q?i=2+(r-e)/(Q-o):r===Q&&(i=4+(e-t)/(Q-o)),(i*=60)<0&&(i+=360),[i,s,n]},_.hsl=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["hsl"]),(function(){}))},p.hsl=R,r.prototype.hsl=function(){return ce(this._rgb)},k=function(){var e,t,r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v;if(n=(e=Ae(arguments))[0],m=e[1],v=e[2],v*=255,0===m)c=i=t=v;else switch(360===n&&(n=0),n>360&&(n-=360),n<0&&(n+=360),a=v*(1-m),s=v*(1-m*(r=(n/=60)-(o=I(n)))),g=v*(1-m*(1-r)),o){case 0:c=(u=[v,g,a])[0],i=u[1],t=u[2];break;case 1:c=(l=[s,v,a])[0],i=l[1],t=l[2];break;case 2:c=(h=[a,v,g])[0],i=h[1],t=h[2];break;case 3:c=(p=[a,s,v])[0],i=p[1],t=p[2];break;case 4:c=(d=[g,a,v])[0],i=d[1],t=d[2];break;case 5:c=(f=[v,a,s])[0],i=f[1],t=f[2]}return[c,i,t,e.length>3?e[3]:1]},ue=function(){var e,t,r,i,n,o,a,s,c;return o=(a=Ae(arguments))[0],r=a[1],e=a[2],n=Math.min(o,r,e),t=(Q=Math.max(o,r,e))-n,c=Q/255,0===Q?(i=Number.NaN,s=0):(s=t/Q,o===Q&&(i=(r-e)/t),r===Q&&(i=2+(e-o)/t),e===Q&&(i=4+(o-r)/t),(i*=60)<0&&(i+=360)),[i,s,c]},_.hsv=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["hsv"]),(function(){}))},p.hsv=k,r.prototype.hsv=function(){return ue(this._rgb)},ee=function(e){return"number"===Se(e)&&e>=0&&e<=16777215?[e>>16,e>>8&255,255&e,1]:(console.warn("unknown num color: "+e),[0,0,0,1])},de=function(){var e;return((e=Ae(arguments))[0]<<16)+(e[1]<<8)+e[2]},_.num=function(e){return new r(e,"num")},r.prototype.num=function(e){return null==e&&(e="rgb"),de(this._rgb,e)},p.num=ee,l.push({p:1,test:function(e){if(1===arguments.length&&"number"===Se(e)&&e>=0&&e<=16777215)return"num"}}),E=function(){var e,t,r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b;if(s=(r=Ae(arguments))[0],n=r[1],t=r[2],a=a/100*255,e=255*(n/=100),0===n)h=a=i=t;else switch(360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360),l=(u=t*(1-n))+e*(1-(o=(s/=60)-(c=I(s)))),y=u+e*o,b=u+e,c){case 0:h=(p=[b,y,u])[0],a=p[1],i=p[2];break;case 1:h=(d=[l,b,u])[0],a=d[1],i=d[2];break;case 2:h=(f=[u,b,y])[0],a=f[1],i=f[2];break;case 3:h=(m=[u,l,b])[0],a=m[1],i=m[2];break;case 4:h=(g=[y,u,b])[0],a=g[1],i=g[2];break;case 5:h=(v=[b,u,l])[0],a=v[1],i=v[2]}return[h,a,i,r.length>3?r[3]:1]},oe=function(){var e,t,r,i,n,o,a,s,c;return s=(c=Ae(arguments))[0],n=c[1],t=c[2],a=Math.min(s,n,t),r=100*(i=(Q=Math.max(s,n,t))-a)/255,e=a/(255-i)*100,0===i?o=Number.NaN:(s===Q&&(o=(n-t)/i),n===Q&&(o=2+(t-s)/i),t===Q&&(o=4+(s-n)/i),(o*=60)<0&&(o+=360)),[o,r,e]},_.hcg=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["hcg"]),(function(){}))},p.hcg=E,r.prototype.hcg=function(){return oe(this._rgb)},M=function(e){var t,r,i,n,o,a,s,c;if(e=e.toLowerCase(),null!=_.colors&&_.colors[e])return D(_.colors[e]);if(o=e.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(s=o.slice(1,4),n=a=0;a<=2;n=++a)s[n]=+s[n];s[3]=1}else if(o=e.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(s=o.slice(1,5),n=c=0;c<=3;n=++c)s[n]=+s[n];else if(o=e.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(s=o.slice(1,4),n=t=0;t<=2;n=++t)s[n]=ye(2.55*s[n]);s[3]=1}else if(o=e.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(s=o.slice(1,5),n=r=0;r<=2;n=++r)s[n]=ye(2.55*s[n]);s[3]=+s[3]}else(o=e.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?((i=o.slice(1,4))[1]*=.01,i[2]*=.01,(s=R(i))[3]=1):(o=e.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&((i=o.slice(1,4))[1]*=.01,i[2]*=.01,(s=R(i))[3]=+o[4]);return s},ne=function(e){var t;return"rgb"===(t=e[3]<1?"rgba":"rgb")?t+"("+e.slice(0,3).map(ye).join(",")+")":"rgba"===t?t+"("+e.slice(0,3).map(ye).join(",")+","+e[3]+")":void 0},ve=function(e){return ye(100*e)/100},O=function(e,t){var r;return r=t<1?"hsla":"hsl",e[0]=ve(e[0]||0),e[1]=ve(100*e[1])+"%",e[2]=ve(100*e[2])+"%","hsla"===r&&(e[3]=t),r+"("+e.join(",")+")"},p.css=function(e){return M(e)},_.css=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["css"]),(function(){}))},r.prototype.css=function(e){return null==e&&(e="rgb"),"rgb"===e.slice(0,3)?ne(this._rgb):"hsl"===e.slice(0,3)?O(this.hsl(),this.alpha()):void 0},p.named=function(e){return D(Me[e])},l.push({p:5,test:function(e){if(1===arguments.length&&null!=Me[e])return"named"}}),r.prototype.name=function(e){var t,r;for(r in arguments.length&&(Me[e]&&(this._rgb=D(Me[e])),this._rgb[3]=1),t=this.hex("rgb"),Me)if(t===Me[r])return r;return t},H=function(){var e,t,r,n;return r=(n=Ae(arguments))[0],e=n[1],t=n[2],[r,A(t*=i)*e,xe(t)*e]},W=function(){var e,t,r,i,n,o,a,s,c;return a=(r=Ae(arguments))[0],n=r[1],o=r[2],e=(s=H(a,n,o))[0],t=s[1],i=s[2],[(c=V(e,t,i))[0],c[1],i=c[2],r.length>3?r[3]:1]},G=function(){var e,t,r,i,n,o;return n=(o=Ae(arguments))[0],e=o[1],t=o[2],r=_e(e*e+t*t),i=(m(t,e)*s+360)%360,0===ye(1e4*r)&&(i=Number.NaN),[n,r,i]},he=function(){var e,t,r,i,n,o,a;return n=(o=Ae(arguments))[0],r=o[1],t=o[2],i=(a=le(n,r,t))[0],e=a[1],t=a[2],G(i,e,t)},_.lch=function(){var e;return e=Ae(arguments),new r(e,"lch")},_.hcl=function(){var e;return e=Ae(arguments),new r(e,"hcl")},p.lch=W,p.hcl=function(){var e,t,r,i;return t=(i=Ae(arguments))[0],e=i[1],r=i[2],W([r,e,t])},r.prototype.lch=function(){return he(this._rgb)},r.prototype.hcl=function(){return he(this._rgb).reverse()},ie=function(e){var t,r,i,n,o,a;return null==e&&(e="rgb"),o=(a=Ae(arguments))[0],i=a[1],t=a[2],i/=255,t/=255,[(1-(o/=255)-(n=1-Math.max(o,Math.max(i,t))))*(r=n<1?1/(1-n):0),(1-i-n)*r,(1-t-n)*r,n]},S=function(){var e,t,r,i,n,o;return r=(t=Ae(arguments))[0],n=t[1],o=t[2],i=t[3],e=t.length>4?t[4]:1,1===i?[0,0,0,e]:[r>=1?0:255*(1-r)*(1-i),n>=1?0:255*(1-n)*(1-i),o>=1?0:255*(1-o)*(1-i),e]},p.cmyk=function(){return S(Ae(arguments))},_.cmyk=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["cmyk"]),(function(){}))},r.prototype.cmyk=function(){return ie(this._rgb)},p.gl=function(){var e,t,r,i,n;for(i=function(){var e,r;for(t in r=[],e=Ae(arguments))n=e[t],r.push(n);return r}.apply(this,arguments),e=r=0;r<=2;e=++r)i[e]*=255;return i},_.gl=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["gl"]),(function(){}))},r.prototype.gl=function(){var e;return[(e=this._rgb)[0]/255,e[1]/255,e[2]/255,e[3]]},pe=function(e,t,r){var i;return e=(i=Ae(arguments))[0],t=i[1],r=i[2],.2126*(e=Z(e))+.7152*(t=Z(t))+.0722*(r=Z(r))},Z=function(e){return(e/=255)<=.03928?e/12.92:re((e+.055)/1.055,2.4)},j=function(e,t,i,n){var o,a;return o=e._rgb,a=t._rgb,new r(o[0]+i*(a[0]-o[0]),o[1]+i*(a[1]-o[1]),o[2]+i*(a[2]-o[2]),n)},d.push(["rgb",j]),r.prototype.luminance=function(e,t){var r,i,n,o,a;return null==t&&(t="rgb"),arguments.length?(o=this._rgb,0===e?o=[0,0,0,this._rgb[3]]:1===e?o=[255,255,255,this[3]]:(r=pe(this._rgb),i=1e-7,n=20,a=function(r,o){var s,c;return s=(c=r.interpolate(o,.5,t)).luminance(),Math.abs(e-s)e?a(r,c):a(c,o)},o=r>e?a(_("black"),this).rgba():a(this,_("white")).rgba()),_(o).alpha(this.alpha())):pe(this._rgb)},we=function(e){var t,r,i,n;return(n=e/100)<66?(i=255,r=-155.25485562709179-.44596950469579133*(r=n-2)+104.49216199393888*Y(r),t=n<20?0:.8274096064007395*(t=n-10)-254.76935184120902+115.67994401066147*Y(t)):(i=351.97690566805693+.114206453784165*(i=n-55)-40.25366309332127*Y(i),r=325.4494125711974+.07943456536662342*(r=n-50)-28.0852963507957*Y(r),t=255),[i,r,t]},fe=function(){var e,t,r,i,n,o,a,s;for(n=(o=Ae(arguments))[0],e=o[2],i=1e3,r=4e4,t=.4;r-i>t;)(a=we(s=.5*(r+i)))[2]/a[0]>=e/n?r=s:i=s;return ye(s)},_.temperature=_.kelvin=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["temperature"]),(function(){}))},p.temperature=p.kelvin=p.K=we,r.prototype.temperature=function(){return fe(this._rgb)},r.prototype.kelvin=r.prototype.temperature,_.contrast=function(e,t){var i,n,o,a;return"string"!==(o=Se(e))&&"number"!==o||(e=new r(e)),"string"!==(a=Se(t))&&"number"!==a||(t=new r(t)),(i=e.luminance())>(n=t.luminance())?(i+.05)/(n+.05):(n+.05)/(i+.05)},_.distance=function(e,t,i){var n,o,a,s,c,u,l;for(o in null==i&&(i="lab"),"string"!==(c=Se(e))&&"number"!==c||(e=new r(e)),"string"!==(u=Se(t))&&"number"!==u||(t=new r(t)),a=e.get(i),s=t.get(i),l=0,a)l+=(n=(a[o]||0)-(s[o]||0))*n;return Math.sqrt(l)},_.deltaE=function(e,t,i,n){var a,s,c,u,l,h,p,d,g,v,y,b,x,_,w,S,M,C,P,T,I,E,D,L;for(null==i&&(i=1),null==n&&(n=1),"string"!==(w=Se(e))&&"number"!==w||(e=new r(e)),"string"!==(S=Se(t))&&"number"!==S||(t=new r(t)),a=(M=e.lab())[0],c=M[1],l=M[2],s=(C=t.lab())[0],u=C[1],h=C[2],p=_e(c*c+l*l),d=_e(u*u+h*h),T=a<16?.511:.040975*a/(1+.01765*a),P=.0638*p/(1+.0131*p)+.638,_=p<1e-6?0:180*m(l,c)/o;_<0;)_+=360;for(;_>=360;)_-=360;return I=_>=164&&_<=345?.56+f(.2*A(o*(_+168)/180)):.36+f(.4*A(o*(_+35)/180)),x=_e((g=p*p*p*p)/(g+1900)),_e((E=(a-s)/(i*T))*E+(D=(b=p-d)/(n*P))*D+((v=c-u)*v+(y=l-h)*y-b*b)/((L=P*(x*I+1-x))*L))},r.prototype.get=function(e){var t,r,i,n,o;return this,i=(n=e.split("."))[0],t=n[1],o=this[i](),t?(r=i.indexOf(t))>-1?o[r]:console.warn("unknown channel "+t+" in mode "+i):o},r.prototype.set=function(e,t){var r,i,n,o,a;if(this,n=(o=e.split("."))[0],r=o[1])if(a=this[n](),(i=n.indexOf(r))>-1)if("string"===Se(t))switch(t.charAt(0)){case"+":case"-":a[i]+=+t;break;case"*":a[i]*=+t.substr(1);break;case"/":a[i]/=+t.substr(1);break;default:a[i]=+t}else a[i]=t;else console.warn("unknown channel "+r+" in mode "+n);else a=t;return _(a,n).alpha(this.alpha())},r.prototype.clipped=function(){return this._rgb._clipped||!1},r.prototype.alpha=function(e){return arguments.length?_.rgb([this._rgb[0],this._rgb[1],this._rgb[2],e]):this._rgb[3]},r.prototype.darken=function(e){var t;return null==e&&(e=1),this,(t=this.lab())[0]-=n.Kn*e,_.lab(t).alpha(this.alpha())},r.prototype.brighten=function(e){return null==e&&(e=1),this.darken(-e)},r.prototype.darker=r.prototype.darken,r.prototype.brighter=r.prototype.brighten,r.prototype.saturate=function(e){var t;return null==e&&(e=1),this,(t=this.lch())[1]+=e*n.Kn,t[1]<0&&(t[1]=0),_.lch(t).alpha(this.alpha())},r.prototype.desaturate=function(e){return null==e&&(e=1),this.saturate(-e)},r.prototype.premultiply=function(){var e,t;return t=this.rgb(),e=this.alpha(),_(t[0]*e,t[1]*e,t[2]*e,e)},T=function(e){return function(t,r){var i,n,o;for(o=[],i=n=0;n<=3;i=++n)o[i]=e(t[i],r[i]);return o}},J=function(e,t){return e*t/255},C=function(e,t){return e>t?t:e},q=function(e,t){return e>t?e:t},be=function(e,t){return 255*(1-(1-e/255)*(1-t/255))},te=function(e,t){return t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255))},x=function(e,t){return 255*(1-(1-t/255)/(e/255))},P=function(e,t){return 255===e||(e=t/255*255/(1-e/255))>255?255:e},(v=function(e,t,r){if(!v[r])throw"unknown blend mode "+r;return v[r](e,t)}).normal=(y=function(e){return function(t,r){var i,n;return i=_(r).rgb(),n=_(t).rgb(),_(e(i,n),"rgb")}})(T((function(e,t){return e}))),v.multiply=y(T(J)),v.screen=y(T(be)),v.overlay=y(T(te)),v.darken=y(T(C)),v.lighten=y(T(q)),v.dodge=y(T(P)),v.burn=y(T(x)),_.blend=v,_.analyze=function(e){var t,r,i,n;for(i={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},r=0,t=e.length;ri.max&&(i.max=n),i.count+=1);return i.domain=[i.min,i.max],i.limits=function(e,t){return _.limits(i,e,t)},i},_.scale=function(e,t){var r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b,x,w,S;return l="rgb",h=_("#ccc"),m=0,a=[0,1],f=[],d=[0,0],r=!1,n=[],p=!1,u=0,c=1,o=!1,i={},g=!0,s=1,w=function(e){var t,r,i,o,a,s;if(null==e&&(e=["#fff","#000"]),null!=e&&"string"===Se(e)&&null!=_.brewer&&(e=_.brewer[e]||_.brewer[e.toLowerCase()]||e),"array"===Se(e)){for(1===e.length&&(e=[e[0],e[0]]),t=i=0,o=(e=e.slice(0)).length-1;0<=o?i<=o:i>=o;t=0<=o?++i:--i)r=e[t],"string"===Se(r)&&(e[t]=_(r));for(f.length=0,t=s=0,a=e.length-1;0<=a?s<=a:s>=a;t=0<=a?++s:--s)f.push(t/(e.length-1))}return x(),n=e},y=function(e){var t,i;if(null!=r){for(i=r.length-1,t=0;t=r[t];)t++;return t-1}return 0},S=function(e){return e},b=function(e,t){var o,a,p,m,v,b,x;if(null==t&&(t=!1),isNaN(e)||null===e)return h;if(x=t?e:r&&r.length>2?y(e)/(r.length-2):c!==u?(e-u)/(c-u):1,t||(x=S(x)),1!==s&&(x=re(x,s)),x=d[0]+x*(1-d[0]-d[1]),x=Math.min(1,Math.max(0,x)),p=Math.floor(1e4*x),g&&i[p])o=i[p];else{if("array"===Se(n))for(a=m=0,b=f.length-1;0<=b?m<=b:m>=b;a=0<=b?++m:--m){if(x<=(v=f[a])){o=n[a];break}if(x>=v&&a===f.length-1){o=n[a];break}if(x>v&&x=l;t=0<=l?++h:--h)f.push(t/(i-1));return a=[u,c],v},v.mode=function(e){return arguments.length?(l=e,x(),v):l},v.range=function(e,t){return w(e),v},v.out=function(e){return p=e,v},v.spread=function(e){return arguments.length?(m=e,v):m},v.correctLightness=function(e){return null==e&&(e=!0),o=e,x(),S=o?function(e){var t,r,i,n,o,a,s,c,u;for(t=b(0,!0).lab()[0],r=b(1,!0).lab()[0],s=t>r,i=b(e,!0).lab()[0],n=i-(o=t+(r-t)*e),c=0,u=1,a=20;Math.abs(n)>.01&&a-- >0;)s&&(n*=-1),n<0?(c=e,e+=.5*(u-e)):(u=e,e+=.5*(c-e)),i=b(e,!0).lab()[0],n=i-o;return e}:function(e){return e},v},v.padding=function(e){return null!=e?("number"===Se(e)&&(e=[e,e]),d=e,v):d},v.colors=function(t,i){var o,s,c,u,l,h,p,d;if(arguments.length<2&&(i="hex"),l=[],0===arguments.length)l=n.slice(0);else if(1===t)l=[v(.5)];else if(t>1)s=a[0],o=a[1]-s,l=function(){h=[];for(var e=0;0<=t?et;0<=t?e++:e--)h.push(e);return h}.apply(this).map((function(e){return v(s+e/(t-1)*o)}));else{if(e=[],p=[],r&&r.length>2)for(c=d=1,u=r.length;1<=u?du;c=1<=u?++d:--d)p.push(.5*(r[c-1]+r[c]));else p=a;l=p.map((function(e){return v(e)}))}return _[i]&&(l=l.map((function(e){return e[i]()}))),l},v.cache=function(e){return null!=e?(g=e,v):g},v.gamma=function(e){return null!=e?(s=e,v):s},v.nodata=function(e){return null!=e?(h=_(e),v):h},v},null==_.scales&&(_.scales={}),_.scales.cool=function(){return _.scale([_.hsl(180,1,.9),_.hsl(250,.7,.4)])},_.scales.hot=function(){return _.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},_.analyze=function(e,t,r){var i,n,o,a,s,c;if(s={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==r&&(r=function(){return!0}),i=function(e){null==e||isNaN(e)||(s.values.push(e),s.sum+=e,es.max&&(s.max=e),s.count+=1)},c=function(e,n){if(r(e,n))return null!=t&&"function"===Se(t)?i(t(e)):null!=t&&"string"===Se(t)||"number"===Se(t)?i(e[t]):i(e)},"array"===Se(e))for(a=0,o=e.length;a=U;A=1<=U?++N:--N)P.push(E+A/r*(Q-E));P.push(Q)}else if("l"===t.substr(0,1)){if(E<=0)throw"Logarithmic scales are only possible for values > 0";for(D=Math.LOG10E*Y(E),T=Math.LOG10E*Y(Q),P.push(E),A=ue=1,j=r-1;1<=j?ue<=j:ue>=j;A=1<=j?++ue:--ue)P.push(re(10,D+A/r*(T-D)));P.push(Q)}else if("q"===t.substr(0,1)){for(P.push(E),A=i=1,q=r-1;1<=q?i<=q:i>=q;A=1<=q?++i:--i)B=(ce.length-1)*A/r,(F=I(B))===B?P.push(ce[F]):(z=B-F,P.push(ce[F]*(1-z)+ce[F+1]*z));P.push(Q)}else if("k"===t.substr(0,1)){for(O=ce.length,v=new Array(O),w=new Array(r),ne=!0,R=0,b=null,(b=[]).push(E),A=n=1,X=r-1;1<=X?n<=X:n>=X;A=1<=X?++n:--n)b.push(E+A/r*(Q-E));for(b.push(Q);ne;){for(M=o=0,Z=r-1;0<=Z?o<=Z:o>=Z;M=0<=Z?++o:--o)w[M]=0;for(A=a=0,K=O-1;0<=K?a<=K:a>=K;A=0<=K?++a:--a){for(se=ce[A],L=Number.MAX_VALUE,M=s=0,J=r-1;0<=J?s<=J:s>=J;M=0<=J?++s:--s)(S=f(b[M]-se))=ee;M=0<=ee?++c:--c)k[M]=null;for(A=u=0,te=O-1;0<=te?u<=te:u>=te;A=0<=te?++u:--u)null===k[x=v[A]]?k[x]=ce[A]:k[x]+=ce[A];for(M=l=0,ie=r-1;0<=ie?l<=ie:l>=ie;M=0<=ie?++l:--l)k[M]*=1/w[M];for(ne=!1,M=h=0,G=r-1;0<=G?h<=G:h>=G;M=0<=G?++h:--h)if(k[M]!==b[A]){ne=!0;break}b=k,++R>200&&(ne=!1)}for(C={},M=p=0,V=r-1;0<=V?p<=V:p>=V;M=0<=V?++p:--p)C[M]=[];for(A=d=0,$=O-1;0<=$?d<=$:d>=$;A=0<=$?++d:--d)C[x=v[A]].push(ce[A]);for(oe=[],M=m=0,H=r-1;0<=H?m<=H:m>=H;M=0<=H?++m:--m)oe.push(C[M][0]),oe.push(C[M][C[M].length-1]);for(oe=oe.sort((function(e,t){return e-t})),P.push(oe[0]),A=g=1,W=oe.length-1;g<=W;A=g+=2)ae=oe[A],isNaN(ae)||-1!==P.indexOf(ae)||P.push(ae)}return P},L=function(e,t,r){var i,n,o,s;return e=(i=Ae(arguments))[0],t=i[1],r=i[2],isNaN(e)&&(e=0),(e/=360)<1/3?o=1-((n=(1-t)/3)+(s=(1+t*A(c*e)/A(a-c*e))/3)):e<2/3?n=1-((s=(1-t)/3)+(o=(1+t*A(c*(e-=1/3))/A(a-c*e))/3)):s=1-((o=(1-t)/3)+(n=(1+t*A(c*(e-=2/3))/A(a-c*e))/3)),[255*(s=X(r*s*3)),255*(o=X(r*o*3)),255*(n=X(r*n*3)),i.length>3?i[3]:1]},se=function(){var e,t,r,i,n,o,a;return n=(o=Ae(arguments))[0],t=o[1],e=o[2],c=2*Math.PI,n/=255,t/=255,e/=255,0===(a=1-Math.min(n,t,e)/(i=(n+t+e)/3))?r=0:(r=(n-t+(n-e))/2,r/=Math.sqrt((n-t)*(n-t)+(n-e)*(t-e)),r=Math.acos(r),e>t&&(r=c-r),r/=c),[360*r,a,i]},_.hsi=function(){return function(e,t,r){r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return Object(n)===n?n:i}(r,Te.call(arguments).concat(["hsi"]),(function(){}))},p.hsi=L,r.prototype.hsi=function(){return se(this._rgb)},B=function(e,t,r,i){var n,o,a,s,c,u,l,h,p,d;return"hsl"===i?(p=e.hsl(),d=t.hsl()):"hsv"===i?(p=e.hsv(),d=t.hsv()):"hcg"===i?(p=e.hcg(),d=t.hcg()):"hsi"===i?(p=e.hsi(),d=t.hsi()):"lch"!==i&&"hcl"!==i||(i="hcl",p=e.hcl(),d=t.hcl()),"h"===i.substr(0,1)&&(o=p[0],l=p[1],s=p[2],a=d[0],h=d[1],c=d[2]),isNaN(o)||isNaN(a)?isNaN(o)?isNaN(a)?n=Number.NaN:(n=a,1!==s&&0!==s||"hsv"===i||(u=h)):(n=o,1!==c&&0!==c||"hsv"===i||(u=l)):n=o+r*(a>o&&a-o>180?a-(o+360):a180?a+360-o:a-o),null==u&&(u=l+r*(h-l)),_[i](n,u,s+r*(c-s))},U=function(e,t,r,i){var n,o;return n=e.num(),o=t.num(),_.num(n+(o-n)*r,"num")},(d=d.concat(function(){var e,t,r,i;for(i=[],t=0,e=(r=["hsv","hsl","hsi","hcl","lch","hcg"]).length;t>16&255)/255,t[r+1]=(e>>8&255)/255,t[r+2]=(255&e)/255,t},sa.prototype.atomColorToArray=function(e,t,r){return this.colorToArray(this.atomColor?this.atomColor(e):0,t,r)},sa.prototype.bondColor=function(e,t){return this.atomProxy&&this.atomColor?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):0},sa.prototype.bondColorToArray=function(e,t,r,i){return this.colorToArray(this.bondColor(e,t),r,i)},sa.prototype.volumeColorToArray=function(e,t,r){return this.colorToArray(this.volumeColor?this.volumeColor(e):0,t,r)},sa.prototype.positionColorToArray=function(e,t,r){return this.colorToArray(this.positionColor?this.positionColor(e):0,t,r)};var ca,ua=ta((function(e){ + ColorBrewer colors for chroma.js + + Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The + Pennsylvania State University. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. See the License for the + specific language governing permissions and limitations under the License. + + @preserve + */ +_.brewer=x={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},function(){var e,t;for(e in t=[],x)t.push(x[e.toLowerCase()]=x[e])}(),_.colors=Me={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},V=function(){var e,t,i,n,s,o,a;return n=(t=Ae(arguments))[0],e=t[1],i=t[2],o=(n+16)/116,s=isNaN(e)?o:o+e/500,a=isNaN(i)?o:o-i/200,o=r.Yn*H(o),s=r.Xn*H(s),a=r.Zn*H(a),[Pe(3.2404542*s-1.5371385*o-.4985314*a),Pe(-.969266*s+1.8760108*o+.041556*a),i=Pe(.0556434*s-.2040259*o+1.0572252*a),t.length>3?t[3]:1]},Pe=function(e){return 255*(e<=.00304?12.92*e:1.055*ie(e,1/2.4)-.055)},H=function(e){return e>r.t1?e*e*e:r.t2*(e-r.t0)},r={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},he=function(){var e,t,i,n,r,s,o;return i=(n=Ae(arguments))[0],t=n[1],e=n[2],s=(r=pe(i,t,e))[0],[116*(o=r[1])-16,500*(s-o),200*(o-r[2])]},ge=function(e){return(e/=255)<=.04045?e/12.92:ie((e+.055)/1.055,2.4)},Ce=function(e){return e>r.t3?ie(e,1/3):e/r.t2+r.t0},pe=function(){var e,t,i,n;return i=(n=Ae(arguments))[0],t=n[1],e=n[2],i=ge(i),t=ge(t),e=ge(e),[Ce((.4124564*i+.3575761*t+.1804375*e)/r.Xn),Ce((.2126729*i+.7151522*t+.072175*e)/r.Yn),Ce((.0193339*i+.119192*t+.9503041*e)/r.Zn)]},_.lab=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["lab"]),(function(){}))},d.lab=V,i.prototype.lab=function(){return he(this._rgb)},g=function(e){var t,i,n,r,s,o,a,c,l,h,u;return 2===(e=function(){var t,i,n;for(n=[],i=0,t=e.length;i=0&&t[3]<=1?"rgb":void 0}}),d.lrgb=d.rgb,z=function(e,t,n,r){var s,o;return s=e._rgb,o=t._rgb,new i(_e(ie(s[0],2)*(1-n)+ie(o[0],2)*n),_e(ie(s[1],2)*(1-n)+ie(o[1],2)*n),_e(ie(s[2],2)*(1-n)+ie(o[2],2)*n),r)},l=function(e){var t,n,r,s,o;for(t=1/e.length,o=[0,0,0,0],r=0,n=e.length;r1&&(o[3]=1),new i(w(o))},f.push(["lrgb",z]),_.average=function(e,t){var i,n,r,o,a,c,h,u,d,f,m,g,v;if(null==t&&(t="rgb"),d=e.length,e=e.map((function(e){return _(e)})),h=e.splice(0,1)[0],"lrgb"===t)return l(e);for(u in o=[],a=0,c=0,g=h.get(t))g[u]=g[u]||0,o.push(isNaN(g[u])?0:1),"h"!==t.charAt(u)||isNaN(g[u])||(i=g[u]/180*s,a+=A(i),c+=be(i));for(n=h.alpha(),m=0,f=e.length;m=360;)i-=360;g[u]=i}else g[u]=g[u]/o[u];return _(g,t).alpha(n/d)},D=function(e){var t,i;if(e.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return 4!==e.length&&7!==e.length||(e=e.substr(1)),3===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]),[(i=parseInt(e,16))>>16,i>>8&255,255&i,1];if(e.match(/^#?([A-Fa-f0-9]{8})$/))return 9===e.length&&(e=e.substr(1)),[(i=parseInt(e,16))>>24&255,i>>16&255,i>>8&255,ye((255&i)/255*100)/100];if(null!=d.css&&(t=d.css(e)))return t;throw"unknown color: "+e},oe=function(e,t){var i,n,r,s,o,a;return null==t&&(t="auto"),o=e[0],r=e[1],n=e[2],i=e[3],"auto"===t&&(t=i<1?"rgba":"rgb"),o=Math.round(o),r=Math.round(r),n=Math.round(n),a=(a="000000"+(o<<16|r<<8|n).toString(16)).substr(a.length-6),s=(s="0"+ye(255*i).toString(16)).substr(s.length-2),"#"+function(){switch(t.toLowerCase()){case"rgba":return a+s;case"argb":return s+a;default:return a}}()},d.hex=function(e){return D(e)},_.hex=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["hex"]),(function(){}))},i.prototype.hex=function(e){return null==e&&(e="auto"),oe(this._rgb,e)},h.push({p:4,test:function(e){if(1===arguments.length&&"string"===Se(e))return"hex"}}),k=function(){var e,t,i,n,r,s,o,a,c,l,h,u,d,f;if(r=(e=Ae(arguments))[0],h=e[1],o=e[2],0===h)c=n=t=255*o;else{for(i=[0,0,0],u=2*o-(d=o<.5?o*(1+h):o+h-o*h),(f=[0,0,0])[0]=(r/=360)+1/3,f[1]=r,f[2]=r-1/3,s=a=0;a<=2;s=++a)f[s]<0&&(f[s]+=1),f[s]>1&&(f[s]-=1),6*f[s]<1?i[s]=u+6*(d-u)*f[s]:2*f[s]<1?i[s]=d:3*f[s]<2?i[s]=u+(d-u)*(2/3-f[s])*6:i[s]=u;c=(l=[ye(255*i[0]),ye(255*i[1]),ye(255*i[2])])[0],n=l[1],t=l[2]}return e.length>3?[c,n,t,e[3]]:[c,n,t]},ce=function(e,t,i){var n,r,s,o,a;return void 0!==e&&e.length>=3&&(e=(o=e)[0],t=o[1],i=o[2]),e/=255,t/=255,i/=255,s=Math.min(e,t,i),r=((Q=Math.max(e,t,i))+s)/2,Q===s?(a=0,n=Number.NaN):a=r<.5?(Q-s)/(Q+s):(Q-s)/(2-Q-s),e===Q?n=(t-i)/(Q-s):t===Q?n=2+(i-e)/(Q-s):i===Q&&(n=4+(e-t)/(Q-s)),(n*=60)<0&&(n+=360),[n,a,r]},_.hsl=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["hsl"]),(function(){}))},d.hsl=k,i.prototype.hsl=function(){return ce(this._rgb)},O=function(){var e,t,i,n,r,s,o,a,c,l,h,u,d,f,m,p,g,v;if(r=(e=Ae(arguments))[0],p=e[1],v=e[2],v*=255,0===p)c=n=t=v;else switch(360===r&&(r=0),r>360&&(r-=360),r<0&&(r+=360),o=v*(1-p),a=v*(1-p*(i=(r/=60)-(s=I(r)))),g=v*(1-p*(1-i)),s){case 0:c=(l=[v,g,o])[0],n=l[1],t=l[2];break;case 1:c=(h=[a,v,o])[0],n=h[1],t=h[2];break;case 2:c=(u=[o,v,g])[0],n=u[1],t=u[2];break;case 3:c=(d=[o,a,v])[0],n=d[1],t=d[2];break;case 4:c=(f=[g,o,v])[0],n=f[1],t=f[2];break;case 5:c=(m=[v,o,a])[0],n=m[1],t=m[2]}return[c,n,t,e.length>3?e[3]:1]},le=function(){var e,t,i,n,r,s,o,a,c;return s=(o=Ae(arguments))[0],i=o[1],e=o[2],r=Math.min(s,i,e),t=(Q=Math.max(s,i,e))-r,c=Q/255,0===Q?(n=Number.NaN,a=0):(a=t/Q,s===Q&&(n=(i-e)/t),i===Q&&(n=2+(e-s)/t),e===Q&&(n=4+(s-i)/t),(n*=60)<0&&(n+=360)),[n,a,c]},_.hsv=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["hsv"]),(function(){}))},d.hsv=O,i.prototype.hsv=function(){return le(this._rgb)},ee=function(e){return"number"===Se(e)&&e>=0&&e<=16777215?[e>>16,e>>8&255,255&e,1]:(console.warn("unknown num color: "+e),[0,0,0,1])},fe=function(){var e;return((e=Ae(arguments))[0]<<16)+(e[1]<<8)+e[2]},_.num=function(e){return new i(e,"num")},i.prototype.num=function(e){return null==e&&(e="rgb"),fe(this._rgb,e)},d.num=ee,h.push({p:1,test:function(e){if(1===arguments.length&&"number"===Se(e)&&e>=0&&e<=16777215)return"num"}}),E=function(){var e,t,i,n,r,s,o,a,c,l,h,u,d,f,m,p,g,v,y,x;if(a=(i=Ae(arguments))[0],r=i[1],t=i[2],o=o/100*255,e=255*(r/=100),0===r)u=o=n=t;else switch(360===a&&(a=0),a>360&&(a-=360),a<0&&(a+=360),h=(l=t*(1-r))+e*(1-(s=(a/=60)-(c=I(a)))),y=l+e*s,x=l+e,c){case 0:u=(d=[x,y,l])[0],o=d[1],n=d[2];break;case 1:u=(f=[h,x,l])[0],o=f[1],n=f[2];break;case 2:u=(m=[l,x,y])[0],o=m[1],n=m[2];break;case 3:u=(p=[l,h,x])[0],o=p[1],n=p[2];break;case 4:u=(g=[y,l,x])[0],o=g[1],n=g[2];break;case 5:u=(v=[x,l,h])[0],o=v[1],n=v[2]}return[u,o,n,i.length>3?i[3]:1]},se=function(){var e,t,i,n,r,s,o,a,c;return a=(c=Ae(arguments))[0],r=c[1],t=c[2],o=Math.min(a,r,t),i=100*(n=(Q=Math.max(a,r,t))-o)/255,e=o/(255-n)*100,0===n?s=Number.NaN:(a===Q&&(s=(r-t)/n),r===Q&&(s=2+(t-a)/n),t===Q&&(s=4+(a-r)/n),(s*=60)<0&&(s+=360)),[s,i,e]},_.hcg=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["hcg"]),(function(){}))},d.hcg=E,i.prototype.hcg=function(){return se(this._rgb)},M=function(e){var t,i,n,r,s,o,a,c;if(e=e.toLowerCase(),null!=_.colors&&_.colors[e])return D(_.colors[e]);if(s=e.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(a=s.slice(1,4),r=o=0;o<=2;r=++o)a[r]=+a[r];a[3]=1}else if(s=e.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(a=s.slice(1,5),r=c=0;c<=3;r=++c)a[r]=+a[r];else if(s=e.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(a=s.slice(1,4),r=t=0;t<=2;r=++t)a[r]=ye(2.55*a[r]);a[3]=1}else if(s=e.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(a=s.slice(1,5),r=i=0;i<=2;r=++i)a[r]=ye(2.55*a[r]);a[3]=+a[3]}else(s=e.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?((n=s.slice(1,4))[1]*=.01,n[2]*=.01,(a=k(n))[3]=1):(s=e.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&((n=s.slice(1,4))[1]*=.01,n[2]*=.01,(a=k(n))[3]=+s[4]);return a},re=function(e){var t;return"rgb"===(t=e[3]<1?"rgba":"rgb")?t+"("+e.slice(0,3).map(ye).join(",")+")":"rgba"===t?t+"("+e.slice(0,3).map(ye).join(",")+","+e[3]+")":void 0},ve=function(e){return ye(100*e)/100},R=function(e,t){var i;return i=t<1?"hsla":"hsl",e[0]=ve(e[0]||0),e[1]=ve(100*e[1])+"%",e[2]=ve(100*e[2])+"%","hsla"===i&&(e[3]=t),i+"("+e.join(",")+")"},d.css=function(e){return M(e)},_.css=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["css"]),(function(){}))},i.prototype.css=function(e){return null==e&&(e="rgb"),"rgb"===e.slice(0,3)?re(this._rgb):"hsl"===e.slice(0,3)?R(this.hsl(),this.alpha()):void 0},d.named=function(e){return D(Me[e])},h.push({p:5,test:function(e){if(1===arguments.length&&null!=Me[e])return"named"}}),i.prototype.name=function(e){var t,i;for(i in arguments.length&&(Me[e]&&(this._rgb=D(Me[e])),this._rgb[3]=1),t=this.hex("rgb"),Me)if(t===Me[i])return i;return t},j=function(){var e,t,i,r;return i=(r=Ae(arguments))[0],e=r[1],t=r[2],[i,A(t*=n)*e,be(t)*e]},W=function(){var e,t,i,n,r,s,o,a,c;return o=(i=Ae(arguments))[0],r=i[1],s=i[2],e=(a=j(o,r,s))[0],t=a[1],n=a[2],[(c=V(e,t,n))[0],c[1],n=c[2],i.length>3?i[3]:1]},G=function(){var e,t,i,n,r,s;return r=(s=Ae(arguments))[0],e=s[1],t=s[2],i=_e(e*e+t*t),n=(p(t,e)*a+360)%360,0===ye(1e4*i)&&(n=Number.NaN),[r,i,n]},ue=function(){var e,t,i,n,r,s,o;return r=(s=Ae(arguments))[0],i=s[1],t=s[2],n=(o=he(r,i,t))[0],e=o[1],t=o[2],G(n,e,t)},_.lch=function(){var e;return e=Ae(arguments),new i(e,"lch")},_.hcl=function(){var e;return e=Ae(arguments),new i(e,"hcl")},d.lch=W,d.hcl=function(){var e,t,i,n;return t=(n=Ae(arguments))[0],e=n[1],i=n[2],W([i,e,t])},i.prototype.lch=function(){return ue(this._rgb)},i.prototype.hcl=function(){return ue(this._rgb).reverse()},ne=function(e){var t,i,n,r,s,o;return null==e&&(e="rgb"),s=(o=Ae(arguments))[0],n=o[1],t=o[2],n/=255,t/=255,[(1-(s/=255)-(r=1-Math.max(s,Math.max(n,t))))*(i=r<1?1/(1-r):0),(1-n-r)*i,(1-t-r)*i,r]},S=function(){var e,t,i,n,r,s;return i=(t=Ae(arguments))[0],r=t[1],s=t[2],n=t[3],e=t.length>4?t[4]:1,1===n?[0,0,0,e]:[i>=1?0:255*(1-i)*(1-n),r>=1?0:255*(1-r)*(1-n),s>=1?0:255*(1-s)*(1-n),e]},d.cmyk=function(){return S(Ae(arguments))},_.cmyk=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["cmyk"]),(function(){}))},i.prototype.cmyk=function(){return ne(this._rgb)},d.gl=function(){var e,t,i,n,r;for(n=function(){var e,i;for(t in i=[],e=Ae(arguments))r=e[t],i.push(r);return i}.apply(this,arguments),e=i=0;i<=2;e=++i)n[e]*=255;return n},_.gl=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["gl"]),(function(){}))},i.prototype.gl=function(){var e;return[(e=this._rgb)[0]/255,e[1]/255,e[2]/255,e[3]]},de=function(e,t,i){var n;return e=(n=Ae(arguments))[0],t=n[1],i=n[2],.2126*(e=Z(e))+.7152*(t=Z(t))+.0722*(i=Z(i))},Z=function(e){return(e/=255)<=.03928?e/12.92:ie((e+.055)/1.055,2.4)},$=function(e,t,n,r){var s,o;return s=e._rgb,o=t._rgb,new i(s[0]+n*(o[0]-s[0]),s[1]+n*(o[1]-s[1]),s[2]+n*(o[2]-s[2]),r)},f.push(["rgb",$]),i.prototype.luminance=function(e,t){var i,n,r,s;return null==t&&(t="rgb"),arguments.length?(r=this._rgb,0===e?r=[0,0,0,this._rgb[3]]:1===e?r=[255,255,255,this[3]]:(i=de(this._rgb),1e-7,n=20,s=function(i,r){var o,a;return o=(a=i.interpolate(r,.5,t)).luminance(),Math.abs(e-o)<1e-7||!n--?a:o>e?s(i,a):s(a,r)},r=i>e?s(_("black"),this).rgba():s(this,_("white")).rgba()),_(r).alpha(this.alpha())):de(this._rgb)},we=function(e){var t,i,n,r;return(r=e/100)<66?(n=255,i=-155.25485562709179-.44596950469579133*(i=r-2)+104.49216199393888*Y(i),t=r<20?0:.8274096064007395*(t=r-10)-254.76935184120902+115.67994401066147*Y(t)):(n=351.97690566805693+.114206453784165*(n=r-55)-40.25366309332127*Y(n),i=325.4494125711974+.07943456536662342*(i=r-50)-28.0852963507957*Y(i),t=255),[n,i,t]},me=function(){var e,t,i,n,r,s,o;for(n=(r=Ae(arguments))[0],e=r[2],i=1e3,t=4e4,.4;t-i>.4;)(s=we(o=.5*(t+i)))[2]/s[0]>=e/n?t=o:i=o;return ye(o)},_.temperature=_.kelvin=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["temperature"]),(function(){}))},d.temperature=d.kelvin=d.K=we,i.prototype.temperature=function(){return me(this._rgb)},i.prototype.kelvin=i.prototype.temperature,_.contrast=function(e,t){var n,r,s,o;return"string"!==(s=Se(e))&&"number"!==s||(e=new i(e)),"string"!==(o=Se(t))&&"number"!==o||(t=new i(t)),(n=e.luminance())>(r=t.luminance())?(n+.05)/(r+.05):(r+.05)/(n+.05)},_.distance=function(e,t,n){var r,s,o,a,c,l,h;for(s in null==n&&(n="lab"),"string"!==(c=Se(e))&&"number"!==c||(e=new i(e)),"string"!==(l=Se(t))&&"number"!==l||(t=new i(t)),o=e.get(n),a=t.get(n),h=0,o)h+=(r=(o[s]||0)-(a[s]||0))*r;return Math.sqrt(h)},_.deltaE=function(e,t,n,r){var o,a,c,l,h,u,d,f,g,v,y,x,b,_,w,S,M,C,P,T,I,E,D,L;for(null==n&&(n=1),null==r&&(r=1),"string"!==(w=Se(e))&&"number"!==w||(e=new i(e)),"string"!==(S=Se(t))&&"number"!==S||(t=new i(t)),o=(M=e.lab())[0],c=M[1],h=M[2],a=(C=t.lab())[0],l=C[1],u=C[2],d=_e(c*c+h*h),f=_e(l*l+u*u),T=o<16?.511:.040975*o/(1+.01765*o),P=.0638*d/(1+.0131*d)+.638,_=d<1e-6?0:180*p(h,c)/s;_<0;)_+=360;for(;_>=360;)_-=360;return I=_>=164&&_<=345?.56+m(.2*A(s*(_+168)/180)):.36+m(.4*A(s*(_+35)/180)),b=_e((g=d*d*d*d)/(g+1900)),_e((E=(o-a)/(n*T))*E+(D=(x=d-f)/(r*P))*D+((v=c-l)*v+(y=h-u)*y-x*x)/((L=P*(b*I+1-b))*L))},i.prototype.get=function(e){var t,i,n,r,s;return this,n=(r=e.split("."))[0],t=r[1],s=this[n](),t?(i=n.indexOf(t))>-1?s[i]:console.warn("unknown channel "+t+" in mode "+n):s},i.prototype.set=function(e,t){var i,n,r,s,o;if(this,r=(s=e.split("."))[0],i=s[1])if(o=this[r](),(n=r.indexOf(i))>-1)if("string"===Se(t))switch(t.charAt(0)){case"+":case"-":o[n]+=+t;break;case"*":o[n]*=+t.substr(1);break;case"/":o[n]/=+t.substr(1);break;default:o[n]=+t}else o[n]=t;else console.warn("unknown channel "+i+" in mode "+r);else o=t;return _(o,r).alpha(this.alpha())},i.prototype.clipped=function(){return this._rgb._clipped||!1},i.prototype.alpha=function(e){return arguments.length?_.rgb([this._rgb[0],this._rgb[1],this._rgb[2],e]):this._rgb[3]},i.prototype.darken=function(e){var t;return null==e&&(e=1),this,(t=this.lab())[0]-=r.Kn*e,_.lab(t).alpha(this.alpha())},i.prototype.brighten=function(e){return null==e&&(e=1),this.darken(-e)},i.prototype.darker=i.prototype.darken,i.prototype.brighter=i.prototype.brighten,i.prototype.saturate=function(e){var t;return null==e&&(e=1),this,(t=this.lch())[1]+=e*r.Kn,t[1]<0&&(t[1]=0),_.lch(t).alpha(this.alpha())},i.prototype.desaturate=function(e){return null==e&&(e=1),this.saturate(-e)},i.prototype.premultiply=function(){var e,t;return t=this.rgb(),e=this.alpha(),_(t[0]*e,t[1]*e,t[2]*e,e)},J=function(e,t){return e*t/255},C=function(e,t){return e>t?t:e},q=function(e,t){return e>t?e:t},xe=function(e,t){return 255*(1-(1-e/255)*(1-t/255))},te=function(e,t){return t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255))},b=function(e,t){return 255*(1-(1-t/255)/(e/255))},P=function(e,t){return 255===e||(e=t/255*255/(1-e/255))>255?255:e},(v=function(e,t,i){if(!v[i])throw"unknown blend mode "+i;return v[i](e,t)}).normal=(y=function(e){return function(t,i){var n,r;return n=_(i).rgb(),r=_(t).rgb(),_(e(n,r),"rgb")}})((T=function(e){return function(t,i){var n,r,s;for(s=[],n=r=0;r<=3;n=++r)s[n]=e(t[n],i[n]);return s}})((function(e,t){return e}))),v.multiply=y(T(J)),v.screen=y(T(xe)),v.overlay=y(T(te)),v.darken=y(T(C)),v.lighten=y(T(q)),v.dodge=y(T(P)),v.burn=y(T(b)),_.blend=v,_.analyze=function(e){var t,i,n,r;for(n={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},i=0,t=e.length;in.max&&(n.max=r),n.count+=1);return n.domain=[n.min,n.max],n.limits=function(e,t){return _.limits(n,e,t)},n},_.scale=function(e,t){var i,n,r,s,o,a,c,l,h,u,d,f,m,p,g,v,y,x,b,w,S;return h="rgb",u=_("#ccc"),p=0,o=[0,1],m=[],f=[0,0],i=!1,r=[],d=!1,l=0,c=1,s=!1,n={},g=!0,a=1,w=function(e){var t,i,n,s,o,a;if(null==e&&(e=["#fff","#000"]),null!=e&&"string"===Se(e)&&null!=_.brewer&&(e=_.brewer[e]||_.brewer[e.toLowerCase()]||e),"array"===Se(e)){for(1===e.length&&(e=[e[0],e[0]]),t=n=0,s=(e=e.slice(0)).length-1;0<=s?n<=s:n>=s;t=0<=s?++n:--n)i=e[t],"string"===Se(i)&&(e[t]=_(i));for(m.length=0,t=a=0,o=e.length-1;0<=o?a<=o:a>=o;t=0<=o?++a:--a)m.push(t/(e.length-1))}return b(),r=e},y=function(e){var t,n;if(null!=i){for(n=i.length-1,t=0;t=i[t];)t++;return t-1}return 0},S=function(e){return e},x=function(e,t){var s,o,d,p,v,x,b;if(null==t&&(t=!1),isNaN(e)||null===e)return u;if(b=t?e:i&&i.length>2?y(e)/(i.length-2):c!==l?(e-l)/(c-l):1,t||(b=S(b)),1!==a&&(b=ie(b,a)),b=f[0]+b*(1-f[0]-f[1]),b=Math.min(1,Math.max(0,b)),d=Math.floor(1e4*b),g&&n[d])s=n[d];else{if("array"===Se(r))for(o=p=0,x=m.length-1;0<=x?p<=x:p>=x;o=0<=x?++p:--p){if(b<=(v=m[o])){s=r[o];break}if(b>=v&&o===m.length-1){s=r[o];break}if(b>v&&b=h;t=0<=h?++u:--u)m.push(t/(n-1));return o=[l,c],v},v.mode=function(e){return arguments.length?(h=e,b(),v):h},v.range=function(e,t){return w(e),v},v.out=function(e){return d=e,v},v.spread=function(e){return arguments.length?(p=e,v):p},v.correctLightness=function(e){return null==e&&(e=!0),s=e,b(),S=s?function(e){var t,i,n,r,s,o,a,c,l;for(t=x(0,!0).lab()[0],i=x(1,!0).lab()[0],a=t>i,n=x(e,!0).lab()[0],r=n-(s=t+(i-t)*e),c=0,l=1,o=20;Math.abs(r)>.01&&o-- >0;)a&&(r*=-1),r<0?(c=e,e+=.5*(l-e)):(l=e,e+=.5*(c-e)),n=x(e,!0).lab()[0],r=n-s;return e}:function(e){return e},v},v.padding=function(e){return null!=e?("number"===Se(e)&&(e=[e,e]),f=e,v):f},v.colors=function(t,n){var s,a,c,l,h,u,d,f;if(arguments.length<2&&(n="hex"),h=[],0===arguments.length)h=r.slice(0);else if(1===t)h=[v(.5)];else if(t>1)a=o[0],s=o[1]-a,h=function(){u=[];for(var e=0;0<=t?et;0<=t?e++:e--)u.push(e);return u}.apply(this).map((function(e){return v(a+e/(t-1)*s)}));else{if(e=[],d=[],i&&i.length>2)for(c=f=1,l=i.length;1<=l?fl;c=1<=l?++f:--f)d.push(.5*(i[c-1]+i[c]));else d=o;h=d.map((function(e){return v(e)}))}return _[n]&&(h=h.map((function(e){return e[n]()}))),h},v.cache=function(e){return null!=e?(g=e,v):g},v.gamma=function(e){return null!=e?(a=e,v):a},v.nodata=function(e){return null!=e?(u=_(e),v):u},v},null==_.scales&&(_.scales={}),_.scales.cool=function(){return _.scale([_.hsl(180,1,.9),_.hsl(250,.7,.4)])},_.scales.hot=function(){return _.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},_.analyze=function(e,t,i){var n,r,s,o,a,c;if(a={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==i&&(i=function(){return!0}),n=function(e){null==e||isNaN(e)||(a.values.push(e),a.sum+=e,ea.max&&(a.max=e),a.count+=1)},c=function(e,r){if(i(e,r))return null!=t&&"function"===Se(t)?n(t(e)):null!=t&&"string"===Se(t)||"number"===Se(t)?n(e[t]):n(e)},"array"===Se(e))for(o=0,s=e.length;o=U;A=1<=U?++B:--B)P.push(E+A/i*(Q-E));P.push(Q)}else if("l"===t.substr(0,1)){if(E<=0)throw"Logarithmic scales are only possible for values > 0";for(D=Math.LOG10E*Y(E),T=Math.LOG10E*Y(Q),P.push(E),A=le=1,$=i-1;1<=$?le<=$:le>=$;A=1<=$?++le:--le)P.push(ie(10,D+A/i*(T-D)));P.push(Q)}else if("q"===t.substr(0,1)){for(P.push(E),A=n=1,q=i-1;1<=q?n<=q:n>=q;A=1<=q?++n:--n)N=(ce.length-1)*A/i,(F=I(N))===N?P.push(ce[F]):(z=N-F,P.push(ce[F]*(1-z)+ce[F+1]*z));P.push(Q)}else if("k"===t.substr(0,1)){for(R=ce.length,v=new Array(R),w=new Array(i),re=!0,k=0,x=null,(x=[]).push(E),A=r=1,X=i-1;1<=X?r<=X:r>=X;A=1<=X?++r:--r)x.push(E+A/i*(Q-E));for(x.push(Q);re;){for(M=s=0,Z=i-1;0<=Z?s<=Z:s>=Z;M=0<=Z?++s:--s)w[M]=0;for(A=o=0,K=R-1;0<=K?o<=K:o>=K;A=0<=K?++o:--o){for(ae=ce[A],L=Number.MAX_VALUE,M=a=0,J=i-1;0<=J?a<=J:a>=J;M=0<=J?++a:--a)(S=m(x[M]-ae))=ee;M=0<=ee?++c:--c)O[M]=null;for(A=l=0,te=R-1;0<=te?l<=te:l>=te;A=0<=te?++l:--l)null===O[b=v[A]]?O[b]=ce[A]:O[b]+=ce[A];for(M=h=0,ne=i-1;0<=ne?h<=ne:h>=ne;M=0<=ne?++h:--h)O[M]*=1/w[M];for(re=!1,M=u=0,G=i-1;0<=G?u<=G:u>=G;M=0<=G?++u:--u)if(O[M]!==x[A]){re=!0;break}x=O,++k>200&&(re=!1)}for(C={},M=d=0,V=i-1;0<=V?d<=V:d>=V;M=0<=V?++d:--d)C[M]=[];for(A=f=0,H=R-1;0<=H?f<=H:f>=H;A=0<=H?++f:--f)C[b=v[A]].push(ce[A]);for(se=[],M=p=0,j=i-1;0<=j?p<=j:p>=j;M=0<=j?++p:--p)se.push(C[M][0]),se.push(C[M][C[M].length-1]);for(se=se.sort((function(e,t){return e-t})),P.push(se[0]),A=g=1,W=se.length-1;g<=W;A=g+=2)oe=se[A],isNaN(oe)||-1!==P.indexOf(oe)||P.push(oe)}return P},L=function(e,t,i){var n,r,s,a;return e=(n=Ae(arguments))[0],t=n[1],i=n[2],isNaN(e)&&(e=0),(e/=360)<1/3?s=1-((r=(1-t)/3)+(a=(1+t*A(c*e)/A(o-c*e))/3)):e<2/3?r=1-((a=(1-t)/3)+(s=(1+t*A(c*(e-=1/3))/A(o-c*e))/3)):a=1-((s=(1-t)/3)+(r=(1+t*A(c*(e-=2/3))/A(o-c*e))/3)),[255*(a=X(i*a*3)),255*(s=X(i*s*3)),255*(r=X(i*r*3)),n.length>3?n[3]:1]},ae=function(){var e,t,i,n,r,s,o;return r=(s=Ae(arguments))[0],t=s[1],e=s[2],c=2*Math.PI,r/=255,t/=255,e/=255,0===(o=1-Math.min(r,t,e)/(n=(r+t+e)/3))?i=0:(i=(r-t+(r-e))/2,i/=Math.sqrt((r-t)*(r-t)+(r-e)*(t-e)),i=Math.acos(i),e>t&&(i=c-i),i/=c),[360*i,o,n]},_.hsi=function(){return function(e,t,i){i.prototype=e.prototype;var n=new i,r=e.apply(n,t);return Object(r)===r?r:n}(i,Te.call(arguments).concat(["hsi"]),(function(){}))},d.hsi=L,i.prototype.hsi=function(){return ae(this._rgb)},N=function(e,t,i,n){var r,s,o,a,c,l,h,u,d,f;return"hsl"===n?(d=e.hsl(),f=t.hsl()):"hsv"===n?(d=e.hsv(),f=t.hsv()):"hcg"===n?(d=e.hcg(),f=t.hcg()):"hsi"===n?(d=e.hsi(),f=t.hsi()):"lch"!==n&&"hcl"!==n||(n="hcl",d=e.hcl(),f=t.hcl()),"h"===n.substr(0,1)&&(s=d[0],h=d[1],a=d[2],o=f[0],u=f[1],c=f[2]),isNaN(s)||isNaN(o)?isNaN(s)?isNaN(o)?r=Number.NaN:(r=o,1!==a&&0!==a||"hsv"===n||(l=u)):(r=s,1!==c&&0!==c||"hsv"===n||(l=h)):r=s+i*(o>s&&o-s>180?o-(s+360):o180?o+360-s:o-s),null==l&&(l=h+i*(u-h)),_[n](r,l,a+i*(c-a))},U=function(e,t,i,n){var r,s;return r=e.num(),s=t.num(),_.num(r+(s-r)*i,"num")},(f=f.concat(function(){var e,t,i,n;for(n=[],t=0,e=(i=["hsv","hsl","hsi","hcl","lch","hcg"]).length;t>16&255)/255,t[i+1]=(e>>8&255)/255,t[i+2]=(255&e)/255,t}atomColorToArray(e,t,i){return this.colorToArray(this.atomColor?this.atomColor(e):0,t,i)}bondColor(e,t){return this.atomProxy&&this.atomColor?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):0}bondColorToArray(e,t,i,n){return this.colorToArray(this.bondColor(e,t),i,n)}volumeColorToArray(e,t,i){return this.colorToArray(this.volumeColor?this.volumeColor(e):0,t,i)}positionColorToArray(e,t,i){return this.colorToArray(this.positionColor?this.positionColor(e):0,t,i)}}var fc,mc=oc((function(e){ /** @license - * JS Signals - * Released under the MIT license - * Author: Miller Medeiros - * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM) - */ -!function(t){function r(e,t,r,i,n){this._listener=t,this._isOnce=r,this.context=i,this._signal=e,this._priority=n||0}function i(e,t){if("function"!=typeof e)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",t))}function n(){this._bindings=[],this._prevParams=null;var e=this;this.dispatch=function(){n.prototype.dispatch.apply(e,arguments)}}r.prototype={active:!0,params:null,execute:function(e){var t,r;return this.active&&this._listener&&(r=this.params?this.params.concat(e):e,t=this._listener.apply(this.context,r),this._isOnce&&this.detach()),t},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},n.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(e,t,i,n){var o,a=this._indexOfListener(e,i);if(-1!==a){if((o=this._bindings[a]).isOnce()!==t)throw new Error("You cannot add"+(t?"":"Once")+"() then add"+(t?"Once":"")+"() the same listener without removing the relationship first.")}else o=new r(this,e,t,i,n),this._addBinding(o);return this.memorize&&this._prevParams&&o.execute(this._prevParams),o},_addBinding:function(e){var t=this._bindings.length;do{--t}while(this._bindings[t]&&e._priority<=this._bindings[t]._priority);this._bindings.splice(t+1,0,e)},_indexOfListener:function(e,t){for(var r,i=this._bindings.length;i--;)if((r=this._bindings[i])._listener===e&&r.context===t)return i;return-1},has:function(e,t){return-1!==this._indexOfListener(e,t)},add:function(e,t,r){return i(e,"add"),this._registerListener(e,!1,t,r)},addOnce:function(e,t,r){return i(e,"addOnce"),this._registerListener(e,!0,t,r)},remove:function(e,t){i(e,"remove");var r=this._indexOfListener(e,t);return-1!==r&&(this._bindings[r]._destroy(),this._bindings.splice(r,1)),e},removeAll:function(){for(var e=this._bindings.length;e--;)this._bindings[e]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(e){if(this.active){var t,r=Array.prototype.slice.call(arguments),i=this._bindings.length;if(this.memorize&&(this._prevParams=r),i){t=this._bindings.slice(),this._shouldPropagate=!0;do{i--}while(t[i]&&this._shouldPropagate&&!1!==t[i].execute(r))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var o=n;o.Signal=n,e.exports?e.exports=o:t.signals=o}(ea)}));!function(e){e[e.PROTEIN=1]="PROTEIN",e[e.NUCLEIC=2]="NUCLEIC",e[e.RNA=3]="RNA",e[e.DNA=4]="DNA",e[e.POLYMER=5]="POLYMER",e[e.WATER=6]="WATER",e[e.HELIX=7]="HELIX",e[e.SHEET=8]="SHEET",e[e.TURN=9]="TURN",e[e.BACKBONE=10]="BACKBONE",e[e.SIDECHAIN=11]="SIDECHAIN",e[e.ALL=12]="ALL",e[e.HETERO=13]="HETERO",e[e.ION=14]="ION",e[e.SACCHARIDE=15]="SACCHARIDE",e[e.SUGAR=15]="SUGAR",e[e.BONDED=16]="BONDED",e[e.RING=17]="RING",e[e.AROMATICRING=18]="AROMATICRING",e[e.METAL=19]="METAL",e[e.POLARH=20]="POLARH",e[e.NONE=21]="NONE"}(ca||(ca={}));var la=["*","","ALL"],ha=["NONE"],pa=[ca.BACKBONE,ca.SIDECHAIN,ca.BONDED,ca.RING,ca.AROMATICRING,ca.METAL,ca.POLARH],da=[ca.POLYMER,ca.WATER],fa=["ALA","GLY","SER"],ma=["CYS","SER","THR"],ga=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],va=["PHE","TRP","TYR","HIS"],ya=["ASN","GLN"],ba=["ASP","GLU"],xa=["ARG","HIS","LYS"],_a=["ARG","ASP","GLU","HIS","LYS"],wa=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],Sa=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Aa=["HIS","PHE","PRO","TRP","TYR"],Ma=["ALA","GLY","ILE","LEU","VAL"];function Ca(e,t){if(void 0===t.atomname&&void 0===t.element&&void 0===t.altloc&&void 0===t.atomindex&&void 0===t.keyword&&void 0===t.inscode&&void 0===t.resname&&void 0===t.sstruc&&void 0===t.resno&&void 0===t.chainname&&void 0===t.model)return-1;if(void 0!==t.keyword){if(t.keyword===ca.BACKBONE&&!e.isBackbone())return!1;if(t.keyword===ca.SIDECHAIN&&!e.isSidechain())return!1;if(t.keyword===ca.BONDED&&!e.isBonded())return!1;if(t.keyword===ca.RING&&!e.isRing())return!1;if(t.keyword===ca.AROMATICRING&&!e.isAromatic())return!1;if(t.keyword===ca.HETERO&&!e.isHetero())return!1;if(t.keyword===ca.PROTEIN&&!e.isProtein())return!1;if(t.keyword===ca.NUCLEIC&&!e.isNucleic())return!1;if(t.keyword===ca.RNA&&!e.isRna())return!1;if(t.keyword===ca.DNA&&!e.isDna())return!1;if(t.keyword===ca.POLYMER&&!e.isPolymer())return!1;if(t.keyword===ca.WATER&&!e.isWater())return!1;if(t.keyword===ca.HELIX&&!e.isHelix())return!1;if(t.keyword===ca.SHEET&&!e.isSheet())return!1;if(t.keyword===ca.TURN&&!e.isTurn())return!1;if(t.keyword===ca.ION&&!e.isIon())return!1;if(t.keyword===ca.SACCHARIDE&&!e.isSaccharide())return!1;if(t.keyword===ca.METAL&&!e.isMetal())return!1;if(t.keyword===ca.POLARH&&!e.isPolarHydrogen())return!1}if(void 0!==t.atomname&&t.atomname!==e.atomname)return!1;if(void 0!==t.element&&t.element!==e.element)return!1;if(void 0!==t.altloc&&t.altloc!==e.altloc)return!1;if(void 0!==t.atomindex&&Do(t.atomindex,e.index)<0)return!1;if(void 0!==t.resname)if(Array.isArray(t.resname)){if(!t.resname.includes(e.resname))return!1}else if(t.resname!==e.resname)return!1;if(void 0!==t.sstruc&&t.sstruc!==e.sstruc)return!1;if(void 0!==t.resno)if(Array.isArray(t.resno)&&2===t.resno.length){if(t.resno[0]>e.resno||t.resno[1]e.resno||t.resno[1]0?e:null}function La(e,t){void 0===t&&(t=!1);var r=e;return t&&(r=Da(e,(function(e){return void 0!==e.keyword&&!pa.includes(e.keyword)||(void 0!==e.model||(void 0!==e.chainname||(void 0!==e.resname||(void 0!==e.resno||void 0!==e.sstruc))))}))),Ea(r,Ca)}function Oa(e,t){void 0===t&&(t=!1);var r=e;return t&&(r=Da(e,(function(e){return!(void 0===e.keyword||!pa.includes(e.keyword))||(void 0!==e.model||(void 0!==e.chainname||(void 0!==e.atomname||(void 0!==e.element||void 0!==e.altloc))))}))),Ea(r,Pa)}function Ra(e,t){void 0===t&&(t=!1);var r=e;return t&&(r=Da(e,(function(e){return void 0!==e.keyword&&!da.includes(e.keyword)||(void 0!==e.resname||(void 0!==e.resno||(void 0!==e.atomname||(void 0!==e.element||(void 0!==e.altloc||(void 0!==e.sstruc||void 0!==e.inscode))))))}))),Ea(r,Ta)}function ka(e,t){void 0===t&&(t=!1);var r=e;return t&&(r=Da(e,(function(e){return void 0!==e.keyword||(void 0!==e.chainname||(void 0!==e.resname||(void 0!==e.resno||(void 0!==e.atomname||(void 0!==e.element||(void 0!==e.altloc||(void 0!==e.sstruc||void 0!==e.inscode)))))))}))),Ea(r,Ia)}var Na=function(e){this.signals={stringChanged:new ua.Signal},this.setString(e)},Ba={type:{configurable:!0}};Ba.type.get=function(){return"selection"},Na.prototype.setString=function(e,t){if(void 0===e&&(e=this.string||""),e!==this.string){try{this.selection=function(e){var t={operator:void 0,rules:[]};if(!e)return t;var r,i,n=t,o=[];"("===(e=e.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===e.substr(-1)&&(e=e.slice(1,-1).trim());for(var a=e.split(/\s+/),s=function(e){r={operator:e,rules:[]},void 0===n?(n=r,t=r):(n.rules.push(r),o.push(n),n=r)},c=function(e){i=n,void 0===(n=o.pop())&&(s(e),u(i))},u=function(e){n.rules.push(e)},l=!1,h=0;h0)if("NOT"===d)l=1;else if(1===l)l=2;else{if(2!==l)throw new Error("something went wrong with 'not'");l=!1,c()}if("AND"!==d)if("OR"!==d)if("NOT"!==p.toUpperCase()){if(+d!=+d){var f=ca[d];if(void 0!==f){u({keyword:f});continue}}if("HYDROGEN"!==d)if("SMALL"!==d)if("NUCLEOPHILIC"!==d)if("HYDROPHOBIC"!==d)if("AROMATIC"!==d)if("AMIDE"!==d)if("ACIDIC"!==d)if("BASIC"!==d)if("CHARGED"!==d)if("POLAR"!==d)if("NONPOLAR"!==d)if("CYCLIC"!==d)if("ALIPHATIC"!==d)if("SIDECHAINATTACHED"!==d)if("APOLARH"!==d)if("LIGAND"!==d)if(-1===la.indexOf(d))if("@"!==p.charAt(0))if("#"!==p.charAt(0))if("_"!==p.charAt(0))if("["!==p[0]||"]"!==p[p.length-1])if(p.length>=1&&p.length<=4&&"^"!==p[0]&&":"!==p[0]&&"."!==p[0]&&"%"!==p[0]&&"/"!==p[0]&&isNaN(parseInt(p)))u({resname:d});else{var m={operator:"AND",rules:[]},g=p.split("/");if(g.length>1&&g[1]){if(isNaN(parseInt(g[1])))throw new Error("model must be an integer");m.rules.push({model:parseInt(g[1])})}var v=g[0].split("%");v.length>1&&m.rules.push({altloc:v[1]});var y=v[0].split(".");if(y.length>1&&y[1]){if(y[1].length>4)throw new Error("atomname must be one to four characters");m.rules.push({atomname:y[1].substring(0,4).toUpperCase()})}var b=y[0].split(":");b.length>1&&b[1]&&m.rules.push({chainname:b[1]});var x=b[0].split("^");if(x.length>1&&m.rules.push({inscode:x[1]}),x[0]){var _=void 0,w=void 0;"-"===x[0][0]&&(x[0]=x[0].substr(1),_=!0),x[0].includes("--")&&(x[0]=x[0].replace("--","-"),w=!0);var S=x[0].split("-");if(1===S.length){var A=parseInt(S[0]);if(isNaN(A))throw new Error("resi must be an integer");_&&(A*=-1),m.rules.push({resno:A})}else{if(2!==S.length)throw new Error("resi range must contain one '-'");var M=S.map((function(e){return parseInt(e)}));_&&(M[0]*=-1),w&&(M[1]*=-1),m.rules.push({resno:[M[0],M[1]]})}}if(1===m.rules.length)u(m.rules[0]);else{if(!(m.rules.length>1))throw new Error("empty selection chunk");u(m)}}else{var C=d.substr(1,p.length-2).split(","),P=C.length>1?C:C[0];u({resname:P})}else u({element:d.substr(1)});else console.error("# for element selection deprecated, use _"),u({element:d.substr(1)});else{var T=p.substr(1).split(",").map((function(e){return parseInt(e)}));T.sort((function(e,t){return e-t})),u({atomindex:T})}else u({keyword:ca.ALL});else u({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:ca.HETERO},{negate:!0,operator:void 0,rules:[{keyword:ca.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:ca.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:ca.WATER},{keyword:ca.ION}]}]}]});else u({operator:"AND",negate:!1,rules:[{element:"H"},{negate:!0,operator:void 0,rules:[{keyword:ca.POLARH}]}]});else u({operator:"OR",rules:[{keyword:ca.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:ca.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:ca.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"HO3'"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"HO5'"},{atomname:"C5'"},{atomname:"C5*"},{atomname:"H5'"},{atomname:"H5''"}]}]}]});else u({resname:Ma});else u({resname:Aa});else u({resname:Sa});else u({resname:wa});else u({resname:_a});else u({resname:xa});else u({resname:ba});else u({resname:ya});else u({resname:va});else u({resname:ga});else u({resname:ma});else u({resname:fa});else u({operator:"OR",rules:[{element:"H"},{element:"D"}]})}else l=1,s(),n.negate=!0;else"AND"===n.operator?c("OR"):n.operator="OR";else if("OR"===n.operator){var I=n.rules.pop();s("AND"),u(I)}else n.operator="AND"}else c(),n.negate&&c();else l=!1,s()}return void 0===t.operator&&1===t.rules.length&&t.rules[0].hasOwnProperty("operator")&&(t=t.rules[0]),t}(e)}catch(e){this.selection={error:e.message}}var r=this.selection;this.string=e,this.test=La(r),this.residueTest=Oa(r),this.chainTest=Ra(r),this.modelTest=ka(r),this.atomOnlyTest=La(r,!0),this.residueOnlyTest=Oa(r,!0),this.chainOnlyTest=Ra(r,!0),this.modelOnlyTest=ka(r,!0),t||this.signals.stringChanged.dispatch(this.string)}},Na.prototype.isAllSelection=function(){return la.includes(this.string.toUpperCase())},Na.prototype.isNoneSelection=function(){return ha.includes(this.string.toUpperCase())},Object.defineProperties(Na.prototype,Ba);var Fa=function(e){function t(t){var r=this;e.call(this,t),this.colormakerList=[],this.selectionList=[],(t.dataList||[]).forEach((function(e){var t=e[0],i=e[1],n=e[2];void 0===n&&(n={}),ss.hasScheme(t)?Object.assign(n,{scheme:t,structure:r.parameters.structure}):Object.assign(n,{scheme:"uniform",value:new pt(t).getHex()}),r.colormakerList.push(ss.getScheme(n)),r.selectionList.push(new Na(i))}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){for(var t=0,r=this.selectionList.length;ti).lines},gs.prototype.chunkCount=function(){return Math.floor(this.data.length/this.chunkSize)+1},gs.prototype.asText=function(){return this.isBinary()?Ro(this.data):this.data},gs.prototype.chunkToLines=function(e,t,r){var i=this.newline;if(!this.isBinary()&&e.length===this.data.length)return{lines:e.split(i),partialLine:""};var n=[],o=this.isBinary()?Ro(e):e,a=o.lastIndexOf(i);if(-1===a)t+=o;else{var s=t+o.substr(0,a);n=n.concat(s.split(i)),t=a===o.length-i.length?"":o.substr(a+i.length)}return r&&""!==t&&n.push(t),{lines:n,partialLine:t}},gs.prototype.nextChunk=function(){var e=this.__pointer;if(!(e>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(e)},gs.prototype.nextChunkOfLines=function(){var e=this.nextChunk();if(void 0!==e){var t=this.__pointer>this.data.length,r=this.chunkToLines(e,this.__partialLine,t);return this.__partialLine=r.partialLine,r.lines}},gs.prototype.eachChunk=function(e){for(var t=this.chunkSize,r=this.data.length,i=this.chunkCount(),n=0;n1?(u.pop()||"").toLowerCase():"",h=t.match(/^(.+):\/\/(.+)$/);h&&(n=h[1].toLowerCase(),t=h[2]||"");var p=t.substring(0,t.lastIndexOf("/")+1);if(i.includes(l)){r=l;var d=t.length-l.length-1;l=(t.substr(0,d).split(".").pop()||"").toLowerCase();var f=c.length-l.length-1;c=c.substr(0,f)}else r=!1;return{path:t,name:s,ext:l,base:c,dir:p,compressed:r,protocol:n,query:a,src:e}}function As(e){var t=Ss(e),r=cs.get(t.protocol);return r&&!(t=Ss(r.getUrl(t.src))).ext&&r.getExt&&(t.ext=r.getExt(e)),t}function Ms(e,t){void 0===t&&(t={});var r,i=Object.assign(As(e),t);return ls.names.includes(i.ext)?r=new xs(i.src,i):os.includes(i.ext)&&(r=new ws(i.src,i)),r?r.load():Promise.reject(new Error("autoLoad: ext '"+i.ext+"' unknown"))}var Cs=ta((function(e,t){!function(){var e={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function r(e){return n(a(e),arguments)}function i(e,t){return r.apply(null,[e].concat(t||[]))}function n(t,i){var n,o,a,s,c,u,l,h,p,d=1,f=t.length,m="";for(o=0;o=0),s.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,s.width?parseInt(s.width):0);break;case"e":n=s.precision?parseFloat(n).toExponential(s.precision):parseFloat(n).toExponential();break;case"f":n=s.precision?parseFloat(n).toFixed(s.precision):parseFloat(n);break;case"g":n=s.precision?String(Number(n.toPrecision(s.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=s.precision?n.substring(0,s.precision):n;break;case"t":n=String(!!n),n=s.precision?n.substring(0,s.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=s.precision?n.substring(0,s.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=s.precision?n.substring(0,s.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}e.json.test(s.type)?m+=n:(!e.number.test(s.type)||h&&!s.sign?p="":(p=h?"+":"-",n=n.toString().replace(e.sign,"")),u=s.pad_char?"0"===s.pad_char?"0":s.pad_char.charAt(1):" ",l=s.width-(p+n).length,c=s.width&&l>0?u.repeat(l):"",m+=s.align?p+n+c:"0"===u?p+c+n:c+p+n)}return m}var o=Object.create(null);function a(t){if(o[t])return o[t];for(var r,i=t,n=[],a=0;i;){if(null!==(r=e.text.exec(i)))n.push(r[0]);else if(null!==(r=e.modulo.exec(i)))n.push("%");else{if(null===(r=e.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){a|=1;var s=[],c=r[2],u=[];if(null===(u=e.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(c=c.substring(u[0].length));)if(null!==(u=e.key_access.exec(c)))s.push(u[1]);else{if(null===(u=e.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}r[2]=s}else a|=2;if(3===a)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}i=i.substring(r[0].length)}return o[t]=n}t.sprintf=r,t.vsprintf=i,"undefined"!=typeof window&&(window.sprintf=r,window.vsprintf=i)}()})),Ps=function(){};Ps.prototype.getBlob=function(){return new Blob([this.getData()],{type:this.mimeType})},Ps.prototype.download=function(e,t){e=So(e,this.defaultName),t=So(t,this.defaultExt),Io(this.getBlob(),e+"."+t)};var Ts=function(e){function t(t,r){e.call(this),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";var i=Object.assign({},r);this.renumberSerial=So(i.renumberSerial,!0),this.remarks=function(e){return Array.isArray(e)?e:[e]}(So(i.remarks,[])),this.structure=t,this._records=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype._writeRecords=function(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()},t.prototype._writeTitle=function(){this._records.push(Cs.sprintf("TITLE %-74s",this.structure.name))},t.prototype._writeRemarks=function(){var e=this;this.remarks.forEach((function(t){e._records.push(Cs.sprintf("REMARK %-73s",t))})),this.structure.trajectory&&(this._records.push(Cs.sprintf("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(Cs.sprintf("REMARK %-73s","Frame "+this.structure.trajectory.frame)))},t.prototype._writeAtoms=function(){var e=this,t=1,r=1,i=" ",n=" ",o=this.structure.modelStore.count>1;this.structure.eachModel((function(a){o&&e._records.push(Cs.sprintf("MODEL %4d%-66s",r++,"")),a.eachAtom((function(r){var o=r.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",a=e.renumberSerial?t:r.serial,s=r.atomname;(1===s.length||s.length<4&&1===r.element.length&&s[0]===r.element)&&(s=" "+s),r.formalCharge?(i=Math.abs(r.formalCharge).toPrecision(1),n=r.formalCharge>0?"+":"-"):(i=" ",n=" "),e._records.push(Cs.sprintf(o,a,s,r.resname,So(r.chainname," "),r.resno,r.x,r.y,r.z,So(r.occupancy,1),So(r.bfactor,0),"",So(r.element,""),i,n)),t+=1}),e.structure.getSelection()),o&&e._records.push(Cs.sprintf("%-80s","ENDMDL"))})),this._records.push(Cs.sprintf("%-80s","END"))},t.prototype.getString=function(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()},t.prototype.getData=function(){return this._writeRecords(),this._records.join("\n")},t}(Ps),Is=function(e){function t(t){e.call(this),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=t,this._records=[]}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={idString:{configurable:!0},titleString:{configurable:!0},countsString:{configurable:!0},chargeLines:{configurable:!0}};return r.idString.get=function(){return this.structure.id},r.titleString.get=function(){return" "+this.structure.title},r.countsString.get=function(){return Cs.sprintf("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)},r.chargeLines.get=function(){var e=[];this.structure.eachAtom((function(t){null!=t.formalCharge&&0!==t.formalCharge&&e.push([t.index,t.formalCharge])}));for(var t=[],r=0;r>>0:0,n=e.byteLength-i,o=i;e instanceof ArrayBuffer||(e.byteLength!==e.buffer.byteLength&&(o=e.byteOffset+i),e=e.buffer),this._lastWrittenByte=r?n:0,this.buffer=e,this.length=n,this.byteLength=n,this.byteOffset=o,this._data=new DataView(this.buffer,o,n)};Ds.prototype.available=function(e){return void 0===e&&(e=1),this.offset+e<=this.length},Ds.prototype.isLittleEndian=function(){return this.littleEndian},Ds.prototype.setLittleEndian=function(){return this.littleEndian=!0,this},Ds.prototype.isBigEndian=function(){return!this.littleEndian},Ds.prototype.setBigEndian=function(){return this.littleEndian=!1,this},Ds.prototype.skip=function(e){return void 0===e&&(e=1),this.offset+=e,this},Ds.prototype.seek=function(e){return this.offset=e,this},Ds.prototype.mark=function(){return this._mark=this.offset,this},Ds.prototype.reset=function(){return this.offset=this._mark,this},Ds.prototype.pushMark=function(){return this._marks.push(this.offset),this},Ds.prototype.popMark=function(){var e=this._marks.pop();if(void 0===e)throw new Error("Mark stack empty");return this.seek(e),this},Ds.prototype.rewind=function(){return this.offset=0,this},Ds.prototype.ensureAvailable=function(e){if(void 0===e&&(e=1),!this.available(e)){var t=2*(this.offset+e),r=new Uint8Array(t);r.set(new Uint8Array(this.buffer)),this.buffer=r.buffer,this.length=this.byteLength=t,this._data=new DataView(this.buffer)}return this},Ds.prototype.readBoolean=function(){return 0!==this.readUint8()},Ds.prototype.readInt8=function(){return this._data.getInt8(this.offset++)},Ds.prototype.readUint8=function(){return this._data.getUint8(this.offset++)},Ds.prototype.readByte=function(){return this.readUint8()},Ds.prototype.readBytes=function(e){void 0===e&&(e=1);for(var t=new Uint8Array(e),r=0;rthis._lastWrittenByte&&(this._lastWrittenByte=this.offset)};var Ls=function(e){function t(t){e.call(this),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=t}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.getData=function(){var e=this.surface.index.length/3,t=new Ds(2*e+3*e*4*4+80+4);t.skip(80),t.writeUint32(e);for(var r=new Y,i=new Y,n=new Y,o=new Y,a=0;athis.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=e,this.frames=0),e},hs.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),hs.add("shader/chunk/interior_fragment.glsl","if( gl_FrontFacing == false ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}"),hs.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),hs.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),hs.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"),hs.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),hs.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),hs.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),hs.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");var ks=/^(?!\/\/)\s*#include\s+(\S+)/gim,Ns={};function Bs(e,t){void 0===t&&(t={});var r=e+"|";for(var i in t)r+=i+":"+t[i];if(!Ns[r]){var n=function(e){if(void 0===e)return"";var t=[];for(var r in e){var i=e[r];i&&t.push("#define "+r+" "+i)}return t.join("\n")+"\n"}(t),o=hs.get("shader/"+e);if(!o)throw new Error("empty shader, '"+e+"'");o=o.replace(ks,(function(e,t){var r="shader/chunk/"+t+".glsl",i=hs.get(r)||Ir[t];if(!i)throw new Error("empty chunk, '"+t+"'");return i})),Ns[r]=n+o}return Ns[r]}if("undefined"!=typeof WebGLRenderingContext){var Fs=WebGLRenderingContext.prototype,zs=Fs.getShaderParameter;Fs.getShaderParameter=function(){return!e.Debug||zs.apply(this,arguments)};var Us=Fs.getShaderInfoLog;Fs.getShaderInfoLog=function(){return e.Debug?Us.apply(this,arguments):""};var js=Fs.getProgramParameter;Fs.getProgramParameter=function(t,r){return!e.Debug&&r===Fs.LINK_STATUS||js.apply(this,arguments)};var Gs=Fs.getProgramInfoLog;Fs.getProgramInfoLog=function(){return e.Debug?Gs.apply(this,arguments):""}}var Vs=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];Vs.forEach((function(e){e.forEach((function(e){e[0]*=.0625,e[1]*=.0625}))}));var $s=function(e,t,r,i){this.canvas=document.createElement("canvas"),this._viewer=r,this._factor=So(i.factor,2),this._antialias=So(i.antialias,!1),this._onProgress=i.onProgress,this._onFinish=i.onFinish,this._antialias&&(this._factor*=2),this._n=this._factor*this._factor,this._width=this._viewer.width,this._height=this._viewer.height,this._antialias?(this.canvas.width=this._width*this._factor/2,this.canvas.height=this._height*this._factor/2):(this.canvas.width=this._width*this._factor,this.canvas.height=this._height*this._factor),this._ctx=this.canvas.getContext("2d"),this._viewerSampleLevel=r.sampleLevel,this._viewer.setSampling(-1)};$s.prototype._renderTile=function(e){var t=this._viewer,r=this._width,i=this._height,n=this._factor,o=e%n*r,a=Math.floor(e/n)*i;if(t.camera.setViewOffset(r*n,i*n,o,a,r,i),t.render(),this._antialias){var s=Math.round((o+r)/2)-Math.round(o/2),c=Math.round((a+i)/2)-Math.round(a/2);this._ctx.drawImage(t.renderer.domElement,Math.round(o/2),Math.round(a/2),s,c)}else this._ctx.drawImage(t.renderer.domElement,Math.floor(o),Math.floor(a),Math.ceil(r),Math.ceil(i));"function"==typeof this._onProgress&&this._onProgress(e+1,this._n,!1)},$s.prototype._finalize=function(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,"function"==typeof this._onFinish&&this._onFinish(this._n+1,this._n,!1)},$s.prototype.render=function(){for(var e=0;e<=this._n;++e)e===this._n?this._finalize():this._renderTile(e)},$s.prototype.renderAsync=function(){for(var e=this,t=0,r=this._n,i=function(){t===r?e._finalize():e._renderTile(t),t+=1},n=0;n<=r;++n)setTimeout(i,0)};var Hs=2*Math.PI,Ws=180/Math.PI;function qs(e,t,r,i,n){void 0===r&&(r=1),void 0===i&&(i=0);var o=n?n.length:e.length/r,a=0,s=0;if(n)for(var c=0;ct&&(t=e[r]);return t}function nc(e){for(var t=1/0,r=0,i=e.length;r=0;a--){for(o=l-1;o>=0;o--)if(h[c=4*(a*l+o)]!==t||h[c+1]!==r||h[c+2]!==i||h[c+3]!==n){s=!0;break}if(s)break}var f=a;for(s=!1,o=l-1;o>=0;o--){for(a=u-1;a>=0;a--)if(h[c=4*(a*l+o)]!==t||h[c+1]!==r||h[c+2]!==i||h[c+3]!==n){s=!0;break}if(s)break}var m=o,g=document.createElement("canvas");return g.width=m-d,g.height=f-p,g.getContext("2d").drawImage(e,d,p,g.width,g.height,0,0,g.width,g.height),g}(e,a?0:255*t.r,a?0:255*t.g,a?0:255*t.b,a?0:255)}return e}function d(e,r,i){"function"==typeof t.onProgress&&t.onProgress(e,r,i)}return new Promise((function(t,r){var i=new $s(s,c,e,{factor:n,antialias:o,onProgress:d,onFinish:function(n,o){p(i.canvas).toBlob((function(i){s.setClearAlpha(u),h(!0),e.requestRender(),d(o,o,!0),i?t(i):r("error creating image")}),"image/png")}});s.setClearAlpha(a?0:1),h(),i.renderAsync()}))}var uc=new Y,lc=new ie,hc=new ie;var pc=new z,dc=new ie,fc=new ie;function mc(e,t){dc.getInverse(t.projectionMatrix),fc.copy(t.projectionMatrix).transpose(),e.traverse((function(e){var t=e.material;if(t){var r=t.uniforms;r&&(r.projectionMatrixInverse&&r.projectionMatrixInverse.value.copy(dc),r.projectionMatrixTranspose&&r.projectionMatrixTranspose.value.copy(fc))}}))}function gc(e,t,r){var i=e.createShader(r);if(i)return e.shaderSource(i,t),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:(console.log("error compiling shader "+i+": "+e.getShaderInfoLog(i)),e.deleteShader(i),null);console.log("error creating WebGL shader "+r)}function vc(e,t){var r=e.getExtension(t);return r||console.log("extension '"+t+"' not available"),r}var yc=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function bc(e){var t=document.createElement("canvas");t.width=16,t.height=16,t.style.width="16px",t.style.height="16px";var r=t.getContext("webgl")||t.getContext("experimental-webgl");if(!r)return console.log("error creating webgl context for "+e),!1;if(!(r instanceof WebGLRenderingContext))return console.log("Got unexpected type for WebGL rendering context"),!1;vc(r,"OES_texture_float"),vc(r,"OES_texture_half_float"),vc(r,"WEBGL_color_buffer_float");var i=gc(r,"\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}",r.VERTEX_SHADER),n=gc(r,"\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}",r.FRAGMENT_SHADER);if(!i||!n)return!1;var o=function(e,t,r,i){var n=e.createProgram();if(n)return t.forEach((function(t){return e.attachShader(n,t)})),r&&r.forEach((function(t,r){e.bindAttribLocation(n,i?i[r]:r,t)})),e.linkProgram(n),e.getProgramParameter(n,e.LINK_STATUS)?n:(console.log("error linking program: "+e.getProgramInfoLog(n)),e.deleteProgram(n),null);console.log("error creating WebGL program")}(r,[i,n]);if(!o)return console.log("error creating WebGL program"),!1;r.useProgram(o);var a=r.getAttribLocation(o,"a_position"),s=r.getUniformLocation(o,"u_color");if(!s)return console.log("error getting 'u_color' uniform location"),!1;var c=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,yc,r.STATIC_DRAW),r.enableVertexAttribArray(a),r.vertexAttribPointer(a,2,r.FLOAT,!1,0,0);var u=r.createTexture(),l=new Uint8Array([255,255,255,255]);r.bindTexture(r.TEXTURE_2D,u),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,l);var h=r.createTexture();r.bindTexture(r.TEXTURE_2D,h),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,e,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST);var p=r.createFramebuffer();if(r.bindFramebuffer(r.FRAMEBUFFER,p),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,h,0),r.checkFramebufferStatus(r.FRAMEBUFFER)!==r.FRAMEBUFFER_COMPLETE)return console.log("error creating framebuffer for "+e),!1;r.bindTexture(r.TEXTURE_2D,u),r.uniform4fv(s,[0,10,20,1]),r.drawArrays(r.TRIANGLES,0,6),r.bindTexture(r.TEXTURE_2D,h),r.bindFramebuffer(r.FRAMEBUFFER,null),r.clearColor(1,0,0,1),r.clear(r.COLOR_BUFFER_BIT),r.uniform4fv(s,[0,.1,.05,1]),r.drawArrays(r.TRIANGLES,0,6);var d=new Uint8Array(4);if(r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,d),0!==d[0]||d[1]<248||d[2]<248||d[3]<254)return console.log("not able to actually render to "+e+" texture"),!1;if(e===r.FLOAT){r.bindFramebuffer(r.FRAMEBUFFER,p);var f=new Float32Array(4);r.readPixels(0,0,1,1,r.RGBA,r.FLOAT,f);var m=r.getError();if(m)return console.log("error reading pixels as float: '"+function(e,t){switch(t){case e.NO_ERROR:return"no error";case e.INVALID_ENUM:return"invalid enum";case e.INVALID_VALUE:return"invalid value";case e.INVALID_OPERATION:return"invalid operation";case e.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case e.OUT_OF_MEMORY:return"out of memory";case e.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}(r,m)+"'"),!1}return!0}var xc=new Float32Array(100),_c=new Uint8Array(100),wc=[12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20],Sc=new ie;function Ac(e,t,r,i,n){var o=n.uniforms,a=[];if(o&&(o.objectId&&(o.objectId.value=Qa?this.id:this.id/255,a.push("objectId")),(o.modelViewMatrixInverse||o.modelViewMatrixInverseTranspose||o.modelViewProjectionMatrix||o.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,this.matrixWorld),o.modelViewMatrixInverse&&(o.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),a.push("modelViewMatrixInverse")),o.modelViewMatrixInverseTranspose&&(o.modelViewMatrixInverse?o.modelViewMatrixInverseTranspose.value.copy(o.modelViewMatrixInverse.value).transpose():o.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),a.push("modelViewMatrixInverseTranspose")),o.modelViewProjectionMatrix&&(o.modelViewProjectionMatrix.value.multiplyMatrices(r.projectionMatrix,this.modelViewMatrix),a.push("modelViewProjectionMatrix")),o.modelViewProjectionMatrixInverse&&(o.modelViewProjectionMatrix?(Sc.copy(o.modelViewProjectionMatrix.value),o.modelViewProjectionMatrixInverse.value.getInverse(Sc)):(Sc.multiplyMatrices(r.projectionMatrix,this.modelViewMatrix),o.modelViewProjectionMatrixInverse.value.getInverse(Sc)),a.push("modelViewProjectionMatrixInverse")),a.length)){var s=e.properties.get(n);if(s.program){var c=e.getContext(),u=s.program;c.useProgram(u.program);var l=u.getUniforms();a.forEach((function(e){l.setValue(c,e,o[e].value)}))}}}var Mc=function(e){if(this.boundingBox=new Ne,this.boundingBoxSize=new Y,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new Y,this.signals={ticked:new ua.Signal,rendered:new ua.Signal},"string"==typeof e){var t=document.getElementById(e);this.container=null===t?document.createElement("div"):t}else e instanceof HTMLElement?this.container=e:this.container=document.createElement("div");if(this.container===document.body)this.width=window.innerWidth||1,this.height=window.innerHeight||1;else{var r=this.container.getBoundingClientRect();this.width=r.width||1,this.height=r.height||1,this.container.style.overflow="hidden"}this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.container.appendChild(this.wrapper),this._initParams(),this._initStats(),this._initCamera(),this._initScene(),!1!==this._initRenderer()?(this._initHelper(),this.setBackground(),this.setFog(),this.animate=this.animate.bind(this)):is.error("Viewer: could not initialize renderer")},Cc={cameraDistance:{configurable:!0}};Mc.prototype._initParams=function(){this.parameters={fogColor:new pt(0),fogNear:50,fogFar:100,backgroundColor:new pt(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new pt(14540253),lightIntensity:1,ambientColor:new pt(14540253),ambientIntensity:.2,sampleLevel:0,rendererEncoding:L}},Mc.prototype._initCamera=function(){var e=new Y(0,0,0),t=this.width,r=this.height;this.perspectiveCamera=new br(this.parameters.cameraFov,t/r),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(e),this.orthographicCamera=new go(t/-2,t/2,r/2,r/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(e),this.stereoCamera=new xo,this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;var i=this.parameters.cameraType;if("orthographic"===i)this.camera=this.orthographicCamera;else{if("perspective"!==i&&"stereo"!==i)throw new Error("Unknown cameraType '"+i+"'");this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()},Mc.prototype._initStats=function(){this.stats=new Rs},Mc.prototype._initScene=function(){this.scene||(this.scene=new we,this.scene.name="scene"),this.rotationGroup=new Pn,this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new Pn,this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new Pn,this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new Pn,this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new Pn,this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new Pn,this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new Ln(this.parameters.fogColor.getHex()),this.spotLight=new mo(this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.spotLight),this.ambientLight=new vo(this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)},Mc.prototype._initRenderer=function(){var t=window.devicePixelRatio,r=this.width,i=this.height;try{this.renderer=new Dn({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(e){return this.wrapper.innerHTML='

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

',!1}this.renderer.setPixelRatio(t),this.renderer.setSize(r,i),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,this.renderer.outputEncoding=this.parameters.rendererEncoding;var n=this.renderer.getContext();this.renderer.capabilities.isWebGL2?(ts(!0),Ja(this.renderer.extensions.get("EXT_color_buffer_float")),this.supportsHalfFloat=!0):(ts(this.renderer.extensions.get("EXT_frag_depth")),this.renderer.extensions.get("OES_element_index_uint"),Ja(this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&bc(n.FLOAT)),this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&bc(36193)),this.wrapper.appendChild(this.renderer.domElement);var o=r*t,a=i*t;e.Debug&&console.log(JSON.stringify({Browser:Xa,OES_texture_float:!!this.renderer.extensions.get("OES_texture_float"),OES_texture_half_float:!!this.renderer.extensions.get("OES_texture_half_float"),WEBGL_color_buffer_float:!!this.renderer.extensions.get("WEBGL_color_buffer_float"),"testTextureSupport Float":bc(n.FLOAT),"testTextureSupport HalfFloat":bc(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:Qa},null,2)),this.pickingTarget=new H(o,a,{minFilter:x,magFilter:x,stencilBuffer:!1,format:I,type:Qa?M:w}),this.pickingTarget.texture.generateMipmaps=!1,this.pickingTarget.texture.encoding=this.parameters.rendererEncoding,this.renderer.setRenderTarget(this.pickingTarget),this.renderer.clear(),this.renderer.setRenderTarget(null),this.sampleTarget=new H(o,a,{minFilter:_,magFilter:_,format:I}),this.sampleTarget.texture.encoding=this.parameters.rendererEncoding,this.holdTarget=new H(o,a,{minFilter:x,magFilter:x,format:I,type:w}),this.holdTarget.texture.encoding=this.parameters.rendererEncoding,this.compositeUniforms={tForeground:new _o(this.sampleTarget.texture),scale:new _o(1)},this.compositeMaterial=new vr({uniforms:this.compositeUniforms,vertexShader:Bs("Quad.vert"),fragmentShader:Bs("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:2,depthTest:!1,depthWrite:!1}),this.compositeCamera=new go(-1,1,1,-1,0,1),this.compositeScene=new we,this.compositeScene.name="compositeScene",this.compositeScene.add(new or(new Pr(2,2),this.compositeMaterial))},Mc.prototype._initHelper=function(){var e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),t=new Float32Array(24),r=new jt;r.setIndex(new wt(e,1)),r.setAttribute("position",new wt(t,3));var i=new vr({uniforms:{uColor:{value:new pt("skyblue")}},vertexShader:Bs("BasicLine.vert"),fragmentShader:Bs("BasicLine.frag")});this.boundingBoxMesh=new Gn(r,i),this.helperGroup.add(this.boundingBoxMesh)},Mc.prototype.updateHelper=function(){var e=this.boundingBoxMesh.geometry.attributes.position,t=e.array,r=this.boundingBox,i=r.min,n=r.max;t[0]=n.x,t[1]=n.y,t[2]=n.z,t[3]=i.x,t[4]=n.y,t[5]=n.z,t[6]=i.x,t[7]=i.y,t[8]=n.z,t[9]=n.x,t[10]=i.y,t[11]=n.z,t[12]=n.x,t[13]=n.y,t[14]=i.z,t[15]=i.x,t[16]=n.y,t[17]=i.z,t[18]=i.x,t[19]=i.y,t[20]=i.z,t[21]=n.x,t[22]=i.y,t[23]=i.z,e.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()},Cc.cameraDistance.get=function(){return Math.abs(this.camera.position.z)},Cc.cameraDistance.set=function(e){this.camera.position.z=-e},Mc.prototype.add=function(t,r){var i=this;r?r.forEach((function(e){return i.addBuffer(t,e)})):this.addBuffer(t),t.group.name="meshGroup",t.wireframeGroup.name="wireframeGroup",t.parameters.background?(this.backgroundGroup.add(t.group),this.backgroundGroup.add(t.wireframeGroup)):(this.modelGroup.add(t.group),this.modelGroup.add(t.wireframeGroup)),t.pickable&&this.pickingGroup.add(t.pickingGroup),e.Debug&&this.updateHelper()},Mc.prototype.addBuffer=function(e,t){function r(i){i instanceof Pn?i.children.forEach(r):(i.userData.buffer=e,i.userData.instance=t,i.onBeforeRender=Ac)}var i=e.getMesh();t&&i.applyMatrix4(t.matrix),r(i),e.group.add(i);var n=e.getWireframeMesh();if(t&&(n.matrix.copy(i.matrix),n.position.copy(i.position),n.quaternion.copy(i.quaternion),n.scale.copy(i.scale)),r(n),e.wireframeGroup.add(n),e.pickable){var o=e.getPickingMesh();t&&(o.matrix.copy(i.matrix),o.position.copy(i.position),o.quaternion.copy(i.quaternion),o.scale.copy(i.scale)),r(o),e.pickingGroup.add(o)}t?this._updateBoundingBox(e.geometry,e.matrix,t.matrix):this._updateBoundingBox(e.geometry,e.matrix)},Mc.prototype.remove=function(t){this.translationGroup.children.forEach((function(e){e.remove(t.group),e.remove(t.wireframeGroup)})),t.pickable&&this.pickingGroup.remove(t.pickingGroup),this.updateBoundingBox(),e.Debug&&this.updateHelper()},Mc.prototype._updateBoundingBox=function(e,t,r){var i=this.boundingBox;function n(e,t,r){null==e.boundingBox&&e.computeBoundingBox();var n=e.boundingBox.clone();t&&n.applyMatrix4(t),r&&n.applyMatrix4(r),n.min.equals(n.max)&&n.expandByScalar(5),i.union(n)}function o(e){var t,r;void 0!==e.geometry&&(e.userData.buffer&&(t=e.userData.buffer.matrix),e.userData.instance&&(r=e.userData.instance.matrix),n(e.geometry,t,r))}e?n(e,t,r):(i.makeEmpty(),this.modelGroup.traverse(o),this.backgroundGroup.traverse(o)),i.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()},Mc.prototype.updateBoundingBox=function(){this._updateBoundingBox(),e.Debug&&this.updateHelper()},Mc.prototype.getPickingPixels=function(){var e=this.width,t=this.height,r=e*t*4,i=Qa?new Float32Array(r):new Uint8Array(r);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,e,t,i),i},Mc.prototype.getImage=function(e){var t=this;return new Promise((function(r){if(e){var i=t,n=i.width,o=i.height,a=n*o*4,s=t.getPickingPixels();if(Qa){for(var c=new Uint8Array(a),u=0;u500&&!this.isStill&&this.sampleLevel<3&&-1!==this.sampleLevel){var t=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=t,e.Debug&&is.log("rendered still frame")}this.frameRequest=window.requestAnimationFrame(this.animate)},Mc.prototype.pick=function(e,t){if("stereo"===this.parameters.cameraType)return{pid:0,instance:void 0,picker:void 0};e*=window.devicePixelRatio,t*=window.devicePixelRatio,e=Math.max(e-2,0),t=Math.max(t-2,0);var r,i,n=0,o=Qa?xc:_c;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,e,t,5,5,o);for(var a=0;a22&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame((function(){e.render(),e.stats.update()})))},Mc.prototype.updateZoom=function(){var e=Wo(this.perspectiveCamera.fov),t=2*Math.tan(e/2)*this.cameraDistance;this.orthographicCamera.zoom=this.height/t},Mc.prototype.absoluteToRelative=function(e){return 50*(1-e/this.bRadius)},Mc.prototype.relativeToAbsolute=function(e){return this.bRadius*(1-e/50)},Mc.prototype.__updateClipping=function(){var e=this.parameters;this.bRadius=Math.max(10,.5*this.boundingBoxLength),isFinite(this.bRadius)||(this.bRadius=50),this.camera.getWorldPosition(this.distVector),this.cDist=this.distVector.length(),this.cDist||(this.cameraDistance=Math.abs(e.cameraZ),this.cDist=Math.abs(e.cameraZ));var t=this.scene.fog;if(t.color.set(e.fogColor),"camera"===e.clipMode)this.camera.near=e.clipNear,this.camera.far=e.clipFar,t.near=e.fogNear,t.far=e.fogFar;else if("absolute"===e.clipScale)this.camera.near=this.cDist-e.clipNear,this.camera.far=this.cDist+e.clipFar,t.near=this.cDist-e.fogNear,t.far=this.cDist+e.fogFar;else{var r=(50-e.clipNear)/50,i=-(50-e.clipFar)/50;this.camera.near=this.cDist-this.bRadius*r,this.camera.far=this.cDist+this.bRadius*i;var n=(50-e.fogNear)/50,o=-(50-e.fogFar)/50;t.near=this.cDist-this.bRadius*n,t.far=this.cDist+this.bRadius*o}"camera"!==e.clipMode&&("PerspectiveCamera"===this.camera.type?(this.camera.near=Math.max(.1,e.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),t.near=Math.max(.1,t.near),t.far=Math.max(1,t.far)):"OrthographicCamera"===this.camera.type&&e.clipDist>0&&(this.camera.near=Math.max(e.clipDist,this.camera.near)))},Mc.prototype.__updateCamera=function(){var e=this.camera;e.updateMatrix(),e.updateMatrixWorld(!0),e.updateProjectionMatrix(),function(e,t,r,i,n){var o=new z;r.getSize(o);var a=o.height,s=r.getPixelRatio(),c="OrthographicCamera"===t.type;pc.set(o.width,o.height),dc.getInverse(t.projectionMatrix),fc.copy(t.projectionMatrix).transpose(),e.traverse((function(e){var t=e.material;if(t){var r=t.uniforms;if(r){if(t.clipNear){var o=(50-t.clipNear)/50,u=i-n*o;r.clipNear.value=u}r.canvasHeight&&(r.canvasHeight.value=a),r.resolution&&r.resolution.value.copy(pc),r.pixelRatio&&(r.pixelRatio.value=s),r.projectionMatrixInverse&&r.projectionMatrixInverse.value.copy(dc),r.projectionMatrixTranspose&&r.projectionMatrixTranspose.value.copy(fc),r.ortho&&(r.ortho.value=c)}}}))}(this.scene,e,this.renderer,this.cDist,this.bRadius),function(e,t){e.traverseVisible((function(e){if(e instanceof Xn&&e.userData.buffer.parameters.sortParticles){var r=e.geometry.attributes,i=r.position.count;if(0!==i){var n,o,a,s,c,u,l;lc.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld),hc.multiplyMatrices(t.projectionMatrix,lc),e.userData.sortData?(n=e.userData.sortData,a=n.__zArray,o=n.__sortArray,s=n.__cmpFn):(a=new Float32Array(i),o=new Uint32Array(i),n={__zArray:a,__sortArray:o,__cmpFn:s=function(e,t){var r=a[e],i=a[t];return r>i?1:rt?1:e=u&&t(e[o],n)>0;)e[o+1]=e[o],--o;e[o+1]=n}if(-1===c)break;l=s[c--],u=s[c--]}else{for(a=l,h(u+l>>1,o=u+1),t(e[u],e[l])>0&&h(u,l),t(e[o],e[l])>0&&h(o,l),t(e[u],e[o])>0&&h(u,o),n=e[o];;){do{o++}while(t(e[o],n)<0);do{a--}while(t(e[a],n)>0);if(a=a-u?(s[++c]=o,s[++c]=l,l=a-1):(s[++c]=u,s[++c]=a-1,u=o)}}(o,s),r){var d=r[p],f=d.array,m=d.itemSize;n[p]||(n[p]=new Float32Array(m*i)),l=n[p],n[p]=f;for(var g=0;g0&&"stereo"!==this.parameters.cameraType?this.__renderSuperSample(t,r):this.__renderModelGroup(t,r)},Mc.prototype.render=function(e,t){if(void 0===e&&(e=!1),this.rendering)is.warn("'tried to call 'render' from within 'render'");else{this.rendering=!0;try{this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),"stereo"===this.parameters.cameraType?this.__renderStereo(e,t):this.__render(e,this.camera,t),this.lastRenderedPicking=e}finally{this.rendering=!1,this.renderPending=!1}this.signals.rendered.dispatch()}},Mc.prototype.clear=function(){is.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()},Mc.prototype.dispose=function(){this.renderer.dispose(),window.cancelAnimationFrame(this.frameRequest)},Object.defineProperties(Mc.prototype,Cc);function Pc(e){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;return Math.sqrt(t*t+r*r)}var Tc=function(e,t){void 0===t&&(t={}),this.domElement=e,this.signals={moved:new ua.Signal,scrolled:new ua.Signal,dragged:new ua.Signal,dropped:new ua.Signal,clicked:new ua.Signal,hovered:new ua.Signal,doubleClicked:new ua.Signal},this.position=new z,this.prevPosition=new z,this.down=new z,this.canvasPosition=new z,this.prevClickCP=new z,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=0,this.buttons=0,this.pressed=!1,this.altKey=!1,this.ctrlKey=!1,this.metaKey=!1,this.shiftKey=!1,this.domElement.style.touchAction="none",this.hoverTimeout=So(t.hoverTimeout,50),this.handleScroll=So(t.handleScroll,!0),this.doubleClickSpeed=So(t.doubleClickSpeed,500),this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();var r={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,r),document.addEventListener("wheel",this._onMousewheel,r),document.addEventListener("MozMousePixelScroll",this._onMousewheel,r),document.addEventListener("mousemove",this._onMousemove,r),document.addEventListener("mousedown",this._onMousedown,r),document.addEventListener("mouseup",this._onMouseup,r),document.addEventListener("contextmenu",this._onContextmenu,r),document.addEventListener("touchstart",this._onTouchstart,r),document.addEventListener("touchend",this._onTouchend,r),document.addEventListener("touchmove",this._onTouchmove,r)},Ic={key:{configurable:!0}};Ic.key.get=function(){var e=0;return this.altKey&&(e+=1),this.ctrlKey&&(e+=2),this.metaKey&&(e+=4),this.shiftKey&&(e+=8),e},Tc.prototype.setParameters=function(e){void 0===e&&(e={}),this.hoverTimeout=So(e.hoverTimeout,this.hoverTimeout)},Tc.prototype._listen=function(){var e=window.performance.now(),t=this.canvasPosition;this.doubleClickPending&&e-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),e-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(t.x,t.y))),this.frameRequest=window.requestAnimationFrame(this._listen)},Tc.prototype._onMousewheel=function(e){var t=this;if(e.target===this.domElement&&this.handleScroll){e.preventDefault(),this._setKeys(e);var r=0;"deltaY"in e&&"deltaMode"in e&&void 0!==e.deltaY&&void 0!==e.deltaMode?r=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?.025*-e.deltaY:e.deltaMode===WheelEvent.DOM_DELTA_LINE?-e.deltaY*(2.5/3):2.5*-e.deltaY:"deltaY"in e&&!("detail"in e)?r=.025*-e.deltaY:void 0!==e.wheelDelta?r=.025*-e.wheelDelta:void 0!==e.wheelDeltaY?r=.025*-e.wheelDeltaY:void 0!==e.detail&&(r=-e.detail/3),this.signals.scrolled.dispatch(r),setTimeout((function(){t.scrolled=!0}),this.hoverTimeout)}},Tc.prototype._onMousemove=function(e){e.target===this.domElement?(e.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(e),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(e.clientX,e.clientY),this._setCanvasPosition(e);var t=this.prevPosition.x-this.position.x,r=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(t,r),this.pressed&&this.signals.dragged.dispatch(t,r)},Tc.prototype._onMousedown=function(e){e.target===this.domElement&&(e.preventDefault(),this._setKeys(e),this.moving=!1,this.hovering=!1,this.down.set(e.clientX,e.clientY),this.position.set(e.clientX,e.clientY),this.which=e.which,this.buttons=function(e){if("object"==typeof e){if("buttons"in e)return e.buttons;if("which"in e){var t=e.which;if(2===t)return 4;if(3===t)return 2;if(t>0)return 1<=0)return 1<2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(n/2);else{this.which=3,this.buttons=2;var o=this.prevPosition.x-this.position.x,a=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(o,a),this.pressed&&this.signals.dragged.dispatch(o,a)}}},Tc.prototype._distance=function(){return this.position.distanceTo(this.down)},Tc.prototype._setCanvasPosition=function(e){var t,r,i=this.domElement.getBoundingClientRect();"clientX"in e&&"clientY"in e?(t=e.clientX-i.left,r=e.clientY-i.top):(t=e.offsetX,r=e.offsetY),this.canvasPosition.set(t,i.height-r)},Tc.prototype._setKeys=function(e){this.altKey=e.altKey,this.ctrlKey=e.ctrlKey,this.metaKey=e.metaKey,this.shiftKey=e.shiftKey},Tc.prototype.dispose=function(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove),window.cancelAnimationFrame(this.frameRequest)},Object.defineProperties(Tc.prototype,Ic);var Ec=new ie,Dc=new ie,Lc=new ie,Oc=new ie,Rc=new ie,kc=new Y,Nc=new W,Bc=new W,Fc=new ie,zc=new Y,Uc=new Y,jc=function(e,t){void 0===t&&(t={}),this.stage=e,this.rotateSpeed=So(t.rotateSpeed,2),this.zoomSpeed=So(t.zoomSpeed,1.2),this.panSpeed=So(t.panSpeed,1),this.viewer=e.viewer,this.mouse=e.mouseObserver,this.controls=e.viewerControls},Gc={component:{configurable:!0},atom:{configurable:!0}};Gc.component.get=function(){return this.stage.transformComponent},Gc.atom.get=function(){return this.stage.transformAtom},jc.prototype._setPanVector=function(e,t,r){void 0===r&&(r=0);var i=this.controls.getCanvasScaleFactor(r);zc.set(e,t,0),zc.multiplyScalar(this.panSpeed*i)},jc.prototype._getRotateXY=function(e,t){return[this.rotateSpeed*-e*.01,this.rotateSpeed*t*.01]},jc.prototype._getCameraRotation=function(e){return e.extractRotation(this.viewer.camera.matrixWorld),e.multiply(Dc.makeRotationY(Math.PI)),e},jc.prototype._transformPanVector=function(){this.component&&(Fc.extractRotation(this.component.transform),Fc.premultiply(this.viewer.rotationGroup.matrix),Fc.getInverse(Fc),Fc.multiply(this._getCameraRotation(Oc)),zc.applyMatrix4(Fc))},jc.prototype.zoom=function(e){this.controls.zoom(this.zoomSpeed*e*.02)},jc.prototype.pan=function(e,t){this._setPanVector(e,t),Fc.getInverse(this.viewer.rotationGroup.matrix),Fc.multiply(this._getCameraRotation(Oc)),zc.applyMatrix4(Fc),this.controls.translate(zc)},jc.prototype.panComponent=function(e,t){this.component&&(this._setPanVector(e,t),this._transformPanVector(),this.component.position.add(zc),this.component.updateMatrix())},jc.prototype.panAtom=function(e,t){this.atom&&this.component&&(this.atom.positionToVector3(Uc),Uc.add(this.viewer.translationGroup.position),Uc.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(e,t,Uc.z),this._transformPanVector(),this.atom.positionAdd(zc),this.component.updateRepresentations({position:!0}))},jc.prototype.rotate=function(e,t){var r=this._getRotateXY(e,t),i=r[0],n=r[1];this._getCameraRotation(Oc),kc.set(1,0,0),kc.applyMatrix4(Oc),Nc.setFromAxisAngle(kc,n),kc.set(0,1,0),kc.applyMatrix4(Oc),Bc.setFromAxisAngle(kc,i),Nc.multiply(Bc),Oc.makeRotationFromQuaternion(Nc),this.controls.applyMatrix(Oc)},jc.prototype.zRotate=function(e,t){var r=this.rotateSpeed*((-e+t)/-2)*.01;Lc.makeRotationZ(r),this.controls.applyMatrix(Lc)},jc.prototype.rotateComponent=function(e,t){if(this.component){var r=this._getRotateXY(e,t),i=r[0],n=r[1];this._getCameraRotation(Rc),Oc.extractRotation(this.component.transform),Oc.premultiply(this.viewer.rotationGroup.matrix),Oc.getInverse(Oc),Oc.premultiply(Rc),kc.set(1,0,0),kc.applyMatrix4(Oc),Ec.makeRotationAxis(kc,n),kc.set(0,1,0),kc.applyMatrix4(Oc),Dc.makeRotationAxis(kc,i),Ec.multiply(Dc),Nc.setFromRotationMatrix(Ec),this.component.quaternion.premultiply(Nc),this.component.quaternion.normalize(),this.component.updateMatrix()}},Object.defineProperties(jc.prototype,Gc);var Vc=new Y;var $c=function(e,t){this.stage=t,this.pid=e.pid,this.picker=e.picker,this.instance=e.instance,this.stage=t,this.controls=t.viewerControls,this.mouse=t.mouseObserver},Hc={type:{configurable:!0},altKey:{configurable:!0},ctrlKey:{configurable:!0},metaKey:{configurable:!0},shiftKey:{configurable:!0},canvasPosition:{configurable:!0},component:{configurable:!0},object:{configurable:!0},position:{configurable:!0},closestBondAtom:{configurable:!0},closeAtom:{configurable:!0},arrow:{configurable:!0},atom:{configurable:!0},axes:{configurable:!0},bond:{configurable:!0},box:{configurable:!0},cone:{configurable:!0},clash:{configurable:!0},contact:{configurable:!0},cylinder:{configurable:!0},distance:{configurable:!0},ellipsoid:{configurable:!0},octahedron:{configurable:!0},point:{configurable:!0},mesh:{configurable:!0},slice:{configurable:!0},sphere:{configurable:!0},tetrahedron:{configurable:!0},torus:{configurable:!0},surface:{configurable:!0},unitcell:{configurable:!0},unknown:{configurable:!0},volume:{configurable:!0},wideline:{configurable:!0}};Hc.type.get=function(){return this.picker.type},Hc.altKey.get=function(){return this.mouse.altKey},Hc.ctrlKey.get=function(){return this.mouse.ctrlKey},Hc.metaKey.get=function(){return this.mouse.metaKey},Hc.shiftKey.get=function(){return this.mouse.shiftKey},Hc.canvasPosition.get=function(){return this.mouse.canvasPosition},Hc.component.get=function(){return this.stage.getComponentsByObject(this.picker.data).list[0]},Hc.object.get=function(){return this.picker.getObject(this.pid)},Hc.position.get=function(){return this.picker.getPosition(this.pid,this.instance,this.component)},Hc.closestBondAtom.get=function(){if("bond"===this.type&&this.bond){var e=this.bond,t=this.controls,r=this.canvasPosition,i=e.atom1.positionToVector3(),n=e.atom2.positionToVector3();i.applyMatrix4(this.component.matrix),n.applyMatrix4(this.component.matrix);var o,a,s,c=t.getPositionOnCanvas(i),u=t.getPositionOnCanvas(n);return a=c,s=u,(o=r).distanceTo(a)=i.length))return new $c(r,this.stage);console.error("pid >= picker.array.length")}};var qc=new W,Xc=new Y,Yc=new Y,Zc=new Y,Kc=new Y,Qc=new ie,Jc=new Y,eu=new ie,tu=function(e){this.stage=e,this.signals={changed:new ua.Signal},this.viewer=e.viewer},ru={position:{configurable:!0},rotation:{configurable:!0}};ru.position.get=function(){return this.viewer.translationGroup.position},ru.rotation.get=function(){return this.viewer.rotationGroup.quaternion},tu.prototype.changed=function(){this.viewer.requestRender(),this.signals.changed.dispatch()},tu.prototype.getPositionOnCanvas=function(e,t){var r=Fo(t,z),i=this.viewer;return Zc.copy(e).add(i.translationGroup.position).applyMatrix4(i.rotationGroup.matrix).project(i.camera),r.set((Zc.x+1)*i.width/2,(Zc.y+1)*i.height/2)},tu.prototype.getCanvasScaleFactor=function(e){void 0===e&&(e=0);var t=this.viewer.camera;if(t instanceof go)return 1/t.zoom;e=Math.abs(e),e+=this.getCameraDistance();var r=Wo(t.fov);return 2*e*Math.tan(r/2)/this.viewer.height},tu.prototype.getOrientation=function(e){var t=Uo(e);t.copy(this.viewer.rotationGroup.matrix);var r=this.getCameraDistance();return t.scale(Kc.set(r,r,r)),t.setPosition(this.viewer.translationGroup.position),t},tu.prototype.orient=function(e){Uo(e).decompose(Xc,qc,Yc);var t=this.viewer;t.rotationGroup.setRotationFromQuaternion(qc),t.translationGroup.position.copy(Xc),t.cameraDistance=Yc.z,t.updateZoom(),this.changed()},tu.prototype.translate=function(e){this.viewer.translationGroup.position.add(zo(e)),this.changed()},tu.prototype.center=function(e){this.viewer.translationGroup.position.copy(zo(e)).negate(),this.changed()},tu.prototype.zoom=function(e){this.distance(this.getCameraDistance()*(1-e))},tu.prototype.getCameraDistance=function(){return this.viewer.cameraDistance},tu.prototype.distance=function(e){this.viewer.cameraDistance=Math.max(Math.abs(e),.2),this.viewer.updateZoom(),this.changed()},tu.prototype.spin=function(e,t){Qc.getInverse(this.viewer.rotationGroup.matrix),Jc.copy(zo(e)).applyMatrix4(Qc),this.viewer.rotationGroup.rotateOnAxis(Jc,t),this.changed()},tu.prototype.rotate=function(e){this.viewer.rotationGroup.setRotationFromQuaternion(jo(e)),this.changed()},tu.prototype.align=function(e){eu.getInverse(Uo(e)),this.viewer.rotationGroup.setRotationFromMatrix(eu),this.changed()},tu.prototype.applyMatrix=function(e){this.viewer.rotationGroup.applyMatrix4(Uo(e)),this.changed()},Object.defineProperties(tu.prototype,ru);var iu=function(e,t){for(var r,i=[],n=arguments.length-2;n-- >0;)i[n]=arguments[n+2];this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=So(e,1e3),this.controls=t,this.startTime=window.performance.now(),(r=this)._init.apply(r,i)},nu={done:{configurable:!0},paused:{configurable:!0}};nu.done.get=function(){return 1===this.alpha},nu.paused.get=function(){return this._paused},iu.prototype.tick=function(e){if(!this._paused)return this.elapsedDuration=e.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=Jo(0,1,this.elapsedDuration/this.duration),this._tick(e),this.done&&this._resolveList.forEach((function(e){return e()})),this.done},iu.prototype.pause=function(e){e&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0},iu.prototype.resume=function(e){!e&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)},iu.prototype.toggle=function(){this._paused?this.resume():this.pause()},iu.prototype.then=function(e){var t,r=this;return t=this.done?Promise.resolve():new Promise((function(e){return r._resolveList.push(e)})),t.then(e)},Object.defineProperties(iu.prototype,nu);var ou=function(e){function t(t,r){for(var i=[],n=arguments.length-2;n-- >0;)i[n]=arguments[n+2];e.apply(this,[So(t,1/0),r].concat(i))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype._init=function(e,t){Array.isArray(e)?this.axis=(new Y).fromArray(e):this.axis=So(e,new Y(0,1,0)),this.angle=So(t,.01)},t.prototype._tick=function(e){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*e.lastDuration/16)},t}(iu),au=function(e){function t(t,r){for(var i=[],n=arguments.length-2;n-- >0;)i[n]=arguments[n+2];e.apply(this,[So(t,1/0),r].concat(i)),this.angleSum=0,this.direction=1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype._init=function(e,t,r){Array.isArray(e)?this.axis=(new Y).fromArray(e):this.axis=So(e,new Y(0,1,0)),this.angleStep=So(t,.01),this.angleEnd=So(r,.2)},t.prototype._tick=function(e){if(this.axis&&this.angleStep&&this.angleEnd){var t=Jo(0,1,Math.abs(this.angleSum)/this.angleEnd),r=this.angleStep*this.direction*(1.1-t);this.controls.spin(this.axis,r*e.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}},t}(iu),su=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype._init=function(e,t){this.moveFrom=zo(So(e,new Y)),this.moveTo=zo(So(t,new Y))},t.prototype._tick=function(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()},t}(iu),cu=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype._init=function(e,t){this.zoomFrom=e,this.zoomTo=t},t.prototype._tick=function(){this.controls.distance(Ko(this.zoomFrom,this.zoomTo,this.alpha))},t}(iu),uu=function(e){function t(){e.apply(this,arguments),this._currentRotation=new W}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype._init=function(e,t){this.rotateFrom=jo(e),this.rotateTo=jo(t),this._currentRotation=new W},t.prototype._tick=function(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)},t}(iu),lu=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype._init=function(e,t,r){this.valueFrom=e,this.valueTo=t,this.callback=r},t.prototype._tick=function(){this.callback(Ko(this.valueFrom,this.valueTo,this.alpha))},t}(iu),hu=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype._init=function(e){this.callback=e},t.prototype._tick=function(){1===this.alpha&&this.callback()},t}(iu),pu=function(e){void 0===e&&(e=[]),this._resolveList=[],this._list=e},du={done:{configurable:!0}};du.done.get=function(){return this._list.every((function(e){return e.done}))},pu.prototype.then=function(e){var t,r=this;return t=this.done?Promise.resolve():new Promise((function(e){r._resolveList.push(e),r._list.forEach((function(e){e.then((function(){r._resolveList.forEach((function(e){e()})),r._resolveList.length=0}))}))})),t.then(e)},Object.defineProperties(pu.prototype,du);var fu=function(e){this.stage=e,this.animationList=[],this.finishedList=[],this.viewer=e.viewer,this.controls=e.viewerControls},mu={paused:{configurable:!0}};mu.paused.get=function(){return this.animationList.every((function(e){return e.paused}))},fu.prototype.add=function(e){return 0===e.duration?e.tick(this.viewer.stats):this.animationList.push(e),e},fu.prototype.remove=function(e){var t=this.animationList,r=t.indexOf(e);r>-1&&t.splice(r,1)},fu.prototype.run=function(e){for(var t=this.finishedList,r=this.animationList,i=r.length,n=0;n0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(e||!1)}else this.lazyProps.build=!0},vu.prototype.make=function(t,r){var i=this;e.Debug&&is.time("Representation.make "+this.type);var n=function(){t?(i.update(t),i.viewer.requestRender(),i.tasks.decrement(),r&&r()):(i.clear(),i.create(),i.manualAttach||i.disposed||(e.Debug&&is.time("Representation.attach "+i.type),i.attach((function(){e.Debug&&is.timeEnd("Representation.attach "+i.type),i.tasks.decrement(),r&&r()})))),e.Debug&&is.timeEnd("Representation.make "+i.type)};this.toBePrepared?this.prepare(n):n()},vu.prototype.attach=function(e){this.setVisibility(this.visible),e()},vu.prototype.setVisibility=function(e,t){if(this.visible=e,this.visible&&this.opacity){var r=this.lazyProps,i=r.bufferParams,n=r.what;if(r.build)return r.build=!1,this.build(),this;(Object.keys(i).length||Object.keys(n).length)&&(r.bufferParams={},r.what={},this.updateParameters(i,n))}return this.bufferList.forEach((function(t){t.setVisibility(e)})),t||this.viewer.requestRender(),this},vu.prototype.setParameters=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r=!1);var i=e||{},n=this.parameters,o={};for(var a in this.opacity||void 0===i.opacity||(this.lazyProps.build?(this.lazyProps.build=!1,r=!0):(Object.assign(o,this.lazyProps.bufferParams),Object.assign(t,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(i.color,i),i)if(void 0!==i[a]&&void 0!==n[a]&&(n[a].int&&(i[a]=parseInt(i[a])),n[a].float&&(i[a]=parseFloat(i[a])),i[a]!==this[a]||i[a].equals&&!i[a].equals(this[a]))){if(this[a]&&this[a].copy&&i[a].copy?this[a].copy(i[a]):this[a]&&this[a].set?this[a].set(i[a]):this[a]=i[a],n[a].buffer)if(!0===n[a].buffer)o[a]=i[a];else o[n[a].buffer]=i[a];n[a].update&&(t[n[a].update]=!0),!n[a].rebuild||"impostor"===n[a].rebuild&&es&&!this.disableImpostor||(r=!0)}return r?this.build():this.updateParameters(o,t),this},vu.prototype.updateParameters=function(e,t){if(void 0===e&&(e={}),this.lazy&&(!this.visible||!this.opacity)&&!1===e.hasOwnProperty("opacity"))return Object.assign(this.lazyProps.bufferParams,e),void Object.assign(this.lazyProps.what,t);this.bufferList.forEach((function(t){t.setParameters(e)})),Object.keys(t).length&&this.update(t),this.viewer.requestRender()},vu.prototype.getParameters=function(){var e=this,t={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach((function(r){null!==e.parameters[r]&&(t[r]=e[r])})),t},vu.prototype.clear=function(){var e=this;this.bufferList.forEach((function(t){e.viewer.remove(t),t.dispose()})),this.bufferList.length=0,this.viewer.requestRender()},vu.prototype.dispose=function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()};var yu=function(t){var r=this;this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=t,this.blobUrl=window.URL.createObjectURL(as.get(t)),this.worker=new Worker(this.blobUrl),as.activeWorkerCount+=1,this.worker.onmessage=function(i){r.pending-=1;var n=i.data.__postId;e.Debug&&is.timeEnd("Worker.postMessage "+t+" #"+n);var o=r.onmessageDict[n];o&&o.call(r.worker,i),delete r.onmessageDict[n],delete r.onerrorDict[n]},this.worker.onerror=function(e){if(r.pending-=1,e.data){var i=e.data.__postId,n=r.onerrorDict[i];n?n.call(r.worker,e):is.error("Worker.onerror",i,t,e),delete r.onmessageDict[i],delete r.onerrorDict[i]}else is.error("Worker.onerror",t,e)}};yu.prototype.post=function(t,r,i,n){void 0===t&&(t={}),this.onmessageDict[this.postCount]=i,this.onerrorDict[this.postCount]=n,t.__name=this.name,t.__postId=this.postCount,t.__debug=e.Debug,e.Debug&&is.time("Worker.postMessage "+this.name+" #"+this.postCount);try{this.worker.postMessage(t,r)}catch(e){is.error("worker.post:",e),this.worker.postMessage(t)}return this.pending+=1,this.postCount+=1,this},yu.prototype.terminate=function(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),as.activeWorkerCount-=1):is.log("no worker to terminate")};var bu=function(e,t){void 0===t&&(t=2),this.pool=[],this.count=0,this.maxCount=Math.min(8,t),this.name=e};function xu(e){for(var t=e.length,r=t/3,i=0,n=0,o=0,a=0;an&&(n=u),l>o&&(o=l),h>a&&(a=h)}return[Cu([t,r,i]),Cu([n,o,a])]}function Su(e,t){for(var r=0,i=t.length;r0){var s=1/Math.sqrt(a);e[t]=i*s,e[t+1]=n*s,e[t+2]=o*s}}}function Cu(e){return new Float32Array(e||3)}function Pu(e,t,r){var i=t[0],n=t[1],o=t[2],a=r[0],s=r[1],c=r[2];e[0]=n*c-o*s,e[1]=o*a-i*c,e[2]=i*s-n*a}function Tu(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Iu(e,t,r){e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2]}function Eu(e,t,r){e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2]}function Du(e,t,r){void 0===r&&(r=0),e[0]=t[r],e[1]=t[r+1],e[2]=t[r+2]}function Lu(e,t,r){void 0===r&&(r=0),t[r]=e[0],t[r+1]=e[1],t[r+2]=e[2]}function Ou(e){return e[0]*e[0]+e[1]*e[1]+e[2]*e[2]}function Ru(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2])}function ku(e,t,r){Nu(e,t,1/r)}function Nu(e,t,r){e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r}function Bu(e,t){var r=Ou(t);0==r?(e[0]=t[0],e[1]=t[1],e[2]=t[2]):Nu(e,t,1/Math.sqrt(r))}function Fu(e,t,r){e[0]=t[0]-r,e[1]=t[1]-r,e[2]=t[2]-r}function zu(e,t,r){e[0]=t[0]+r,e[1]=t[1]+r,e[2]=t[2]+r}function Uu(e,t){e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2])}function ju(e,t){e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2])}function Gu(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2]}function Vu(e,t){void 0===t&&(t=9);for(var r=Math.floor(t/2),i=e.position1.length/3,n=3*(r*i),o=1/t,a=Ys(e.position1,e.position2),s=new Float32Array(n),c=new Float32Array(n),u=new Y,l=0;l0){var P=3*d;n[P]=e.position2[3*l-3],n[P+1]=e.position2[3*l-2],n[P+1]=e.position2[3*l-1]}var T=new Float32Array(i),I=new Float32Array(n),E=Xs(T,I),D=new Float32Array(o),L={position:E,position1:T,position2:I,color:D,color2:D};return a&&(L.radius=new Float32Array(a)),s&&e.picking&&(e.picking.array=new Float32Array(s),L.picking=e.picking),c&&(L.primitiveId=new Float32Array(c)),L}bu.prototype.post=function(e,t,r,i){void 0===e&&(e={});var n=this.getNextWorker();return n?n.post(e,t,r,i):console.error("unable to get worker from pool"),this},bu.prototype.terminate=function(){this.pool.forEach((function(e){e.terminate()}))},bu.prototype.getNextWorker=function(){for(var e,t=1/0,r=0;r=this.count){e=new yu(this.name),this.pool.push(e),this.count+=1;break}var i=this.pool[r];if(0===i.pending){e=i;break}i.pending>this.exp),this.boundY=1+(r.max.y-this.minY>>this.exp),this.boundZ=1+(r.max.z-this.minZ>>this.exp);for(var i=this.boundX*this.boundY*this.boundZ,n=void 0!==e.count?e.count:e.x.length,o=e.x,a=e.y,s=e.z,c=0,u=new Uint32Array(i),l=new Int32Array(n),h=0;h>this.exp,d=a[h]-this.minY>>this.exp,f=s[h]-this.minZ>>this.exp,m=(p*this.boundY+d)*this.boundZ+f;1===(u[m]+=1)&&(c+=1),l[h]=m}for(var g=new Uint16Array(c),v=0,y=0;v0&&(u[v]=y+1,g[y]=b,y+=1)}for(var x=new Uint32Array(c),_=1;_0){var C=M-1;S[x[C]+w[C]]=A,w[C]+=1}}this.grid=u,this.bucketCount=g,this.bucketOffset=x,this.bucketArray=S,this.xArray=o,this.yArray=a,this.zArray=s};sl.prototype.within=function(e,t,r,i){var n=[];return this.eachWithin(e,t,r,i,(function(e){return n.push(e)})),n},sl.prototype.eachWithin=function(e,t,r,i,n){for(var o=i*i,a=Math.max(0,e-i-this.minX>>this.exp),s=Math.max(0,t-i-this.minY>>this.exp),c=Math.max(0,r-i-this.minZ>>this.exp),u=Math.min(this.boundX,1+(e+i-this.minX>>this.exp)),l=Math.min(this.boundY,1+(t+i-this.minY>>this.exp)),h=Math.min(this.boundZ,1+(r+i-this.minZ>>this.exp)),p=a;p0)for(var v=g-1,y=this.bucketOffset[v],b=y+this.bucketCount[v],x=y;xo?a.set(this[i].subarray(0,o)):a.set(this[i]),this[i]=a}},cl.prototype.growIfFull=function(){if(this.count>=this.length){var e=Math.round(1.5*this.length);this.resize(Math.max(256,e))}},cl.prototype.copyFrom=function(e,t,r,i){for(var n=0,o=this._fields.length;n0;)c-=1;s<=c&&(s===a?a=c:c===a&&(a=s),(u=s)!==(l=c)&&(r.copyFrom(t,0,u,1),t.copyWithin(u,l,1),t.copyFrom(r,l,0,1)),s+=1,c-=1)}while(s<=c);i(n,c),i(s,o)}var u,l}(0,this.count-1),is.timeEnd("Store.sort")},cl.prototype.clear=function(){this.count=0},cl.prototype.dispose=function(){for(var e=0,t=this._fields.length;e>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24}var pl=function(e,t){this.length=e,this._words=new Uint32Array(e+32>>>5),!0===t&&this.setAll()};function dl(e){for(var t=e.edgeCount,r=e.nodeCount,i=e.nodeArray1,n=e.nodeArray2,o=new Uint8Array(r),a=new Int32Array(r),s=0;s0){var i=e.types,n=e.groups,o=e.centers,a=e.atomSets;i.push(t.type),n.push(t.group),o.x.push(t.x/r),o.y.push(t.y/r),o.z.push(t.z/r),a.push(t.atomSet)}}pl.prototype.get=function(e){return 0!=(this._words[e>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,a=t>>>5,s=o+1;s>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>r,this},pl.prototype._isRangeValue=function(e,t,r){if(!(t>>5,a=t>>>5,s=o+1;s>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<1||1!==t.number&&(r.index=t.index,n[o++].subVectors(t,e))})),1===o&&r.eachBondedAtom((function(t){o>1||1!==t.number&&t.index!==e.index&&n[o++].subVectors(t,e)})),2===o){var a=n[0].cross(n[1]);return Math.abs(Math.PI/2-a.angleTo(i))}}function Yl(e,t){var r=e.structure,i=r.atomCount,n=new Int8Array(i),o=new Int8Array(i),a=new Int8Array(i),s=new Int8Array(i);return r.eachAtom((function(e){var r=e.index,i=function(e,t){var r=e.bondToElementCount(1),i=e.formalCharge||0,n="always"===t.assignCharge||"auto"===t.assignCharge&&0===i,o="always"===t.assignH||"auto"===t.assignH&&0===r,a=e.bondCount,s=function(e){var t=0;return e.eachBond((function(e){return t+=e.bondOrder})),t}(e),c=function(e){var t=e.structure.getBondProxy(),r=e.number,i=8===r||7===r;if(i&&4===e.bondCount)return!1;var n=!1;return e.eachBond((function(r){if(r.bondOrder>1)n=!0;else if(i){var o=r.getOtherAtom(e);o.eachBond((function(e){if(e.bondOrder>1){var t=o.number;if((15===t||16===t)&&8===e.getOtherAtom(o).number)return;n=!0}}),t)}})),n}(e),u=s-a>0,l=0,h=8;switch(e.number){case 1:n&&(0===a?(i=1,h=0):1===a&&(i=0,h=1));break;case 6:n&&(i=0),o&&(l=Math.max(0,4-s-Math.abs(i))),h=Hl(a+l+Math.max(0,-i));break;case 7:if(n)if(o)if(c&&s<4)i=a-r==1&&s-r==2?1:0;else{var p=!1;e.eachBondedAtom((function(e){(16===e.number||e.isMetal())&&(p=!0)})),i=p?0:1}else i=s-3;o&&(l=Math.max(0,3-s+i)),h=Hl(c&&!u?a+l-i:a+l+1-i);break;case 8:n&&(o||(i=s-2),1===s&&e.eachBondedAtom((function(t){t.eachBond((function(r){var n=r.getOtherAtom(t);n.index!==e.index&&8===n.number&&2===r.bondOrder&&(i=-1)}))}))),o&&(l=Math.max(0,2-s+i)),h=Hl(c&&!u?a+l-i+1:a+l-i+2);break;case 16:n&&(o||(i=s<=3&&!e.bondToElementCount(8)?s-2:0)),o&&s<2&&(l=Math.max(0,2-s+i)),s<=3&&(h=Hl(a+l-i+2));break;case 9:case 17:case 35:case 53:case 85:n&&(i=s-1);break;case 3:case 11:case 19:case 37:case 55:case 87:n&&(i=1-s);break;case 4:case 12:case 20:case 38:case 56:case 88:n&&(i=2-s);break;default:console.warn("Requested charge, protonation for an unhandled element",e.element)}return[i,l,l+r,h]}(e,t),c=i[0],u=i[1],l=i[2],h=i[3];n[r]=c,o[r]=u,a[r]=l,s[r]=h})),{charge:n,implicitH:o,totalH:a,idealGeometry:s}}function Zl(e){if(e["@valenceModel"])return e["@valenceModel"];var t=Yl(e,{assignCharge:"auto",assignH:"auto"});return e["@valenceModel"]=t,t}function Kl(e){return 15===e.number&&e.bondToElementCount(8)===e.bondCount}var Ql=["ARG","HIS","LYS"],Jl=["GLU","ASP"];function eh(e,t,r){void 0===r&&(r={});for(var i=So(r.maxIonicDist,uh.maxIonicDist),n=So(r.maxPiStackingDist,uh.maxPiStackingDist),o=So(r.maxPiStackingOffset,uh.maxPiStackingOffset),a=So(r.maxPiStackingAngle,uh.maxPiStackingAngle),s=So(r.maxCationPiDist,uh.maxCationPiDist),c=So(r.maxCationPiOffset,uh.maxCationPiOffset),u=So(r.masterModelIndex,uh.masterModelIndex),l=Math.max(i+2,n,s),h=n*n,p=s*s,d=t.features,f=t.spatialHash,m=t.contactStore,g=t.featureSet,v=d.types,y=d.centers,b=d.atomSets,x=y.x,_=y.y,w=y.z,S=v.length,A=e.atomStore.x,M=e.atomStore.y,C=e.atomStore.z,P=e.getAtomProxy(),T=e.getAtomProxy(),I=new Y,E=new Y,D=new Y,L=new Y,O=new Y,R=new Y,k=new Y,N=function(e,t){I.set(A[e[0]],M[e[0]],C[e[0]]),E.set(A[e[1]],M[e[1]],C[e[1]]),D.set(A[e[2]],M[e[2]],C[e[2]]),L.subVectors(I,E),O.subVectors(I,D),t.crossVectors(L,O)},B=function(e,t,r){return I.set(x[e],_[e],w[e]),E.set(x[t],_[t],w[t]),I.sub(E).projectOnPlane(r).add(E).distanceTo(E)},F=function(e,t,r){g.setBits(e,t),m.addContact(e,t,r)},z=function(e){f.eachWithin(x[e],_[e],w[e],l,(function(t,r){if(!(t<=e||(P.index=b[e][0],T.index=b[t][0],hh(P,T,u)))){var n=v[e],s=v[t];if(function(e,t){return 2===e&&1===t||1===e&&2===t}(n,s))(function(e,t,r){for(var i=e.length,n=t.length,o=0;o=180-a||l<=a+90&&l>=90-a)&&F(e,t,3)}}else if(function(e,t){return 3===e&&1===t||1===e&&3===t}(n,s)&&r<=p){var d=3===n?[e,t]:[t,e],f=d[0],m=d[1];N(b[f],R),B(m,f,R)<=c&&F(f,m,2)}}}))},U=0;U0&&(i[e.index]||(ml(n,e),gl(t,n)))})))}))}(t,r),function(e,t){var r=Zl(e.data).charge,i={};e.eachResidue((function(e){if(Jl.includes(e.resname)){var n=fl(2);e.eachAtom((function(e){8===e.number&&e.isSidechain()&&ml(n,e)})),gl(t,n)}else if(Bl.includes(e.resname)){var o=fl(2);e.eachAtom((function(e){Kl(e)&&(o.group=6,e.eachBondedAtom((function(e){8===e.number&&ml(o,e)})),gl(t,o))}))}else Ol.includes(e.resname)||Bl.includes(e.resname)||(e.eachAtom((function(e){var r=!1,n=fl(2);!function(e){return 16===e.number&&3===e.bondToElementCount(8)}(e)?Kl(e)?(n.group=6,r=!0):function(e){return 16===e.number&&4===e.bondToElementCount(8)}(e)?(n.group=5,r=!0):function(e){var t=0;return 6===e.number&&2===e.bondToElementCount(8)&&1===e.bondToElementCount(6)&&e.eachBondedAtom((function(e){8===e.number&&e.bondCount-e.bondToElementCount(1)==1&&++t})),2===t}(e)&&(n.group=10,r=!0):(n.group=4,r=!0),r&&(e.eachBondedAtom((function(e){8===e.number&&(i[e.index]=!0,ml(n,e))})),gl(t,n))})),e.eachAtom((function(e){var n=fl(2);r[e.index]<0&&(i[e.index]||(ml(n,e),gl(t,n)))})))}))}(t,r),function(e,t){var r=e.getAtomProxy();e.eachResidue((function(e){var i=e.getAromaticRings();if(i){var n=e.atomOffset;i.forEach((function(e){var i=fl(3);e.forEach((function(e){r.index=e+n,ml(i,r)})),gl(t,i)}))}}))}(t,r),function(e,t){var r=Zl(e.data),i=r.charge,n=r.implicitH,o=r.idealGeometry;e.eachAtom((function(e){var r=fl(5),a=e.number;if(8===a)ml(r,e),gl(t,r);else if(7===a){if(th(e))ml(r,e),gl(t,r);else if(i[e.index]<1){var s=e.bondCount+n[e.index],c=o[e.index];(4===c&&s<4||3===c&&s<3||2===c&&s<2)&&(ml(r,e),gl(t,r))}}else 16===a&&("CYS"!==e.resname&&"MET"!==e.resname&&-1!==e.formalCharge||(ml(r,e),gl(t,r)))}))}(t,r),function(e,t){var r=Zl(e.data).totalH;e.eachAtom((function(e){var i=fl(4),n=e.number;(th(e)||r[e.index]>0&&(7===n||8===n||16===n))&&(ml(i,e),gl(t,i))}))}(t,r),function(e,t){var r=Zl(e.data).totalH;e.eachAtom((function(e){if(6===e.number&&r[e.index]>0&&(e.bondToElementCount(7)>0||e.bondToElementCount(8)>0||function(e){if(!e.isAromatic())return!1;var t=e.residueType.getRings();if(!t)return!1;var r=!1;return t.rings.forEach((function(t){r||t.some((function(t){return e.index-e.residueAtomOffset===t}))&&(r=t.some((function(t){var r=e.residueType.atomTypeIdList[t],i=e.atomMap.get(r).number;return 7===i||8===i})))})),r}(e))){var i=fl(9);ml(i,e),gl(t,i)}}))}(t,r),function(e,t){e.eachAtom((function(e){var r=!1,i=!1,n=Ol.includes(e.resname),o=Bl.includes(e.resname);if(n||o?n?8===e.number?(["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(e.resname)&&e.isSidechain()||e.isBackbone())&&(r=!0,i=!0):16===e.number&&"CYS"===e.resname?(r=!0,i=!0):7===e.number&&"HIS"===e.resname&&e.isSidechain()&&(r=!0):o&&(8===e.number&&e.isBackbone()?(r=!0,i=!0):["N3","N4","N7"].includes(e.atomname)?r=!0:["O2","O4","O6"].includes(e.atomname)&&(r=!0,i=!0)):e.isHalogen()||8===e.number||16===e.number?(r=!0,i=!0):7===e.number&&(r=!0),r){var a=fl(11);ml(a,e),gl(t,a)}if(i){var s=fl(10);ml(s,e),gl(t,s)}}))}(t,r),function(e,t){e.eachAtom((function(e){if(e.isTransitionMetal()||30===e.number||48===e.number){var r=fl(12);ml(r,e),gl(t,r)}else if(rh.includes(e.number)){var i=fl(13);ml(i,e),gl(t,i)}}))}(t,r),function(e,t){e.eachAtom((function(e){var r=fl(8),i=!1;6===e.number?(i=!0,e.eachBondedAtom((function(e){var t=e.number;6!==t&&1!==t&&(i=!1)}))):9===e.number&&(i=!0),i&&(ml(r,e),gl(t,r))}))}(t,r),function(e,t){e.eachAtom((function(e){if(nh.includes(e.number)){var r=!1;if(e.eachBondedAtom((function(e){oh.includes(e.number)&&(r=!0)})),r){var i=fl(7);ml(i,e),gl(t,i)}}}))}(t,r),function(e,t){e.eachAtom((function(e){if(ih.includes(e.number)&&1===e.bondToElementCount(6)){var r=fl(6);ml(r,e),gl(t,r)}}))}(t,r),e.Debug&&is.timeEnd("calculateFeatures"),r}function dh(t,r){void 0===r&&(r=uh);var i=function(e){var t=e.types,r=e.centers;return{features:e,spatialHash:new sl(r),contactStore:new ll,featureSet:new pl(t.length,!1)}}(ph(t));e.Debug&&is.time("calculateContacts"),eh(t,i,r),function(e,t,r){void 0===r&&(r={});for(var i=So(r.maxHbondDist,uh.maxHbondDist),n=So(r.maxHbondSulfurDist,uh.maxHbondSulfurDist),o=Wo(So(r.maxHbondAccAngle,uh.maxHbondAccAngle)),a=Wo(So(r.maxHbondDonAngle,uh.maxHbondDonAngle)),s=Wo(So(r.maxHbondAccPlaneAngle,uh.maxHbondAccPlaneAngle)),c=Wo(So(r.maxHbondDonPlaneAngle,uh.maxHbondDonPlaneAngle)),u=So(r.masterModelIndex,uh.masterModelIndex),l=Math.max(i,n),h=i*i,p=t.features,d=t.spatialHash,f=t.contactStore,m=t.featureSet,g=p.types,v=p.centers,y=p.atomSets,b=v.x,x=v.y,_=v.z,w=g.length,S=Zl(e.data).idealGeometry,A=e.getAtomProxy(),M=e.getAtomProxy(),C=function(e){d.eachWithin(b[e],x[e],_[e],l,(function(t,r){if(!(t<=e)){var i=g[e],n=g[t],l=function(e,t){return 9===e&&5===t||5===e&&9===t}(i,n);if(l||function(e,t){return 5===e&&4===t||4===e&&5===t}(i,n)){var p=5===n?[e,t]:[t,e],d=p[0],v=p[1];if(A.index=y[d][0],M.index=y[v][0],M.index!==A.index&&!hh(A,M,u)&&!(16!==A.number&&16!==M.number&&r>h||A.connectedTo(M))){var b=ql(A,M),x=Wl.get(S[A.index])||Wo(120);if(!b.some((function(e){return Math.abs(x-e)>a}))){if(3===S[A.index]){var _=Xl(A,M);if(void 0!==_&&_>c)return}var w=ql(M,A),C=Wl.get(S[M.index])||Wo(120);if(!w.some((function(e){return C-e>o}))){if(3===S[M.index]){var P=Xl(M,A);if(void 0!==P&&P>s)return}m.setBits(d,v);var T,I,E=l?8:function(e,t){return e.isWater()&&t.isWater()}(T=A,I=M)?9:function(e,t){return e.isBackbone()&&t.isBackbone()}(T,I)?10:4;f.addContact(d,v,E)}}}}}}))},P=0;Pn)){var m=ql(d,h);0!==m.length&&(m.some((function(e){return sh-e>n}))||(u.setBits(e,t),c.addContact(e,t,5)))}}}))},x=0;xi&&!ch(v,b,o)&&!ch(y,b,o)&&!c.includes(r)&&!u.includes(r)&&x.distanceToSquared(b)>1&&_.distanceToSquared(b)>1&&(s.clear(t),e.Debug&&is.log("removing",v.qualifiedName(),y.qualifiedName(),"because",b.qualifiedName()))}))})),e.Debug&&is.timeEnd("refineLineOfSight")}(t,n,r),function(e,t){var r=t.contactSet,i=t.contactStore,n=t.features,o=i.type,a=i.index1,s=i.index2,c=n.atomSets,u=e.getAtomProxy(),l=e.getAtomProxy(),h={},p=function(e,t,i){var n=h[i]||[1/0,-1],o=n[0],a=n[1];e=d){O=y,I=!0;break}if(I)break}if(I)break}for(I=!1,v=o;v=d){L=v,I=!0;break}if(I)break}if(I)break}for(I=!1,m=n;m=d){D=m,I=!0;break}if(I)break}if(I)break}for(I=!1,y=l;y>=s;--y){for(v=u;v>=o;--v){for(m=c;m>=n;--m)if(e[h=t*r*y+t*v+m]>=d){B=y,I=!0;break}if(I)break}if(I)break}for(I=!1,v=u;v>=o;--v){for(y=B;y>=s;--y){for(m=c;m>=n;--m)if(e[h=t*r*y+t*v+m]>=d){N=v,I=!0;break}if(I)break}if(I)break}for(I=!1,m=c;m>=n;--m){for(v=N;v>=o;--v){for(y=B;y>=s;--y)if(e[h=t*r*y+t*v+m]>=d){R=m,I=!0;break}if(I)break}if(I)break}f?(n=Math.max(0,D-1),o=Math.max(0,L-1),s=Math.max(0,O-1),c=Math.min(t-1,R+1),u=Math.min(r-1,N+1),l=Math.min(i-1,B+1)):(n=Math.max(1,D-1),o=Math.max(1,L-1),s=Math.max(1,O-1),c=Math.min(t-2,R+1),u=Math.min(r-2,N+1),l=Math.min(i-2,B+1))}var F=15;for(y=s;y0?-1:1,o||(o=new Float32Array(3*b)));var P=3*b;if(a&&a.length===P||(a=new Int32Array(P)),s=0,c=0,void 0!==x){var T=x[0].map(Math.round),I=x[1].map(Math.round);u=t*Math.ceil(Math.abs(T[0])/t),l=r*Math.ceil(Math.abs(T[1])/r),h=i*Math.ceil(Math.abs(T[2])/i),N(T[0],T[1],T[2],I[0],I[1],I[2])}else u=l=h=0,N();return S.length=3*s,f||(A.length=3*s),M.length=c,n&&(C.length=s),{position:new Float32Array(S),normal:f?void 0:new Float32Array(A),index:No(M,S.length/3),atomindex:n?new Int32Array(C):void 0,contour:m}}}ms.add("arrow",wh),ms.add("box",Lh),ms.add("cone",Ph),ms.add("cylinder",_h),ms.add("ellipsoid",Eh),ms.add("octahedron",Dh),ms.add("sphere",kh),ms.add("tetrahedron",Bh),ms.add("torus",Fh),ms.add("point",Gh),ms.add("wideline",Vh),Object.assign(Wh,{__deps:[$h,Hh,No]});var qh=function(e,t){this.cols=e,this.rows=t,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)};function Xh(e,t){for(var r=0,i=0,n=t.rows,o=t.cols,a=0,s=0,c=0,u=t.data,l=e.data;r(t=Math.abs(t))?(t/=e,e*Math.sqrt(1+t*t)):t>0?(e/=t,t*Math.sqrt(1+e*e)):0}qh.prototype.copyTo=function(e){e.data.set(this.data)};function tp(e,t,r,i){var n=0,o=0,a=e.rows,s=e.cols,c=a,u=s;c>16)?L:-L,e[c*t+l]=D;for(h=0;h<2;h++)for(u=0;ur){var i=t;t=r,r=i}var n=e[t];return void 0===n?(e[t]=[r],!0):!n.includes(r)&&(n.push(r),!0)}var r=this.geometry,i=r.index;if(this.parameters.wireframe)if(i){var n,o=i.array,a=o.length;if(r.drawRange.count!==1/0&&(a=r.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*a)n=this.wireframeIndex;else n=No(2*a,r.attributes.position.count);var s=0;e.length=0;for(var c=0;c2*d?this.wireframeIndex:No(2*d,d);for(var f=0,m=0;fthis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new wt(this.wireframeIndex,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0));else{var e=this.wireframeGeometry.getIndex();if(!e)return void is.error("Index is null");e.set(this.wireframeIndex),e.needsUpdate=this.wireframeIndexCount>0,e.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}},Ap.prototype.getRenderOrder=function(){var e=0;return this.isText?e=1:this.transparent&&(e=this.isSurface?3:2),e},Ap.prototype._getMesh=function(e){this.material||this.makeMaterial();var t,r=this.geometry,i=this[e];return(t=this.isLine?new Gn(r,i):this.isPoint?new Xn(r,i):new or(r,i)).frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},Ap.prototype.getMesh=function(){return this._getMesh("material")},Ap.prototype.getWireframeMesh=function(){var e;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),(e=new Gn(this.wireframeGeometry,this.wireframeMaterial)).frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e},Ap.prototype.getPickingMesh=function(){return this._getMesh("pickingMaterial")},Ap.prototype.getShader=function(e,t){return Bs(e,this.getDefines(t))},Ap.prototype.getVertexShader=function(e){return this.getShader(this.vertexShader,e)},Ap.prototype.getFragmentShader=function(e){return this.getShader(this.fragmentShader,e)},Ap.prototype.getDefines=function(e){var t={};return this.parameters.clipNear&&(t.NEAR_CLIP=1),this.parameters.clipRadius&&(t.RADIUS_CLIP=1),"picking"===e?t.PICKING=1:(("background"===e||this.parameters.background)&&(t.NOLIGHT=1),this.parameters.flatShaded&&(t.FLAT_SHADED=1),this.parameters.opaqueBack&&(t.OPAQUE_BACK=1),this.parameters.diffuseInterior&&(t.DIFFUSE_INTERIOR=1),this.parameters.useInteriorColor&&(t.USE_INTERIOR_COLOR=1)),t},Ap.prototype.getParameters=function(){return this.parameters},Ap.prototype.addUniforms=function(e){this.uniforms=gr.merge([this.uniforms,e]),this.pickingUniforms=gr.merge([this.pickingUniforms,e])},Ap.prototype.addAttributes=function(e){for(var t in e){var r=void 0,i=e[t],n=this.attributeSize*xp[i.type];i.value?(n!==i.value.length&&is.error("attribute value has wrong length",t),r=i.value):r=ko("float32",n),this.geometry.setAttribute(t,new wt(r,xp[i.type]).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0))}},Ap.prototype.updateRenderOrder=function(){var e=this.getRenderOrder();function t(t){t.renderOrder=e}this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)},Ap.prototype.updateShader=function(){var e=this.material,t=this.wireframeMaterial,r=this.pickingMaterial;e.vertexShader=this.getVertexShader(),e.fragmentShader=this.getFragmentShader(),e.needsUpdate=!0,t.vertexShader=this.getShader("Line.vert"),t.fragmentShader=this.getShader("Line.frag"),t.needsUpdate=!0,r.vertexShader=this.getVertexShader("picking"),r.fragmentShader=this.getFragmentShader("picking"),r.needsUpdate=!0},Ap.prototype.setParameters=function(e){var t=e,r=this.parameterTypes,i=this.parameters,n={},o={},a=!1,s=!1;for(var c in t){var u=t[c];void 0!==u&&(i[c]=u,void 0!==r[c]&&(r[c].property&&(!0!==r[c].property?n[r[c].property]=u:n[c]=u),r[c].uniform&&(!0!==r[c].uniform?o[r[c].uniform]=u:o[c]=u),r[c].updateShader&&(a=!0),r[c].updateVisibility&&(s=!0),this.dynamic&&"wireframe"===c&&!0===u&&this.updateWireframeIndex(),"forceTransparent"===c&&(n.transparent=this.transparent),"matrix"===c&&(this.matrix=u)))}this.setProperties(n),this.setUniforms(o),a&&this.updateShader(),s&&this.setVisibility(this.visible)},Ap.prototype.setAttributes=function(e){var t=this.geometry,r=t.attributes;for(var i in e)if("picking"!==i){var n=e[i],o=n.length;if("index"===i){var a=t.getIndex();if(!a){is.error("Index is null");continue}t.setDrawRange(0,1/0),o>a.array.length?t.setIndex(new wt(n,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(a.set(n),a.count=o,a.needsUpdate=o>0,a.updateRange.count=o,t.setDrawRange(0,o)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{var s=r[i];o>s.array.length?t.setAttribute(i,new wt(n,s.itemSize).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(r[i].set(n),r[i].needsUpdate=o>0,r[i].updateRange.count=o)}}},Ap.prototype.setUniforms=function(e){if(e){var t=this.material.uniforms,r=this.wireframeMaterial.uniforms,i=this.pickingMaterial.uniforms;for(var n in e)"opacity"===n&&this.setProperties({transparent:this.transparent}),void 0!==t[n]&&(t[n].value.isVector3?t[n].value.copy(e[n]):t[n].value.set?t[n].value.set(e[n]):t[n].value=e[n]),void 0!==r[n]&&(r[n].value.isVector3?r[n].value.copy(e[n]):r[n].value.set?r[n].value.set(e[n]):r[n].value=e[n]),void 0!==i[n]&&(i[n].value.isVector3?i[n].value.copy(e[n]):i[n].value.set?i[n].value.set(e[n]):i[n].value=e[n])}},Ap.prototype.setProperties=function(e){if(e){var t=this.material,r=this.wireframeMaterial,i=this.pickingMaterial;for(var n in e){var o=n,a=e[o];"transparent"===o?this.updateRenderOrder():"side"===o&&(a=bp(a)),t[o]=a,r[o]=a,i[o]=a}t.needsUpdate=!0,r.needsUpdate=!0,i.needsUpdate=!0}},Ap.prototype.setVisibility=function(e){this.visible=e,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=e,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=e,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=e))},Ap.prototype.dispose=function(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()},Ap.prototype.toJSON=function(){var e={};for(var t in this)"group"!==t&&"wireframeGroup"!==t&&"pickingGroup"!=t&&"picking"!==t&&(e[t]=this[t]);return e},Object.defineProperties(Ap.prototype,Mp);var Cp=function(e){function t(t,r){void 0===r&&(r={}),e.call(this,t,r),this.vertexShader="Mesh.vert",this.fragmentShader="Mesh.frag",this.addAttributes({normal:{type:"v3",value:t.normal}}),void 0===t.normal&&this.geometry.computeVertexNormals()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Ap),Pp=function(e){function t(){e.apply(this,arguments),this.isSurface=!0}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Cp);function Tp(e){e.visible=!0}function Ip(e){e.visible=!1}var Ep=function(e){this.group=new Pn,this.wireframeGroup=new Pn,this.pickingGroup=new Pn,this.frontMeshes=[],this.backMeshes=[],this.size=e.size,this.side=e.parameters.side,this.visible=e.visible,this.geometry=e.geometry,this.picking=e.picking,this.group=new Pn,this.wireframeGroup=new Pn,this.pickingGroup=new Pn,this.matrix=e.matrix;var t=e,r=new e.constructor({position:new Float32Array(0)});t.makeMaterial(),r.makeMaterial(),r.picking=e.picking,r.geometry=e.geometry,r.wireframeGeometry=e.wireframeGeometry,r.setParameters(e.getParameters()),r.updateShader(),t.setParameters({side:"front"}),r.setParameters({side:"back",opacity:r.parameters.opacity}),this.buffer=e,this.frontBuffer=t,this.backBuffer=r},Dp={matrix:{configurable:!0},pickable:{configurable:!0},parameters:{configurable:!0}};Dp.matrix.set=function(e){Ap.prototype.setMatrix.call(this,e)},Dp.matrix.get=function(){return this.group.matrix.clone()},Dp.pickable.get=function(){return!!this.picking&&!this.parameters.disablePicking},Dp.parameters.get=function(){return this.buffer.parameters},Ep.prototype.getParameters=function(){var e=Object.assign({},this.buffer.parameters);return e.side=this.side,e},Ep.prototype.getMesh=function(e){var t,r;return e?(r=this.backBuffer.getPickingMesh(),t=this.frontBuffer.getPickingMesh()):(r=this.backBuffer.getMesh(),t=this.frontBuffer.getMesh()),this.frontMeshes.push(t),this.backMeshes.push(r),this.setParameters({side:this.side}),(new Pn).add(r,t)},Ep.prototype.getWireframeMesh=function(){return this.buffer.getWireframeMesh()},Ep.prototype.getPickingMesh=function(){return this.getMesh(!0)},Ep.prototype.setAttributes=function(e){this.buffer.setAttributes(e)},Ep.prototype.setParameters=function(e){"front"===(e=Object.assign({},e)).side?(this.frontMeshes.forEach(Tp),this.backMeshes.forEach(Ip)):"back"===e.side?(this.frontMeshes.forEach(Ip),this.backMeshes.forEach(Tp)):"double"===e.side&&(this.frontMeshes.forEach(Tp),this.backMeshes.forEach(Tp)),void 0!==e.side&&(this.side=e.side),delete e.side,void 0!==e.matrix&&(this.matrix=e.matrix),delete e.matrix,this.frontBuffer.setParameters(e),void 0!==e.wireframe&&(this.wireframe=e.wireframe,this.setVisibility(this.visible)),delete e.wireframe,this.backBuffer.setParameters(e)},Ep.prototype.setVisibility=function(e){this.visible=e,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=e,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=e,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=e))},Ep.prototype.dispose=function(){this.frontBuffer.dispose(),this.backBuffer.dispose()},Ep.prototype.toJSON=function(){var e={};for(var t in this)["side","size","visible","matrix","parameters"].includes(t)&&(e[t]=this[t]);return e},Object.defineProperties(Ep.prototype,Dp),hs.add("shader/Line.vert","uniform float clipNear;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),hs.add("shader/Line.frag","uniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");var Lp=function(e){function t(){e.apply(this,arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Ap),Op=function(e){function t(t,r,i){e.call(this,t,r,i),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},isolevelScroll:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),t instanceof vp?(this.surface=void 0,this.volume=t):(this.surface=t,this.volume=void 0),this.boxCenter=new Y,this.__boxCenter=new Y,this.box=new Ne,this.__box=new Ne,this._position=new Y,this.inverseMatrix=new ie,this.setBox=function(){this._position.copy(r.translationGroup.position).negate(),this._position.applyMatrix4(this.inverseMatrix),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(i)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){var r=t||{};r.colorScheme=So(r.colorScheme,"uniform"),r.colorValue=So(r.colorValue,14540253),this.isolevelType=So(r.isolevelType,"sigma"),this.isolevel=So(r.isolevel,2),this.negateIsolevel=So(r.negateIsolevel,!1),this.isolevelScroll=So(r.isolevelScroll,!1),this.smooth=So(r.smooth,0),this.background=So(r.background,!1),this.opaqueBack=So(r.opaqueBack,!0),this.boxSize=So(r.boxSize,0),this.colorVolume=So(r.colorVolume,void 0),this.contour=So(r.contour,!1),this.useWorker=So(r.useWorker,!0),this.wrap=So(r.wrap,!1),e.prototype.init.call(this,r),this.inverseMatrix.getInverse(this.matrix),this.build()},t.prototype.attach=function(e){var t=this;this.bufferList.forEach((function(e){t.viewer.add(e)})),this.setVisibility(this.visible),e()},t.prototype.prepare=function(e){var t,r=this;if(this.volume)if(t="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(t*=-1),!this.surface||this.__isolevel!==t||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=t,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);var i=function(t){r.surface=t,e()};this.useWorker?this.volume.getSurfaceWorker(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else e();else e()},t.prototype.create=function(){var e,t={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};if(this.contour)e=new Lp(t,this.getBufferParams({wireframe:!1}));else{Object.assign(t,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});var r=new Pp(t,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));e=new Ep(r)}this.bufferList.push(e)},t.prototype.update=function(e){if(0!==this.bufferList.length){var t={};(e=e||{}).position&&(t.position=this.surface.getPosition()),e.color&&(t.color=this.surface.getColor(this.getColorParams())),e.index&&(t.index=this.surface.getIndex()),e.normal&&(t.normal=this.surface.getNormal()),this.bufferList.forEach((function(e){e.setAttributes(t)}))}},t.prototype.setParameters=function(t,r,i){return t&&void 0!==t.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===t.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===t.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=t.isolevelType),t&&t.boxCenter&&(this.boxCenter.copy(t.boxCenter),delete t.boxCenter),t&&t.wireframe&&(t.contour||void 0===t.contour&&this.contour)&&(t.wireframe=!1),e.prototype.setParameters.call(this,t,r,i),t.matrix&&this.inverseMatrix.getInverse(t.matrix),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),t&&void 0!==t.colorVolume&&r&&(r.color=!0),this.surface&&(void 0!==t.isolevel||void 0!==t.negateIsolevel||void 0!==t.smooth||void 0!==t.wrap||void 0!==t.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this},t.prototype.getColorParams=function(){var t=e.prototype.getColorParams.call(this);return t.volume=this.colorVolume,t},t.prototype.dispose=function(){this.viewer.signals.ticked.remove(this.setBox,this),e.prototype.dispose.call(this)},t}(vu),Rp=function(){};Rp.zoomScroll=function(e,t){e.trackballControls.zoom(t)},Rp.clipNearScroll=function(e,t){var r=e.getParameters();e.setParameters({clipNear:r.clipNear+t/10})},Rp.focusScroll=function(e,t){var r=e.getFocus(),i=Math.sign(t)*function(e,t,r){if(e>t)return e;var i=e/t;return((2*r-t)*i+(2*t-3*r))*i*i+r}((100-r)/10,5,.2);e.setFocus(r+i)},Rp.zoomFocusScroll=function(e,t){e.trackballControls.zoom(t);var r=e.viewer.camera.position.z;e.setFocus(100-Math.abs(r/8))},Rp.isolevelScroll=function(e,t){var r=Math.sign(t)/10;e.eachRepresentation((function(e,t){if(e.repr instanceof Op){var i=e.getParameters();i.isolevelScroll&&e.setParameters({isolevel:i.isolevel+r})}}))},Rp.panDrag=function(e,t,r){e.trackballControls.pan(t,r)},Rp.rotateDrag=function(e,t,r){e.trackballControls.rotate(t,r)},Rp.zRotateDrag=function(e,t,r){e.trackballControls.zRotate(t,r)},Rp.zoomDrag=function(e,t,r){e.trackballControls.zoom((t+r)/-2)},Rp.zoomFocusDrag=function(e,t,r){e.trackballControls.zoom((t+r)/-2);var i=e.viewer.camera.position.z;e.setFocus(100-Math.abs(i/8))},Rp.panComponentDrag=function(e,t,r){e.trackballControls.panComponent(t,r)},Rp.panAtomDrag=function(e,t,r){e.trackballControls.panAtom(t,r)},Rp.rotateComponentDrag=function(e,t,r){e.trackballControls.rotateComponent(t,r)},Rp.movePick=function(e,t){t&&e.animationControls.move(t.position.clone())},Rp.tooltipPick=function(e,t){var r=e.tooltip;if(e.getParameters().tooltip&&t){var i=t.mouse.position;r.innerText=t.getLabel(),r.style.bottom=window.innerHeight-i.y+3+"px",r.style.left=i.x+3+"px",r.style.display="block"}else r.style.display="none"};var kp={default:[["scroll",Rp.zoomScroll],["scroll-shift",Rp.focusScroll],["scroll-ctrl",Rp.isolevelScroll],["scroll-shift-ctrl",Rp.zoomFocusScroll],["drag-left",Rp.rotateDrag],["drag-right",Rp.panDrag],["drag-ctrl-left",Rp.panDrag],["drag-ctrl-right",Rp.zRotateDrag],["drag-shift-left",Rp.zoomDrag],["drag-middle",Rp.zoomFocusDrag],["drag-ctrl-shift-right",Rp.panComponentDrag],["drag-ctrl-shift-left",Rp.rotateComponentDrag],["clickPick-right",Rp.measurePick=function(e,t){if(t&&(t.atom||t.bond)){var r=t.atom||t.closestBondAtom;t.component.measurePick(r)}else e.measureClear()}],["clickPick-ctrl-left",Rp.measurePick],["clickPick-middle",Rp.movePick],["clickPick-left",Rp.movePick],["hoverPick",Rp.tooltipPick]],pymol:[["drag-left",Rp.rotateDrag],["drag-middle",Rp.panDrag],["drag-right",Rp.zoomDrag],["drag-shift-right",Rp.focusScroll],["clickPick-ctrl+shift-middle",Rp.movePick],["hoverPick",Rp.tooltipPick]],coot:[["scroll",Rp.isolevelScroll],["drag-left",Rp.rotateDrag],["drag-middle",Rp.panDrag],["drag-ctrl-left",Rp.panDrag],["drag-right",Rp.zoomFocusDrag],["drag-ctrl-right",Rp.focusScroll],["clickPick-middle",Rp.movePick],["hoverPick",Rp.tooltipPick]],astexviewer:[["drag-left",Rp.rotateDrag],["drag-ctrl-left",Rp.panDrag],["drag-shift-left",Rp.zoomDrag],["scroll",Rp.focusScroll],["clickPick-middle",Rp.movePick],["hoverPick",Rp.tooltipPick]]};function Np(e){var t=e.split(/[-+]/),r="";t.includes("scroll")&&(r="scroll"),t.includes("drag")&&(r="drag"),t.includes("click")&&(r="click"),t.includes("doubleClick")&&(r="doubleClick"),t.includes("hover")&&(r="hover"),t.includes("clickPick")&&(r="clickPick"),t.includes("hoverPick")&&(r="hoverPick");var i=0;t.includes("alt")&&(i+=1),t.includes("ctrl")&&(i+=2),t.includes("meta")&&(i+=4),t.includes("shift")&&(i+=8);var n=0;return t.includes("left")&&(n+=1),t.includes("right")&&(n+=2),t.includes("middle")&&(n+=4),[r,i,n]}var Bp=function(e,t){void 0===t&&(t={}),this.stage=e,this.actionList=[],this.mouse=e.mouseObserver,this.disabled=t.disabled||!1,this.preset(t.preset||"default")};Bp.prototype.run=function(e){for(var t=this,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];if(!this.disabled){var n=this.mouse.key||0,o=this.mouse.buttons||0;this.actionList.forEach((function(i){i.type===e&&i.key===n&&i.button===o&&i.callback.apply(i,[t.stage].concat(r))}))}},Bp.prototype.add=function(e,t){var r=Np(e),i=r[0],n=r[1],o=r[2];this.actionList.push({type:i,key:n,button:o,callback:t})},Bp.prototype.remove=function(e,t){var r=e.includes("*"),i=Np(e),n=i[0],o=i[1],a=i[2],s=this.actionList.filter((function(e){return!((e.type===n||r&&""===n)&&(e.key===o||r&&0===o)&&(e.button===a||r&&0===a)&&(e.callback===t||void 0===t))}));this.actionList=s},Bp.prototype.preset=function(e){var t=this;this.clear(),(kp[e]||[]).forEach((function(e){return t.add(e[0],e[1])}))},Bp.prototype.clear=function(){this.actionList.length=0};var Fp=function(){};Fp.autoView=function(e){e.autoView(1e3)},Fp.toggleAnimations=function(e){e.animationControls.toggle()},Fp.toggleRock=function(e){e.toggleRock()};var zp={default:[["i",Fp.toggleSpin=function(e){e.toggleSpin()}],["k",Fp.toggleRock],["p",Fp.toggleAnimations],["a",Fp.toggleAntialiasing=function(e){var t=e.getParameters();e.setParameters({sampleLevel:-1===t.sampleLevel?0:-1})}],["r",Fp.autoView]]},Up=function(e,t){void 0===t&&(t={}),this.stage=e,this.actionList=[],this.disabled=t.disabled||!1,this.preset(t.preset||"default")};Up.prototype.run=function(e){var t=this;this.disabled||this.actionList.forEach((function(r){r.key===e&&r.callback(t.stage)}))},Up.prototype.add=function(e,t){this.actionList.push({key:e,callback:t})},Up.prototype.remove=function(e,t){var r=this.actionList.filter((function(r){return!(r.key===e&&(r.callback===t||void 0===t))}));this.actionList=r},Up.prototype.preset=function(e){var t=this;this.clear(),(zp[e]||[]).forEach((function(e){return t.add(e[0],e[1])}))},Up.prototype.clear=function(){this.actionList.length=0};var jp=function(e){this.stage=e,this.stage=e,this.mouse=e.mouseObserver,this.controls=e.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)};jp.prototype._onClick=function(e,t){var r=this.stage.pickingControls.pick(e,t);this.stage.signals.clicked.dispatch(r),this.controls.run("clickPick",r)},jp.prototype._onHover=function(e,t){var r=this.stage.pickingControls.pick(e,t);r&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=r.component,this.stage.transformAtom=r.atom),this.stage.signals.hovered.dispatch(r),this.controls.run("hoverPick",r)},jp.prototype.dispose=function(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Gp=function(e){this.stage=e,this.stage=e,this.mouse=e.mouseObserver,this.controls=e.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)};Gp.prototype._onMove=function(){this.stage.tooltip.style.display="none"},Gp.prototype._onScroll=function(e){this.controls.run("scroll",e)},Gp.prototype._onDrag=function(e,t){this.controls.run("drag",e,t)},Gp.prototype._onClick=function(e,t){this.controls.run("click",e,t)},Gp.prototype._onDblclick=function(e,t){this.controls.run("doubleClick",e,t)},Gp.prototype._onHover=function(e,t){this.controls.run("hover",e,t)},Gp.prototype.dispose=function(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Vp=function(e){this.stage=e,this.viewer=e.viewer,this.animationControls=e.animationControls,this.viewer.signals.ticked.add(this._onTick,this)};Vp.prototype._onTick=function(e){this.animationControls.run(e)},Vp.prototype.dispose=function(){this.viewer.signals.ticked.remove(this._onTick,this)};var $p=!!Ya&&{passive:!0},Hp=function(e){this.stage=e,this.stage=e,this.controls=e.keyControls,this.domElement=e.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,$p),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)};Hp.prototype._onKeydown=function(){},Hp.prototype._onKeyup=function(){},Hp.prototype._onKeypress=function(e){var t;t="key"in KeyboardEvent.prototype?e.key:String.fromCharCode(e.which||e.keyCode),this.controls.run(t)},Hp.prototype._focusDomElement=function(){this.domElement.focus()},Hp.prototype.dispose=function(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,$p),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)};var Wp=function(e,t,r,i){void 0===i&&(i={}),this.component=e,this.position=t,this.offsetX=So(i.offsetX,0),this.offsetY=So(i.offsetY,0),this.visible=So(i.visible,!0),this.stage=e.stage,this.viewer=e.stage.viewer,this._viewerPosition=new Y,this._updateViewerPosition(),this._canvasPosition=new z,this._cameraPosition=new Y,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",left:"-10000px"}),this.viewer.wrapper.appendChild(this.element),this.setContent(r),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)};Wp.prototype.setContent=function(e){var t=this.element.style.display;if("none"===t&&(this.element.style.left="-10000px",this.element.style.display="block"),e instanceof HTMLElement)this.element.appendChild(e);else{var r=document.createElement("div");r.innerText=e,Object.assign(r.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(r)}this._clientRect=this.element.getBoundingClientRect(),"none"===t&&(this.element.style.display=t)},Wp.prototype.setVisibility=function(e){this.visible=e,this.updateVisibility()},Wp.prototype.getVisibility=function(){return this.visible&&this.component.parameters.visible},Wp.prototype.updateVisibility=function(){this.element.style.display=this.getVisibility()?"block":"none"},Wp.prototype._updateViewerPosition=function(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)},Wp.prototype._update=function(){if(this.getVisibility()){var e=this.element.style,t=this._canvasPosition,r=this._viewerPosition,i=this._clientRect;if(this._cameraPosition.copy(r).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)e.display="none";else{e.display="block";var n=this._cameraPosition.length(),o=this.viewer.scene.fog;e.opacity=(1-Jo(o.near,o.far,n)).toString(),e.zIndex=Math.round(100*(o.far-n)).toString(),this.stage.viewerControls.getPositionOnCanvas(r,t),e.bottom=this.offsetX+t.y+i.height/2+"px",e.left=this.offsetY+t.x-i.width/2+"px"}}},Wp.prototype.dispose=function(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)};var qp=new ie,Xp=new Y,Yp=new W,Zp=function(e){this.component=e,this.signals={changed:new ua.Signal},this.stage=e.stage,this.viewer=e.stage.viewer},Kp={position:{configurable:!0},rotation:{configurable:!0}};Kp.position.get=function(){return this.component.position},Kp.rotation.get=function(){return this.component.quaternion},Zp.prototype.changed=function(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()},Zp.prototype.spin=function(e,t){qp.getInverse(this.viewer.rotationGroup.matrix),Xp.copy(zo(e)).applyMatrix4(qp),qp.extractRotation(this.component.transform),qp.premultiply(this.viewer.rotationGroup.matrix),qp.getInverse(qp),Xp.copy(zo(e)),Xp.applyMatrix4(qp),qp.makeRotationAxis(Xp,t),Yp.setFromRotationMatrix(qp),this.component.quaternion.premultiply(Yp),this.changed()},Object.defineProperties(Zp.prototype,Kp);var Qp={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"},Jp=function(e){void 0===e&&(e={}),this.max=10,this.type=So(e.type,"size"),this.scale=So(e.scale,1),this.size=So(e.size,1),this.data=So(e.data,{})};Jp.prototype.atomRadius=function(e){var t;switch(this.type){case"vdw":t=e.vdw;break;case"covalent":t=e.covalent;break;case"bfactor":t=e.bfactor||1;break;case"sstruc":var r=e.sstruc;t="h"===r||"g"===r||"i"===r||"e"===r||"b"===r?.25:Gl.includes(e.atomname)?.4:.1;break;case"data":t=So(this.data[e.index],1);break;case"explicit":null===(t=e.radius)&&(t=this.size);break;default:t=this.size}return Math.min(t*this.scale,this.max)},Jp.types=Qp;var ed=new Y(-1,-1,-1),td=new ie,rd=function(e){var t=e.rows,r=t/3,i=new qh(t,3),n=new qh(3,3),o=new qh(1,3),a=new qh(3,3),s=new qh(3,3),c=Kh(e);Qh(e,c),Xh(i,e),Yh(n,i,i),tp(n,o,a,s);var u=new Y(c[0],c[1],c[2]),l=new Y(a.data[0],a.data[3],a.data[6]),h=new Y(a.data[1],a.data[4],a.data[7]),p=new Y(a.data[2],a.data[5],a.data[8]),d=l.clone().multiplyScalar(Math.sqrt(o.data[0]/r)),f=h.clone().multiplyScalar(Math.sqrt(o.data[1]/r)),m=p.clone().multiplyScalar(Math.sqrt(o.data[2]/r));this.begA=u.clone().sub(d),this.endA=u.clone().add(d),this.begB=u.clone().sub(f),this.endB=u.clone().add(f),this.begC=u.clone().sub(m),this.endC=u.clone().add(m),this.center=u,this.vecA=d,this.vecB=f,this.vecC=m,this.normVecA=l,this.normVecB=h,this.normVecC=p};rd.prototype.getBasisMatrix=function(e){void 0===e&&(e=new ie);var t=e;return t.makeBasis(this.normVecB,this.normVecA,this.normVecC),t.determinant()<0&&t.scale(ed),t},rd.prototype.getRotationQuaternion=function(e){void 0===e&&(e=new W);var t=e;return t.setFromRotationMatrix(this.getBasisMatrix(td)),t.inverse()},rd.prototype.getProjectedScaleForAtoms=function(e){var t=-1/0,r=-1/0,i=-1/0,n=-1/0,o=-1/0,a=-1/0,s=new Y,c=new Y,u=this.center,l=this.normVecA,h=this.normVecB,p=this.normVecC;return e.eachAtom((function(e){_u(s.copy(e),l,u);var d=c.subVectors(s,u).normalize().dot(l),f=s.distanceTo(u);d>0?f>t&&(t=f):f>r&&(r=f),_u(s.copy(e),h,u);var m=c.subVectors(s,u).normalize().dot(h),g=s.distanceTo(u);m>0?g>i&&(i=g):g>n&&(n=g),_u(s.copy(e),p,u);var v=c.subVectors(s,u).normalize().dot(p),y=s.distanceTo(u);v>0?y>o&&(o=y):y>a&&(a=y)})),{d1a:t,d2a:i,d3a:o,d1b:-r,d2b:-n,d3b:-a}};var id=function(e,t,r,i){this.volume=e,this.setFilter(t,r,i)},nd={header:{configurable:!0},matrix:{configurable:!0},normalMatrix:{configurable:!0},inverseMatrix:{configurable:!0},center:{configurable:!0},boundingBox:{configurable:!0},min:{configurable:!0},max:{configurable:!0},mean:{configurable:!0},rms:{configurable:!0}};nd.header.get=function(){return this.volume.header},nd.matrix.get=function(){return this.volume.matrix},nd.normalMatrix.get=function(){return this.volume.normalMatrix},nd.inverseMatrix.get=function(){return this.volume.inverseMatrix},nd.center.get=function(){return this.volume.center},nd.boundingBox.get=function(){return this.volume.boundingBox},nd.min.get=function(){return this.volume.min},nd.max.get=function(){return this.volume.max},nd.mean.get=function(){return this.volume.mean},nd.rms.get=function(){return this.volume.rms},id.prototype._getFilterHash=function(e,t,r){return JSON.stringify([e,t,r])},id.prototype.setFilter=function(e,t,r){isNaN(e)&&this.header&&(e=this.header.DMEAN+2*this.header.ARMS),e=void 0===e||isNaN(e)?-1/0:e,t=So(t,1/0),r=So(r,!1);var i=this.volume.data,n=this.volume.position,o=this.volume.atomindex,a=this._getFilterHash(e,t,r);if(a!==this._filterHash){if(e===-1/0&&t===1/0)this.data=i,this.position=n,this.atomindex=o;else{var s=i.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*s),this._positionBuffer=new ArrayBuffer(3*s*4),o&&(this._atomindexBuffer=new ArrayBuffer(4*s)));var c,u=new Float32Array(this._dataBuffer),l=new Float32Array(this._positionBuffer);o&&(c=new Uint32Array(this._atomindexBuffer));for(var h=0,p=0;p=e&&f<=t||r&&(ft)){var m=3*h;u[h]=f,l[m+0]=n[d+0],l[m+1]=n[d+1],l[m+2]=n[d+2],o&&c&&(c[h]=o[p]),h+=1}}this.data=new Float32Array(this._dataBuffer,0,h),this.position=new Float32Array(this._positionBuffer,0,3*h),o&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,h))}this._filterHash=a}},Object.defineProperties(id.prototype,nd),id.prototype.getValueForSigma=vp.prototype.getValueForSigma,id.prototype.getSigmaForValue=vp.prototype.getSigmaForValue,id.prototype.getDataAtomindex=vp.prototype.getDataAtomindex,id.prototype.getDataPosition=vp.prototype.getDataPosition,id.prototype.getDataColor=vp.prototype.getDataColor,id.prototype.getDataPicking=vp.prototype.getDataPicking,id.prototype.getDataSize=vp.prototype.getDataSize;var od=function(e,t){var r=dl({nodeArray1:e.atomIndex1,nodeArray2:e.atomIndex2,edgeCount:e.count,nodeCount:t});this.countArray=r.countArray,this.offsetArray=r.offsetArray,this.indexArray=r.indexArray},ad=function(e){function t(){e.apply(this,arguments)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={_defaultFields:{configurable:!0}};return r._defaultFields.get=function(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]},t.prototype.addBond=function(e,t,r){this.growIfFull();var i=this.count,n=e.index,o=t.index;n0&&(a[T]=b.angleTo(x));var E=Math.cos(f.angleTo(m));u[T]=180/Math.PI*Math.acos(E);var D=f.length(),L=m.length();s[T]=Math.sqrt(L*D)/Math.max(2,2*(1-E)),c[T]=Math.abs(p.dot(b)),g.copy(f).multiplyScalar(s[T]/D),v.copy(m).multiplyScalar(s[T]/L),g.subVectors(M,g),v.subVectors(C,v),g.toArray(n,I+3),v.toArray(n,I+6),_.subVectors(A,w),_.toArray(l,I),x.copy(b),w.copy(g)}g.fromArray(n,3),v.fromArray(n,6),b.subVectors(g,v).normalize(),A.index=e.getAtomIndexByType(0,S),w.copy(A),y.copy(A),_u(y,b,g),y.toArray(n,0),_.subVectors(w,g),_.toArray(l,0),g.fromArray(n,3*r-6),v.fromArray(n,3*r-9),b.subVectors(g,v).normalize(),A.index=e.getAtomIndexByType(r-1,S),w.copy(A),y.copy(A),_u(y,b,g),y.toArray(n,3*r-3);for(var O=r-3;Ot||u.bending[N]>e)&&(k=!0)),k){if(N-m<4){m=N,k=!1;continue}L.index=E.traceAtomIndex,C=u.axis.subarray(3*m+3,3*N),P=u.center.subarray(3*m,3*N+3),h=xu(C).normalize(),p=xu(P),T.fromArray(P),_u(T,h,p),I.fromArray(P,P.length-3),_u(I,h,p),h.subVectors(I,T),h.toArray(v,g),p.toArray(y,g),T.toArray(b,g),I.toArray(x,g),d.atomColorToArray(L,_,g),w.push(L.index),S.push(f.atomRadius(L)),A.push(c+m),M.push(c+N+1-m),g+=3,m=N,k=!1}var B=new Float32Array(w);return{axis:new Float32Array(v),center:new Float32Array(y),begin:new Float32Array(b),end:new Float32Array(x),color:new Float32Array(_),picking:new Sh(B,a),size:new Float32Array(S),residueOffset:A,residueCount:M}};var dd=function(e){this.scoreFunction=e,this.content=[],this.scoreFunction=e};dd.prototype.push=function(e){this.content.push(e),this.bubbleUp(this.content.length-1)},dd.prototype.pop=function(){var e=this.content[0],t=this.content.pop();return t&&this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e},dd.prototype.peek=function(){return this.content[0]},dd.prototype.remove=function(e){for(var t=this.content.length,r=0;r0;){var r=Math.floor((e+1)/2)-1,i=this.content[r];if(!(this.scoreFunction(t) + * Released under the MIT license + * Author: Miller Medeiros + * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM) + */ +!function(t){function i(e,t,i,n,r){this._listener=t,this._isOnce=i,this.context=n,this._signal=e,this._priority=r||0}function n(e,t){if("function"!=typeof e)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",t))}function r(){this._bindings=[],this._prevParams=null;var e=this;this.dispatch=function(){r.prototype.dispatch.apply(e,arguments)}}i.prototype={active:!0,params:null,execute:function(e){var t,i;return this.active&&this._listener&&(i=this.params?this.params.concat(e):e,t=this._listener.apply(this.context,i),this._isOnce&&this.detach()),t},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},r.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(e,t,n,r){var s,o=this._indexOfListener(e,n);if(-1!==o){if((s=this._bindings[o]).isOnce()!==t)throw new Error("You cannot add"+(t?"":"Once")+"() then add"+(t?"Once":"")+"() the same listener without removing the relationship first.")}else s=new i(this,e,t,n,r),this._addBinding(s);return this.memorize&&this._prevParams&&s.execute(this._prevParams),s},_addBinding:function(e){var t=this._bindings.length;do{--t}while(this._bindings[t]&&e._priority<=this._bindings[t]._priority);this._bindings.splice(t+1,0,e)},_indexOfListener:function(e,t){for(var i,n=this._bindings.length;n--;)if((i=this._bindings[n])._listener===e&&i.context===t)return n;return-1},has:function(e,t){return-1!==this._indexOfListener(e,t)},add:function(e,t,i){return n(e,"add"),this._registerListener(e,!1,t,i)},addOnce:function(e,t,i){return n(e,"addOnce"),this._registerListener(e,!0,t,i)},remove:function(e,t){n(e,"remove");var i=this._indexOfListener(e,t);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),e},removeAll:function(){for(var e=this._bindings.length;e--;)this._bindings[e]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(e){if(this.active){var t,i=Array.prototype.slice.call(arguments),n=this._bindings.length;if(this.memorize&&(this._prevParams=i),n){t=this._bindings.slice(),this._shouldPropagate=!0;do{n--}while(t[n]&&this._shouldPropagate&&!1!==t[n].execute(i))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var s=r;s.Signal=r,e.exports?e.exports=s:t.signals=s}(sc)}));!function(e){e[e.PROTEIN=1]="PROTEIN",e[e.NUCLEIC=2]="NUCLEIC",e[e.RNA=3]="RNA",e[e.DNA=4]="DNA",e[e.POLYMER=5]="POLYMER",e[e.WATER=6]="WATER",e[e.HELIX=7]="HELIX",e[e.SHEET=8]="SHEET",e[e.TURN=9]="TURN",e[e.BACKBONE=10]="BACKBONE",e[e.SIDECHAIN=11]="SIDECHAIN",e[e.ALL=12]="ALL",e[e.HETERO=13]="HETERO",e[e.ION=14]="ION",e[e.SACCHARIDE=15]="SACCHARIDE",e[e.SUGAR=15]="SUGAR",e[e.BONDED=16]="BONDED",e[e.RING=17]="RING",e[e.AROMATICRING=18]="AROMATICRING",e[e.METAL=19]="METAL",e[e.POLARH=20]="POLARH",e[e.NONE=21]="NONE"}(fc||(fc={}));const pc=["*","","ALL"],gc=["NONE"],vc=[fc.BACKBONE,fc.SIDECHAIN,fc.BONDED,fc.RING,fc.AROMATICRING,fc.METAL,fc.POLARH],yc=[fc.POLYMER,fc.WATER],xc=["ALA","GLY","SER"],bc=["CYS","SER","THR"],_c=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],wc=["PHE","TRP","TYR","HIS"],Sc=["ASN","GLN"],Ac=["ASP","GLU"],Mc=["ARG","HIS","LYS"],Cc=["ARG","ASP","GLU","HIS","LYS"],Pc=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],Tc=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Ic=["HIS","PHE","PRO","TRP","TYR"],Ec=["ALA","GLY","ILE","LEU","VAL"];function Dc(e,t){if(void 0===t.atomname&&void 0===t.element&&void 0===t.altloc&&void 0===t.atomindex&&void 0===t.keyword&&void 0===t.inscode&&void 0===t.resname&&void 0===t.sstruc&&void 0===t.resno&&void 0===t.chainname&&void 0===t.model)return-1;if(void 0!==t.keyword){if(t.keyword===fc.BACKBONE&&!e.isBackbone())return!1;if(t.keyword===fc.SIDECHAIN&&!e.isSidechain())return!1;if(t.keyword===fc.BONDED&&!e.isBonded())return!1;if(t.keyword===fc.RING&&!e.isRing())return!1;if(t.keyword===fc.AROMATICRING&&!e.isAromatic())return!1;if(t.keyword===fc.HETERO&&!e.isHetero())return!1;if(t.keyword===fc.PROTEIN&&!e.isProtein())return!1;if(t.keyword===fc.NUCLEIC&&!e.isNucleic())return!1;if(t.keyword===fc.RNA&&!e.isRna())return!1;if(t.keyword===fc.DNA&&!e.isDna())return!1;if(t.keyword===fc.POLYMER&&!e.isPolymer())return!1;if(t.keyword===fc.WATER&&!e.isWater())return!1;if(t.keyword===fc.HELIX&&!e.isHelix())return!1;if(t.keyword===fc.SHEET&&!e.isSheet())return!1;if(t.keyword===fc.TURN&&!e.isTurn())return!1;if(t.keyword===fc.ION&&!e.isIon())return!1;if(t.keyword===fc.SACCHARIDE&&!e.isSaccharide())return!1;if(t.keyword===fc.METAL&&!e.isMetal())return!1;if(t.keyword===fc.POLARH&&!e.isPolarHydrogen())return!1}if(void 0!==t.atomname&&t.atomname!==e.atomname)return!1;if(void 0!==t.element&&t.element!==e.element)return!1;if(void 0!==t.altloc&&t.altloc!==e.altloc)return!1;if(void 0!==t.atomindex&&Na(t.atomindex,e.index)<0)return!1;if(void 0!==t.resname)if(Array.isArray(t.resname)){if(!t.resname.includes(e.resname))return!1}else if(t.resname!==e.resname)return!1;if(void 0!==t.sstruc&&t.sstruc!==e.sstruc)return!1;if(void 0!==t.resno)if(Array.isArray(t.resno)&&2===t.resno.length){if(t.resno[0]>e.resno||t.resno[1]e.resno||t.resno[1]0?e:null}function Nc(e,t=!1){let i=e;return t&&(i=Bc(e,(function(e){return void 0!==e.keyword&&!vc.includes(e.keyword)||(void 0!==e.model||(void 0!==e.chainname||(void 0!==e.resname||(void 0!==e.resno||void 0!==e.sstruc))))}))),Oc(i,Dc)}function Fc(e,t=!1){let i=e;return t&&(i=Bc(e,(function(e){return!(void 0===e.keyword||!vc.includes(e.keyword))||(void 0!==e.model||(void 0!==e.chainname||(void 0!==e.atomname||(void 0!==e.element||void 0!==e.altloc))))}))),Oc(i,Lc)}function zc(e,t=!1){let i=e;return t&&(i=Bc(e,(function(e){return void 0!==e.keyword&&!yc.includes(e.keyword)||(void 0!==e.resname||(void 0!==e.resno||(void 0!==e.atomname||(void 0!==e.element||(void 0!==e.altloc||(void 0!==e.sstruc||void 0!==e.inscode))))))}))),Oc(i,Rc)}function Uc(e,t=!1){let i=e;return t&&(i=Bc(e,(function(e){return void 0!==e.keyword||(void 0!==e.chainname||(void 0!==e.resname||(void 0!==e.resno||(void 0!==e.atomname||(void 0!==e.element||(void 0!==e.altloc||(void 0!==e.sstruc||void 0!==e.inscode)))))))}))),Oc(i,kc)}class $c{constructor(e){this.signals={stringChanged:new mc.Signal},this.setString(e)}get type(){return"selection"}setString(e,t){if(void 0===e&&(e=this.string||""),e===this.string)return;try{this.selection=function(e){let t={operator:void 0,rules:[]};if(!e)return t;let i,n,r=t;const s=[];"("===(e=e.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===e.substr(-1)&&(e=e.slice(1,-1).trim());const o=e.split(/\s+/),a=e=>{i={operator:e,rules:[]},void 0===r?(r=i,t=i):(r.rules.push(i),s.push(r),r=i)},c=function(e){n=r,r=s.pop(),void 0===r&&(a(e),l(n))},l=function(e){r.rules.push(e)};let h=!1;for(let e=0;e0)if("NOT"===i)h=1;else if(1===h)h=2;else{if(2!==h)throw new Error("something went wrong with 'not'");h=!1,c()}if("AND"===i){if("OR"===r.operator){const e=r.rules.pop();a("AND"),l(e)}else r.operator="AND";continue}if("OR"===i){"AND"===r.operator?c("OR"):r.operator="OR";continue}if("NOT"===t.toUpperCase()){h=1,a(),r.negate=!0;continue}if(+i!=+i){const e=fc[i];if(void 0!==e){l({keyword:e});continue}}if("HYDROGEN"===i){l({operator:"OR",rules:[{element:"H"},{element:"D"}]});continue}if("SMALL"===i){l({resname:xc});continue}if("NUCLEOPHILIC"===i){l({resname:bc});continue}if("HYDROPHOBIC"===i){l({resname:_c});continue}if("AROMATIC"===i){l({resname:wc});continue}if("AMIDE"===i){l({resname:Sc});continue}if("ACIDIC"===i){l({resname:Ac});continue}if("BASIC"===i){l({resname:Mc});continue}if("CHARGED"===i){l({resname:Cc});continue}if("POLAR"===i){l({resname:Pc});continue}if("NONPOLAR"===i){l({resname:Tc});continue}if("CYCLIC"===i){l({resname:Ic});continue}if("ALIPHATIC"===i){l({resname:Ec});continue}if("SIDECHAINATTACHED"===i){l({operator:"OR",rules:[{keyword:fc.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:fc.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:fc.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"HO3'"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"HO5'"},{atomname:"C5'"},{atomname:"C5*"},{atomname:"H5'"},{atomname:"H5''"}]}]}]});continue}if("APOLARH"===i){l({operator:"AND",negate:!1,rules:[{element:"H"},{negate:!0,operator:void 0,rules:[{keyword:fc.POLARH}]}]});continue}if("LIGAND"===i){l({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:fc.HETERO},{negate:!0,operator:void 0,rules:[{keyword:fc.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:fc.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:fc.WATER},{keyword:fc.ION}]}]}]});continue}if(-1!==pc.indexOf(i)){l({keyword:fc.ALL});continue}if("@"===t.charAt(0)){const e=t.substr(1).split(",").map((e=>parseInt(e)));e.sort((function(e,t){return e-t})),l({atomindex:e});continue}if("#"===t.charAt(0)){console.error("# for element selection deprecated, use _"),l({element:i.substr(1)});continue}if("_"===t.charAt(0)){l({element:i.substr(1)});continue}if("["===t[0]&&"]"===t[t.length-1]){const e=i.substr(1,t.length-2).split(","),n=e.length>1?e:e[0];l({resname:n});continue}if(t.length>=1&&t.length<=4&&"^"!==t[0]&&":"!==t[0]&&"."!==t[0]&&"%"!==t[0]&&"/"!==t[0]&&isNaN(parseInt(t))){l({resname:i});continue}const n={operator:"AND",rules:[]},s=t.split("/");if(s.length>1&&s[1]){if(isNaN(parseInt(s[1])))throw new Error("model must be an integer");n.rules.push({model:parseInt(s[1])})}const u=s[0].split("%");u.length>1&&n.rules.push({altloc:u[1]});const d=u[0].split(".");if(d.length>1&&d[1]){if(d[1].length>4)throw new Error("atomname must be one to four characters");n.rules.push({atomname:d[1].substring(0,4).toUpperCase()})}const f=d[0].split(":");f.length>1&&f[1]&&n.rules.push({chainname:f[1]});const m=f[0].split("^");if(m.length>1&&n.rules.push({inscode:m[1]}),m[0]){let e,t;"-"===m[0][0]&&(m[0]=m[0].substr(1),e=!0),m[0].includes("--")&&(m[0]=m[0].replace("--","-"),t=!0);let i=m[0].split("-");if(1===i.length){let t=parseInt(i[0]);if(isNaN(t))throw new Error("resi must be an integer");e&&(t*=-1),n.rules.push({resno:t})}else{if(2!==i.length)throw new Error("resi range must contain one '-'");{const r=i.map((e=>parseInt(e)));e&&(r[0]*=-1),t&&(r[1]*=-1),n.rules.push({resno:[r[0],r[1]]})}}}if(1===n.rules.length)l(n.rules[0]);else{if(!(n.rules.length>1))throw new Error("empty selection chunk");l(n)}}return void 0===t.operator&&1===t.rules.length&&t.rules[0].hasOwnProperty("operator")&&(t=t.rules[0]),t}(e)}catch(e){this.selection={error:e.message}}const i=this.selection;this.string=e,this.test=Nc(i),this.residueTest=Fc(i),this.chainTest=zc(i),this.modelTest=Uc(i),this.atomOnlyTest=Nc(i,!0),this.residueOnlyTest=Fc(i,!0),this.chainOnlyTest=zc(i,!0),this.modelOnlyTest=Uc(i,!0),t||this.signals.stringChanged.dispatch(this.string)}isAllSelection(){return pc.includes(this.string.toUpperCase())}isNoneSelection(){return gc.includes(this.string.toUpperCase())}}class Gc extends dc{constructor(e){super(e),this.colormakerList=[],this.selectionList=[];(e.dataList||[]).forEach((e=>{const[t,i,n={}]=e;al.hasScheme(t)?Object.assign(n,{scheme:t,structure:this.parameters.structure}):Object.assign(n,{scheme:"uniform",value:new mn(t).getHex()}),this.colormakerList.push(al.getScheme(n)),this.selectionList.push(new $c(i))}))}atomColor(e){for(let t=0,i=this.selectionList.length;t{}),e)}catch(e){}const Kc="undefined"!=typeof window&&void 0!==window.orientation;let Qc=!1;function Jc(e){Qc=e}let el=!1;function tl(e){el=e}const il={log:Function.prototype.bind.call(console.log,console),info:Function.prototype.bind.call(console.info,console),warn:Function.prototype.bind.call(console.warn,console),error:Function.prototype.bind.call(console.error,console),time:Function.prototype.bind.call(console.time,console),timeEnd:Function.prototype.bind.call(console.timeEnd,console)};let nl={color:"green",labelColor:8421504,labelAttachment:"bottom-center",labelSize:.7,labelZOffset:.5,labelYOffset:.1,labelBorder:!0,labelBorderColor:13882323,labelBorderWidth:.25,lineOpacity:.8,linewidth:5,opacity:.6,labelUnit:"angstrom",arcVisible:!0,planeVisible:!1};var rl;e.Debug=!!(rl=Ta("debug"))&&("string"!=typeof rl||/^1|true|t|yes|y$/i.test(rl));const sl=["ngl","js"],ol=new class{constructor(){this.activeWorkerCount=0,this._funcDict={},this._depsDict={},this._blobDict={}}add(e,t,i){this._funcDict[e]=t,this._depsDict[e]=i}get(e){return this._blobDict[e]||(this._blobDict[e]=Xc(this._funcDict[e],this._depsDict[e])),this._blobDict[e]}},al=new class{constructor(){this.schemes={},this.userSchemes={}}getScheme(e){const t=((e||{}).scheme||"").toLowerCase();let i;return i=t in this.schemes?this.schemes[t]:t in this.userSchemes?this.userSchemes[t]:dc,new i(e)}getSchemes(){const e={};return Object.keys(this.schemes).forEach((function(t){e[t]=t})),Object.keys(this.userSchemes).forEach((function(t){e[t]=t.split("|")[1]})),e}getScales(){return Vc}getModes(){return Hc}add(e,t){e=e.toLowerCase(),this.schemes[e]=t}addScheme(e,t){return e instanceof dc||(e=this._createScheme(e)),this._addUserScheme(e,t)}_addUserScheme(e,t){t=t||"";const i=`${ec()}|${t}`.toLowerCase();return this.userSchemes[i]=e,i}removeScheme(e){e=e.toLowerCase(),delete this.userSchemes[e]}_createScheme(e){const t=function(t){dc.call(this,t),e.call(this,t)};return(t.prototype=dc.prototype).constructor=dc,t}addSelectionScheme(e,t){return this._addUserScheme(class extends Gc{constructor(t){super(Object.assign({dataList:e},t))}},t)}hasScheme(e){return(e=e.toLowerCase())in this.schemes||e in this.userSchemes}},cl=new Za("datasource"),ll=new Za("representatation"),hl=new class extends Za{constructor(){super("parser")}__hasObjName(e,t){const i=this.get(e);return i&&i.prototype.__objName===t}isTrajectory(e){return this.__hasObjName(e,"frames")}isStructure(e){return this.__hasObjName(e,"structure")}isVolume(e){return this.__hasObjName(e,"volume")}isSurface(e){return this.__hasObjName(e,"surface")}isBinary(e){const t=this.get(e);return t&&t.prototype.isBinary}isXml(e){const t=this.get(e);return t&&t.prototype.isXml}isJson(e){const t=this.get(e);return t&&t.prototype.isJson}getTrajectoryExtensions(){return this.names.filter((e=>this.isTrajectory(e)))}getStructureExtensions(){return this.names.filter((e=>this.isStructure(e)))}getVolumeExtensions(){return this.names.filter((e=>this.isVolume(e)))}getSurfaceExtensions(){return this.names.filter((e=>this.isSurface(e)))}},ul=new Za("shader"),dl=new Za("decompressor"),fl=new Za("component"),ml=new Za("buffer"),pl=new Za("picker");e.ListingDatasource=void 0,e.TrajectoryDatasource=void 0;class gl{constructor(e,t={}){this.chunkSize=10485760,this.newline="\n",this.__pointer=0,this.__partialLine="",this.compressed=Ia(t.compressed,!1),this.binary=Ia(t.binary,!1),this.json=Ia(t.json,!1),this.xml=Ia(t.xml,!1),this.src=e}isBinary(){return this.binary||this.compressed}read(){return this._read().then((e=>{const t=this.compressed?dl.get(this.compressed):void 0;return this.compressed&&t?this.data=t(e):((this.binary||this.compressed)&&e instanceof ArrayBuffer&&(e=new Uint8Array(e)),this.data=e),this.data}))}_chunk(e,t){return t=Math.min(this.data.length,t),0===e&&this.data.length===t?this.data:this.isBinary()?this.data.subarray(e,t):this.data.substring(e,t)}chunk(e){const t=e+this.chunkSize;return this._chunk(e,t)}peekLines(e){const t=this.data,i=t.length,n=this.isBinary()?this.newline.charCodeAt(0):this.newline;let r,s=0;for(r=0;ri).lines}chunkCount(){return Math.floor(this.data.length/this.chunkSize)+1}asText(){return this.isBinary()?Ua(this.data):this.data}chunkToLines(e,t,i){const n=this.newline;if(!this.isBinary()&&e.length===this.data.length)return{lines:e.split(n),partialLine:""};let r=[];const s=this.isBinary()?Ua(e):e,o=s.lastIndexOf(n);if(-1===o)t+=s;else{const e=t+s.substr(0,o);r=r.concat(e.split(n)),t=o===s.length-n.length?"":s.substr(o+n.length)}return i&&""!==t&&r.push(t),{lines:r,partialLine:t}}nextChunk(){const e=this.__pointer;if(!(e>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(e)}nextChunkOfLines(){const e=this.nextChunk();if(void 0===e)return;const t=this.__pointer>this.data.length,i=this.chunkToLines(e,this.__partialLine,t);return this.__partialLine=i.partialLine,i.lines}eachChunk(e){const t=this.chunkSize,i=this.data.length,n=this.chunkCount();for(let r=0;r{const r=i===n+1,s=this.chunkToLines(t,this.__partialLine,r);this.__partialLine=s.partialLine,e(s.lines,i,n)}))}dispose(){delete this.src}}class vl extends gl{_read(){return new Promise(((e,t)=>{const i=this.src,n=new FileReader;n.onload=t=>{t.target&&e(t.target.result)},n.onerror=e=>t(e),this.binary||this.compressed?n.readAsArrayBuffer(i):n.readAsText(i)}))}}class yl extends gl{_read(){return new Promise(((e,t)=>{const i=this.src,n=new XMLHttpRequest;n.open("GET",i,!0),n.addEventListener("load",(()=>{if(200===n.status||304===n.status||0===n.status)try{e(n.response)}catch(e){t(e)}else t(n.statusText)}),!1),n.addEventListener("error",(e=>t("network error")),!1),this.isBinary()?n.responseType="arraybuffer":this.json?n.responseType="json":this.xml?n.responseType="document":n.responseType="text",n.send()}))}}class xl{constructor(e,t={}){this.parameters=Ea(t,{ext:"",compressed:!1,binary:hl.isBinary(t.ext||""),name:"",dir:"",path:"",protocol:""});const i={compressed:this.parameters.compressed,binary:this.parameters.binary,json:hl.isJson(this.parameters.ext),xml:hl.isXml(this.parameters.ext)};"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob?this.streamer=new vl(e,i):this.streamer=new yl(e,i)}}class bl extends xl{constructor(e,t={}){super(e,t),this.parserParams={voxelSize:t.voxelSize,firstModelOnly:t.firstModelOnly,asTrajectory:t.asTrajectory,cAlphaOnly:t.cAlphaOnly,delimiter:t.delimiter,comment:t.comment,columnNames:t.columnNames,name:this.parameters.name,path:this.parameters.path}}load(){return new(hl.get(this.parameters.ext))(this.streamer,this.parserParams).parse()}}class _l{constructor(e,t,i){this.name=t,this.path=i,this.signals={elementAdded:new mc.Signal,elementRemoved:new mc.Signal,nameChanged:new mc.Signal},this.type="Script",this.dir=i.substring(0,i.lastIndexOf("/")+1);try{this.fn=new Function("stage","__name","__path","__dir",e)}catch(e){il.error("Script compilation failed",e),this.fn=function(){}}}run(e){return new Promise(((t,i)=>{try{this.fn.apply(null,[e,this.name,this.path,this.dir]),t()}catch(e){il.error("Script.fn",e),i(e)}}))}}class wl extends xl{load(){return this.streamer.read().then((()=>new _l(this.streamer.asText(),this.parameters.name,this.parameters.path)))}}function Sl(e){const t=dl.names;let i,n,r="";i=e instanceof File?e.name:e instanceof Blob?"":e;const s=i.lastIndexOf("?"),o=-1!==s?i.substring(s):"";i=i.substring(0,-1===s?i.length:s);const a=i.replace(/^.*[\\/]/,"");let c=a.substring(0,a.lastIndexOf("."));const l=a.split(".");let h=l.length>1?(l.pop()||"").toLowerCase():"";const u=i.match(/^(.+):\/\/(.+)$/);u&&(r=u[1].toLowerCase(),i=u[2]||"");const d=i.substring(0,i.lastIndexOf("/")+1);if(t.includes(h)){n=h;const e=i.length-h.length-1;h=(i.substr(0,e).split(".").pop()||"").toLowerCase();const t=c.length-h.length-1;c=c.substr(0,t)}else n=!1;return{path:i,name:a,ext:h,base:c,dir:d,compressed:n,protocol:r,query:o,src:e}}function Al(e){let t=Sl(e);const i=cl.get(t.protocol);return i&&(t=Sl(i.getUrl(t.src)),!t.ext&&i.getExt&&(t.ext=i.getExt(e))),t}function Ml(e,t={}){const i=Object.assign(Al(e),t);let n;return hl.names.includes(i.ext)?n=new bl(i.src,i):sl.includes(i.ext)&&(n=new wl(i.src,i)),n?n.load():Promise.reject(new Error(`autoLoad: ext '${i.ext}' unknown`))}var Cl=oc((function(e,t){!function(){var e={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function i(t){return function(t,n){var r,s,o,a,c,l,h,u,d,f=1,m=t.length,p="";for(s=0;s=0),a.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,a.width?parseInt(a.width):0);break;case"e":r=a.precision?parseFloat(r).toExponential(a.precision):parseFloat(r).toExponential();break;case"f":r=a.precision?parseFloat(r).toFixed(a.precision):parseFloat(r);break;case"g":r=a.precision?String(Number(r.toPrecision(a.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=a.precision?r.substring(0,a.precision):r;break;case"t":r=String(!!r),r=a.precision?r.substring(0,a.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=a.precision?r.substring(0,a.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=a.precision?r.substring(0,a.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}e.json.test(a.type)?p+=r:(!e.number.test(a.type)||u&&!a.sign?d="":(d=u?"+":"-",r=r.toString().replace(e.sign,"")),l=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",h=a.width-(d+r).length,c=a.width&&h>0?l.repeat(h):"",p+=a.align?d+r+c:"0"===l?d+c+r:c+d+r)}return p}(function(t){if(r[t])return r[t];var i,n=t,s=[],o=0;for(;n;){if(null!==(i=e.text.exec(n)))s.push(i[0]);else if(null!==(i=e.modulo.exec(n)))s.push("%");else{if(null===(i=e.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(i[2]){o|=1;var a=[],c=i[2],l=[];if(null===(l=e.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a.push(l[1]);""!==(c=c.substring(l[0].length));)if(null!==(l=e.key_access.exec(c)))a.push(l[1]);else{if(null===(l=e.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");a.push(l[1])}i[2]=a}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");s.push({placeholder:i[0],param_no:i[1],keys:i[2],sign:i[3],pad_char:i[4],align:i[5],width:i[6],precision:i[7],type:i[8]})}n=n.substring(i[0].length)}return r[t]=s}(t),arguments)}function n(e,t){return i.apply(null,[e].concat(t||[]))}var r=Object.create(null);t.sprintf=i,t.vsprintf=n,"undefined"!=typeof window&&(window.sprintf=i,window.vsprintf=n)}()}));class Pl{getBlob(){return new Blob([this.getData()],{type:this.mimeType})}download(e,t){e=Ia(e,this.defaultName),t=Ia(t,this.defaultExt),Oa(this.getBlob(),`${e}.${t}`)}}const Tl=[];class Il{constructor(e,t={}){this._mark=0,this._marks=[],this.offset=0,this.littleEndian=!0;let i=!1;void 0===e&&(e=8192),"number"==typeof e?e=new ArrayBuffer(e):i=!0;const n=t.offset?t.offset>>>0:0;let r=e.byteLength-n,s=n;e instanceof ArrayBuffer||(e.byteLength!==e.buffer.byteLength&&(s=e.byteOffset+n),e=e.buffer),this._lastWrittenByte=i?r:0,this.buffer=e,this.length=r,this.byteLength=r,this.byteOffset=s,this._data=new DataView(this.buffer,s,r)}available(e){return void 0===e&&(e=1),this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e){return void 0===e&&(e=1),this.offset+=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(void 0===e)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e){if(void 0===e&&(e=1),!this.available(e)){const t=2*(this.offset+e),i=new Uint8Array(t);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e){void 0===e&&(e=1);for(var t=new Uint8Array(e),i=0;ithis._lastWrittenByte&&(this._lastWrittenByte=this.offset)}}class El{constructor(){this.count=0,this.signals={countChanged:new mc.Signal}}clear(){this.change(-this.count)}change(e){this.count+=e,this.signals.countChanged.dispatch(e,this.count),this.count<0&&il.warn("Counter.count below zero",this.count)}increment(){this.change(1)}decrement(){this.change(-1)}listen(e){this.change(e.count),e.signals.countChanged.add(this.change,this)}unlisten(e){const t=e.signals.countChanged;t.has(this.change,this)&&t.remove(this.change,this)}onZeroOnce(e,t){if(0===this.count)e.call(t);else{const i=()=>{0===this.count&&(this.signals.countChanged.remove(i,this),e.call(t))};this.signals.countChanged.add(i,this)}}dispose(){this.clear(),this.signals.countChanged.dispose()}}ul.add("shader/BasicLine.vert","void main(){\n#include begin_vertex\n#include project_vertex\n}"),ul.add("shader/BasicLine.frag","uniform vec3 uColor;\n#include common\n#include fog_pars_fragment\nvoid main(){\ngl_FragColor = vec4( uColor, 1.0 );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}"),ul.add("shader/Quad.vert","varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"),ul.add("shader/Quad.frag","varying vec2 vUv;\nuniform sampler2D tForeground;\nuniform float scale;\nvoid main() {\nvec4 foreground = texture2D( tForeground, vUv );\ngl_FragColor = foreground * scale;\n}");class Dl{constructor(){this.signals={updated:new mc.Signal},this.maxDuration=-1/0,this.minDuration=1/0,this.avgDuration=14,this.lastDuration=1/0,this.prevFpsTime=0,this.lastFps=1/0,this.lastFrames=1,this.frames=0,this.count=0,this.begin()}update(){this.startTime=this.end(),this.currentTime=this.startTime,this.signals.updated.dispatch()}begin(){this.startTime=window.performance.now(),this.lastFrames=this.frames}end(){const e=window.performance.now();return this.count+=1,this.frames+=1,this.lastDuration=e-this.startTime,this.minDuration=Math.min(this.minDuration,this.lastDuration),this.maxDuration=Math.max(this.maxDuration,this.lastDuration),this.avgDuration-=this.avgDuration/30,this.avgDuration+=this.lastDuration/30,e>this.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=e,this.frames=0),e}}ul.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),ul.add("shader/chunk/interior_fragment.glsl","if( gl_FrontFacing == false ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}"),ul.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),ul.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),ul.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"),ul.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),ul.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),ul.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),ul.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");const Ll=/^(?!\/\/)\s*#include\s+(\S+)/gim,Rl={};function kl(e,t={}){let i=e+"|";for(const e in t)i+=e+":"+t[e];if(!Rl[i]){const n=function(e){if(void 0===e)return"";const t=[];for(const i in e){const n=e[i];n&&t.push(`#define ${i} ${n}`)}return t.join("\n")+"\n"}(t);let r=ul.get(`shader/${e}`);if(!r)throw new Error(`empty shader, '${e}'`);r=r.replace(Ll,(function(e,t){const i=`shader/chunk/${t}.glsl`,n=ul.get(i)||Rr[t];if(!n)throw new Error(`empty chunk, '${t}'`);return n})),Rl[i]=n+r}return Rl[i]}if("undefined"!=typeof WebGLRenderingContext){const t=WebGLRenderingContext.prototype,i=t.getShaderParameter;t.getShaderParameter=function(){return!e.Debug||i.apply(this,arguments)};const n=t.getShaderInfoLog;t.getShaderInfoLog=function(){return e.Debug?n.apply(this,arguments):""};const r=t.getProgramParameter;t.getProgramParameter=function(i,n){return!e.Debug&&n===t.LINK_STATUS||r.apply(this,arguments)};const s=t.getProgramInfoLog;t.getProgramInfoLog=function(){return e.Debug?s.apply(this,arguments):""}}const Ol=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];Ol.forEach((e=>{e.forEach((e=>{e[0]*=.0625,e[1]*=.0625}))}));class Bl{constructor(e,t,i,n){this.canvas=document.createElement("canvas"),this._viewer=i,this._factor=Ia(n.factor,2),this._antialias=Ia(n.antialias,!1),this._onProgress=n.onProgress,this._onFinish=n.onFinish,this._antialias&&(this._factor*=2),this._n=this._factor*this._factor,this._width=this._viewer.width,this._height=this._viewer.height,this._antialias?(this.canvas.width=this._width*this._factor/2,this.canvas.height=this._height*this._factor/2):(this.canvas.width=this._width*this._factor,this.canvas.height=this._height*this._factor),this._ctx=this.canvas.getContext("2d"),this._viewerSampleLevel=i.sampleLevel,this._viewer.setSampling(-1)}_renderTile(e){const t=this._viewer,i=this._width,n=this._height,r=this._factor,s=e%r*i,o=Math.floor(e/r)*n;if(t.camera.setViewOffset(i*r,n*r,s,o,i,n),t.render(),this._antialias){const e=Math.round((s+i)/2)-Math.round(s/2),r=Math.round((o+n)/2)-Math.round(o/2);this._ctx.drawImage(t.renderer.domElement,Math.round(s/2),Math.round(o/2),e,r)}else this._ctx.drawImage(t.renderer.domElement,Math.floor(s),Math.floor(o),Math.ceil(i),Math.ceil(n));"function"==typeof this._onProgress&&this._onProgress(e+1,this._n,!1)}_finalize(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,"function"==typeof this._onFinish&&this._onFinish(this._n+1,this._n,!1)}render(){for(let e=0;e<=this._n;++e)e===this._n?this._finalize():this._renderTile(e)}renderAsync(){let e=0;const t=this._n,i=()=>{e===t?this._finalize():this._renderTile(e),e+=1};for(let e=0;e<=t;++e)setTimeout(i,0)}}const Nl=2*Math.PI,Fl=180/Math.PI;function zl(e,t,i=1,n=0,r){const s=r?r.length:e.length/i;let o=0,a=0;if(r)for(let c=0;ct&&(t=e[i]);return t}function Zl(e){let t=1/0;for(let i=0,n=e.length;i=0;l--){for(c=o-1;c>=0;c--)if(u=4*(l*o+c),a[u]!==t||a[u+1]!==i||a[u+2]!==n||a[u+3]!==r){h=!0;break}if(h)break}const m=l;for(h=!1,c=o-1;c>=0;c--){for(l=s-1;l>=0;l--)if(u=4*(l*o+c),a[u]!==t||a[u+1]!==i||a[u+2]!==n||a[u+3]!==r){h=!0;break}if(h)break}const p=c,g=document.createElement("canvas");return g.width=p-f,g.height=m-d,g.getContext("2d").drawImage(e,f,d,g.width,g.height,0,0,g.width,g.height),g}(e,s?0:255*t.r,s?0:255*t.g,s?0:255*t.b,s?0:255)}return e}function d(e,i,n){"function"==typeof t.onProgress&&t.onProgress(e,i,n)}return new Promise((function(t,i){const l=new Bl(o,a,e,{factor:n,antialias:r,onProgress:d,onFinish:function(n,r){u(l.canvas).toBlob((function(n){o.setClearAlpha(c),h(!0),e.requestRender(),d(r,r,!0),n?t(n):i("error creating image")}),"image/png")}});o.setClearAlpha(s?0:1),h(),l.renderAsync()}))}const th=new Zt,ih=new ri,nh=new ri;const rh=new zt,sh=new ri,oh=new ri;function ah(e,t){sh.getInverse(t.projectionMatrix),oh.copy(t.projectionMatrix).transpose(),e.traverse((function(e){const t=e.material;if(!t)return;const i=t.uniforms;i&&(i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(sh),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(oh))}))}function ch(e,t,i){const n=e.createShader(i);if(!n)return void console.log(`error creating WebGL shader ${i}`);e.shaderSource(n,t),e.compileShader(n);return e.getShaderParameter(n,e.COMPILE_STATUS)?n:(console.log(`error compiling shader ${n}: ${e.getShaderInfoLog(n)}`),e.deleteShader(n),null)}function lh(e,t){const i=e.getExtension(t);return i||console.log(`extension '${t}' not available`),i}const hh=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function uh(e){const t=document.createElement("canvas");t.width=16,t.height=16,t.style.width="16px",t.style.height="16px";const i=t.getContext("webgl")||t.getContext("experimental-webgl");if(!i)return console.log(`error creating webgl context for ${e}`),!1;if(!(i instanceof WebGLRenderingContext))return console.log("Got unexpected type for WebGL rendering context"),!1;lh(i,"OES_texture_float"),lh(i,"OES_texture_half_float"),lh(i,"WEBGL_color_buffer_float");const n=ch(i,"\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}",i.VERTEX_SHADER),r=ch(i,"\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}",i.FRAGMENT_SHADER);if(!n||!r)return!1;const s=function(e,t,i,n){const r=e.createProgram();return r?(t.forEach((t=>e.attachShader(r,t))),i&&i.forEach(((t,i)=>{e.bindAttribLocation(r,n?n[i]:i,t)})),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)?r:(console.log(`error linking program: ${e.getProgramInfoLog(r)}`),e.deleteProgram(r),null)):void console.log("error creating WebGL program")}(i,[n,r]);if(!s)return console.log("error creating WebGL program"),!1;i.useProgram(s);const o=i.getAttribLocation(s,"a_position"),a=i.getUniformLocation(s,"u_color");if(!a)return console.log("error getting 'u_color' uniform location"),!1;const c=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,hh,i.STATIC_DRAW),i.enableVertexAttribArray(o),i.vertexAttribPointer(o,2,i.FLOAT,!1,0,0);const l=i.createTexture(),h=new Uint8Array([255,255,255,255]);i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,h);const u=i.createTexture();i.bindTexture(i.TEXTURE_2D,u),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,e,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST);const d=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,d),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,u,0);if(i.checkFramebufferStatus(i.FRAMEBUFFER)!==i.FRAMEBUFFER_COMPLETE)return console.log(`error creating framebuffer for ${e}`),!1;i.bindTexture(i.TEXTURE_2D,l),i.uniform4fv(a,[0,10,20,1]),i.drawArrays(i.TRIANGLES,0,6),i.bindTexture(i.TEXTURE_2D,u),i.bindFramebuffer(i.FRAMEBUFFER,null),i.clearColor(1,0,0,1),i.clear(i.COLOR_BUFFER_BIT),i.uniform4fv(a,[0,.1,.05,1]),i.drawArrays(i.TRIANGLES,0,6);const f=new Uint8Array(4);if(i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,f),0!==f[0]||f[1]<248||f[2]<248||f[3]<254)return console.log(`not able to actually render to ${e} texture`),!1;if(e===i.FLOAT){i.bindFramebuffer(i.FRAMEBUFFER,d);const e=new Float32Array(4);i.readPixels(0,0,1,1,i.RGBA,i.FLOAT,e);const t=i.getError();if(t)return console.log(`error reading pixels as float: '${function(e,t){switch(t){case e.NO_ERROR:return"no error";case e.INVALID_ENUM:return"invalid enum";case e.INVALID_VALUE:return"invalid value";case e.INVALID_OPERATION:return"invalid operation";case e.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case e.OUT_OF_MEMORY:return"out of memory";case e.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}(i,t)}'`),!1}return!0}const dh=new Float32Array(100),fh=new Uint8Array(100),mh=[12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20],ph=new ri;function gh(e,t,i,n,r){const s=r.uniforms,o=[];if(s&&(s.objectId&&(s.objectId.value=Qc?this.id:this.id/255,o.push("objectId")),(s.modelViewMatrixInverse||s.modelViewMatrixInverseTranspose||s.modelViewProjectionMatrix||s.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,this.matrixWorld),s.modelViewMatrixInverse&&(s.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),o.push("modelViewMatrixInverse")),s.modelViewMatrixInverseTranspose&&(s.modelViewMatrixInverse?s.modelViewMatrixInverseTranspose.value.copy(s.modelViewMatrixInverse.value).transpose():s.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),o.push("modelViewMatrixInverseTranspose")),s.modelViewProjectionMatrix&&(s.modelViewProjectionMatrix.value.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),s.modelViewProjectionMatrixInverse&&(s.modelViewProjectionMatrix?(ph.copy(s.modelViewProjectionMatrix.value),s.modelViewProjectionMatrixInverse.value.getInverse(ph)):(ph.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),s.modelViewProjectionMatrixInverse.value.getInverse(ph)),o.push("modelViewProjectionMatrixInverse")),o.length)){const t=e.properties.get(r);if(t.program){const i=e.getContext(),n=t.program;i.useProgram(n.program);const r=n.getUniforms();o.forEach((function(e){r.setValue(i,e,s[e].value)}))}}}class vh{constructor(e){if(this.boundingBox=new Ni,this.boundingBoxSize=new Zt,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new Zt,this.signals={ticked:new mc.Signal,rendered:new mc.Signal},"string"==typeof e){const t=document.getElementById(e);this.container=null===t?document.createElement("div"):t}else e instanceof HTMLElement?this.container=e:this.container=document.createElement("div");if(this.container===document.body)this.width=window.innerWidth||1,this.height=window.innerHeight||1;else{const e=this.container.getBoundingClientRect();this.width=e.width||1,this.height=e.height||1,this.container.style.overflow="hidden"}this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.container.appendChild(this.wrapper),this._initParams(),this._initStats(),this._initCamera(),this._initScene(),!1!==this._initRenderer()?(this._initHelper(),this.setBackground(),this.setFog(),this.animate=this.animate.bind(this)):il.error("Viewer: could not initialize renderer")}_initParams(){this.parameters={fogColor:new mn(0),fogNear:50,fogFar:100,backgroundColor:new mn(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new mn(14540253),lightIntensity:1,ambientColor:new mn(14540253),ambientIntensity:.2,sampleLevel:0,rendererEncoding:_t}}_initCamera(){const e=new Zt(0,0,0),{width:t,height:i}=this;this.perspectiveCamera=new Sr(this.parameters.cameraFov,t/i),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(e),this.orthographicCamera=new wa(t/-2,t/2,i/2,i/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(e),this.stereoCamera=new Ca,this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;const n=this.parameters.cameraType;if("orthographic"===n)this.camera=this.orthographicCamera;else{if("perspective"!==n&&"stereo"!==n)throw new Error(`Unknown cameraType '${n}'`);this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()}_initStats(){this.stats=new Dl}_initScene(){this.scene||(this.scene=new Si,this.scene.name="scene"),this.rotationGroup=new ko,this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new ko,this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new ko,this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new ko,this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new ko,this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new ko,this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new zo(this.parameters.fogColor.getHex()),this.spotLight=new _a(this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.spotLight),this.ambientLight=new Sa(this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)}_initRenderer(){const t=window.devicePixelRatio,{width:i,height:n}=this;try{this.renderer=new Fo({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(e){return this.wrapper.innerHTML='

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

',!1}this.renderer.setPixelRatio(t),this.renderer.setSize(i,n),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,this.renderer.outputEncoding=this.parameters.rendererEncoding;const r=this.renderer.getContext();this.renderer.capabilities.isWebGL2?(tl(!0),Jc(this.renderer.extensions.get("EXT_color_buffer_float")),this.supportsHalfFloat=!0):(tl(this.renderer.extensions.get("EXT_frag_depth")),this.renderer.extensions.get("OES_element_index_uint"),Jc(this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&uh(r.FLOAT)),this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&uh(36193)),this.wrapper.appendChild(this.renderer.domElement);const s=i*t,o=n*t;e.Debug&&console.log(JSON.stringify({Browser:Yc,OES_texture_float:!!this.renderer.extensions.get("OES_texture_float"),OES_texture_half_float:!!this.renderer.extensions.get("OES_texture_half_float"),WEBGL_color_buffer_float:!!this.renderer.extensions.get("WEBGL_color_buffer_float"),"testTextureSupport Float":uh(r.FLOAT),"testTextureSupport HalfFloat":uh(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:Qc},null,2)),this.pickingTarget=new Wt(s,o,{minFilter:re,magFilter:re,stencilBuffer:!1,format:Ae,type:Qc?ge:he}),this.pickingTarget.texture.generateMipmaps=!1,this.pickingTarget.texture.encoding=this.parameters.rendererEncoding,this.renderer.setRenderTarget(this.pickingTarget),this.renderer.clear(),this.renderer.setRenderTarget(null),this.sampleTarget=new Wt(s,o,{minFilter:ae,magFilter:ae,format:Ae}),this.sampleTarget.texture.encoding=this.parameters.rendererEncoding,this.holdTarget=new Wt(s,o,{minFilter:re,magFilter:re,format:Ae,type:he}),this.holdTarget.texture.encoding=this.parameters.rendererEncoding,this.compositeUniforms={tForeground:new Pa(this.sampleTarget.texture),scale:new Pa(1)},this.compositeMaterial=new _r({uniforms:this.compositeUniforms,vertexShader:kl("Quad.vert"),fragmentShader:kl("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:d,depthTest:!1,depthWrite:!1}),this.compositeCamera=new wa(-1,1,1,-1,0,1),this.compositeScene=new Si,this.compositeScene.name="compositeScene",this.compositeScene.add(new ar(new Dr(2,2),this.compositeMaterial))}_initHelper(){const e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),t=new Float32Array(24),i=new Vn;i.setIndex(new An(e,1)),i.setAttribute("position",new An(t,3));const n=new _r({uniforms:{uColor:{value:new mn("skyblue")}},vertexShader:kl("BasicLine.vert"),fragmentShader:kl("BasicLine.frag")});this.boundingBoxMesh=new Yo(i,n),this.helperGroup.add(this.boundingBoxMesh)}updateHelper(){const e=this.boundingBoxMesh.geometry.attributes.position,t=e.array,{min:i,max:n}=this.boundingBox;t[0]=n.x,t[1]=n.y,t[2]=n.z,t[3]=i.x,t[4]=n.y,t[5]=n.z,t[6]=i.x,t[7]=i.y,t[8]=n.z,t[9]=n.x,t[10]=i.y,t[11]=n.z,t[12]=n.x,t[13]=n.y,t[14]=i.z,t[15]=i.x,t[16]=n.y,t[17]=i.z,t[18]=i.x,t[19]=i.y,t[20]=i.z,t[21]=n.x,t[22]=i.y,t[23]=i.z,e.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()}get cameraDistance(){return Math.abs(this.camera.position.z)}set cameraDistance(e){this.camera.position.z=-e}add(t,i){i?i.forEach((e=>this.addBuffer(t,e))):this.addBuffer(t),t.group.name="meshGroup",t.wireframeGroup.name="wireframeGroup",t.parameters.background?(this.backgroundGroup.add(t.group),this.backgroundGroup.add(t.wireframeGroup)):(this.modelGroup.add(t.group),this.modelGroup.add(t.wireframeGroup)),t.pickable&&this.pickingGroup.add(t.pickingGroup),e.Debug&&this.updateHelper()}addBuffer(e,t){function i(n){n instanceof ko?n.children.forEach(i):(n.userData.buffer=e,n.userData.instance=t,n.onBeforeRender=gh)}const n=e.getMesh();t&&n.applyMatrix4(t.matrix),i(n),e.group.add(n);const r=e.getWireframeMesh();if(t&&(r.matrix.copy(n.matrix),r.position.copy(n.position),r.quaternion.copy(n.quaternion),r.scale.copy(n.scale)),i(r),e.wireframeGroup.add(r),e.pickable){const r=e.getPickingMesh();t&&(r.matrix.copy(n.matrix),r.position.copy(n.position),r.quaternion.copy(n.quaternion),r.scale.copy(n.scale)),i(r),e.pickingGroup.add(r)}t?this._updateBoundingBox(e.geometry,e.matrix,t.matrix):this._updateBoundingBox(e.geometry,e.matrix)}remove(t){this.translationGroup.children.forEach((function(e){e.remove(t.group),e.remove(t.wireframeGroup)})),t.pickable&&this.pickingGroup.remove(t.pickingGroup),this.updateBoundingBox(),e.Debug&&this.updateHelper()}_updateBoundingBox(e,t,i){const n=this.boundingBox;function r(e,t,i){null==e.boundingBox&&e.computeBoundingBox();const r=e.boundingBox.clone();t&&r.applyMatrix4(t),i&&r.applyMatrix4(i),r.min.equals(r.max)&&r.expandByScalar(5),n.union(r)}function s(e){if(void 0!==e.geometry){let t,i;e.userData.buffer&&(t=e.userData.buffer.matrix),e.userData.instance&&(i=e.userData.instance.matrix),r(e.geometry,t,i)}}e?r(e,t,i):(n.makeEmpty(),this.modelGroup.traverse(s),this.backgroundGroup.traverse(s)),n.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()}updateBoundingBox(){this._updateBoundingBox(),e.Debug&&this.updateHelper()}getPickingPixels(){const{width:e,height:t}=this,i=e*t*4,n=Qc?new Float32Array(i):new Uint8Array(i);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,e,t,n),n}getImage(e){return new Promise((t=>{if(e){const{width:e,height:i}=this,n=e*i*4;let r=this.getPickingPixels();if(Qc){const e=new Uint8Array(n);for(let t=0;t500&&!this.isStill&&this.sampleLevel<3&&-1!==this.sampleLevel){const t=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=t,e.Debug&&il.log("rendered still frame")}this.frameRequest=window.requestAnimationFrame(this.animate)}pick(e,t){if("stereo"===this.parameters.cameraType)return{pid:0,instance:void 0,picker:void 0};e*=window.devicePixelRatio,t*=window.devicePixelRatio,e=Math.max(e-2,0),t=Math.max(t-2,0);let i,n,r=0;const s=Qc?dh:fh;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,e,t,5,5,s);for(let e=0;e22&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame((()=>{this.render(),this.stats.update()})))}updateZoom(){const e=Ka(this.perspectiveCamera.fov),t=2*Math.tan(e/2)*this.cameraDistance;this.orthographicCamera.zoom=this.height/t}absoluteToRelative(e){return 50*(1-e/this.bRadius)}relativeToAbsolute(e){return this.bRadius*(1-e/50)}__updateClipping(){const e=this.parameters;this.bRadius=Math.max(10,.5*this.boundingBoxLength),isFinite(this.bRadius)||(this.bRadius=50),this.camera.getWorldPosition(this.distVector),this.cDist=this.distVector.length(),this.cDist||(this.cameraDistance=Math.abs(e.cameraZ),this.cDist=Math.abs(e.cameraZ));const t=this.scene.fog;if(t.color.set(e.fogColor),"camera"===e.clipMode)this.camera.near=e.clipNear,this.camera.far=e.clipFar,t.near=e.fogNear,t.far=e.fogFar;else if("absolute"===e.clipScale)this.camera.near=this.cDist-e.clipNear,this.camera.far=this.cDist+e.clipFar,t.near=this.cDist-e.fogNear,t.far=this.cDist+e.fogFar;else{const i=(50-e.clipNear)/50,n=-(50-e.clipFar)/50;this.camera.near=this.cDist-this.bRadius*i,this.camera.far=this.cDist+this.bRadius*n;const r=(50-e.fogNear)/50,s=-(50-e.fogFar)/50;t.near=this.cDist-this.bRadius*r,t.far=this.cDist+this.bRadius*s}"camera"!==e.clipMode&&("PerspectiveCamera"===this.camera.type?(this.camera.near=Math.max(.1,e.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),t.near=Math.max(.1,t.near),t.far=Math.max(1,t.far)):"OrthographicCamera"===this.camera.type&&e.clipDist>0&&(this.camera.near=Math.max(e.clipDist,this.camera.near)))}__updateCamera(){const e=this.camera;e.updateMatrix(),e.updateMatrixWorld(!0),e.updateProjectionMatrix(),function(e,t,i,n,r){let s=new zt;i.getSize(s);const o=s.height,a=i.getPixelRatio(),c="OrthographicCamera"===t.type;rh.set(s.width,s.height),sh.getInverse(t.projectionMatrix),oh.copy(t.projectionMatrix).transpose(),e.traverse((function(e){const t=e.material;if(!t)return;const i=t.uniforms;if(i){if(t.clipNear){const e=(50-t.clipNear)/50,s=n-r*e;i.clipNear.value=s}i.canvasHeight&&(i.canvasHeight.value=o),i.resolution&&i.resolution.value.copy(rh),i.pixelRatio&&(i.pixelRatio.value=a),i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(sh),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(oh),i.ortho&&(i.ortho.value=c)}}))}(this.scene,e,this.renderer,this.cDist,this.bRadius),function(e,t){e.traverseVisible((function(e){if(!(e instanceof ta&&e.userData.buffer.parameters.sortParticles))return;const i=e.geometry.attributes,n=i.position.count;if(0===n)return;let r,s,o,a,c,l,h,u;ih.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld),nh.multiplyMatrices(t.projectionMatrix,ih),e.userData.sortData?(r=e.userData.sortData,o=r.__zArray,s=r.__sortArray,a=r.__cmpFn):(o=new Float32Array(n),s=new Uint32Array(n),a=function(e,t){const i=o[e],n=o[t];return i>n?1:it?1:e=l&&t(e[o],s)>0;)e[o+1]=e[o],--o;e[o+1]=s}if(-1===c)break;h=r[c--],l=r[c--]}else{for(o=l+1,a=h,u(l+h>>1,o),t(e[l],e[h])>0&&u(l,h),t(e[o],e[h])>0&&u(o,h),t(e[l],e[o])>0&&u(l,o),s=e[o];;){do{o++}while(t(e[o],s)<0);do{a--}while(t(e[a],s)>0);if(a=a-l?(r[++c]=o,r[++c]=h,h=a-1):(r[++c]=l,r[++c]=a-1,l=o)}}(s,a);for(let e in i){const t=i[e],o=t.array,a=t.itemSize;r[e]||(r[e]=new Float32Array(a*n)),u=r[e],r[e]=o;for(let e=0;e0&&"stereo"!==this.parameters.cameraType?this.__renderSuperSample(t,i):this.__renderModelGroup(t,i)}render(e=!1,t){if(this.rendering)il.warn("'tried to call 'render' from within 'render'");else{this.rendering=!0;try{this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),"stereo"===this.parameters.cameraType?this.__renderStereo(e,t):this.__render(e,this.camera,t),this.lastRenderedPicking=e}finally{this.rendering=!1,this.renderPending=!1}this.signals.rendered.dispatch()}}clear(){il.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()}dispose(){this.renderer.dispose(),window.cancelAnimationFrame(this.frameRequest)}}function yh(e){const t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;return Math.sqrt(t*t+i*i)}class xh{constructor(e,t={}){this.domElement=e,this.signals={moved:new mc.Signal,scrolled:new mc.Signal,dragged:new mc.Signal,dropped:new mc.Signal,clicked:new mc.Signal,hovered:new mc.Signal,doubleClicked:new mc.Signal},this.position=new zt,this.prevPosition=new zt,this.down=new zt,this.canvasPosition=new zt,this.prevClickCP=new zt,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=0,this.buttons=0,this.pressed=!1,this.altKey=!1,this.ctrlKey=!1,this.metaKey=!1,this.shiftKey=!1,this.domElement.style.touchAction="none",this.hoverTimeout=Ia(t.hoverTimeout,50),this.handleScroll=Ia(t.handleScroll,!0),this.doubleClickSpeed=Ia(t.doubleClickSpeed,500),this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();const i={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,i),document.addEventListener("wheel",this._onMousewheel,i),document.addEventListener("MozMousePixelScroll",this._onMousewheel,i),document.addEventListener("mousemove",this._onMousemove,i),document.addEventListener("mousedown",this._onMousedown,i),document.addEventListener("mouseup",this._onMouseup,i),document.addEventListener("contextmenu",this._onContextmenu,i),document.addEventListener("touchstart",this._onTouchstart,i),document.addEventListener("touchend",this._onTouchend,i),document.addEventListener("touchmove",this._onTouchmove,i)}get key(){let e=0;return this.altKey&&(e+=1),this.ctrlKey&&(e+=2),this.metaKey&&(e+=4),this.shiftKey&&(e+=8),e}setParameters(e={}){this.hoverTimeout=Ia(e.hoverTimeout,this.hoverTimeout)}_listen(){const e=window.performance.now(),t=this.canvasPosition;this.doubleClickPending&&e-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),e-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(t.x,t.y))),this.frameRequest=window.requestAnimationFrame(this._listen)}_onMousewheel(e){if(e.target!==this.domElement||!this.handleScroll)return;e.preventDefault(),this._setKeys(e);let t=0;"deltaY"in e&&"deltaMode"in e&&void 0!==e.deltaY&&void 0!==e.deltaMode?t=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?.025*-e.deltaY:e.deltaMode===WheelEvent.DOM_DELTA_LINE?-e.deltaY*(2.5/3):2.5*-e.deltaY:"deltaY"in e&&!("detail"in e)?t=.025*-e.deltaY:void 0!==e.wheelDelta?t=.025*-e.wheelDelta:void 0!==e.wheelDeltaY?t=.025*-e.wheelDeltaY:void 0!==e.detail&&(t=-e.detail/3),this.signals.scrolled.dispatch(t),setTimeout((()=>{this.scrolled=!0}),this.hoverTimeout)}_onMousemove(e){e.target===this.domElement?(e.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(e),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(e.clientX,e.clientY),this._setCanvasPosition(e);const t=this.prevPosition.x-this.position.x,i=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(t,i),this.pressed&&this.signals.dragged.dispatch(t,i)}_onMousedown(e){e.target===this.domElement&&(e.preventDefault(),this._setKeys(e),this.moving=!1,this.hovering=!1,this.down.set(e.clientX,e.clientY),this.position.set(e.clientX,e.clientY),this.which=e.which,this.buttons=function(e){if("object"==typeof e){if("buttons"in e)return e.buttons;if("which"in e){const t=e.which;if(2===t)return 4;if(3===t)return 2;if(t>0)return 1<=0)return 1<2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(i/2);else{this.which=3,this.buttons=2;const e=this.prevPosition.x-this.position.x,t=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,t),this.pressed&&this.signals.dragged.dispatch(e,t)}}}}_distance(){return this.position.distanceTo(this.down)}_setCanvasPosition(e){const t=this.domElement.getBoundingClientRect();let i,n;"clientX"in e&&"clientY"in e?(i=e.clientX-t.left,n=e.clientY-t.top):(i=e.offsetX,n=e.offsetY),this.canvasPosition.set(i,t.height-n)}_setKeys(e){this.altKey=e.altKey,this.ctrlKey=e.ctrlKey,this.metaKey=e.metaKey,this.shiftKey=e.shiftKey}dispose(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove),window.cancelAnimationFrame(this.frameRequest)}}const bh=new ri,_h=new ri,wh=new ri,Sh=new ri,Ah=new ri,Mh=new Zt,Ch=new qt,Ph=new qt,Th=new ri,Ih=new Zt,Eh=new Zt;class Dh{constructor(e,t={}){this.stage=e,this.rotateSpeed=Ia(t.rotateSpeed,2),this.zoomSpeed=Ia(t.zoomSpeed,1.2),this.panSpeed=Ia(t.panSpeed,1),this.viewer=e.viewer,this.mouse=e.mouseObserver,this.controls=e.viewerControls}get component(){return this.stage.transformComponent}get atom(){return this.stage.transformAtom}_setPanVector(e,t,i=0){const n=this.controls.getCanvasScaleFactor(i);Ih.set(e,t,0),Ih.multiplyScalar(this.panSpeed*n)}_getRotateXY(e,t){return[this.rotateSpeed*-e*.01,this.rotateSpeed*t*.01]}_getCameraRotation(e){return e.extractRotation(this.viewer.camera.matrixWorld),e.multiply(_h.makeRotationY(Math.PI)),e}_transformPanVector(){this.component&&(Th.extractRotation(this.component.transform),Th.premultiply(this.viewer.rotationGroup.matrix),Th.getInverse(Th),Th.multiply(this._getCameraRotation(Sh)),Ih.applyMatrix4(Th))}zoom(e){this.controls.zoom(this.zoomSpeed*e*.02)}pan(e,t){this._setPanVector(e,t),Th.getInverse(this.viewer.rotationGroup.matrix),Th.multiply(this._getCameraRotation(Sh)),Ih.applyMatrix4(Th),this.controls.translate(Ih)}panComponent(e,t){this.component&&(this._setPanVector(e,t),this._transformPanVector(),this.component.position.add(Ih),this.component.updateMatrix())}panAtom(e,t){this.atom&&this.component&&(this.atom.positionToVector3(Eh),Eh.add(this.viewer.translationGroup.position),Eh.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(e,t,Eh.z),this._transformPanVector(),this.atom.positionAdd(Ih),this.component.updateRepresentations({position:!0}))}rotate(e,t){const[i,n]=this._getRotateXY(e,t);this._getCameraRotation(Sh),Mh.set(1,0,0),Mh.applyMatrix4(Sh),Ch.setFromAxisAngle(Mh,n),Mh.set(0,1,0),Mh.applyMatrix4(Sh),Ph.setFromAxisAngle(Mh,i),Ch.multiply(Ph),Sh.makeRotationFromQuaternion(Ch),this.controls.applyMatrix(Sh)}zRotate(e,t){const i=this.rotateSpeed*((-e+t)/-2)*.01;wh.makeRotationZ(i),this.controls.applyMatrix(wh)}rotateComponent(e,t){if(!this.component)return;const[i,n]=this._getRotateXY(e,t);this._getCameraRotation(Ah),Sh.extractRotation(this.component.transform),Sh.premultiply(this.viewer.rotationGroup.matrix),Sh.getInverse(Sh),Sh.premultiply(Ah),Mh.set(1,0,0),Mh.applyMatrix4(Sh),bh.makeRotationAxis(Mh,n),Mh.set(0,1,0),Mh.applyMatrix4(Sh),_h.makeRotationAxis(Mh,i),bh.multiply(_h),Ch.setFromRotationMatrix(bh),this.component.quaternion.premultiply(Ch),this.component.quaternion.normalize(),this.component.updateMatrix()}}const Lh=new Zt;class Rh{constructor(e,t){this.stage=t,this.pid=e.pid,this.picker=e.picker,this.instance=e.instance,this.stage=t,this.controls=t.viewerControls,this.mouse=t.mouseObserver}get type(){return this.picker.type}get altKey(){return this.mouse.altKey}get ctrlKey(){return this.mouse.ctrlKey}get metaKey(){return this.mouse.metaKey}get shiftKey(){return this.mouse.shiftKey}get canvasPosition(){return this.mouse.canvasPosition}get component(){return this.stage.getComponentsByObject(this.picker.data).list[0]}get object(){return this.picker.getObject(this.pid)}get position(){return this.picker.getPosition(this.pid,this.instance,this.component)}get closestBondAtom(){if("bond"!==this.type||!this.bond)return;const e=this.bond,t=this.controls,i=this.canvasPosition,n=e.atom1.positionToVector3(),r=e.atom2.positionToVector3();n.applyMatrix4(this.component.matrix),r.applyMatrix4(this.component.matrix);const s=t.getPositionOnCanvas(n),o=t.getPositionOnCanvas(r);return c=s,l=o,(a=i).distanceTo(c)=e.length))return new Rh(i,this.stage);console.error("pid >= picker.array.length")}}}const Oh=new qt,Bh=new Zt,Nh=new Zt,Fh=new Zt,zh=new Zt,Uh=new ri,$h=new Zt,Gh=new ri;class Vh{constructor(e){this.stage=e,this.signals={changed:new mc.Signal},this.viewer=e.viewer}get position(){return this.viewer.translationGroup.position}get rotation(){return this.viewer.rotationGroup.quaternion}changed(){this.viewer.requestRender(),this.signals.changed.dispatch()}getPositionOnCanvas(e,t){const i=Ha(t,zt);const n=this.viewer;return Fh.copy(e).add(n.translationGroup.position).applyMatrix4(n.rotationGroup.matrix).project(n.camera),i.set((Fh.x+1)*n.width/2,(Fh.y+1)*n.height/2)}getCanvasScaleFactor(e=0){const t=this.viewer.camera;if(t instanceof wa)return 1/t.zoom;{e=Math.abs(e),e+=this.getCameraDistance();const i=Ka(t.fov);return 2*e*Math.tan(i/2)/this.viewer.height}}getOrientation(e){const t=Wa(e);t.copy(this.viewer.rotationGroup.matrix);const i=this.getCameraDistance();return t.scale(zh.set(i,i,i)),t.setPosition(this.viewer.translationGroup.position),t}orient(e){Wa(e).decompose(Bh,Oh,Nh);const t=this.viewer;t.rotationGroup.setRotationFromQuaternion(Oh),t.translationGroup.position.copy(Bh),t.cameraDistance=Nh.z,t.updateZoom(),this.changed()}translate(e){this.viewer.translationGroup.position.add(ja(e)),this.changed()}center(e){this.viewer.translationGroup.position.copy(ja(e)).negate(),this.changed()}zoom(e){this.distance(this.getCameraDistance()*(1-e))}getCameraDistance(){return this.viewer.cameraDistance}distance(e){this.viewer.cameraDistance=Math.max(Math.abs(e),.2),this.viewer.updateZoom(),this.changed()}spin(e,t){Uh.getInverse(this.viewer.rotationGroup.matrix),$h.copy(ja(e)).applyMatrix4(Uh),this.viewer.rotationGroup.rotateOnAxis($h,t),this.changed()}rotate(e){this.viewer.rotationGroup.setRotationFromQuaternion(qa(e)),this.changed()}align(e){Gh.getInverse(Wa(e)),this.viewer.rotationGroup.setRotationFromMatrix(Gh),this.changed()}applyMatrix(e){this.viewer.rotationGroup.applyMatrix4(Wa(e)),this.changed()}}class Hh{constructor(e,t,...i){this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=Ia(e,1e3),this.controls=t,this.startTime=window.performance.now(),this._init(...i)}get done(){return 1===this.alpha}get paused(){return this._paused}tick(e){if(!this._paused)return this.elapsedDuration=e.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=rc(0,1,this.elapsedDuration/this.duration),this._tick(e),this.done&&this._resolveList.forEach((e=>e())),this.done}pause(e){e&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0}resume(e){!e&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)}toggle(){this._paused?this.resume():this.pause()}then(e){let t;return t=this.done?Promise.resolve():new Promise((e=>this._resolveList.push(e))),t.then(e)}}class jh extends Hh{constructor(e,t,...i){super(Ia(e,1/0),t,...i)}_init(e,t){Array.isArray(e)?this.axis=(new Zt).fromArray(e):this.axis=Ia(e,new Zt(0,1,0)),this.angle=Ia(t,.01)}_tick(e){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*e.lastDuration/16)}}class Wh extends Hh{constructor(e,t,...i){super(Ia(e,1/0),t,...i),this.angleSum=0,this.direction=1}_init(e,t,i){Array.isArray(e)?this.axis=(new Zt).fromArray(e):this.axis=Ia(e,new Zt(0,1,0)),this.angleStep=Ia(t,.01),this.angleEnd=Ia(i,.2)}_tick(e){if(!this.axis||!this.angleStep||!this.angleEnd)return;const t=rc(0,1,Math.abs(this.angleSum)/this.angleEnd),i=this.angleStep*this.direction*(1.1-t);this.controls.spin(this.axis,i*e.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}}class qh extends Hh{_init(e,t){this.moveFrom=ja(Ia(e,new Zt)),this.moveTo=ja(Ia(t,new Zt))}_tick(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()}}class Xh extends Hh{_init(e,t){this.zoomFrom=e,this.zoomTo=t}_tick(){this.controls.distance(ic(this.zoomFrom,this.zoomTo,this.alpha))}}class Yh extends Hh{constructor(){super(...arguments),this._currentRotation=new qt}_init(e,t){this.rotateFrom=qa(e),this.rotateTo=qa(t),this._currentRotation=new qt}_tick(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)}}class Zh extends Hh{_init(e,t,i){this.valueFrom=e,this.valueTo=t,this.callback=i}_tick(){this.callback(ic(this.valueFrom,this.valueTo,this.alpha))}}class Kh extends Hh{_init(e){this.callback=e}_tick(){1===this.alpha&&this.callback()}}class Qh{constructor(e=[]){this._resolveList=[],this._list=e}get done(){return this._list.every((e=>e.done))}then(e){let t;return t=this.done?Promise.resolve():new Promise((e=>{this._resolveList.push(e),this._list.forEach((e=>{e.then((()=>{this._resolveList.forEach((e=>{e()})),this._resolveList.length=0}))}))})),t.then(e)}}class Jh{constructor(e){this.stage=e,this.animationList=[],this.finishedList=[],this.viewer=e.viewer,this.controls=e.viewerControls}get paused(){return this.animationList.every((e=>e.paused))}add(e){return 0===e.duration?e.tick(this.viewer.stats):this.animationList.push(e),e}remove(e){const t=this.animationList,i=t.indexOf(e);i>-1&&t.splice(i,1)}run(e){const t=this.finishedList,i=this.animationList,n=i.length;for(let r=0;re.pause()))}resume(){this.animationList.forEach((e=>e.resume()))}toggle(){this.paused?this.resume():this.pause()}clear(){this.animationList.length=0}dispose(){this.clear()}}class eu{constructor(e,t){if(this.fn=e,this.queue=[],this.pending=!1,this.next=this.next.bind(this),t){for(let e=0,i=t.length;ethis.run(e)))):this.pending=!1}push(e){this.queue.push(e),this.pending||this.next()}kill(){this.queue.length=0}length(){return this.queue.length}}class tu{constructor(e,t,i){this.type="",this.parameters={lazy:{type:"boolean"},clipNear:{type:"range",step:1,max:100,min:0,buffer:!0},clipRadius:{type:"number",precision:1,max:1e3,min:0,buffer:!0},clipCenter:{type:"vector3",precision:1,buffer:!0},flatShaded:{type:"boolean",buffer:!0},opacity:{type:"range",step:.01,max:1,min:0,buffer:!0},depthWrite:{type:"boolean",buffer:!0},side:{type:"select",buffer:!0,options:{front:"front",back:"back",double:"double"}},wireframe:{type:"boolean",buffer:!0},colorData:{type:"hidden",update:"color"},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:al.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:al.getModes()},roughness:{type:"range",step:.01,max:1,min:0,buffer:!0},metalness:{type:"range",step:.01,max:1,min:0,buffer:!0},diffuse:{type:"color",buffer:!0},diffuseInterior:{type:"boolean",buffer:!0},useInteriorColor:{type:"boolean",buffer:!0},interiorColor:{type:"color",buffer:!0},interiorDarkening:{type:"range",step:.01,max:1,min:0,buffer:!0},matrix:{type:"hidden",buffer:!0},disablePicking:{type:"boolean",rebuild:!0}},this.viewer=t,this.tasks=new El,this.queue=new eu(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=al.getSchemes()),this.toBePrepared=!1}init(e){const t=e||{};this.clipNear=Ia(t.clipNear,0),this.clipRadius=Ia(t.clipRadius,0),this.clipCenter=Ia(t.clipCenter,new Zt),this.flatShaded=Ia(t.flatShaded,!1),this.side=Ia(t.side,"double"),this.opacity=Ia(t.opacity,1),this.depthWrite=Ia(t.depthWrite,!0),this.wireframe=Ia(t.wireframe,!1),this.setColor(t.color,t),this.colorData=Ia(t.colorData,void 0),this.colorScheme=Ia(t.colorScheme,"uniform"),this.colorScale=Ia(t.colorScale,""),this.colorReverse=Ia(t.colorReverse,!1),this.colorValue=Ia(t.colorValue,9474192),this.colorDomain=Ia(t.colorDomain,void 0),this.colorMode=Ia(t.colorMode,"hcl"),this.visible=Ia(t.visible,!0),this.quality=Ia(t.quality,void 0),this.roughness=Ia(t.roughness,.4),this.metalness=Ia(t.metalness,0),this.diffuse=Ia(t.diffuse,16777215),this.diffuseInterior=Ia(t.diffuseInterior,!1),this.useInteriorColor=Ia(t.useInteriorColor,!1),this.interiorColor=Ia(t.interiorColor,2236962),this.interiorDarkening=Ia(t.interiorDarkening,0),this.lazy=Ia(t.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=Ia(t.matrix,new ri),this.disablePicking=Ia(t.disablePicking,!1);const i=this.parameters;!0===i.sphereDetail&&(i.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===i.radialSegments&&(i.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===i.openEnded&&(i.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===i.disableImpostor&&(i.disableImpostor={type:"boolean",rebuild:!0}),"low"===t.quality?(i.sphereDetail&&(this.sphereDetail=0),i.radialSegments&&(this.radialSegments=5)):"medium"===t.quality?(i.sphereDetail&&(this.sphereDetail=1),i.radialSegments&&(this.radialSegments=10)):"high"===t.quality?(i.sphereDetail&&(this.sphereDetail=2),i.radialSegments&&(this.radialSegments=20)):(i.sphereDetail&&(this.sphereDetail=Ia(t.sphereDetail,1)),i.radialSegments&&(this.radialSegments=Ia(t.radialSegments,10))),i.openEnded&&(this.openEnded=Ia(t.openEnded,!0)),i.disableImpostor&&(this.disableImpostor=Ia(t.disableImpostor,!1))}getColorParams(e){return Object.assign({data:this.colorData,scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode,colorSpace:this.colorSpace},e)}getBufferParams(e={}){return Object.assign({clipNear:this.clipNear,clipRadius:this.clipRadius,clipCenter:this.clipCenter,flatShaded:this.flatShaded,opacity:this.opacity,depthWrite:this.depthWrite,side:this.side,wireframe:this.wireframe,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,diffuseInterior:this.diffuseInterior,useInteriorColor:this.useInteriorColor,interiorColor:this.interiorColor,interiorDarkening:this.interiorDarkening,matrix:this.matrix,disablePicking:this.disablePicking},e)}setColor(e,t){const i=Object.keys(al.getSchemes());if("string"==typeof e&&i.includes(e.toLowerCase()))t?t.colorScheme=e:this.setParameters({colorScheme:e});else if(void 0!==e){let i=new mn(e).getHex();t?(t.colorScheme="uniform",t.colorValue=i):this.setParameters({colorScheme:"uniform",colorValue:i})}return this}prepare(e){}create(){}update(e){this.build()}build(e){if(!this.lazy||this.visible&&this.opacity){if(!this.toBePrepared)return this.tasks.increment(),void this.make();this.queue.length()>0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(e||!1)}else this.lazyProps.build=!0}make(t,i){e.Debug&&il.time("Representation.make "+this.type);const n=()=>{t?(this.update(t),this.viewer.requestRender(),this.tasks.decrement(),i&&i()):(this.clear(),this.create(),this.manualAttach||this.disposed||(e.Debug&&il.time("Representation.attach "+this.type),this.attach((()=>{e.Debug&&il.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),i&&i()})))),e.Debug&&il.timeEnd("Representation.make "+this.type)};this.toBePrepared?this.prepare(n):n()}attach(e){this.setVisibility(this.visible),e()}setVisibility(e,t){if(this.visible=e,this.visible&&this.opacity){const e=this.lazyProps,t=e.bufferParams,i=e.what;if(e.build)return e.build=!1,this.build(),this;(Object.keys(t).length||Object.keys(i).length)&&(e.bufferParams={},e.what={},this.updateParameters(t,i))}return this.bufferList.forEach((function(t){t.setVisibility(e)})),t||this.viewer.requestRender(),this}setParameters(e,t={},i=!1){const n=e||{},r=this.parameters,s={};this.opacity||void 0===n.opacity||(this.lazyProps.build?(this.lazyProps.build=!1,i=!0):(Object.assign(s,this.lazyProps.bufferParams),Object.assign(t,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(n.color,n);for(let e in n)if(void 0!==n[e]&&null!=r[e]&&(r[e].int&&(n[e]=parseInt(n[e])),r[e].float&&(n[e]=parseFloat(n[e])),n[e]!==this[e]||n[e].equals&&!n[e].equals(this[e]))){if(this[e]&&this[e].copy&&n[e].copy?this[e].copy(n[e]):this[e]&&this[e].set?this[e].set(n[e]):this[e]=n[e],r[e].buffer)if(!0===r[e].buffer)s[e]=n[e];else{s[r[e].buffer]=n[e]}r[e].update&&(t[r[e].update]=!0),!r[e].rebuild||"impostor"===r[e].rebuild&&el&&!this.disableImpostor||(i=!0)}return i?this.build():this.updateParameters(s,t),this}updateParameters(e={},t){if(this.lazy&&(!this.visible||!this.opacity)&&!1===e.hasOwnProperty("opacity"))return Object.assign(this.lazyProps.bufferParams,e),void Object.assign(this.lazyProps.what,t);this.bufferList.forEach((function(t){t.setParameters(e)})),Object.keys(t).length&&this.update(t),this.viewer.requestRender()}getParameters(){const e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach((t=>{null!==this.parameters[t]&&(e[t]=this[t])})),e}clear(){this.bufferList.forEach((e=>{this.viewer.remove(e),e.dispose()})),this.bufferList.length=0,this.viewer.requestRender()}dispose(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()}}class iu{constructor(t){this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=t,this.blobUrl=window.URL.createObjectURL(ol.get(t)),this.worker=new Worker(this.blobUrl),ol.activeWorkerCount+=1,this.worker.onmessage=i=>{this.pending-=1;const n=i.data.__postId;e.Debug&&il.timeEnd("Worker.postMessage "+t+" #"+n);const r=this.onmessageDict[n];r&&r.call(this.worker,i),delete this.onmessageDict[n],delete this.onerrorDict[n]},this.worker.onerror=e=>{if(this.pending-=1,e.data){const i=e.data.__postId,n=this.onerrorDict[i];n?n.call(this.worker,e):il.error("Worker.onerror",i,t,e),delete this.onmessageDict[i],delete this.onerrorDict[i]}else il.error("Worker.onerror",t,e)}}post(t={},i,n,r){this.onmessageDict[this.postCount]=n,this.onerrorDict[this.postCount]=r,t.__name=this.name,t.__postId=this.postCount,t.__debug=e.Debug,e.Debug&&il.time(`Worker.postMessage ${this.name} #${this.postCount}`);try{this.worker.postMessage(t,i)}catch(e){il.error("worker.post:",e),this.worker.postMessage(t)}return this.pending+=1,this.postCount+=1,this}terminate(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),ol.activeWorkerCount-=1):il.log("no worker to terminate")}}class nu{constructor(e,t=2){this.pool=[],this.count=0,this.maxCount=Math.min(8,t),this.name=e}post(e={},t,i,n){const r=this.getNextWorker();return r?r.post(e,t,i,n):console.error("unable to get worker from pool"),this}terminate(){this.pool.forEach((function(e){e.terminate()}))}getNextWorker(){let e,t=1/0;for(let i=0;i=this.count){e=new iu(this.name),this.pool.push(e),this.count+=1;break}const n=this.pool[i];if(0===n.pending){e=n;break}n.pendingr&&(r=c),l>s&&(s=l),h>o&&(o=h)}return[hu([t,i,n]),hu([r,s,o])]}function au(e,t){for(let i=0,n=t.length;i0){const o=1/Math.sqrt(s);e[t]=i*o,e[t+1]=n*o,e[t+2]=r*o}}}function hu(e){return new Float32Array(e||3)}function uu(e,t,i){const n=t[0],r=t[1],s=t[2],o=i[0],a=i[1],c=i[2];e[0]=r*c-s*a,e[1]=s*o-n*c,e[2]=n*a-r*o}function du(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function fu(e,t,i){e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2]}function mu(e,t,i){e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2]}function pu(e,t,i=0){e[0]=t[i],e[1]=t[i+1],e[2]=t[i+2]}function gu(e,t,i=0){t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2]}function vu(e){return e[0]*e[0]+e[1]*e[1]+e[2]*e[2]}function yu(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2])}function xu(e,t,i){bu(e,t,1/i)}function bu(e,t,i){e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i}function _u(e,t){const i=vu(t);0==i?(e[0]=t[0],e[1]=t[1],e[2]=t[2]):bu(e,t,1/Math.sqrt(i))}function wu(e,t,i){e[0]=t[0]-i,e[1]=t[1]-i,e[2]=t[2]-i}function Su(e,t,i){e[0]=t[0]+i,e[1]=t[1]+i,e[2]=t[2]+i}function Au(e,t){e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2])}function Mu(e,t){e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2])}function Cu(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2]}function Pu(e,t){const i=e[0],n=e[1],r=e[2],s=t[0],o=t[1],a=t[2],c=n*a-r*o,l=r*s-i*a,h=i*o-n*s,u=Math.sqrt(c*c+l*l+h*h),d=i*s+n*o+r*a;return Math.atan2(u,d)}function Tu(e,t=9){const i=Math.floor(t/2),n=e.position1.length/3,r=3*(i*n),s=1/t,o=$l(e.position1,e.position2),a=new Float32Array(r),c=new Float32Array(r),l=new Zt;for(let t=0;t0){const t=3*f;r[t]=e.position2[3*h-3],r[t+1]=e.position2[3*h-2],r[t+1]=e.position2[3*h-1]}const g=new Float32Array(n),v=new Float32Array(r),y=Ul(g,v),x=new Float32Array(s),b={position:y,position1:g,position2:v,color:x,color2:x};return o&&(b.radius=new Float32Array(o)),a&&e.picking&&(e.picking.array=new Float32Array(a),b.picking=e.picking),c&&(b.primitiveId=new Float32Array(c)),b}nu.prototype.constructor=nu,ou.__deps=[hu],xu.__deps=[bu],_u.__deps=[bu,vu];const Du=new Zt;class Lu{static get Picker(){return pl.get(this.type)}static get Buffer(){return ml.get(this.type)}static getShapeKey(e){return this.type+e[0].toUpperCase()+e.substr(1)}static expandBoundingBox(e,t){}static valueToShape(e,t,i){const n=e._primitiveData[this.getShapeKey(t)];switch(this.fields[t]){case"v3":case"c":s=n,void 0!==(r=i).toArray?r=r.toArray():void 0!==r.x?r=[r.x,r.y,r.z]:void 0!==r.r&&(r=[r.r,r.g,r.b]),s.push.apply(s,r);break;default:n.push(i)}var r,s}static objectToShape(e,t){Object.keys(this.fields).forEach((i=>{this.valueToShape(e,i,t[i])})),this.valueToShape(e,"name",t.name),this.expandBoundingBox(e.boundingBox,t)}static valueFromShape(e,t,i){const n=e._primitiveData[this.getShapeKey(i)];switch(this.fields[i]){case"v3":return(new Zt).fromArray(n,3*t);case"c":return(new mn).fromArray(n,3*t);default:return n[t]}}static objectFromShape(e,t){let i=this.valueFromShape(e,t,"name");void 0===i&&(i=`${this.type}: ${t} (${e.name})`);const n={shape:e,name:i};return Object.keys(this.fields).forEach((i=>{n[i]=this.valueFromShape(e,t,i)})),n}static arrayFromShape(e,t){const i=e._primitiveData[this.getShapeKey(t)];return"s"===this.fields[t]?i:new Float32Array(i)}static dataFromShape(e){const t={};return this.Picker&&(t.picking=new this.Picker(e)),Object.keys(this.fields).forEach((i=>{t[i]=this.arrayFromShape(e,i)})),t}static bufferFromShape(e,t){return new this.Buffer(this.dataFromShape(e),t)}}Lu.type="",Lu.fields={};class Ru extends Lu{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(Du.fromArray(t.position))}}Ru.type="sphere",Ru.fields={position:"v3",color:"c",radius:"f"};class ku extends Lu{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(Du.fromArray(t.position))}}ku.type="box",ku.fields={position:"v3",color:"c",size:"f",heightAxis:"v3",depthAxis:"v3"};class Ou extends ku{}Ou.type="octahedron";class Bu extends ku{}Bu.type="tetrahedron";class Nu extends Lu{static positionFromShape(e,t){const i=this.valueFromShape(e,t,"position1"),n=this.valueFromShape(e,t,"position2");return i.add(n).multiplyScalar(.5)}static expandBoundingBox(e,t){e.expandByPoint(Du.fromArray(t.position1)),e.expandByPoint(Du.fromArray(t.position2))}static bufferFromShape(e,t={}){let i=this.dataFromShape(e);return"cylinder"===this.type&&t.dashedCylinder&&(i=Iu(i)),new this.Buffer(i,t)}}Nu.type="cylinder",Nu.fields={position1:"v3",position2:"v3",color:"c",radius:"f"};class Fu extends Nu{}Fu.type="arrow";class zu extends Nu{}zu.type="cone";class Uu extends Ru{}Uu.type="ellipsoid",Uu.fields={position:"v3",color:"c",radius:"f",majorAxis:"v3",minorAxis:"v3"};class $u extends Uu{}$u.type="torus";class Gu extends Lu{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(Du.fromArray(t.position))}}Gu.type="text",Gu.fields={position:"v3",color:"c",size:"f",text:"s"};class Vu extends Lu{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(Du.fromArray(t.position))}}Vu.type="point",Vu.fields={position:"v3",color:"c"};class Hu extends Lu{static positionFromShape(e,t){const i=this.valueFromShape(e,t,"position1"),n=this.valueFromShape(e,t,"position2");return i.add(n).multiplyScalar(.5)}static expandBoundingBox(e,t){e.expandByPoint(Du.fromArray(t.position1)),e.expandByPoint(Du.fromArray(t.position2))}}Hu.type="wideline",Hu.fields={position1:"v3",position2:"v3",color:"c"};class ju{constructor(e,t){this.exp=3;const i=t||function(e){const{x:t,y:i,z:n}=e,r=new Ni,s=t.length,{min:o,max:a}=r;for(let e=0;e>this.exp),this.boundY=1+(i.max.y-this.minY>>this.exp),this.boundZ=1+(i.max.z-this.minZ>>this.exp);const n=this.boundX*this.boundY*this.boundZ,r=void 0!==e.count?e.count:e.x.length,s=e.x,o=e.y,a=e.z;let c=0;const l=new Uint32Array(n),h=new Int32Array(r);for(let e=0;e>this.exp,i=o[e]-this.minY>>this.exp,n=a[e]-this.minZ>>this.exp,r=(t*this.boundY+i)*this.boundZ+n;1===(l[r]+=1)&&(c+=1),h[e]=r}const u=new Uint16Array(c);for(let e=0,t=0;e0&&(l[e]=t+1,u[t]=i,t+=1)}const d=new Uint32Array(c);for(let e=1;e0){const i=t-1;m[d[i]+f[i]]=e,f[i]+=1}}this.grid=l,this.bucketCount=u,this.bucketOffset=d,this.bucketArray=m,this.xArray=s,this.yArray=o,this.zArray=a}within(e,t,i,n){const r=[];return this.eachWithin(e,t,i,n,(e=>r.push(e))),r}eachWithin(e,t,i,n,r){const s=n*n,o=Math.max(0,e-n-this.minX>>this.exp),a=Math.max(0,t-n-this.minY>>this.exp),c=Math.max(0,i-n-this.minZ>>this.exp),l=Math.min(this.boundX,1+(e+n-this.minX>>this.exp)),h=Math.min(this.boundY,1+(t+n-this.minY>>this.exp)),u=Math.min(this.boundZ,1+(i+n-this.minZ>>this.exp));for(let n=o;n0){const n=l-1,o=this.bucketOffset[n],a=o+this.bucketCount[n];for(let n=o;nn?r.set(this[t].subarray(0,n)):r.set(this[t]),this[t]=r}}growIfFull(){if(this.count>=this.length){const e=Math.round(1.5*this.length);this.resize(Math.max(256,e))}}copyFrom(e,t,i,n){for(let r=0,s=this._fields.length;r0;)h-=1;l<=h&&(l===c?c=h:h===c&&(c=l),(o=l)!==(a=h)&&(i.copyFrom(t,0,o,1),t.copyWithin(o,a,1),t.copyFrom(i,a,0,1)),l+=1,h-=1)}while(l<=h);n(r,h),n(l,s)}var o,a}(0,this.count-1),il.timeEnd("Store.sort")}clear(){this.count=0}dispose(){for(let e=0,t=this._fields.length;e>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24}class Yu{constructor(e,t){this.length=e,this._words=new Uint32Array(e+32>>>5),!0===t&&this.setAll()}get(e){return 0!=(this._words[e>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,o=t>>>5;for(let e=s+1;e>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>i,this}_isRangeValue(e,t,i){if(t>>5,o=t>>>5;for(let e=s+1;e>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<0){const{types:n,groups:r,centers:s,atomSets:o}=e;n.push(t.type),r.push(t.group),s.x.push(t.x/i),s.y.push(t.y/i),s.z.push(t.z/i),o.push(t.atomSet)}}const ed=0,td=["D-BETA-PEPTIDE, C-GAMMA LINKING","D-GAMMA-PEPTIDE, C-DELTA LINKING","D-PEPTIDE COOH CARBOXY TERMINUS","D-PEPTIDE NH3 AMINO TERMINUS","D-PEPTIDE LINKING","L-BETA-PEPTIDE, C-GAMMA LINKING","L-GAMMA-PEPTIDE, C-DELTA LINKING","L-PEPTIDE COOH CARBOXY TERMINUS","L-PEPTIDE NH3 AMINO TERMINUS","L-PEPTIDE LINKING","PEPTIDE LINKING","PEPTIDE-LIKE"],id=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],nd=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],rd=["D-SACCHARIDE","D-SACCHARIDE 1,4 AND 1,4 LINKING","D-SACCHARIDE 1,4 AND 1,6 LINKING","L-SACCHARIDE","L-SACCHARIDE 1,4 AND 1,4 LINKING","L-SACCHARIDE 1,4 AND 1,6 LINKING","SACCHARIDE"],sd=["NON-POLYMER"].concat(["OTHER"],rd),od=["h","g","i"],ad=["e","b"],cd=["s","t","l",""],ld={H:1,D:1,T:1,HE:2,LI:3,BE:4,B:5,C:6,N:7,O:8,F:9,NE:10,NA:11,MG:12,AL:13,SI:14,P:15,S:16,CL:17,AR:18,K:19,CA:20,SC:21,TI:22,V:23,CR:24,MN:25,FE:26,CO:27,NI:28,CU:29,ZN:30,GA:31,GE:32,AS:33,SE:34,BR:35,KR:36,RB:37,SR:38,Y:39,ZR:40,NB:41,MO:42,TC:43,RU:44,RH:45,PD:46,AG:47,CD:48,IN:49,SN:50,SB:51,TE:52,I:53,XE:54,CS:55,BA:56,LA:57,CE:58,PR:59,ND:60,PM:61,SM:62,EU:63,GD:64,TB:65,DY:66,HO:67,ER:68,TM:69,YB:70,LU:71,HF:72,TA:73,W:74,RE:75,OS:76,IR:77,PT:78,AU:79,HG:80,TL:81,PB:82,BI:83,PO:84,AT:85,RN:86,FR:87,RA:88,AC:89,TH:90,PA:91,U:92,NP:93,PU:94,AM:95,CM:96,BK:97,CF:98,ES:99,FM:100,MD:101,NO:102,LR:103,RF:104,DB:105,SG:106,BH:107,HS:108,MT:109,DS:110,RG:111,CN:112,NH:113,FL:114,MC:115,LV:116,TS:117,OG:118},hd={1:1.1,2:1.4,3:1.81,4:1.53,5:1.92,6:1.7,7:1.55,8:1.52,9:1.47,10:1.54,11:2.27,12:1.73,13:1.84,14:2.1,15:1.8,16:1.8,17:1.75,18:1.88,19:2.75,20:2.31,21:2.3,22:2.15,23:2.05,24:2.05,25:2.05,26:2.05,27:2,28:2,29:2,30:2.1,31:1.87,32:2.11,33:1.85,34:1.9,35:1.83,36:2.02,37:3.03,38:2.49,39:2.4,40:2.3,41:2.15,42:2.1,43:2.05,44:2.05,45:2,46:2.05,47:2.1,48:2.2,49:2.2,50:1.93,51:2.17,52:2.06,53:1.98,54:2.16,55:3.43,56:2.68,57:2.5,58:2.48,59:2.47,60:2.45,61:2.43,62:2.42,63:2.4,64:2.38,65:2.37,66:2.35,67:2.33,68:2.32,69:2.3,70:2.28,71:2.27,72:2.25,73:2.2,74:2.1,75:2.05,76:2,77:2,78:2.05,79:2.1,80:2.05,81:1.96,82:2.02,83:2.07,84:1.97,85:2.02,86:2.2,87:3.48,88:2.83,89:2,90:2.4,91:2,92:2.3,93:2,94:2,95:2,96:2,97:2,98:2,99:2,100:2,101:2,102:2,103:2,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:2,114:2,115:2,116:2,117:2,118:2},ud={1:.31,2:.28,3:1.28,4:.96,5:.84,6:.76,7:.71,8:.66,9:.57,10:.58,11:1.66,12:1.41,13:1.21,14:1.11,15:1.07,16:1.05,17:1.02,18:1.06,19:2.03,20:1.76,21:1.7,22:1.6,23:1.53,24:1.39,25:1.39,26:1.32,27:1.26,28:1.24,29:1.32,30:1.22,31:1.22,32:1.2,33:1.19,34:1.2,35:1.2,36:1.16,37:2.2,38:1.95,39:1.9,40:1.75,41:1.64,42:1.54,43:1.47,44:1.46,45:1.42,46:1.39,47:1.45,48:1.44,49:1.42,50:1.39,51:1.39,52:1.38,53:1.39,54:1.4,55:2.44,56:2.15,57:2.07,58:2.04,59:2.03,60:2.01,61:1.99,62:1.98,63:1.98,64:1.96,65:1.94,66:1.92,67:1.92,68:1.89,69:1.9,70:1.87,71:1.87,72:1.75,73:1.7,74:1.62,75:1.51,76:1.44,77:1.41,78:1.36,79:1.36,80:1.32,81:1.45,82:1.46,83:1.48,84:1.4,85:1.5,86:1.5,87:2.6,88:2.21,89:2.15,90:2.06,91:2,92:1.96,93:1.9,94:1.87,95:1.8,96:1.69,97:1.6,98:1.6,99:1.6,100:1.6,101:1.6,102:1.6,103:1.6,104:1.6,105:1.6,106:1.6,107:1.6,108:1.6,109:1.6,110:1.6,111:1.6,112:1.6,113:1.6,114:1.6,115:1.6,116:1.6,117:1.6,118:1.6},dd={1:[1],2:[0],3:[1],4:[2],5:[3],6:[4],7:[3],8:[2],9:[1],10:[0],11:[1],12:[2],13:[6],14:[6],15:[3,5,7],16:[2,4,6],17:[1],18:[0],19:[1],20:[2],31:[3],32:[4],33:[3,5],34:[2,4,6],35:[1],36:[0],37:[1],38:[2],49:[3],50:[4],51:[3,5],52:[2],53:[1,2,5],54:[0,2],55:[1],56:[2],81:[3],82:[4],83:[3],84:[2],85:[1],86:[0],87:[1],88:[2]},fd={1:1,2:2,3:1,4:2,5:3,6:4,7:5,8:6,9:7,10:8,11:1,12:2,13:3,14:4,15:5,16:6,17:7,18:8,19:1,20:2,21:3,22:4,23:5,24:6,25:7,26:8,27:9,28:10,29:11,30:2,31:3,32:4,33:5,34:6,35:7,36:8,37:1,38:2,39:3,40:4,41:5,42:6,43:7,44:8,45:9,46:10,47:11,48:2,49:3,50:4,51:5,52:6,53:7,54:8,55:1,56:2,57:3,58:4,59:3,60:4,61:5,62:6,63:7,64:8,65:9,66:10,67:11,68:12,69:13,70:14,71:15,72:4,73:5,74:6,75:7,76:8,77:9,78:10,79:11,80:2,81:3,82:4,83:5,84:6,85:7,86:8,87:1,88:2,89:3,90:4,91:3,92:4,93:5,94:6,95:7,96:8,97:9,98:10,99:11,100:12,101:13,102:14,103:15,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:3,114:4,115:5,116:6,117:7,118:8},md={ALA:[.17,.5,.33],ARG:[.81,1.81,1],ASN:[.42,.85,.43],ASP:[1.23,3.64,2.41],ASH:[-.07,.43,.5],CYS:[-.24,-.02,.22],GLN:[.58,.77,.19],GLU:[2.02,3.63,1.61],GLH:[-.01,.11,.12],GLY:[.01,1.15,1.14],HIS:[.17,.11,-.06],ILE:[-.31,-1.12,-.81],LEU:[-.56,-1.25,-.69],LYS:[.99,2.8,1.81],MET:[-.23,-.67,-.44],PHE:[-1.13,-1.71,-.58],PRO:[.45,.14,-.31],SER:[.13,.46,.33],THR:[.14,.25,.11],TRP:[-1.85,-2.09,-.24],TYR:[-.94,-.71,.23],VAL:[.07,-.46,-.53]},pd=[0,0,0],gd={HIS:"H",ARG:"R",LYS:"K",ILE:"I",PHE:"F",LEU:"L",TRP:"W",ALA:"A",MET:"M",PRO:"P",CYS:"C",ASN:"N",VAL:"V",GLY:"G",SER:"S",GLN:"Q",TYR:"Y",ASP:"D",GLU:"E",THR:"T",SEC:"U",PYL:"O"},vd=Object.keys(gd),yd=["A","C","T","G","U","I"],xd=["DA","DC","DT","DG","DU","DI"],bd=["A","G","I","DA","DG","DI"],_d=yd.concat(xd),wd=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4","SPC"],Sd=["118","119","1AL","1CU","2FK","2HP","2OF","3CO","3MT","3NI","3OF","3P8","4MO","4PU","543","6MO","ACT","AG","AL","ALF","AM","ATH","AU","AU3","AUC","AZI","BA","BCT","BEF","BF4","BO4","BR","BS3","BSY","CA","CAC","CD","CD1","CD3","CD5","CE","CHT","CL","CO","CO3","CO5","CON","CR","CS","CSB","CU","CU1","CU3","CUA","CUZ","CYN","DME","DMI","DSC","DTI","DY","E4N","EDR","EMC","ER3","EU","EU3","F","FE","FE2","FPO","GA","GD3","GEP","HAI","HG","HGC","IN","IOD","IR","IR3","IRI","IUM","K","KO4","LA","LCO","LCP","LI","LU","MAC","MG","MH2","MH3","MLI","MLT","MMC","MN","MN3","MN5","MN6","MO1","MO2","MO3","MO4","MO5","MO6","MOO","MOS","MOW","MW1","MW2","MW3","NA","NA2","NA5","NA6","NAO","NAW","NCO","NET","NH4","NI","NI1","NI2","NI3","NO2","NO3","NRU","O4M","OAA","OC1","OC2","OC3","OC4","OC5","OC6","OC7","OC8","OCL","OCM","OCN","OCO","OF1","OF2","OF3","OH","OS","OS4","OXL","PB","PBM","PD","PDV","PER","PI","PO3","PO4","PR","PT","PT4","PTN","RB","RH3","RHD","RU","SB","SCN","SE4","SEK","SM","SMO","SO3","SO4","SR","T1A","TB","TBA","TCN","TEA","TH","THE","TL","TMA","TRA","UNX","V","VN3","VO4","W","WO5","Y1","YB","YB2","YH","YT3","ZCM","ZN","ZN2","ZN3","ZNO","ZO3","OHX"],Ad=["045","0AT","0BD","0MK","0NZ","0TS","0V4","0XY","0YT","10M","147","149","14T","15L","16G","18T","18Y","1AR","1BW","1GL","1GN","1JB","1LL","1NA","1S3","26M","26Q","26R","26V","26W","26Y","27C","289","291","293","2DG","2F8","2FG","2FL","2FP","2GL","2M4","2M5","32O","34V","3CM","3DO","3DY","3FM","3LR","3MF","3MG","3SA","3ZW","46D","46M","46Z","48Z","4CQ","4GC","4NN","50A","5DI","5GF","5MM","5RP","5SA","5SP","64K","6PG","6SA","7JZ","7SA","A1Q","A2G","AAB","AAL","AAO","ABC","ABD","ABE","ABF","ABL","ACG","ACI","ACR","ACX","ADA","ADG","ADR","AF1","AFD","AFL","AFO","AFP","AFR","AGC","AGH","AGL","AHR","AIG","ALL","ALX","AMU","AOG","AOS","ARA","ARB","ARE","ARI","ASG","ASO","AXP","AXR","B0D","B16","B2G","B4G","B6D","B8D","B9D","BBK","BCD","BDG","BDP","BDR","BEM","BFP","BGC","BGL","BGP","BGS","BHG","BMA","BMX","BNG","BNX","BOG","BRI","BXF","BXP","BXX","BXY","C3X","C4X","C5X","CAP","CBI","CBK","CBS","CDR","CEG","CGF","CHO","CR1","CR6","CRA","CT3","CTO","CTR","CTT","D6G","DAF","DAG","DDA","DDB","DDL","DEL","DFR","DFX","DG0","DGC","DGD","DGM","DGS","DIG","DLF","DLG","DMU","DNO","DOM","DP5","DQQ","DQR","DR2","DR3","DR4","DRI","DSR","DT6","DVC","E4P","E5G","EAG","EBG","EBQ","EGA","EJT","EPG","ERE","ERI","F1P","F1X","F6P","FBP","FCA","FCB","FCT","FDP","FDQ","FFC","FIX","FMO","FRU","FSI","FU4","FUB","FUC","FUD","FUL","FXP","G16","G1P","G2F","G3I","G4D","G4S","G6D","G6P","G6S","GAC","GAD","GAL","GC1","GC4","GCD","GCN","GCO","GCS","GCT","GCU","GCV","GCW","GCX","GE1","GFG","GFP","GIV","GL0","GL2","GL5","GL6","GL7","GL9","GLA","GLB","GLC","GLD","GLF","GLG","GLO","GLP","GLS","GLT","GLW","GMH","GN1","GNX","GP1","GP4","GPH","GPM","GQ1","GQ2","GQ4","GS1","GS4","GSA","GSD","GTE","GTH","GTK","GTR","GTZ","GU0","GU1","GU2","GU3","GU4","GU5","GU6","GU8","GU9","GUF","GUP","GUZ","GYP","GYV","H2P","HDL","HMS","HS2","HSD","HSG","HSH","HSJ","HSQ","HSR","HSU","HSX","HSY","HSZ","IAB","IDG","IDR","IDS","IDT","IDU","IDX","IDY","IMK","IN1","IPT","ISL","KBG","KD2","KDA","KDM","KDO","KFN","KO1","KO2","KTU","L6S","LAG","LAI","LAK","LAO","LAT","LB2","LBT","LCN","LDY","LGC","LGU","LM2","LMT","LMU","LOG","LOX","LPK","LSM","LTM","LVZ","LXB","LXZ","M1F","M3M","M6P","M8C","MA1","MA2","MA3","MAB","MAG","MAL","MAN","MAT","MAV","MAW","MBG","MCU","MDA","MDM","MDP","MFA","MFB","MFU","MG5","MGA","MGL","MLB","MMA","MMN","MN0","MRP","MTT","MUG","MVP","MXY","N1L","N9S","NAA","NAG","NBG","NDG","NED","NG1","NG6","NGA","NGB","NGC","NGE","NGF","NGL","NGS","NGY","NHF","NM6","NM9","NTF","NTO","NTP","NXD","NYT","OPG","OPM","ORP","OX2","P3M","P53","P6P","PA5","PNA","PNG","PNW","PRP","PSJ","PSV","PTQ","QDK","QPS","QV4","R1P","R1X","R2B","R5P","RAA","RAE","RAF","RAM","RAO","RAT","RB5","RBL","RCD","RDP","REL","RER","RF5","RG1","RGG","RHA","RIB","RIP","RNS","RNT","ROB","ROR","RPA","RST","RUB","RUU","RZM","S6P","S7P","SA0","SCR","SDD","SF6","SF9","SG4","SG5","SG6","SG7","SGA","SGC","SGD","SGN","SGS","SHB","SHG","SI3","SIO","SOE","SOL","SSG","SUC","SUP","SUS","T6P","T6T","TAG","TCB","TDG","TGK","TGY","TH1","TIA","TM5","TM6","TM9","TMR","TMX","TOA","TOC","TRE","TYV","UCD","UDC","VG1","X0X","X1X","X2F","X4S","X5S","X6X","XBP","XDN","XDP","XIF","XIM","XLF","XLS","XMM","XUL","XXR","XYP","XYS","YO5","Z3Q","Z6J","Z9M","ZDC","ZDM"],Md=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","OT1","OT2","H","H1","H2","H3","HA","HN","BB"],Cd=["P","OP1","OP2","HOP2","HOP3","O2'","O3'","O4'","O5'","C1'","C2'","C3'","C4'","C5'","H1'","H2'","H2''","HO2'","H3'","H4'","H5'","H5''","HO3'","HO5'","O2*","O3*","O4*","O5*","C1*","C2*","C3*","C4*","C5*"],Pd={1:{trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT","OT1","OT2"],backboneStart:"N",backboneEnd:"C"},2:{trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},3:{trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},4:{trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},5:{trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},6:{trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]}};Pd[ed]={};const Td={HD:"H",HS:"H",A:"C",NA:"N",NS:"N",OA:"O",OS:"O",SA:"S",G0:"C",G1:"C",G2:"C",G3:"C",CG0:"C",CG1:"C",CG2:"C",CG3:"C",W:"O"};function Id(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;default:return 8}}const Ed=new Map([[2,Ka(180)],[3,Ka(120)],[4,Ka(109.4721)],[6,Ka(90)]]);function Dd(e,t){let i=[];const n=new Zt,r=new Zt;return n.subVectors(t,e),e.eachBondedAtom((t=>{1!==t.number&&(r.subVectors(t,e),i.push(n.angleTo(r)))})),i}function Ld(e,t){const i=e.clone(),n=new Zt;n.subVectors(t,e);const r=[new Zt,new Zt];let s=0;if(e.eachBondedAtom((t=>{s>1||1!==t.number&&(i.index=t.index,r[s++].subVectors(t,e))})),1===s&&i.eachBondedAtom((t=>{s>1||1!==t.number&&t.index!==e.index&&r[s++].subVectors(t,e)})),2!==s)return;const o=r[0].cross(r[1]);return Math.abs(Math.PI/2-o.angleTo(n))}function Rd(e,t){const i=e.structure,n=i.atomCount,r=new Int8Array(n),s=new Int8Array(n),o=new Int8Array(n),a=new Int8Array(n);return i.eachAtom((e=>{const i=e.index,[n,c,l,h]=function(e,t){const i=e.bondToElementCount(1);let n=e.formalCharge||0;const r="always"===t.assignCharge||"auto"===t.assignCharge&&0===n,s="always"===t.assignH||"auto"===t.assignH&&0===i,o=e.bondCount,a=function(e){let t=0;return e.eachBond((e=>t+=e.bondOrder)),t}(e),c=function(e){const t=e.structure.getBondProxy(),i=e.number,n=8===i||7===i;if(n&&4===e.bondCount)return!1;let r=!1;return e.eachBond((i=>{if(i.bondOrder>1)r=!0;else if(n){const n=i.getOtherAtom(e);n.eachBond((e=>{if(e.bondOrder>1){const t=n.number;if((15===t||16===t)&&8===e.getOtherAtom(n).number)return;r=!0}}),t)}})),r}(e),l=a-o>0;let h=0,u=8;switch(e.number){case 1:r&&(0===o?(n=1,u=0):1===o&&(n=0,u=1));break;case 6:r&&(n=0),s&&(h=Math.max(0,4-a-Math.abs(n))),u=Id(o+h+Math.max(0,-n));break;case 7:if(r)if(s)if(c&&a<4)n=o-i==1&&a-i==2?1:0;else{let t=!1;e.eachBondedAtom((e=>{(16===e.number||e.isMetal())&&(t=!0)})),n=t?0:1}else n=a-3;s&&(h=Math.max(0,3-a+n)),u=Id(c&&!l?o+h-n:o+h+1-n);break;case 8:r&&(s||(n=a-2),1===a&&e.eachBondedAtom((t=>{t.eachBond((i=>{const r=i.getOtherAtom(t);r.index!==e.index&&8===r.number&&2===i.bondOrder&&(n=-1)}))}))),s&&(h=Math.max(0,2-a+n)),u=Id(c&&!l?o+h-n+1:o+h-n+2);break;case 16:r&&(s||(n=a<=3&&!e.bondToElementCount(8)?a-2:0)),s&&a<2&&(h=Math.max(0,2-a+n)),a<=3&&(u=Id(o+h-n+2));break;case 9:case 17:case 35:case 53:case 85:r&&(n=a-1);break;case 3:case 11:case 19:case 37:case 55:case 87:r&&(n=1-a);break;case 4:case 12:case 20:case 38:case 56:case 88:r&&(n=2-a);break;default:console.warn("Requested charge, protonation for an unhandled element",e.element)}return[n,h,h+i,u]}(e,t);r[i]=n,s[i]=c,o[i]=l,a[i]=h})),{charge:r,implicitH:s,totalH:o,idealGeometry:a}}function kd(e){if(e["@valenceModel"])return e["@valenceModel"];const t=Rd(e,{assignCharge:"auto",assignH:"auto"});return e["@valenceModel"]=t,t}function Od(e){return 15===e.number&&e.bondToElementCount(8)===e.bondCount}const Bd=["ARG","HIS","LYS"],Nd=["GLU","ASP"];function Fd(e,t){return 2===e&&1===t||1===e&&2===t}function zd(e,t){return 3===e&&3===t}function Ud(e,t){return 3===e&&1===t||1===e&&3===t}function $d(e){return"HIS"===e.resname&&7==e.number&&e.isRing()}function Gd(e,t){return 5===e&&4===t||4===e&&5===t}function Vd(e,t){return 9===e&&5===t||5===e&&9===t}const Hd=[3,11,19,37,55,12,20,38,56,13,31,49,81,21,50,82,83,51,80];function jd(e,t){return 12===e?11===t||12===t:13===e?10===t:void 0}const Wd=[17,35,53,85];const qd=[7,8,16],Xd=[6,7,15,16];const Yd=Ka(180),Zd=Ka(120);function Kd(e,t,i){return!Jd(e,t,i)&&(e.modelIndex!==t.modelIndex||e.altloc&&t.altloc&&e.altloc!==t.altloc)}const Qd={maxHydrophobicDist:4,maxHbondDist:3.5,maxHbondSulfurDist:4.1,maxHbondAccAngle:45,maxHbondDonAngle:45,maxHbondAccPlaneAngle:90,maxHbondDonPlaneAngle:30,maxPiStackingDist:5.5,maxPiStackingOffset:2,maxPiStackingAngle:30,maxCationPiDist:6,maxCationPiOffset:2,maxIonicDist:5,maxHalogenBondDist:4,maxHalogenBondAngle:30,maxMetalDist:3,refineSaltBridges:!0,masterModelIndex:-1,lineOfSightDistFactor:1};function Jd(e,t,i){return e.modelIndex===i&&t.modelIndex!==i||t.modelIndex===i&&e.modelIndex!==i}function ef(e,t,i){return!Jd(e,t,i)&&(e.modelIndex!==t.modelIndex||e.residueIndex===t.residueIndex||e.altloc&&t.altloc&&e.altloc!==t.altloc)}function tf(t){const i={types:[],groups:[],centers:{x:[],y:[],z:[]},atomSets:[]};return e.Debug&&il.time("calculateFeatures"),function(e,t){const{charge:i}=kd(e.data),n={};e.eachResidue((e=>{if(Bd.includes(e.resname)){const i=Ku(1);e.eachAtom((e=>{7===e.number&&e.isSidechain()&&Qu(i,e)})),Ju(t,i)}else vd.includes(e.resname)||e.isNucleic()||(e.eachAtom((e=>{let i=!1;const r=Ku(1);!function(e){let t=0;return 6===e.number&&3===e.bondCount&&3===e.bondToElementCount(7)&&e.eachBondedAtom((e=>{e.bondCount-e.bondToElementCount(1)==1&&++t})),2===t}(e)?function(e){let t=0;return 6===e.number&&3===e.bondCount&&2===e.bondToElementCount(7)&&1===e.bondToElementCount(6)&&e.eachBondedAtom((e=>{e.bondCount-e.bondToElementCount(1)==1&&++t})),2===t}(e)&&(r.group=9,i=!0):(r.group=8,i=!0),i&&(e.eachBondedAtom((e=>{7===e.number&&(n[e.index]=!0,Qu(r,e))})),Ju(t,r))})),e.eachAtom((e=>{const r=Ku(1);i[e.index]>0&&(n[e.index]||(Qu(r,e),Ju(t,r)))})))}))}(t,i),function(e,t){const{charge:i}=kd(e.data),n={};e.eachResidue((e=>{if(Nd.includes(e.resname)){const i=Ku(2);e.eachAtom((e=>{8===e.number&&e.isSidechain()&&Qu(i,e)})),Ju(t,i)}else if(_d.includes(e.resname)){const i=Ku(2);e.eachAtom((e=>{Od(e)&&(i.group=6,e.eachBondedAtom((e=>{8===e.number&&Qu(i,e)})),Ju(t,i))}))}else vd.includes(e.resname)||_d.includes(e.resname)||(e.eachAtom((e=>{let i=!1;const r=Ku(2);!function(e){return 16===e.number&&3===e.bondToElementCount(8)}(e)?Od(e)?(r.group=6,i=!0):function(e){return 16===e.number&&4===e.bondToElementCount(8)}(e)?(r.group=5,i=!0):function(e){let t=0;return 6===e.number&&2===e.bondToElementCount(8)&&1===e.bondToElementCount(6)&&e.eachBondedAtom((e=>{8===e.number&&e.bondCount-e.bondToElementCount(1)==1&&++t})),2===t}(e)&&(r.group=10,i=!0):(r.group=4,i=!0),i&&(e.eachBondedAtom((e=>{8===e.number&&(n[e.index]=!0,Qu(r,e))})),Ju(t,r))})),e.eachAtom((e=>{const r=Ku(2);i[e.index]<0&&(n[e.index]||(Qu(r,e),Ju(t,r)))})))}))}(t,i),function(e,t){const i=e.getAtomProxy();e.eachResidue((e=>{const n=e.getAromaticRings();if(n){const r=e.atomOffset;n.forEach((e=>{const n=Ku(3);e.forEach((e=>{i.index=e+r,Qu(n,i)})),Ju(t,n)}))}}))}(t,i),function(e,t){const{charge:i,implicitH:n,idealGeometry:r}=kd(e.data);e.eachAtom((e=>{const s=Ku(5),o=e.number;if(8===o)Qu(s,e),Ju(t,s);else if(7===o){if($d(e))Qu(s,e),Ju(t,s);else if(i[e.index]<1){const i=e.bondCount+n[e.index],o=r[e.index];(4===o&&i<4||3===o&&i<3||2===o&&i<2)&&(Qu(s,e),Ju(t,s))}}else 16===o&&("CYS"!==e.resname&&"MET"!==e.resname&&-1!==e.formalCharge||(Qu(s,e),Ju(t,s)))}))}(t,i),function(e,t){const{totalH:i}=kd(e.data);e.eachAtom((e=>{const n=Ku(4),r=e.number;($d(e)||i[e.index]>0&&(7===r||8===r||16===r))&&(Qu(n,e),Ju(t,n))}))}(t,i),function(e,t){const{totalH:i}=kd(e.data);e.eachAtom((e=>{if(6===e.number&&i[e.index]>0&&(e.bondToElementCount(7)>0||e.bondToElementCount(8)>0||function(e){if(!e.isAromatic())return!1;const t=e.residueType.getRings();if(!t)return!1;let i=!1;return t.rings.forEach((t=>{i||t.some((t=>e.index-e.residueAtomOffset===t))&&(i=t.some((t=>{const i=e.residueType.atomTypeIdList[t],n=e.atomMap.get(i).number;return 7===n||8===n})))})),i}(e))){const i=Ku(9);Qu(i,e),Ju(t,i)}}))}(t,i),function(e,t){e.eachAtom((e=>{let i=!1,n=!1;const r=vd.includes(e.resname),s=_d.includes(e.resname);if(r||s?r?8===e.number?(["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(e.resname)&&e.isSidechain()||e.isBackbone())&&(i=!0,n=!0):16===e.number&&"CYS"===e.resname?(i=!0,n=!0):7===e.number&&"HIS"===e.resname&&e.isSidechain()&&(i=!0):s&&(8===e.number&&e.isBackbone()?(i=!0,n=!0):["N3","N4","N7"].includes(e.atomname)?i=!0:["O2","O4","O6"].includes(e.atomname)&&(i=!0,n=!0)):e.isHalogen()||8===e.number||16===e.number?(i=!0,n=!0):7===e.number&&(i=!0),i){const i=Ku(11);Qu(i,e),Ju(t,i)}if(n){const i=Ku(10);Qu(i,e),Ju(t,i)}}))}(t,i),function(e,t){e.eachAtom((e=>{if(e.isTransitionMetal()||30===e.number||48===e.number){const i=Ku(12);Qu(i,e),Ju(t,i)}else if(Hd.includes(e.number)){const i=Ku(13);Qu(i,e),Ju(t,i)}}))}(t,i),function(e,t){e.eachAtom((e=>{const i=Ku(8);let n=!1;6===e.number?(n=!0,e.eachBondedAtom((e=>{const t=e.number;6!==t&&1!==t&&(n=!1)}))):9===e.number&&(n=!0),n&&(Qu(i,e),Ju(t,i))}))}(t,i),function(e,t){e.eachAtom((e=>{if(qd.includes(e.number)){let i=!1;if(e.eachBondedAtom((e=>{Xd.includes(e.number)&&(i=!0)})),i){const i=Ku(7);Qu(i,e),Ju(t,i)}}}))}(t,i),function(e,t){e.eachAtom((e=>{if(Wd.includes(e.number)&&1===e.bondToElementCount(6)){const i=Ku(6);Qu(i,e),Ju(t,i)}}))}(t,i),e.Debug&&il.timeEnd("calculateFeatures"),i}function nf(t,i=Qd){const n=function(e){const{types:t,centers:i}=e;return{features:e,spatialHash:new ju(i),contactStore:new qu,featureSet:new Yu(t.length,!1)}}(tf(t));e.Debug&&il.time("calculateContacts"),function(e,t,i={}){const n=Ia(i.maxIonicDist,Qd.maxIonicDist),r=Ia(i.maxPiStackingDist,Qd.maxPiStackingDist),s=Ia(i.maxPiStackingOffset,Qd.maxPiStackingOffset),o=Ia(i.maxPiStackingAngle,Qd.maxPiStackingAngle),a=Ia(i.maxCationPiDist,Qd.maxCationPiDist),c=Ia(i.maxCationPiOffset,Qd.maxCationPiOffset),l=Ia(i.masterModelIndex,Qd.masterModelIndex),h=Math.max(n+2,r,a),u=r*r,d=a*a,{features:f,spatialHash:m,contactStore:p,featureSet:g}=t,{types:v,centers:y,atomSets:x}=f,{x:b,y:_,z:w}=y,S=v.length,A=e.atomStore.x,M=e.atomStore.y,C=e.atomStore.z,P=e.getAtomProxy(),T=e.getAtomProxy(),I=function(e,t,i){const n=e.length,r=t.length;for(let s=0;s{if(t<=e)return;if(P.index=x[e][0],T.index=x[t][0],ef(P,T,l))return;const r=v[e],a=v[t];if(Fd(r,a))I(x[e],x[t],n)&&z(e,t,1);else if(zd(r,a)){if(i<=u){N(x[e],O),N(x[t],B);const i=57.29578*O.angleTo(B);Math.min(F(e,t,B),F(t,e,O))<=s&&(i<=o||i>=180-o||i<=o+90&&i>=90-o)&&z(e,t,3)}}else if(Ud(r,a)&&i<=d){const[i,n]=3===r?[e,t]:[t,e];N(x[i],O),F(n,i,O)<=c&&z(i,n,2)}}))}(t,n,i),function(e,t,i={}){const n=Ia(i.maxHbondDist,Qd.maxHbondDist),r=Ia(i.maxHbondSulfurDist,Qd.maxHbondSulfurDist),s=Ka(Ia(i.maxHbondAccAngle,Qd.maxHbondAccAngle)),o=Ka(Ia(i.maxHbondDonAngle,Qd.maxHbondDonAngle)),a=Ka(Ia(i.maxHbondAccPlaneAngle,Qd.maxHbondAccPlaneAngle)),c=Ka(Ia(i.maxHbondDonPlaneAngle,Qd.maxHbondDonPlaneAngle)),l=Ia(i.masterModelIndex,Qd.masterModelIndex),h=Math.max(n,r),u=n*n,{features:d,spatialHash:f,contactStore:m,featureSet:p}=t,{types:g,centers:v,atomSets:y}=d,{x:x,y:b,z:_}=v,w=g.length,{idealGeometry:S}=kd(e.data),A=e.getAtomProxy(),M=e.getAtomProxy();for(let e=0;e{if(t<=e)return;const n=g[e],r=g[t],h=Vd(n,r);if(!h&&!Gd(n,r))return;const[d,f]=5===r?[e,t]:[t,e];if(A.index=y[d][0],M.index=y[f][0],M.index===A.index)return;if(ef(A,M,l))return;if(16!==A.number&&16!==M.number&&i>u)return;if(A.connectedTo(M))return;const v=Dd(A,M),x=Ed.get(S[A.index])||Ka(120);if(v.some((e=>Math.abs(x-e)>o)))return;if(3===S[A.index]){const e=Ld(A,M);if(void 0!==e&&e>c)return}const b=Dd(M,A),_=Ed.get(S[M.index])||Ka(120);if(b.some((e=>_-e>s)))return;if(3===S[M.index]){const e=Ld(M,A);if(void 0!==e&&e>a)return}p.setBits(d,f);const w=h?8:function(e,t){return e.isWater()&&t.isWater()}(C=A,P=M)?9:function(e,t){return e.isBackbone()&&t.isBackbone()}(C,P)?10:4;var C,P;m.addContact(d,f,w)}))}(t,n,i),function(e,t,i={}){const n=Ia(i.maxMetalDist,Qd.maxMetalDist),r=Ia(i.masterModelIndex,Qd.masterModelIndex),{features:s,spatialHash:o,contactStore:a,featureSet:c}=t,{types:l,centers:h,atomSets:u}=s,{x:d,y:f,z:m}=h,p=l.length,g=e.getAtomProxy(),v=e.getAtomProxy();for(let e=0;e{if(t<=e)return;if(g.index=u[e][0],v.index=u[t][0],ef(g,v,r))return;const n=g.isMetal(),s=v.isMetal();if(!n&&!s)return;const[o,h]=n?[l[e],l[t]]:[l[t],l[e]];jd(o,h)&&(c.setBits(e,t),a.addContact(e,t,7))}))}(t,n,i),function(e,t,i={}){const n=Ia(i.maxHydrophobicDist,Qd.maxHydrophobicDist),r=Ia(i.masterModelIndex,Qd.masterModelIndex),{features:s,spatialHash:o,contactStore:a,featureSet:c}=t,{types:l,centers:h,atomSets:u}=s,{x:d,y:f,z:m}=h,p=l.length,g=e.getAtomProxy(),v=e.getAtomProxy();for(let e=0;e{var n,s;t<=e||(g.index=u[e][0],v.index=u[t][0],ef(g,v,r)||9===g.number&&9===v.number||g.connectedTo(v)||(n=l[e],s=l[t],8===n&&8===s&&(c.setBits(e,t),a.addContact(e,t,6))))}))}(t,n,i),function(e,t,i={}){const n=Ia(i.maxHalogenBondDist,Qd.maxHalogenBondDist),r=Ka(Ia(i.maxHalogenBondAngle,Qd.maxHalogenBondAngle)),s=Ia(i.masterModelIndex,Qd.masterModelIndex),{features:o,spatialHash:a,contactStore:c,featureSet:l}=t,{types:h,centers:u,atomSets:d}=o,{x:f,y:m,z:p}=u,g=h.length,v=e.getAtomProxy(),y=e.getAtomProxy();for(let e=0;e{if(t<=e)return;if(v.index=d[e][0],y.index=d[t][0],ef(v,y,s))return;if(n=h[e],o=h[t],!(7===n&&6===o||6===n&&7===o))return;var n,o;const[a,u]=6===h[e]?[v,y]:[y,v],f=Dd(a,u);if(1!==f.length)return;if(Yd-f[0]>r)return;const m=Dd(u,a);0!==m.length&&(m.some((e=>Zd-e>r))||(l.setBits(e,t),c.addContact(e,t,5)))}))}(t,n,i);const r=function(e){const{index1:t,index2:i,count:n}=e.contactStore,r=Zu({nodeArray1:t,nodeArray2:i,edgeCount:n,nodeCount:e.featureSet.length}),s=new Yu(e.contactStore.count,!0);return Object.assign({adjacencyList:r,contactSet:s},e)}(n);return function(t,i,n={}){e.Debug&&il.time("refineLineOfSight");const r=Ia(n.lineOfSightDistFactor,Qd.lineOfSightDistFactor),s=Ia(n.masterModelIndex,Qd.masterModelIndex),o=t.spatialHash,{contactSet:a,contactStore:c,features:l}=i,{index1:h,index2:u}=c,{centers:d,atomSets:f}=l,{x:m,y:p,z:g}=d,v=t.getAtomProxy(),y=t.getAtomProxy(),x=t.getAtomProxy(),b=new Zt,_=new Zt,w=3*r,S=r*r;a.forEach((t=>{b.set(m[h[t]],p[h[t]],g[h[t]]),_.set(m[u[t]],p[u[t]],g[u[t]]);const i=(b.x+_.x)/2,n=(b.y+_.y)/2,r=(b.z+_.z)/2,c=f[h[t]],l=f[u[t]];v.index=c[0],y.index=l[0],o.eachWithin(i,n,r,w,((i,n)=>{x.index=i,1!==x.number&&x.vdw*x.vdw*S>n&&!Kd(v,x,s)&&!Kd(y,x,s)&&!c.includes(i)&&!l.includes(i)&&b.distanceToSquared(x)>1&&_.distanceToSquared(x)>1&&(a.clear(t),e.Debug&&il.log("removing",v.qualifiedName(),y.qualifiedName(),"because",x.qualifiedName()))}))})),e.Debug&&il.timeEnd("refineLineOfSight")}(t,r,i),function(e,t){const{contactSet:i,contactStore:n,features:r}=t,{type:s,index1:o,index2:a}=n,{atomSets:c}=r,l=e.getAtomProxy(),h=e.getAtomProxy(),u={},d=function(e,t,n){const[r,s]=u[n]||[1/0,-1];e{if(6!==s[e])return;l.index=c[o[e]][0],h.index=c[a[e]][0];const t=l.distanceTo(h);d(t,e,`${l.index}|${h.residueIndex}`),d(t,e,`${h.index}|${l.residueIndex}`)}))}(t,r),i.refineSaltBridges&&function(e,t){const{contactSet:i,contactStore:n,features:r}=t,{type:s,index1:o,index2:a}=n,{atomSets:c}=r,l={},h=function(e,t){l[e]||(l[e]=[]),l[e].push(t)};i.forEach((e=>{1===s[e]&&(c[o[e]].forEach((t=>h(t,e))),c[a[e]].forEach((t=>h(t,e))))})),i.forEach((e=>{if(!function(e){return 4===e||9===e||10===e}(s[e]))return;const t=l[c[o[e]][0]],n=l[c[a[e]][0]];if(!t||!n)return;const r=t.length;for(let s=0;s{3===s[e]&&(c[o[e]].forEach((t=>h(t,e))),c[a[e]].forEach((t=>h(t,e))))})),i.forEach((e=>{if(6!==s[e]&&2!==s[e])return;const t=l[c[o[e]][0]],n=l[c[a[e]][0]];if(!t||!n)return;const r=t.length;for(let s=0;s{1===s[e]&&(c[o[e]].forEach((t=>h(t,e))),c[a[e]].forEach((t=>h(t,e))))})),i.forEach((e=>{if(7!==s[e])return;const t=l[c[o[e]][0]],n=l[c[a[e]][0]];if(!t||!n)return;const r=t.length;for(let e=0;et.getAtomSet(new $c(e)))):t.getAtomSet(new $c(n.filterSele))),o.forEach((e=>{const t=p[e];if(!r.includes(t))return;if(_){const t=l[f[e]][0],i=l[m[e]][0];if(Array.isArray(_)){if(!(_[0].isSet(t)&&_[1].isSet(i)||_[1].isSet(t)&&_[0].isSet(i)))return}else if(!_.isSet(t)&&!_.isSet(i))return}const i=f[e],s=m[e];g.push(h[i],u[i],d[i]),v.push(h[s],u[s],d[s]),y.push(...function(e){switch(e){case 4:case 9:case 10:return of.setHex(2851770).toArray();case 6:return of.setHex(8421504).toArray();case 5:return of.setHex(4259775).toArray();case 1:return of.setHex(15779860).toArray();case 7:return of.setHex(9191577).toArray();case 2:return of.setHex(16744448).toArray();case 3:return of.setHex(9220966).toArray();case 8:return of.setHex(12967404).toArray();default:return of.setHex(13421772).toArray()}}(t)),x.push(n.radius),b.push(e)})),{position1:new Float32Array(g),position2:new Float32Array(v),color:new Float32Array(y),color2:new Float32Array(y),radius:new Float32Array(x),picking:new ff(b,e,t)}}class cf{constructor(e){this.array=e}get type(){return""}get data(){return{}}getIndex(e){return this.array?this.array[e]:e}getObject(e){return{}}_applyTransformations(e,t,i){return t&&e.applyMatrix4(t.matrix),i&&e.applyMatrix4(i.matrix),e}_getPosition(e){return new Zt}getPosition(e,t,i){return this._applyTransformations(this._getPosition(e),t,i)}}class lf extends cf{constructor(e){super(),this.shape=e}get primitive(){}get data(){return this.shape}get type(){return this.primitive.type}getObject(e){return this.primitive.objectFromShape(this.shape,this.getIndex(e))}_getPosition(e){return this.primitive.positionFromShape(this.shape,this.getIndex(e))}}class hf extends cf{constructor(e,t){super(e),this.structure=t}get type(){return"atom"}get data(){return this.structure}getObject(e){return this.structure.getAtomProxy(this.getIndex(e))}_getPosition(e){return(new Zt).copy(this.getObject(e))}}class uf extends cf{constructor(e){super(),this.axes=e}get type(){return"axes"}get data(){return this.axes}getObject(){return{axes:this.axes}}_getPosition(){return this.axes.center.clone()}}class df extends cf{constructor(e,t,i){super(e),this.structure=t,this.bondStore=i||t.bondStore}get type(){return"bond"}get data(){return this.structure}getObject(e){const t=this.structure.getBondProxy(this.getIndex(e));return t.bondStore=this.bondStore,t}_getPosition(e){const t=this.getObject(e);return(new Zt).copy(t.atom1).add(t.atom2).multiplyScalar(.5)}}class ff extends cf{constructor(e,t,i){super(e),this.contacts=t,this.structure=i}get type(){return"contact"}get data(){return this.contacts}getObject(e){const t=this.getIndex(e),{features:i,contactStore:n}=this.contacts,{centers:r,atomSets:s}=i,{x:o,y:a,z:c}=r,{index1:l,index2:h,type:u}=n,d=l[t],f=h[t];return{center1:new Zt(o[d],a[d],c[d]),center2:new Zt(o[f],a[f],c[f]),atom1:this.structure.getAtomProxy(s[d][0]),atom2:this.structure.getAtomProxy(s[f][0]),type:rf(u[t])}}_getPosition(e){const{center1:t,center2:i}=this.getObject(e);return(new Zt).addVectors(t,i).multiplyScalar(.5)}}class mf extends cf{constructor(e,t,i){super(e),this.validation=t,this.structure=i}get type(){return"clash"}get data(){return this.validation}getObject(e){const t=this.validation,i=this.getIndex(e);return{validation:t,index:i,clash:t.clashArray[i]}}_getAtomProxyFromSele(e){const t=new $c(e),i=this.structure.getAtomIndices(t)[0];return this.structure.getAtomProxy(i)}_getPosition(e){const t=this.getObject(e).clash,i=this._getAtomProxyFromSele(t.sele1),n=this._getAtomProxyFromSele(t.sele2);return(new Zt).copy(i).add(n).multiplyScalar(.5)}}class pf extends df{get type(){return"distance"}}class gf extends cf{get type(){return"ignore"}}class vf extends lf{constructor(e,t){super(e),this.mesh=t}get type(){return"mesh"}getObject(){const e=this.mesh;return{shape:this.shape,name:e.name,serial:e.serial}}_getPosition(){return this.__position||(this.__position=ru(this.mesh.position)),this.__position}}class yf extends cf{constructor(e,t){super(e),this.surface=t}get type(){return"surface"}get data(){return this.surface}getObject(e){return{surface:this.surface,index:this.getIndex(e)}}_getPosition(){return this.surface.center.clone()}}class xf extends cf{constructor(e,t){super(),this.unitcell=e,this.structure=t}get type(){return"unitcell"}get data(){return this.unitcell}getObject(){return{unitcell:this.unitcell,structure:this.structure}}_getPosition(){return this.unitcell.getCenter(this.structure)}}class bf extends cf{constructor(e,t){super(e),this.volume=t}get type(){return"volume"}get data(){return this.volume}getObject(e){const t=this.volume,i=this.getIndex(e);return{volume:t,index:i,value:t.data[i]}}_getPosition(e){const t=this.volume.position,i=this.getIndex(e);return new Zt(t[3*i],t[3*i+1],t[3*i+2])}}class _f extends bf{get type(){return"slice"}}function wf(){return new Uint32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0])}function Sf(){return new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-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1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])}function Af(e,t,i,n,r){var s,o,a,c,l,h,u,d=[[0,4,4,4,2,0,0,0,2,2,0,0],[4,0,4,4,0,8,0,0,0,8,8,0],[4,4,0,4,0,0,8,0,0,0,8,8],[4,4,4,0,0,0,0,1,1,0,0,1],[2,0,0,0,0,8,8,8,2,2,0,0],[0,8,0,0,8,0,8,8,0,8,8,0],[0,0,8,0,8,8,0,8,0,0,8,8],[0,0,0,1,8,8,8,0,1,0,0,1],[2,0,0,1,2,0,0,1,0,2,0,1],[2,8,0,0,2,8,0,0,2,0,8,0],[0,8,8,0,0,8,8,0,0,8,0,8],[0,0,8,1,0,0,8,1,1,0,8,0]],f=0,m=!1,p=!1,g=!1,v=!1,y=-1,x=t*i*n,b=t,_=t*i,w=new Int32Array(12),S=[],A=[],M=[],C=[],P=wf(),T=Sf();function I(e,t,i){return e+(t-e)*i}function E(e,r,s){return _*(s=(s+u)%n)+b*(r=(r+h)%i)+(e=(e+l)%t)}function D(e,t,i,n,c,l,h){var u=3*e;if(o[u]<0){var d=(f-l)/(h-l),p=s,g=3*a;if(S[g]=i+d,S[g+1]=n,S[g+2]=c,!m){var v=3*e;A[g]=y*I(p[v],p[v+3],d),A[g+1]=y*I(p[v+1],p[v+4],d),A[g+2]=y*I(p[v+2],p[v+5],d)}r&&(C[a]=r[e+Math.round(d)]),o[u]=a,w[t]=a,a+=1}else w[t]=o[u]}function L(e,t,i,n,c,l,h){var u=3*e+1;if(o[u]<0){var d=(f-l)/(h-l),p=s,g=3*a;if(S[g]=i,S[g+1]=n+d,S[g+2]=c,!m){var v=3*e,x=v+3*b;A[g]=y*I(p[v],p[x],d),A[g+1]=y*I(p[v+1],p[x+1],d),A[g+2]=y*I(p[v+2],p[x+2],d)}r&&(C[a]=r[e+Math.round(d)*b]),o[u]=a,w[t]=a,a+=1}else w[t]=o[u]}function R(e,t,i,n,c,l,h){var u=3*e+2;if(o[u]<0){var d=(f-l)/(h-l),p=s,g=3*a;if(S[g]=i,S[g+1]=n,S[g+2]=c+d,!m){var v=3*e,x=v+3*_;A[g]=y*I(p[v],p[x],d),A[g+1]=y*I(p[v+1],p[x+1],d),A[g+2]=y*I(p[v+2],p[x+2],d)}r&&(C[a]=r[e+Math.round(d)*_]),o[u]=a,w[t]=a,a+=1}else w[t]=o[u]}function k(t){var i=3*t;0===s[i]&&(s[i]=e[(t-1+x)%x]-e[(t+1)%x],s[i+1]=e[(t-b+x)%x]-e[(t+b)%x],s[i+2]=e[(t-_+x)%x]-e[(t+_)%x])}function O(t,i,n,r,s){var o,a,l,h,u,y,x;g?(r=E(t,i,n),o=E(t+1,i,n),a=E(t,i+1,n),l=E(t,i,n+1),h=E(t+1,i+1,n),u=E(t+1,i,n+1),y=E(t,i+1,n+1),x=E(t+1,i+1,n+1)):(o=r+1,h=(a=r+b)+1,u=(l=r+_)+1,x=(y=a+_)+1);var S=0,A=e[r],C=e[o],I=e[a],O=e[h],B=e[l],N=e[u],F=e[y],z=e[x];A=f){R=y,I=!0;break}if(I)break}if(I)break}for(I=!1,v=s;v=f){L=v,I=!0;break}if(I)break}if(I)break}for(I=!1,p=r;p=f){D=p,I=!0;break}if(I)break}if(I)break}for(I=!1,y=h;y>=a;--y){for(v=l;v>=s;--v){for(p=c;p>=r;--p)if(u=t*i*y+t*v+p,e[u]>=f){N=y,I=!0;break}if(I)break}if(I)break}for(I=!1,v=l;v>=s;--v){for(y=N;y>=a;--y){for(p=c;p>=r;--p)if(u=t*i*y+t*v+p,e[u]>=f){B=v,I=!0;break}if(I)break}if(I)break}for(I=!1,p=c;p>=r;--p){for(v=B;v>=s;--v){for(y=N;y>=a;--y)if(u=t*i*y+t*v+p,e[u]>=f){k=p,I=!0;break}if(I)break}if(I)break}m?(r=Math.max(0,D-1),s=Math.max(0,L-1),a=Math.max(0,R-1),c=Math.min(t-1,k+1),l=Math.min(i-1,B+1),h=Math.min(n-1,N+1)):(r=Math.max(1,D-1),s=Math.max(1,L-1),a=Math.max(1,R-1),c=Math.min(t-2,k+1),l=Math.min(i-2,B+1),h=Math.min(n-2,N+1))}var F=15;for(y=a;y0?-1:1,s||(s=new Float32Array(3*x)));var P=3*x;if(o&&o.length===P||(o=new Int32Array(P)),a=0,c=0,void 0!==b){var T=b[0].map(Math.round),I=b[1].map(Math.round);l=t*Math.ceil(Math.abs(T[0])/t),h=i*Math.ceil(Math.abs(T[1])/i),u=n*Math.ceil(Math.abs(T[2])/n),B(T[0],T[1],T[2],I[0],I[1],I[2])}else l=h=u=0,B();return S.length=3*a,m||(A.length=3*a),M.length=c,r&&(C.length=a),{position:new Float32Array(S),normal:m?void 0:new Float32Array(A),index:Ga(M,S.length/3),atomindex:r?new Int32Array(C):void 0,contour:p}}}pl.add("arrow",class extends lf{get primitive(){return Fu}}),pl.add("box",class extends lf{get primitive(){return ku}}),pl.add("cone",class extends lf{get primitive(){return zu}}),pl.add("cylinder",class extends lf{get primitive(){return Nu}}),pl.add("ellipsoid",class extends lf{get primitive(){return Uu}}),pl.add("octahedron",class extends lf{get primitive(){return Ou}}),pl.add("sphere",class extends lf{get primitive(){return Ru}}),pl.add("tetrahedron",class extends lf{get primitive(){return Bu}}),pl.add("torus",class extends lf{get primitive(){return $u}}),pl.add("point",class extends lf{get primitive(){return Vu}}),pl.add("wideline",class extends lf{get primitive(){return Hu}}),Object.assign(Af,{__deps:[wf,Sf,Ga]});class Mf{constructor(e,t){this.cols=e,this.rows=t,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}copyTo(e){e.data.set(this.data)}}function Cf(e,t){let i=0,n=0;const r=t.rows,s=t.cols;let o=0,a=0,c=0;const l=t.data,h=e.data;for(;i(t=Math.abs(t))?(t/=e,e*Math.sqrt(1+t*t)):t>0?(e/=t,t*Math.sqrt(1+e*e)):0}const Rf=1.192092896e-7,kf=1e-37;function Of(e,t,i,n){let r=0,s=0;const o=e.rows,a=e.cols;let c=o,l=a;c>16)?k:-k,e[h*t+d]=R;for(f=0;f<2;f++)for(u=0;u{const t=e.data.sd,i=e.data.p;o(this._makeSurface(t,i.isolevel,i.smooth))}),(a=>{console.warn("Volume.getSurfaceWorker error - trying without worker",a);const c=this.getSurface(e,t,i,n,r,s);o(c)}))}else{const a=this.getSurface(e,t,i,n,r,s);o(a)}}getValueForSigma(e){return this.mean+Ia(e,2)*this.rms}getSigmaForValue(e){return(Ia(e,0)-this.mean)/this.rms}get position(){if(!this._position){const e=this.nz,t=this.ny,i=this.nx,n=new Float32Array(i*t*e*3);let r=0;for(let s=0;si){const e=t;t=i,i=e}const n=e[t];return void 0===n?(e[t]=[i],!0):!n.includes(i)&&(n.push(i),!0)}const i=this.geometry,n=i.index;if(this.parameters.wireframe)if(n){const r=n.array;let s,o=r.length;if(i.drawRange.count!==1/0&&(o=i.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*o)s=this.wireframeIndex;else{s=Ga(2*o,i.attributes.position.count)}let a=0;e.length=0;for(let e=0;e2*e?this.wireframeIndex:Ga(2*e,e);for(let i=0,n=0;ithis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new An(this.wireframeIndex,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0));else{const e=this.wireframeGeometry.getIndex();if(!e)return void il.error("Index is null");e.set(this.wireframeIndex),e.needsUpdate=this.wireframeIndexCount>0,e.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}}getRenderOrder(){let e=0;return this.isText?e=1:this.transparent&&(e=this.isSurface?3:2),e}_getMesh(e){this.material||this.makeMaterial();const t=this.geometry,i=this[e];let n;return n=this.isLine?new Yo(t,i):this.isPoint?new ta(t,i):new ar(t,i),n.frustumCulled=!1,n.renderOrder=this.getRenderOrder(),n}getMesh(){return this._getMesh("material")}getWireframeMesh(){let e;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),e=new Yo(this.wireframeGeometry,this.wireframeMaterial),e.frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e}getPickingMesh(){return this._getMesh("pickingMaterial")}getShader(e,t){return kl(e,this.getDefines(t))}getVertexShader(e){return this.getShader(this.vertexShader,e)}getFragmentShader(e){return this.getShader(this.fragmentShader,e)}getDefines(e){const t={};return this.parameters.clipNear&&(t.NEAR_CLIP=1),this.parameters.clipRadius&&(t.RADIUS_CLIP=1),"picking"===e?t.PICKING=1:(("background"===e||this.parameters.background)&&(t.NOLIGHT=1),this.parameters.flatShaded&&(t.FLAT_SHADED=1),this.parameters.opaqueBack&&(t.OPAQUE_BACK=1),this.parameters.diffuseInterior&&(t.DIFFUSE_INTERIOR=1),this.parameters.useInteriorColor&&(t.USE_INTERIOR_COLOR=1)),t}getParameters(){return this.parameters}addUniforms(e){this.uniforms=yr.merge([this.uniforms,e]),this.pickingUniforms=yr.merge([this.pickingUniforms,e])}addAttributes(e){for(let t in e){let i;const n=e[t],r=this.attributeSize*Qf[n.type];n.value?(r!==n.value.length&&il.error("attribute value has wrong length",t),i=n.value):i=$a("float32",r),this.geometry.setAttribute(t,new An(i,Qf[n.type]).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0))}}updateRenderOrder(){const e=this.getRenderOrder();function t(t){t.renderOrder=e}this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)}updateShader(){const e=this.material,t=this.wireframeMaterial,i=this.pickingMaterial;e.vertexShader=this.getVertexShader(),e.fragmentShader=this.getFragmentShader(),e.needsUpdate=!0,t.vertexShader=this.getShader("Line.vert"),t.fragmentShader=this.getShader("Line.frag"),t.needsUpdate=!0,i.vertexShader=this.getVertexShader("picking"),i.fragmentShader=this.getFragmentShader("picking"),i.needsUpdate=!0}setParameters(e){const t=e,i=this.parameterTypes,n=this.parameters,r={},s={};let o=!1,a=!1;for(const e in t){const c=t[e];void 0!==c&&(n[e]=c,void 0!==i[e]&&(i[e].property&&(!0!==i[e].property?r[i[e].property]=c:r[e]=c),i[e].uniform&&(!0!==i[e].uniform?s[i[e].uniform]=c:s[e]=c),i[e].updateShader&&(o=!0),i[e].updateVisibility&&(a=!0),this.dynamic&&"wireframe"===e&&!0===c&&this.updateWireframeIndex(),"forceTransparent"===e&&(r.transparent=this.transparent),"matrix"===e&&(this.matrix=c)))}this.setProperties(r),this.setUniforms(s),o&&this.updateShader(),a&&this.setVisibility(this.visible)}setAttributes(e){const t=this.geometry,i=t.attributes;for(const n in e){if("picking"===n)continue;const r=e[n],s=r.length;if("index"===n){const e=t.getIndex();if(!e){il.error("Index is null");continue}t.setDrawRange(0,1/0),s>e.array.length?t.setIndex(new An(r,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(e.set(r),e.count=s,e.needsUpdate=s>0,e.updateRange.count=s,t.setDrawRange(0,s)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{const e=i[n];s>e.array.length?t.setAttribute(n,new An(r,e.itemSize).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(i[n].set(r),i[n].needsUpdate=s>0,i[n].updateRange.count=s)}}}setUniforms(e){if(!e)return;const t=this.material.uniforms,i=this.wireframeMaterial.uniforms,n=this.pickingMaterial.uniforms;for(let r in e)"opacity"===r&&this.setProperties({transparent:this.transparent}),void 0!==t[r]&&(t[r].value.isVector3?t[r].value.copy(e[r]):t[r].value.set?t[r].value.set(e[r]):t[r].value=e[r]),void 0!==i[r]&&(i[r].value.isVector3?i[r].value.copy(e[r]):i[r].value.set?i[r].value.set(e[r]):i[r].value=e[r]),void 0!==n[r]&&(n[r].value.isVector3?n[r].value.copy(e[r]):n[r].value.set?n[r].value.set(e[r]):n[r].value=e[r])}setProperties(e){if(!e)return;const t=this.material,i=this.wireframeMaterial,n=this.pickingMaterial;for(const r in e){const s=r;let o=e[s];"transparent"===s?this.updateRenderOrder():"side"===s&&(o=Kf(o)),t[s]=o,i[s]=o,n[s]=o}t.needsUpdate=!0,i.needsUpdate=!0,n.needsUpdate=!0}setVisibility(e){this.visible=e,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=e,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=e,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=e))}dispose(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()}toJSON(){var e={};for(var t in this)"group"!==t&&"wireframeGroup"!==t&&"pickingGroup"!=t&&"picking"!==t&&(e[t]=this[t]);return e}}class nm extends im{constructor(e,t={}){super(e,t),this.vertexShader="Mesh.vert",this.fragmentShader="Mesh.frag",this.addAttributes({normal:{type:"v3",value:e.normal}}),void 0===e.normal&&this.geometry.computeVertexNormals()}}class rm extends nm{constructor(){super(...arguments),this.isSurface=!0}}function sm(e){e.visible=!0}function om(e){e.visible=!1}class am{constructor(e){this.group=new ko,this.wireframeGroup=new ko,this.pickingGroup=new ko,this.frontMeshes=[],this.backMeshes=[],this.size=e.size,this.side=e.parameters.side,this.visible=e.visible,this.geometry=e.geometry,this.picking=e.picking,this.group=new ko,this.wireframeGroup=new ko,this.pickingGroup=new ko,this.matrix=e.matrix;const t=e,i=new e.constructor({position:new Float32Array(0)});t.makeMaterial(),i.makeMaterial(),i.picking=e.picking,i.geometry=e.geometry,i.wireframeGeometry=e.wireframeGeometry,i.setParameters(e.getParameters()),i.updateShader(),t.setParameters({side:"front"}),i.setParameters({side:"back",opacity:i.parameters.opacity}),this.buffer=e,this.frontBuffer=t,this.backBuffer=i}set matrix(e){im.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking&&!this.parameters.disablePicking}get parameters(){return this.buffer.parameters}getParameters(){const e=Object.assign({},this.buffer.parameters);return e.side=this.side,e}getMesh(e){let t,i;return e?(i=this.backBuffer.getPickingMesh(),t=this.frontBuffer.getPickingMesh()):(i=this.backBuffer.getMesh(),t=this.frontBuffer.getMesh()),this.frontMeshes.push(t),this.backMeshes.push(i),this.setParameters({side:this.side}),(new ko).add(i,t)}getWireframeMesh(){return this.buffer.getWireframeMesh()}getPickingMesh(){return this.getMesh(!0)}setAttributes(e){this.buffer.setAttributes(e)}setParameters(e){"front"===(e=Object.assign({},e)).side?(this.frontMeshes.forEach(sm),this.backMeshes.forEach(om)):"back"===e.side?(this.frontMeshes.forEach(om),this.backMeshes.forEach(sm)):"double"===e.side&&(this.frontMeshes.forEach(sm),this.backMeshes.forEach(sm)),void 0!==e.side&&(this.side=e.side),delete e.side,void 0!==e.matrix&&(this.matrix=e.matrix),delete e.matrix,this.frontBuffer.setParameters(e),void 0!==e.wireframe&&(this.wireframe=e.wireframe,this.setVisibility(this.visible)),delete e.wireframe,this.backBuffer.setParameters(e)}setVisibility(e){this.visible=e,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=e,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=e,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=e))}dispose(){this.frontBuffer.dispose(),this.backBuffer.dispose()}toJSON(){var e={};for(var t in this)["side","size","visible","matrix","parameters"].includes(t)&&(e[t]=this[t]);return e}}ul.add("shader/Line.vert","uniform float clipNear;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),ul.add("shader/Line.frag","uniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");class cm extends im{constructor(){super(...arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}}class lm extends tu{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},isolevelScroll:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),e instanceof Zf?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new Zt,this.__boxCenter=new Zt,this.box=new Ni,this.__box=new Ni,this._position=new Zt,this.inverseMatrix=new ri,this.setBox=function(){this._position.copy(t.translationGroup.position).negate(),this._position.applyMatrix4(this.inverseMatrix),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(i)}init(e){const t=e||{};t.colorScheme=Ia(t.colorScheme,"uniform"),t.colorValue=Ia(t.colorValue,14540253),this.isolevelType=Ia(t.isolevelType,"sigma"),this.isolevel=Ia(t.isolevel,2),this.negateIsolevel=Ia(t.negateIsolevel,!1),this.isolevelScroll=Ia(t.isolevelScroll,!1),this.smooth=Ia(t.smooth,0),this.background=Ia(t.background,!1),this.opaqueBack=Ia(t.opaqueBack,!0),this.boxSize=Ia(t.boxSize,0),this.colorVolume=Ia(t.colorVolume,void 0),this.contour=Ia(t.contour,!1),this.useWorker=Ia(t.useWorker,!0),this.wrap=Ia(t.wrap,!1),super.init(t),this.inverseMatrix.getInverse(this.matrix),this.build()}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e)})),this.setVisibility(this.visible),e()}prepare(e){if(this.volume){let t;if(t="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(t*=-1),!this.surface||this.__isolevel!==t||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=t,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);const i=t=>{this.surface=t,e()};this.useWorker?this.volume.getSurfaceWorker(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else e()}else e()}create(){const e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};let t;if(this.contour)t=new cm(e,this.getBufferParams({wireframe:!1}));else{Object.assign(e,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});const i=new rm(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new am(i)}this.bufferList.push(t)}update(e){if(0===this.bufferList.length)return;const t={};(e=e||{}).position&&(t.position=this.surface.getPosition()),e.color&&(t.color=this.surface.getColor(this.getColorParams())),e.index&&(t.index=this.surface.getIndex()),e.normal&&(t.normal=this.surface.getNormal()),this.bufferList.forEach((function(e){e.setAttributes(t)}))}setParameters(e,t,i){return e&&void 0!==e.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===e.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===e.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=e.isolevelType),e&&e.boxCenter&&(this.boxCenter.copy(e.boxCenter),delete e.boxCenter),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),e.matrix&&this.inverseMatrix.getInverse(e.matrix),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&void 0!==e.colorVolume&&t&&(t.color=!0),this.surface&&(void 0!==e.isolevel||void 0!==e.negateIsolevel||void 0!==e.smooth||void 0!==e.wrap||void 0!==e.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this}getColorParams(){const e=super.getColorParams();return e.volume=this.colorVolume,e}dispose(){this.viewer.signals.ticked.remove(this.setBox,this),super.dispose()}}class hm{static zoomScroll(e,t){e.trackballControls.zoom(t)}static clipNearScroll(e,t){const i=e.getParameters();e.setParameters({clipNear:i.clipNear+t/10})}static focusScroll(e,t){const i=e.getFocus(),n=Math.sign(t)*function(e,t,i){if(e>t)return e;const n=e/t;return((2*i-t)*n+(2*t-3*i))*n*n+i}((100-i)/10,5,.2);e.setFocus(i+n)}static zoomFocusScroll(e,t){e.trackballControls.zoom(t);const i=e.viewer.camera.position.z;e.setFocus(100-Math.abs(i/8))}static isolevelScroll(e,t){const i=Math.sign(t)/10;e.eachRepresentation(((e,t)=>{if(e.repr instanceof lm){const t=e.getParameters();t.isolevelScroll&&e.setParameters({isolevel:t.isolevel+i})}}))}static panDrag(e,t,i){e.trackballControls.pan(t,i)}static rotateDrag(e,t,i){e.trackballControls.rotate(t,i)}static zRotateDrag(e,t,i){e.trackballControls.zRotate(t,i)}static zoomDrag(e,t,i){e.trackballControls.zoom((t+i)/-2)}static zoomFocusDrag(e,t,i){e.trackballControls.zoom((t+i)/-2);const n=e.viewer.camera.position.z;e.setFocus(100-Math.abs(n/8))}static panComponentDrag(e,t,i){e.trackballControls.panComponent(t,i)}static panAtomDrag(e,t,i){e.trackballControls.panAtom(t,i)}static rotateComponentDrag(e,t,i){e.trackballControls.rotateComponent(t,i)}static movePick(e,t){t&&e.animationControls.move(t.position.clone())}static tooltipPick(e,t){const i=e.tooltip;if(e.getParameters().tooltip&&t){const e=t.mouse.position;i.innerText=t.getLabel(),i.style.bottom=window.innerHeight-e.y+3+"px",i.style.left=e.x+3+"px",i.style.display="block"}else i.style.display="none"}static measurePick(e,t){if(t&&(t.atom||t.bond)){const e=t.atom||t.closestBondAtom;t.component.measurePick(e)}else e.measureClear()}}const um={default:[["scroll",hm.zoomScroll],["scroll-shift",hm.focusScroll],["scroll-ctrl",hm.isolevelScroll],["scroll-shift-ctrl",hm.zoomFocusScroll],["drag-left",hm.rotateDrag],["drag-right",hm.panDrag],["drag-ctrl-left",hm.panDrag],["drag-ctrl-right",hm.zRotateDrag],["drag-shift-left",hm.zoomDrag],["drag-middle",hm.zoomFocusDrag],["drag-ctrl-shift-right",hm.panComponentDrag],["drag-ctrl-shift-left",hm.rotateComponentDrag],["clickPick-right",hm.measurePick],["clickPick-ctrl-left",hm.measurePick],["clickPick-middle",hm.movePick],["clickPick-left",hm.movePick],["hoverPick",hm.tooltipPick]],pymol:[["drag-left",hm.rotateDrag],["drag-middle",hm.panDrag],["drag-right",hm.zoomDrag],["scroll",hm.focusScroll],["drag-shift-right",hm.focusScroll],["clickPick-ctrl+shift-middle",hm.movePick],["hoverPick",hm.tooltipPick]],coot:[["scroll",hm.isolevelScroll],["drag-left",hm.rotateDrag],["drag-middle",hm.panDrag],["drag-ctrl-left",hm.panDrag],["drag-right",hm.zoomFocusDrag],["drag-ctrl-right",hm.focusScroll],["clickPick-middle",hm.movePick],["hoverPick",hm.tooltipPick]],astexviewer:[["drag-left",hm.rotateDrag],["drag-ctrl-left",hm.panDrag],["drag-shift-left",hm.zoomDrag],["scroll",hm.focusScroll],["clickPick-middle",hm.movePick],["hoverPick",hm.tooltipPick]]};function dm(e){const t=e.split(/[-+]/);let i="";t.includes("scroll")&&(i="scroll"),t.includes("drag")&&(i="drag"),t.includes("click")&&(i="click"),t.includes("doubleClick")&&(i="doubleClick"),t.includes("hover")&&(i="hover"),t.includes("clickPick")&&(i="clickPick"),t.includes("hoverPick")&&(i="hoverPick");let n=0;t.includes("alt")&&(n+=1),t.includes("ctrl")&&(n+=2),t.includes("meta")&&(n+=4),t.includes("shift")&&(n+=8);let r=0;return t.includes("left")&&(r+=1),t.includes("right")&&(r+=2),t.includes("middle")&&(r+=4),[i,n,r]}class fm{constructor(e,t={}){this.stage=e,this.actionList=[],this.mouse=e.mouseObserver,this.disabled=t.disabled||!1,this.preset(t.preset||"default")}run(e,...t){if(this.disabled)return;const i=this.mouse.key||0,n=this.mouse.buttons||0;this.actionList.forEach((r=>{r.type===e&&r.key===i&&r.button===n&&r.callback(this.stage,...t)}))}add(e,t){const[i,n,r]=dm(e);this.actionList.push({type:i,key:n,button:r,callback:t})}remove(e,t){const i=e.includes("*"),[n,r,s]=dm(e),o=this.actionList.filter((function(e){return!((e.type===n||i&&""===n)&&(e.key===r||i&&0===r)&&(e.button===s||i&&0===s)&&(e.callback===t||void 0===t))}));this.actionList=o}preset(e){this.clear();(um[e]||[]).forEach((e=>this.add(e[0],e[1])))}clear(){this.actionList.length=0}}class mm{static autoView(e){e.autoView(1e3)}static toggleAnimations(e){e.animationControls.toggle()}static toggleRock(e){e.toggleRock()}static toggleSpin(e){e.toggleSpin()}static toggleAntialiasing(e){const t=e.getParameters();e.setParameters({sampleLevel:-1===t.sampleLevel?0:-1})}}const pm={default:[["i",mm.toggleSpin],["k",mm.toggleRock],["p",mm.toggleAnimations],["a",mm.toggleAntialiasing],["r",mm.autoView]]};class gm{constructor(e,t={}){this.stage=e,this.actionList=[],this.disabled=t.disabled||!1,this.preset(t.preset||"default")}run(e){this.disabled||this.actionList.forEach((t=>{t.key===e&&t.callback(this.stage)}))}add(e,t){this.actionList.push({key:e,callback:t})}remove(e,t){const i=this.actionList.filter((function(i){return!(i.key===e&&(i.callback===t||void 0===t))}));this.actionList=i}preset(e){this.clear();(pm[e]||[]).forEach((e=>this.add(e[0],e[1])))}clear(){this.actionList.length=0}}class vm{constructor(e){this.stage=e,this.stage=e,this.mouse=e.mouseObserver,this.controls=e.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)}_onClick(e,t){const i=this.stage.pickingControls.pick(e,t);this.stage.signals.clicked.dispatch(i),this.controls.run("clickPick",i)}_onHover(e,t){const i=this.stage.pickingControls.pick(e,t);i&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=i.component,this.stage.transformAtom=i.atom),this.stage.signals.hovered.dispatch(i),this.controls.run("hoverPick",i)}dispose(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}}class ym{constructor(e){this.stage=e,this.stage=e,this.mouse=e.mouseObserver,this.controls=e.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)}_onMove(){this.stage.tooltip.style.display="none"}_onScroll(e){this.controls.run("scroll",e)}_onDrag(e,t){this.controls.run("drag",e,t)}_onClick(e,t){this.controls.run("click",e,t)}_onDblclick(e,t){this.controls.run("doubleClick",e,t)}_onHover(e,t){this.controls.run("hover",e,t)}dispose(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}}class xm{constructor(e){this.stage=e,this.viewer=e.viewer,this.animationControls=e.animationControls,this.viewer.signals.ticked.add(this._onTick,this)}_onTick(e){this.animationControls.run(e)}dispose(){this.viewer.signals.ticked.remove(this._onTick,this)}}const bm=!!Zc&&{passive:!0};class _m{constructor(e){this.stage=e,this.stage=e,this.controls=e.keyControls,this.domElement=e.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,bm),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)}_onKeydown(){}_onKeyup(){}_onKeypress(e){let t;t="key"in KeyboardEvent.prototype?e.key:String.fromCharCode(e.which||e.keyCode),this.controls.run(t)}_focusDomElement(){this.domElement.focus()}dispose(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,bm),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)}}class wm{constructor(e,t,i,n={}){this.component=e,this.position=t,this.offsetX=Ia(n.offsetX,0),this.offsetY=Ia(n.offsetY,0),this.visible=Ia(n.visible,!0),this.stage=e.stage,this.viewer=e.stage.viewer,this._viewerPosition=new Zt,this._updateViewerPosition(),this._canvasPosition=new zt,this._cameraPosition=new Zt,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",left:"-10000px"}),this.viewer.wrapper.appendChild(this.element),this.setContent(i),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)}setContent(e){const t=this.element.style.display;if("none"===t&&(this.element.style.left="-10000px",this.element.style.display="block"),e instanceof HTMLElement)this.element.appendChild(e);else{const t=document.createElement("div");t.innerText=e,Object.assign(t.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(t)}this._clientRect=this.element.getBoundingClientRect(),"none"===t&&(this.element.style.display=t)}setVisibility(e){this.visible=e,this.updateVisibility()}getVisibility(){return this.visible&&this.component.parameters.visible}updateVisibility(){this.element.style.display=this.getVisibility()?"block":"none"}_updateViewerPosition(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)}_update(){if(!this.getVisibility())return;const e=this.element.style,t=this._canvasPosition,i=this._viewerPosition,n=this._clientRect;if(this._cameraPosition.copy(i).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)return void(e.display="none");e.display="block";const r=this._cameraPosition.length(),s=this.viewer.scene.fog;e.opacity=(1-rc(s.near,s.far,r)).toString(),e.zIndex=Math.round(100*(s.far-r)).toString(),this.stage.viewerControls.getPositionOnCanvas(i,t),e.bottom=this.offsetX+t.y+n.height/2+"px",e.left=this.offsetY+t.x-n.width/2+"px"}dispose(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)}}const Sm=new ri,Am=new Zt,Mm=new qt;class Cm{constructor(e){this.component=e,this.signals={changed:new mc.Signal},this.stage=e.stage,this.viewer=e.stage.viewer}get position(){return this.component.position}get rotation(){return this.component.quaternion}changed(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()}spin(e,t){Sm.getInverse(this.viewer.rotationGroup.matrix),Am.copy(ja(e)).applyMatrix4(Sm),Sm.extractRotation(this.component.transform),Sm.premultiply(this.viewer.rotationGroup.matrix),Sm.getInverse(Sm),Am.copy(ja(e)),Am.applyMatrix4(Sm),Sm.makeRotationAxis(Am,t),Mm.setFromRotationMatrix(Sm),this.component.quaternion.premultiply(Mm),this.changed()}}const Pm={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"};class Tm{constructor(e={}){this.max=10,this.type=Ia(e.type,"size"),this.scale=Ia(e.scale,1),this.size=Ia(e.size,1),this.data=Ia(e.data,{})}atomRadius(e){let t;switch(this.type){case"vdw":t=e.vdw;break;case"covalent":t=e.covalent;break;case"bfactor":t=e.bfactor||1;break;case"sstruc":const i=e.sstruc;t="h"===i||"g"===i||"i"===i||"e"===i||"b"===i?.25:Cd.includes(e.atomname)?.4:.1;break;case"data":t=Ia(this.data[e.index],1);break;case"explicit":t=e.radius,null===t&&(t=this.size);break;default:t=this.size}return Math.min(t*this.scale,this.max)}}Tm.types=Pm;const Im=new Zt(-1,-1,-1),Em=new ri;class Dm{constructor(e){const t=e.rows,i=t/3,n=new Mf(t,3),r=new Mf(3,3),s=new Mf(1,3),o=new Mf(3,3),a=new Mf(3,3),c=If(e);Ef(e,c),Cf(n,e),Pf(r,n,n),Of(r,s,o,a);const l=new Zt(c[0],c[1],c[2]),h=new Zt(o.data[0],o.data[3],o.data[6]),u=new Zt(o.data[1],o.data[4],o.data[7]),d=new Zt(o.data[2],o.data[5],o.data[8]),f=h.clone().multiplyScalar(Math.sqrt(s.data[0]/i)),m=u.clone().multiplyScalar(Math.sqrt(s.data[1]/i)),p=d.clone().multiplyScalar(Math.sqrt(s.data[2]/i));this.begA=l.clone().sub(f),this.endA=l.clone().add(f),this.begB=l.clone().sub(m),this.endB=l.clone().add(m),this.begC=l.clone().sub(p),this.endC=l.clone().add(p),this.center=l,this.vecA=f,this.vecB=m,this.vecC=p,this.normVecA=h,this.normVecB=u,this.normVecC=d}getBasisMatrix(e=new ri){const t=e;return t.makeBasis(this.normVecB,this.normVecA,this.normVecC),t.determinant()<0&&t.scale(Im),t}getRotationQuaternion(e=new qt){const t=e;return t.setFromRotationMatrix(this.getBasisMatrix(Em)),t.inverse()}getProjectedScaleForAtoms(e){let t=-1/0,i=-1/0,n=-1/0,r=-1/0,s=-1/0,o=-1/0;const a=new Zt,c=new Zt,l=this.center,h=this.normVecA,u=this.normVecB,d=this.normVecC;return e.eachAtom((function(e){su(a.copy(e),h,l);const f=c.subVectors(a,l).normalize().dot(h),m=a.distanceTo(l);f>0?m>t&&(t=m):m>i&&(i=m),su(a.copy(e),u,l);const p=c.subVectors(a,l).normalize().dot(u),g=a.distanceTo(l);p>0?g>n&&(n=g):g>r&&(r=g),su(a.copy(e),d,l);const v=c.subVectors(a,l).normalize().dot(d),y=a.distanceTo(l);v>0?y>s&&(s=y):y>o&&(o=y)})),{d1a:t,d2a:n,d3a:s,d1b:-i,d2b:-r,d3b:-o}}}class Lm{constructor(e,t,i,n){this.volume=e,this.setFilter(t,i,n)}get header(){return this.volume.header}get matrix(){return this.volume.matrix}get normalMatrix(){return this.volume.normalMatrix}get inverseMatrix(){return this.volume.inverseMatrix}get center(){return this.volume.center}get boundingBox(){return this.volume.boundingBox}get min(){return this.volume.min}get max(){return this.volume.max}get mean(){return this.volume.mean}get rms(){return this.volume.rms}_getFilterHash(e,t,i){return JSON.stringify([e,t,i])}setFilter(e,t,i){isNaN(e)&&this.header&&(e=this.header.DMEAN+2*this.header.ARMS),e=void 0===e||isNaN(e)?-1/0:e,t=Ia(t,1/0),i=Ia(i,!1);const n=this.volume.data,r=this.volume.position,s=this.volume.atomindex,o=this._getFilterHash(e,t,i);if(o!==this._filterHash){if(e===-1/0&&t===1/0)this.data=n,this.position=r,this.atomindex=s;else{const o=n.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*o),this._positionBuffer=new ArrayBuffer(3*o*4),s&&(this._atomindexBuffer=new ArrayBuffer(4*o)));const a=new Float32Array(this._dataBuffer),c=new Float32Array(this._positionBuffer);let l;s&&(l=new Uint32Array(this._atomindexBuffer));let h=0;for(let u=0;u=e&&d<=t||i&&(dt)){const e=3*h;a[h]=d,c[e+0]=r[o+0],c[e+1]=r[o+1],c[e+2]=r[o+2],s&&l&&(l[h]=s[u]),h+=1}}this.data=new Float32Array(this._dataBuffer,0,h),this.position=new Float32Array(this._positionBuffer,0,3*h),s&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,h))}this._filterHash=o}}}Lm.prototype.getValueForSigma=Zf.prototype.getValueForSigma,Lm.prototype.getSigmaForValue=Zf.prototype.getSigmaForValue,Lm.prototype.getDataAtomindex=Zf.prototype.getDataAtomindex,Lm.prototype.getDataPosition=Zf.prototype.getDataPosition,Lm.prototype.getDataColor=Zf.prototype.getDataColor,Lm.prototype.getDataPicking=Zf.prototype.getDataPicking,Lm.prototype.getDataSize=Zf.prototype.getDataSize;class Rm{constructor(e,t){const i=Zu({nodeArray1:e.atomIndex1,nodeArray2:e.atomIndex2,edgeCount:e.count,nodeCount:t});this.countArray=i.countArray,this.offsetArray=i.offsetArray,this.indexArray=i.indexArray}}class km extends Wu{get _defaultFields(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]}addBond(e,t,i){this.growIfFull();const n=this.count,r=e.index,s=t.index;r0&&(o[t]=x.angleTo(b));const n=Math.cos(m.angleTo(p));l[t]=180/Math.PI*Math.acos(n);const y=m.length(),T=p.length();a[t]=Math.sqrt(T*y)/Math.max(2,2*(1-n)),c[t]=Math.abs(d.dot(x)),g.copy(m).multiplyScalar(a[t]/y),v.copy(p).multiplyScalar(a[t]/T),g.subVectors(M,g),v.subVectors(C,v),g.toArray(r,i+3),v.toArray(r,i+6),_.subVectors(A,w),_.toArray(h,i),b.copy(x),w.copy(g)}g.fromArray(r,3),v.fromArray(r,6),x.subVectors(g,v).normalize(),A.index=e.getAtomIndexByType(0,S),w.copy(A),y.copy(A),su(y,x,g),y.toArray(r,0),_.subVectors(w,g),_.toArray(h,0),g.fromArray(r,3*i-6),v.fromArray(r,3*i-9),x.subVectors(g,v).normalize(),A.index=e.getAtomIndexByType(i-1,S),w.copy(A),y.copy(A),su(y,x,g),y.toArray(r,3*i-3);for(let t=i-3;tt||l.bending[n]>e)&&(O=!0)),O){if(n-f<4){f=n,O=!1;continue}L.index=E.traceAtomIndex,C=l.axis.subarray(3*f+3,3*n),P=l.center.subarray(3*f,3*n+3),A=ru(C).normalize(),M=ru(P),T.fromArray(P),su(T,A,M),I.fromArray(P,P.length-3),su(I,A,M),A.subVectors(I,T),A.toArray(p,m),M.toArray(g,m),T.toArray(v,m),I.toArray(y,m),u.atomColorToArray(L,x,m),b.push(L.index),_.push(d.atomRadius(L)),w.push(c+f),S.push(c+n+1-f),m+=3,f=n,O=!1}const B=new Float32Array(b);return{axis:new Float32Array(p),center:new Float32Array(g),begin:new Float32Array(v),end:new Float32Array(y),color:new Float32Array(x),picking:new hf(B,o),size:new Float32Array(_),residueOffset:w,residueCount:S}}}class $m{constructor(e){this.scoreFunction=e,this.content=[],this.scoreFunction=e}push(e){this.content.push(e),this.bubbleUp(this.content.length-1)}pop(){const e=this.content[0],t=this.content.pop();return t&&this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e}peek(){return this.content[0]}remove(e){const t=this.content.length;for(let i=0;i0;){const i=Math.floor((e+1)/2)-1,n=this.content[i];if(!(this.scoreFunction(t), 2016 - * @author Roman Bolzern , 2013 - * @author I4DS http://www.fhnw.ch/i4ds, 2013 - * @license MIT License - * @description - * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place - * provides fast nearest neighbour search - * - * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs - * - * Further information (including mathematical properties) - * http://en.wikipedia.org/wiki/Binary_tree - * http://en.wikipedia.org/wiki/K-d_tree - * - * @example - * points: [x, y, z, x, y, z, x, y, z, ...] - * metric: function(a, b){ - * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2); - * } - * - * @param {Float32Array} points - points - * @param {Function} metric - metric - */ -var fd=function(e,t){this.points=e,this.metric=t,this.maxDepth=0,this.currentNode=0;for(var r=e.length/3,i=new Uint32Array(r),n=0;nthis.maxDepth&&(this.maxDepth=e);var n=i-r;if(0===n)return-1;var o=4*this.currentNode,a=this.nodes;if(this.currentNode+=1,1===n)return a[o]=r,a[o+1]=-1,a[o+2]=-1,a[o+3]=t,o;for(var s,c,u,l,h,p=this.indices,d=this.points,f=r+Math.floor(n/2),m=e%3,g=r,v=i-1;v>g;){for(l=d[3*p[u=g+v>>1]+m],c=p[u],p[u]=p[v],p[v]=c,h=g,s=g;st&&n.pop()}var v=o[u+1],y=o[u+2];if(-1!==y||-1!==v){l=-1===y?v:-1===v?y:e[p]<=a[d+p]?v:y,c(l),(n.size()o[3*a[n[e]]+i])throw new Error("left child is > parent!");r+=this.verify(s,t+1)}if(-1!==c){if(o[3*a[n[c]]+i]0},md.prototype.isBackbone=function(){var e=this.residueType.backboneIndexList;return e.length>0&&e.includes(this.index-this.residueAtomOffset)},md.prototype.isPolymer=function(){if(this.structure.entityList.length>0)return this.entity.isPolymer();var e=this.residueType.moleculeType;return 3===e||4===e||5===e},md.prototype.isSidechain=function(){return this.isPolymer()&&!this.isBackbone()},md.prototype.isCg=function(){var e=this.residueType.backboneType;return 4===e||5===e||6===e},md.prototype.isTrace=function(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset},md.prototype.isHetero=function(){return 1===this.residueType.hetero},md.prototype.isProtein=function(){return 3===this.residueType.moleculeType},md.prototype.isNucleic=function(){var e=this.residueType.moleculeType;return 4===e||5===e},md.prototype.isRna=function(){return 4===this.residueType.moleculeType},md.prototype.isDna=function(){return 5===this.residueType.moleculeType},md.prototype.isWater=function(){return 1===this.residueType.moleculeType},md.prototype.isIon=function(){return 2===this.residueType.moleculeType},md.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},md.prototype.isHelix=function(){return wl.includes(this.sstruc)},md.prototype.isSheet=function(){return Sl.includes(this.sstruc)},md.prototype.isTurn=function(){return Al.includes(this.sstruc)&&this.isProtein()},md.prototype.isBonded=function(){return 0!==this.bondHash.countArray[this.index]},md.prototype.isRing=function(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]},md.prototype.isAromatic=function(){return 1===this.aromatic},md.prototype.isPolarHydrogen=function(){var e=!1;return 1!==this.number?e:e=!this.hasBondToElement(6)},md.prototype.isMetal=function(){return this.atomType.isMetal()},md.prototype.isNonmetal=function(){return this.atomType.isNonmetal()},md.prototype.isMetalloid=function(){return this.atomType.isMetalloid()},md.prototype.isHalogen=function(){return this.atomType.isHalogen()},md.prototype.isDiatomicNonmetal=function(){return this.atomType.isDiatomicNonmetal()},md.prototype.isPolyatomicNonmetal=function(){return this.atomType.isPolyatomicNonmetal()},md.prototype.isAlkaliMetal=function(){return this.atomType.isAlkaliMetal()},md.prototype.isAlkalineEarthMetal=function(){return this.atomType.isAlkalineEarthMetal()},md.prototype.isNobleGas=function(){return this.atomType.isNobleGas()},md.prototype.isTransitionMetal=function(){return this.atomType.isTransitionMetal()},md.prototype.isPostTransitionMetal=function(){return this.atomType.isPostTransitionMetal()},md.prototype.isLanthanide=function(){return this.atomType.isLanthanide()},md.prototype.isActinide=function(){return this.atomType.isActinide()},md.prototype.getDefaultValence=function(){return this.atomType.getDefaultValence()},md.prototype.getValenceList=function(){return this.atomType.getValenceList()},md.prototype.getOuterShellElectronCount=function(){return this.atomType.getOuterShellElectronCount()},md.prototype.distanceTo=function(e){var t=this.atomStore,r=e.atomStore,i=this.index,n=e.index,o=t.x[i]-r.x[n],a=t.y[i]-r.y[n],s=t.z[i]-r.z[n],c=o*o+a*a+s*s;return Math.sqrt(c)},md.prototype.connectedTo=function(e){var t=this.atomStore,r=e.atomStore,i=this.index,n=e.index;if(t.altloc&&r.altloc){var o=t.altloc[i],a=r.altloc[n];if(0!==o&&0!==a&&32!==o&&32!==a&&o!==a)return!1}var s=t.x[i]-r.x[n],c=t.y[i]-r.y[n],u=t.z[i]-r.z[n],l=s*s+c*c+u*u;if(l<48&&this.isCg())return!0;if(isNaN(l))return!1;var h=this.covalent+e.covalent,p=h+.3,d=h-.5;return ld*d},md.prototype.positionFromArray=function(e,t){return void 0===t&&(t=0),this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this},md.prototype.positionToArray=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var r=this.index,i=this.atomStore;return e[t+0]=i.x[r],e[t+1]=i.y[r],e[t+2]=i.z[r],e},md.prototype.positionToVector3=function(e){return void 0===e&&(e=new Y),e.x=this.x,e.y=this.y,e.z=this.z,e},md.prototype.positionFromVector3=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},md.prototype.positionAdd=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},md.prototype.positionSub=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},md.prototype.getResidueBonds=function(e){void 0===e&&(e=!1);var t,r,i,n,o=this.residueAtomOffset,a=this.index-this.residueAtomOffset,s=this.residueType.getBonds(),c=s.atomIndices1,u=s.atomIndices2;for(e||(n=[]),t=c.indexOf(a);-1!==t;){if(i=u[t]+o,!n)return i;n.push(i),t=c.indexOf(a,t+1)}for(r=u.indexOf(a);-1!==r;){if(i=c[r]+o,!n)return i;n.push(i),r=u.indexOf(a,r+1)}return n},md.prototype.qualifiedName=function(e){void 0===e&&(e=!1);var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chainname&&(t+=":"+this.chainname),this.atomname&&(t+="."+this.atomname),this.altloc&&(t+="%"+this.altloc),this.structure.modelStore.count>1&&(t+="/"+this.modelIndex),t},md.prototype.clone=function(){return new md(this.structure,this.index)},md.prototype.toObject=function(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}},Object.defineProperties(md.prototype,gd);var bd=new Float32Array(3),xd=function(t,r){void 0===r&&(r=!1),e.Debug&&is.time("Kdtree build");var i=r?vd:yd,n=new Float32Array(3*t.atomCount),o=new Uint32Array(t.atomCount),a=0;t.eachAtom((function(e){n[a+0]=e.x,n[a+1]=e.y,n[a+2]=e.z,o[a/3]=e.index,a+=3})),this.atomIndices=o,this.points=n,this.kdtree=new fd(n,i),e.Debug&&is.timeEnd("Kdtree build")};xd.prototype.nearest=function(e,t,r){e instanceof Y?e.toArray(bd):e instanceof md&&e.positionToArray(bd);for(var i=this.kdtree.nearest(bd,t,r),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,s=[],c=0,u=i.length;c":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},wd={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","F 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ","F 4/m -3 2/c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Sd=/^[1-9]$/;function Ad(e){var t="";return e.length>0&&(t=":"+Oo(e).join(" OR :")),new Na(t)}var Md=function(e){void 0===e&&(e=""),this.name=e,this.partList=[]},Cd={type:{configurable:!0}};Cd.type.get=function(){return"Assembly"},Md.prototype.addPart=function(e,t){var r=new Pd(e,t);return this.partList.push(r),r},Md.prototype.getAtomCount=function(e){return this.partList.reduce((function(t,r){return t+r.getAtomCount(e)}),0)},Md.prototype.getResidueCount=function(e){return this.partList.reduce((function(t,r){return t+r.getResidueCount(e)}),0)},Md.prototype.getInstanceCount=function(){var e=0;return this.partList.forEach((function(t){e+=t.matrixList.length})),e},Md.prototype.isIdentity=function(e){if(1!==this.partList.length)return!1;var t=this.partList[0];if(1!==t.matrixList.length)return!1;if(!(new ie).equals(t.matrixList[0]))return!1;var r=[];return e.eachChain((function(e){r.push(e.chainname)})),r=Oo(r),t.chainList.length===r.length},Md.prototype.getBoundingBox=function(e){var t=new Ne;return this.partList.forEach((function(r){var i=r.getBoundingBox(e);t.expandByPoint(i.min),t.expandByPoint(i.max)})),t},Md.prototype.getCenter=function(e){return this.getBoundingBox(e).getCenter(new Y)},Md.prototype.getSelection=function(){var e=[];return this.partList.forEach((function(t){e=e.concat(t.chainList)})),Ad(e)},Object.defineProperties(Md.prototype,Cd);var Pd=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=[]),this.matrixList=e,this.chainList=t},Td={type:{configurable:!0}};Td.type.get=function(){return"AssemblyPart"},Pd.prototype._getCount=function(e,t){var r=this,i=0;return e.eachChain((function(e){(0===r.chainList.length||r.chainList.includes(e.chainname))&&(i+=e[t])})),this.matrixList.length*i},Pd.prototype.getAtomCount=function(e){return this._getCount(e,"atomCount")},Pd.prototype.getResidueCount=function(e){return this._getCount(e,"residueCount")},Pd.prototype.getBoundingBox=function(e){var t=new Ne,r=new Ne,i=this.getSelection(),n=e.getBoundingBox(i);return this.matrixList.forEach((function(e){r.copy(n).applyMatrix4(e),t.expandByPoint(r.min),t.expandByPoint(r.max)})),t},Pd.prototype.getSelection=function(){return Ad(this.chainList)},Pd.prototype.getView=function(e){var t=this.getSelection();return t?e.getView(t):e},Pd.prototype.getInstanceList=function(){for(var e=[],t=0,r=this.matrixList.length;t=0}));a.sort((function(e,t){var r=e[0],i=t[0],a=e[1],s=t[1];if(r===i)return a===s?0:a=0}));c.sort((function(e,t){var r=e[0],i=t[0];if(r===i)return 0;var a=Do(n,r),s=Do(n,i);return o[a]0&&this.addResidueType(this.ri-1),u.growIfFull(),u.resno[this.ri]=n,void 0!==a&&(u.sstruc[this.ri]=a.charCodeAt(0)),void 0!==s&&(u.inscode[this.ri]=s.charCodeAt(0)),u.atomOffset[this.ri]=this.ai,u.atomCount[this.ri]=0,u.count+=1,u.chainIndex[this.ri]=this.ci,l.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,u.atomCount[this.ri]+=1,this.currentModelindex=e,this.currentChainid=r,this.currentResname=i,this.currentResno=n,this.currentInscode=s,this.currentHetero=o},Id.prototype.finalize=function(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)};var Dd,Ld,Od,Rd=(Dd=function(e,t,r,i){for(var n=e.structure,o=e.residueIndexStart,a=n.getResidueProxy(),s=n.getResidueProxy(),c=n.getAtomProxy(),u=n.getAtomProxy(),l=Math.max(0,t-2);l<=t;++l)for(var h=2;h<5;++h)if(!(l+h>=e.residueCount)){a.index=o+l,s.index=o+l+h,c.index=a.traceAtomIndex,u.index=s.traceAtomIndex;var p=c.distanceTo(u);if(Math.abs(p-r[h-2])>i)return!1}return!0},Ld=function(e,t){return Dd(e,t,[5.45,5.18,6.37],2.1)},Od=function(e,t){return Dd(e,t,[6.1,10.4,13],1.42)},function(t){e.Debug&&is.time("calculateSecondaryStructure"),t.eachPolymer((function(e){if(!(e.residueCount<4)){if(e.isCg())!function(e){for(var t=e.residueStore,r=e.residueIndexStart,i=new pd(e).position,n=new Y,o=new Y,a=0,s=e.residueCount;a1&&i.bending[a]<20&&(t.sstruc[r+a]="h".charCodeAt(0),t.sstruc[r+a+1]="h".charCodeAt(0))}}(e);else{if(!e.isProtein())return;!function(e){for(var t=e.residueStore,r=e.residueIndexStart,i=0,n=e.residueCount;i=t;)r=Math.floor(r/t),n+=kd[r%t],i+=1;return i>=5&&is.warn("chainname overflow"),n}function Bd(t,r){void 0===r&&(r=!1),e.Debug&&is.time("calculateChainnames");var i=!0;if(t.eachChain((function(e){e.chainname&&(i=!1)})),i){var n=t.modelStore,o=t.chainStore,a=t.residueStore,s=t.getAtomProxy(),c=t.getAtomProxy(),u=0,l=0,h=0,p=0,d=[];1===a.count?d.push({mIndex:0,chainname:"A",rStart:0,rCount:1}):t.eachResidueN(2,(function(e,t){var i=!1,n=e.backboneType,o=t.backboneType;p=e.index,e.modelIndex!==t.modelIndex||e.moleculeType!==t.moleculeType?i=!0:0!==n&&n===o&&(s.index=e.backboneEndAtomIndex,c.index=t.backboneStartAtomIndex,i=r?!s.hasBondTo(c):!s.connectedTo(c)),i||t.index!==a.count-1||(i=!0,p=t.index),i&&(d.push({mIndex:l,chainname:Nd(u),rStart:h,rCount:p-h+1}),u+=1,e.modelIndex!==t.modelIndex&&(u=0,l+=1),t.index===a.count-1&&p!==t.index&&d.push({mIndex:l,chainname:Nd(u),rStart:a.count-1,rCount:1}),h=t.index,p=t.index)})),o.count=0,n.chainCount.fill(0,0,n.count),n.chainOffset.fill(0,0,n.count),d.forEach((function(e){!function(e,t,r,i){for(var s=o.count,c=0;c500)return void is.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName());for(var h=e.getBonds(),p=h.atomIndices1,d=h.atomIndices2,f=h.bondOrders,m=p.length,g=0;g0)break;++r}else i=n+1;(r>0||i=3&&-1!==$d.indexOf(t[0])?t[0]:""}function qd(e){var t=e.bondHash,r=t.countArray,i=t.offsetArray,n=t.indexArray,o=e.getBondProxy();e.eachResidue((function(e){var t=e.residueType;if(void 0===t.bonds){var a=e.atomOffset,s=[],c=[],u=[],l={},h=a+e.atomCount;e.eachAtom((function(e){for(var t=e.index,p=i[t],d=0,f=r[t];d=h)){var g=o.atomIndex2;if(!(g=h)){if(m>g){var v=g;g=m,m=v}var y=m+"|"+g;void 0===l[y]&&(l[y]=!0,s.push(m-a),c.push(g-a),u.push(o.bondOrder))}}}})),t.bonds={atomIndices1:s,atomIndices2:c,bondOrders:u}}}))}var Xd=[3,11,19,37,55,87],Yd=[4,12,20,38,56,88],Zd=[6,15,16,34],Kd=[1,7,8,9,17,35,53],Qd=[2,10,18,36,54,86],Jd=[13,30,31,48,49,50,80,81,82,83,84,85,112],ef=[5,14,32,33,51,52,85],tf=[9,17,35,53,85],rf=function(e,t,r){this.structure=e,this.atomname=t,r=r||Wd(t),this.element=r,this.number=Ml[r]||0,this.vdw=Cl[this.number]||2,this.covalent=Pl[this.number]||1.6};rf.prototype.getDefaultValence=function(){var e=Tl[this.number];return e?e[0]:-1},rf.prototype.getValenceList=function(){return Tl[this.number]||[]},rf.prototype.getOuterShellElectronCount=function(){return Il[this.number]||2},rf.prototype.isMetal=function(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()},rf.prototype.isNonmetal=function(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()},rf.prototype.isMetalloid=function(){return ef.includes(this.number)},rf.prototype.isHalogen=function(){return tf.includes(this.number)},rf.prototype.isDiatomicNonmetal=function(){return Kd.includes(this.number)},rf.prototype.isPolyatomicNonmetal=function(){return Zd.includes(this.number)},rf.prototype.isAlkaliMetal=function(){return Xd.includes(this.number)},rf.prototype.isAlkalineEarthMetal=function(){return Yd.includes(this.number)},rf.prototype.isNobleGas=function(){return Qd.includes(this.number)},rf.prototype.isTransitionMetal=function(){var e=this.number;return e>=21&&e<=29||e>=39&&e<=47||e>=72&&e<=79||e>=104&&e<=108},rf.prototype.isPostTransitionMetal=function(){return Jd.includes(this.number)},rf.prototype.isLanthanide=function(){return this.number>=57&&this.number<=71},rf.prototype.isActinide=function(){return this.number>=89&&this.number<=103};var nf=function(e){this.structure=e,this.dict={},this.list=[],this.structure=e};nf.prototype.add=function(e,t){var r=function(e,t){return e+"|"+t}(e=e.toUpperCase(),t=t?t.toUpperCase():Wd(e)),i=this.dict[r];if(void 0===i){var n=new rf(this.structure,e,t);i=this.list.length,this.dict[r]=i,this.list.push(n)}return i},nf.prototype.get=function(e){return this.list[e]};var of=function(e,t,r,i,n,o){this.structure=e,this.bondReferenceAtomIndices=[],this.resname=t,this.atomTypeIdList=r,this.hetero=i?1:0,this.chemCompType=n,this.bonds=o,this.atomCount=r.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();var a=Vl[this.backboneType],s=Vl[this.backboneStartType],c=Vl[this.backboneEndType],u=this.getAtomIndexByName(a.trace);this.traceAtomIndex=So(u,-1);var l=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=So(l,-1);var h=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=So(h,-1);var p=this.getAtomIndexByName(s.backboneStart);this.backboneStartAtomIndex=So(p,-1);var d,f=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=So(f,-1),d=Nl.includes(t)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=So(d,-1)};of.prototype.getBackboneIndexList=function(){var e,t=[];switch(this.moleculeType){case 3:e=jl;break;case 4:case 5:e=Gl;break;default:return t}for(var r=this.structure.atomMap,i=this.atomTypeIdList,n=0,o=this.atomCount;n500)e.Debug&&is.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(o>50)for(var h=new xd(t,!0),p=t.isCg()?1.2:2.3,d=a;d=0||cf(e,t);this.rings={atomRings:e.atomRings,rings:e.rings}},of.prototype.isAromatic=function(e){return this.aromaticAtoms=this.getAromatic(e),1===this.aromaticAtoms[e.index-e.residueAtomOffset]},of.prototype.calculateAromatic=function(e){var t=this,r=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,n=i.map((function(r){return function(e){if(e.some((function(e){return!af.includes(e.number)})))return!1;var t=0,r=new qh(3,e.length),i=r.data;return e.forEach((function(e){i[t+0]=e.x,i[t+1]=e.y,i[t+2]=e.z,t+=3})),new rd(r).vecC.length()<.05}(r.map((function(r){return t.structure.getAtomProxy(r+e.atomOffset)})))})),o=this.aromaticRings=[];i.forEach((function(e,t){n[t]&&(o.push(e),e.forEach((function(e){return r[e]=1})))}))},of.prototype.assignBondReferenceAtomIndices=function(){var e=this.getBondGraph(),t=this.getRings(),r=t.atomRings,i=t.rings,n=this.bonds,o=n.atomIndices1,a=n.atomIndices2,s=n.bondOrders,c=this.bondReferenceAtomIndices,u=n.atomIndices1.length;c.length=0;for(var l=0;l1)for(var v=0;v1)for(var b=0;b=0;x--)v[y++]=a[x];for(var _=e.rings.length,w=0;w0?o[h]!==c&&o[c]!==h&&sf(e,c,h):(i[h]=1,n[s++]=h,o[h]=c)}}}var uf=4;var lf=function(e){this.structure=e,this.dict={},this.list=[]};lf.prototype.add=function(e,t,r,i,n){void 0===i&&(i="");var o=function(e,t,r,i){return void 0===i&&(i=""),e+"|"+t.join(",")+"|"+(r?1:0)+"|"+i}(e=e.toUpperCase(),t,r,i),a=this.dict[o];if(void 0===a){var s=new of(this.structure,e,t,r,i,n);a=this.list.length,this.dict[o]=a,this.list.push(s)}return a},lf.prototype.get=function(e){return this.list[e]};var hf=function(e,t){void 0===t&&(t=0),this.structure=e,this.index=t,this.bondStore=e.bondStore,this._v12=new Y,this._v13=new Y,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()},pf={atom1:{configurable:!0},atom2:{configurable:!0},atomIndex1:{configurable:!0},atomIndex2:{configurable:!0},bondOrder:{configurable:!0}};pf.atom1.get=function(){return this.structure.getAtomProxy(this.atomIndex1)},pf.atom2.get=function(){return this.structure.getAtomProxy(this.atomIndex2)},pf.atomIndex1.get=function(){return this.bondStore.atomIndex1[this.index]},pf.atomIndex1.set=function(e){this.bondStore.atomIndex1[this.index]=e},pf.atomIndex2.get=function(){return this.bondStore.atomIndex2[this.index]},pf.atomIndex2.set=function(e){this.bondStore.atomIndex2[this.index]=e},pf.bondOrder.get=function(){return this.bondStore.bondOrder[this.index]},pf.bondOrder.set=function(e){this.bondStore.bondOrder[this.index]=e},hf.prototype.getOtherAtomIndex=function(e){return e===this.atomIndex1?this.atomIndex2:this.atomIndex1},hf.prototype.getOtherAtom=function(e){return this.structure.getAtomProxy(this.getOtherAtomIndex(e.index))},hf.prototype.getReferenceAtomIndex=function(){var e=this._ap1,t=this._ap2;if(e.index=this.atomIndex1,t.index=this.atomIndex2,e.residueIndex===t.residueIndex){var r=e.index-e.residueAtomOffset,i=t.index-t.residueAtomOffset,n=e.residueType.getBondReferenceAtomIndex(r,i);if(void 0!==n)return n+e.residueAtomOffset;console.warn("No reference atom found",e.index,t.index)}},hf.prototype.calculateShiftDir=function(e){void 0===e&&(e=new Y);var t=this._ap1,r=this._ap2,i=this._ap3,n=this._v12,o=this._v13;t.index=this.atomIndex1,r.index=this.atomIndex2;var a=this.getReferenceAtomIndex();n.subVectors(t,r).normalize(),void 0!==a?(i.index=a,o.subVectors(t,i)):o.copy(t),o.normalize();var s=n.dot(o);return 1-Math.abs(s)<1e-5&&(o.set(1,0,0),s=n.dot(o),1-Math.abs(s)<1e-5&&(o.set(0,1,0),s=n.dot(o))),e.copy(o.sub(n.multiplyScalar(s))).normalize()},hf.prototype.qualifiedName=function(){return this.atomIndex1+"="+this.atomIndex2},hf.prototype.clone=function(){return new hf(this.structure,this.index)},hf.prototype.toObject=function(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}},Object.defineProperties(hf.prototype,pf);var df=function(e,t){void 0===t&&(t=0),this.structure=e,this.index=t,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueMap=e.residueMap,this.atomMap=e.atomMap},ff={entity:{configurable:!0},entityIndex:{configurable:!0},chain:{configurable:!0},chainIndex:{configurable:!0},atomOffset:{configurable:!0},atomCount:{configurable:!0},atomEnd:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0},chainid:{configurable:!0},resno:{configurable:!0},sstruc:{configurable:!0},inscode:{configurable:!0},residueType:{configurable:!0},resname:{configurable:!0},hetero:{configurable:!0},moleculeType:{configurable:!0},backboneType:{configurable:!0},backboneStartType:{configurable:!0},backboneEndType:{configurable:!0},traceAtomIndex:{configurable:!0},direction1AtomIndex:{configurable:!0},direction2AtomIndex:{configurable:!0},backboneStartAtomIndex:{configurable:!0},backboneEndAtomIndex:{configurable:!0},rungEndAtomIndex:{configurable:!0},x:{configurable:!0},y:{configurable:!0},z:{configurable:!0}};ff.entity.get=function(){return this.structure.entityList[this.entityIndex]},ff.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},ff.chain.get=function(){return this.structure.getChainProxy(this.chainIndex)},ff.chainIndex.get=function(){return this.residueStore.chainIndex[this.index]},ff.chainIndex.set=function(e){this.residueStore.chainIndex[this.index]=e},ff.atomOffset.get=function(){return this.residueStore.atomOffset[this.index]},ff.atomOffset.set=function(e){this.residueStore.atomOffset[this.index]=e},ff.atomCount.get=function(){return this.residueStore.atomCount[this.index]},ff.atomCount.set=function(e){this.residueStore.atomCount[this.index]=e},ff.atomEnd.get=function(){return this.atomOffset+this.atomCount-1},ff.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},ff.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},ff.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},ff.resno.get=function(){return this.residueStore.resno[this.index]},ff.resno.set=function(e){this.residueStore.resno[this.index]=e},ff.sstruc.get=function(){return this.residueStore.getSstruc(this.index)},ff.sstruc.set=function(e){this.residueStore.setSstruc(this.index,e)},ff.inscode.get=function(){return this.residueStore.getInscode(this.index)},ff.inscode.set=function(e){this.residueStore.setInscode(this.index,e)},ff.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},ff.resname.get=function(){return this.residueType.resname},ff.hetero.get=function(){return this.residueType.hetero},ff.moleculeType.get=function(){return this.residueType.moleculeType},ff.backboneType.get=function(){return this.residueType.backboneType},ff.backboneStartType.get=function(){return this.residueType.backboneStartType},ff.backboneEndType.get=function(){return this.residueType.backboneEndType},ff.traceAtomIndex.get=function(){return this.residueType.traceAtomIndex+this.atomOffset},ff.direction1AtomIndex.get=function(){return this.residueType.direction1AtomIndex+this.atomOffset},ff.direction2AtomIndex.get=function(){return this.residueType.direction2AtomIndex+this.atomOffset},ff.backboneStartAtomIndex.get=function(){return this.residueType.backboneStartAtomIndex+this.atomOffset},ff.backboneEndAtomIndex.get=function(){return this.residueType.backboneEndAtomIndex+this.atomOffset},ff.rungEndAtomIndex.get=function(){return this.residueType.rungEndAtomIndex+this.atomOffset},ff.x.get=function(){for(var e=0,t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.x[t];return e/this.atomCount},ff.y.get=function(){for(var e=0,t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.y[t];return e/this.atomCount},ff.z.get=function(){for(var e=0,t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.z[t];return e/this.atomCount},df.prototype.eachAtom=function(e,t){var r=this.atomCount,i=this.atomOffset,n=this.structure._ap,o=i+r;if(t&&t.atomOnlyTest)for(var a=t.atomOnlyTest,s=i;s0)return this.entity.isPolymer();var e=this.residueType.moleculeType;return 3===e||4===e||5===e},df.prototype.isHetero=function(){return 1===this.residueType.hetero},df.prototype.isWater=function(){return 1===this.residueType.moleculeType},df.prototype.isIon=function(){return 2===this.residueType.moleculeType},df.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},df.prototype.isStandardAminoacid=function(){return this.residueType.isStandardAminoacid()},df.prototype.isStandardBase=function(){return this.residueType.isStandardBase()},df.prototype.isHelix=function(){return wl.includes(this.sstruc)},df.prototype.isSheet=function(){return Sl.includes(this.sstruc)},df.prototype.isTurn=function(){return Al.includes(this.sstruc)&&this.isProtein()},df.prototype.getAtomType=function(e){return this.atomMap.get(this.atomStore.atomTypeId[e])},df.prototype.getResname1=function(){return Ll[this.resname.toUpperCase()]||"X"},df.prototype.getBackboneType=function(e){switch(e){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},df.prototype.getAtomIndexByName=function(e){var t=this.residueType.getAtomIndexByName(e);return void 0!==t&&(t+=this.atomOffset),t},df.prototype.hasAtomWithName=function(e){return this.residueType.hasAtomWithName(e)},df.prototype.getAtomnameList=function(){console.warn("getAtomnameList - might be expensive");for(var e=this.atomCount,t=this.atomOffset,r=new Array(e),i=0;i=t){var i=So(e,this.structure.getResidueProxy());if(i.index=r,i.connectedTo(this))return i}else if(r===t-1){var n=this.chainStore.residueCount[this.chainIndex],o=So(e,this.structure.getResidueProxy());if(o.index=t+n-1,o.connectedTo(this))return o}},df.prototype.getBonds=function(){return this.residueType.getBonds(this)},df.prototype.getRings=function(){return this.residueType.getRings()},df.prototype.getAromaticRings=function(){return this.residueType.getAromaticRings(this)},df.prototype.qualifiedName=function(e){void 0===e&&(e=!1);var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chain&&(t+=":"+this.chainname),t+="/"+this.modelIndex},df.prototype.clone=function(){return new df(this.structure,this.index)},df.prototype.toObject=function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}},Object.defineProperties(df.prototype,ff);var mf=function(e,t,r){this.structure=e,this.residueIndexStart=t,this.residueIndexEnd=r,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueCount=r-t+1;var i=this.structure.getResidueProxy(this.residueIndexStart),n=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==i.getPreviousConnectedResidue();var o=n.getNextConnectedResidue();this.isNextConnected=void 0!==o,this.isNextNextConnected=void 0!==o&&void 0!==o.getNextConnectedResidue(),this.isCyclic=n.connectedTo(i),this.__residueProxy=this.structure.getResidueProxy()},gf={chainIndex:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0}};gf.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndexStart]},gf.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},gf.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},mf.prototype.isProtein=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},mf.prototype.isCg=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},mf.prototype.isNucleic=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},mf.prototype.getMoleculeType=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},mf.prototype.getBackboneType=function(e){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(e)},mf.prototype.getAtomIndexByType=function(e,t){this.isCyclic?-1===e?e=this.residueCount-1:e===this.residueCount&&(e=0):(-1!==e||this.isPrevConnected||(e+=1),e!==this.residueCount||this.isNextNextConnected||(e-=1));var r,i=this.__residueProxy;switch(i.index=this.residueIndexStart+e,t){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(t)}return r},mf.prototype.eachAtom=function(e,t){this.eachResidue((function(r){r.eachAtom(e,t)}))},mf.prototype.eachAtomN=function(e,t,r){for(var i=this.residueCount,n=new Array(e),o=0;o1&&e(new mf(o,r,u.index)),r=i)):(0!==m&&u.index-r>1&&e(new mf(o,r,u.index)),r=i)}i-r>1&&this.structure.getResidueProxy(r).backboneEndType&&e(new mf(o,r,i))},vf.prototype.qualifiedName=function(){return":"+this.chainname+"/"+this.modelIndex},vf.prototype.clone=function(){return new vf(this.structure,this.index)},vf.prototype.toObject=function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}},Object.defineProperties(vf.prototype,yf);var bf=function(e,t){void 0===t&&(t=0),this.structure=e,this.index=t,this.modelStore=e.modelStore,this.chainStore=e.chainStore,this.residueStore=e.residueStore},xf={chainOffset:{configurable:!0},chainCount:{configurable:!0},residueOffset:{configurable:!0},atomOffset:{configurable:!0},chainEnd:{configurable:!0},residueEnd:{configurable:!0},atomEnd:{configurable:!0},residueCount:{configurable:!0},atomCount:{configurable:!0}};xf.chainOffset.get=function(){return this.modelStore.chainOffset[this.index]},xf.chainOffset.set=function(e){this.modelStore.chainOffset[this.index]=e},xf.chainCount.get=function(){return this.modelStore.chainCount[this.index]},xf.chainCount.set=function(e){this.modelStore.chainCount[this.index]=e},xf.residueOffset.get=function(){return this.chainStore.residueOffset[this.chainOffset]},xf.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},xf.chainEnd.get=function(){return this.chainOffset+this.chainCount-1},xf.residueEnd.get=function(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},xf.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},xf.residueCount.get=function(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},xf.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},bf.prototype.eachAtom=function(e,t){this.eachChain((function(r){r.eachAtom(e,t)}),t)},bf.prototype.eachResidue=function(e,t){this.eachChain((function(r){r.eachResidue(e,t)}),t)},bf.prototype.eachPolymer=function(e,t){if(t&&t.chainOnlyTest){var r=t.chainOnlyTest;this.eachChain((function(i){r(i)&&i.eachPolymer(e,t)}))}else this.eachChain((function(r){r.eachPolymer(e,t)}))},bf.prototype.eachChain=function(e,t){var r=this.chainCount,i=this.chainOffset,n=this.structure._cp,o=i+r;if(t&&t.test){var a=t.chainOnlyTest;if(a)for(var s=i;s1){var t=r.atomRadius(f);w=t*u/(.5*x),p.calculateShiftDir(O),c?(_=2*l*t,O.multiplyScalar(_),O.negate(),L.subVectors(m,f).multiplyScalar(Math.max(.1,_/1.88)),f.positionToArray(S,y),m.positionToArray(A,y),x>=2&&(D.addVectors(f,O).add(L).toArray(S,y+3),D.addVectors(m,O).sub(L).toArray(A,y+3),x>=3&&(D.subVectors(f,O).add(L).toArray(S,y+6),D.subVectors(m,O).sub(L).toArray(A,y+6)))):(_=(l-u)*t,O.multiplyScalar(_),2===x?(D.addVectors(f,O).toArray(S,y),D.subVectors(f,O).toArray(S,y+3),D.addVectors(m,O).toArray(A,y),D.subVectors(m,O).toArray(A,y+3)):3===x?(f.positionToArray(S,y),D.addVectors(f,O).toArray(S,y+3),D.subVectors(f,O).toArray(S,y+6),m.positionToArray(A,y),D.addVectors(m,O).toArray(A,y+3),D.subVectors(m,O).toArray(A,y+6)):(f.positionToArray(S,y),m.positionToArray(A,y)))}else f.positionToArray(S,y),m.positionToArray(A,y);if(M&&C&&(i.bondColorToArray(p,1,M,y),i.bondColorToArray(p,0,C,y),s&&x>1))for(v=1;v1))for(v=1;v1))for(w=T[E]*u/(c?1:.5*x),v=c?1:0;v1))for(w=I[E]*u/(c?1:.5*x),v=c?1:0;va&&(a=t),r>s&&(s=r),u>c&&(c=u)}),t),r.min.set(i,n,o),r.max.set(a,s,c),e.Debug&&is.timeEnd("getBoundingBox"),r},_f.prototype.getPrincipalAxes=function(t){e.Debug&&is.time("getPrincipalAxes");var r=0,i=new qh(3,this.atomCount),n=i.data;return this.eachAtom((function(e){n[r+0]=e.x,n[r+1]=e.y,n[r+2]=e.z,r+=3}),t),e.Debug&&is.timeEnd("getPrincipalAxes"),new rd(i)},_f.prototype.atomCenter=function(e){return e?this.getBoundingBox(e).getCenter(new Y):this.center.clone()},_f.prototype.hasCoords=function(){if(void 0===this._hasCoords){var e=this.atomStore;this._hasCoords=0!==nc(e.x)||0!==ic(e.x)||0!==nc(e.y)||0!==ic(e.y)||0!==nc(e.z)||0!==ic(e.z)||e.count/this.modelStore.count==1}return this._hasCoords},_f.prototype.getSequence=function(e){var t=[],r=this.getResidueProxy();return this.eachAtom((function(e){r.index=e.residueIndex,e.index===r.traceAtomIndex&&t.push(r.getResname1())}),e),t},_f.prototype.getAtomIndices=function(e){if(e&&e.string){var t=[];return this.eachAtom((function(e){t.push(e.index)}),e),new Uint32Array(t)}return this.getAtomData({what:{index:!0}}).index},_f.prototype.getChainnameCount=function(e){var t=new Set;return this.eachChain((function(e){e.residueCount&&t.add(e.chainname)}),e),t.size},_f.prototype.updatePosition=function(e,t){void 0===t&&(t=!0);var r=0;this.eachAtom((function(t){t.positionFromArray(e,r),r+=3}),void 0),this._hasCoords=void 0,t&&this.refreshPosition()},_f.prototype.refreshPosition=function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new sl(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)},_f.prototype.dispose=function(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet},Object.defineProperties(_f.prototype,wf);var Sf=new Ne,Af=[el,Zu,tl,Ju,rl,Ku,Yu,Qu,nl,il,ol,al],Mf={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2},Cf=function(e,t){var r=this;void 0===e&&(e="shape"),void 0===t&&(t={}),this.boundingBox=new Ne,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=e,this.parameters=Ao(t,Mf),Af.forEach((function(e){Object.keys(e.fields).forEach((function(t){r._primitiveData[e.getShapeKey(t)]=[]})),r._primitiveData[e.getShapeKey("name")]=[]}))},Pf={center:{configurable:!0},type:{configurable:!0}};Cf.prototype.addBuffer=function(e){this.bufferList.push(e);var t=e.geometry;return t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox),this},Cf.prototype.addMesh=function(e,t,r,i,n){var o;e=Go(e),t=Go(t),Array.isArray(r)&&(r=No(r,e.length)),i&&(i=Go(i)),o=void 0===i||0==i.length?{position:e,color:t,index:r}:{position:e,color:t,index:r,normal:i};var a=new Rh(this,Object.assign({serial:this.meshCount,name:n},o)),s=new Cp(Object.assign({picking:a},o));return this.bufferList.push(s),Sf.setFromArray(e),this.boundingBox.union(Sf),this.meshCount+=1,this},Cf.prototype.addSphere=function(e,t,r,i){return Yu.objectToShape(this,{position:e,color:t,radius:r,name:i}),this},Cf.prototype.addEllipsoid=function(e,t,r,i,n,o){return rl.objectToShape(this,{position:e,color:t,radius:r,majorAxis:i,minorAxis:n,name:o}),this},Cf.prototype.addTorus=function(e,t,r,i,n,o){return il.objectToShape(this,{position:e,color:t,radius:r,majorAxis:i,minorAxis:n,name:o}),this},Cf.prototype.addCylinder=function(e,t,r,i,n){return Ju.objectToShape(this,{position1:e,position2:t,color:r,radius:i,name:n}),this},Cf.prototype.addCone=function(e,t,r,i,n){return tl.objectToShape(this,{position1:e,position2:t,color:r,radius:i,name:n}),this},Cf.prototype.addArrow=function(e,t,r,i,n){return el.objectToShape(this,{position1:e,position2:t,color:r,radius:i,name:n}),this},Cf.prototype.addBox=function(e,t,r,i,n,o){return Zu.objectToShape(this,{position:e,color:t,size:r,heightAxis:i,depthAxis:n,name:o}),this},Cf.prototype.addOctahedron=function(e,t,r,i,n,o){return Ku.objectToShape(this,{position:e,color:t,size:r,heightAxis:i,depthAxis:n,name:o}),this},Cf.prototype.addTetrahedron=function(e,t,r,i,n,o){return Qu.objectToShape(this,{position:e,color:t,size:r,heightAxis:i,depthAxis:n,name:o}),this},Cf.prototype.addText=function(e,t,r,i){return nl.objectToShape(this,{position:e,color:t,size:r,text:i}),this},Cf.prototype.addPoint=function(e,t,r){return ol.objectToShape(this,{position:e,color:t,name:r}),this},Cf.prototype.addWideline=function(e,t,r,i,n){return this.parameters.linewidth=i,al.objectToShape(this,{position1:e,position2:t,color:r,name:n}),this},Cf.prototype.addLabel=function(e,t,r,i){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(e,t,r,i)},Cf.prototype.getBufferList=function(){var e=this,t=[];return Af.forEach((function(r){e._primitiveData[r.getShapeKey("color")].length&&t.push(r.bufferFromShape(e,e.parameters))})),this.bufferList.concat(t)},Cf.prototype.dispose=function(){var e=this;this.bufferList.forEach((function(e){e.dispose()})),this.bufferList.length=0,Af.forEach((function(t){Object.keys(t.fields).forEach((function(r){e._primitiveData[t.getShapeKey(r)].length=0})),e._primitiveData[t.getShapeKey("name")].length=0}))},Pf.center.get=function(){return this._center||(this._center=this.boundingBox.getCenter(new Y)),this._center},Pf.type.get=function(){return"Shape"},Object.defineProperties(Cf.prototype,Pf);var Tf=function(e){function t(t,r,i){Array.isArray(t)||(t=[t]),e.call(this,t,r,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=t,this.init(i)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){e.prototype.init.call(this,t),this.build()},t.prototype.create=function(){this.bufferList.push.apply(this.bufferList,this.buffer)},t.prototype.attach=function(e){var t=this;this.bufferList.forEach((function(e){t.viewer.add(e),e.setParameters(t.getBufferParams())})),this.setVisibility(this.visible),e()},t}(vu),If=new ie,Ef=new U;var Df=function(e){function t(t,r,i){void 0===r&&(r={}),e.call(this,function(e,t){var r,i=t.attributes.position.array,n=t.index?t.index.array:void 0,o=e.position.length/3,a=i.length/3,s=o*a,c=new Float32Array(3*s),u=new Float32Array(3*s),l=new Float32Array(3*s);return n&&(r=No(o*n.length,s)),{position:c,color:l,index:r,normal:u,primitiveId:e.primitiveId||Js(o,a),picking:e.picking}}(t,i),r),this.updateNormals=!1;var n=i.attributes.position.array,o=i.attributes.normal.array,a=i.index?i.index.array:void 0;this.geoPosition=n,this.geoNormal=o,this.geoIndex=a,this.positionCount=t.position.length/3,this.geoPositionCount=n.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);var s=this.geometry.attributes;if(this.meshPosition=s.position.array,this.meshColor=s.color.array,this.meshNormal=s.normal.array,this.setAttributes(t),a){var c=this.geometry.getIndex();if(!c)return void is.error("Index is null");this.meshIndex=c.array,this.makeIndex()}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.setAttributes=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!1);var r,i,n,o,a,s,c,u,l,h=this.geometry.attributes,p=this.updateNormals;e.position&&(r=e.position,n=this.geoPosition,c=this.meshPosition,a=this.transformedGeoPosition,h.position.needsUpdate=!0,(p||t)&&(o=this.geoNormal,l=this.meshNormal,s=this.transformedGeoNormal,h.normal.needsUpdate=!0)),e.color&&(i=e.color,u=this.meshColor,h.color.needsUpdate=!0);for(var d=this.positionCount,f=this.geoPositionCount,m=0;m 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var kf=function(e){function t(t,r,i){void 0===i&&(i={}),e.call(this,r,i),this.index=No(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:t,value:null}}),this.setAttributes({primitiveId:Qs(this.size)})}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={attributeSize:{configurable:!0},indexSize:{configurable:!0}};return r.attributeSize.get=function(){return this.size*this.mappingSize},r.indexSize.get=function(){return this.size*this.mappingIndicesSize},t.prototype.addAttributes=function(t){var r={};for(var i in t){var n=t[i];r[i]={type:n.type,value:null}}e.prototype.addAttributes.call(this,r)},t.prototype.getAttributeIndex=function(e){return 3*e*this.mappingSize},t.prototype.setAttributes=function(e){e&&!e.position&&e.position1&&e.position2&&(e.position=Xs(e.position1,e.position2));var t,r,i,n,o,a,s,c=this.size,u=this.mappingSize,l=this.geometry.attributes;for(var h in e)if("index"!==h&&"picking"!==h){r=e[h],i=(t=l[h]).itemSize,n=t.array;for(var p=0;p0&&this.parameters.alphaTest<=1&&(r.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),r},t.prototype.setUniforms=function(t){t&&void 0!==t.edgeBleach&&(this.makeTexture(),t.map=this.tex),e.prototype.setUniforms.call(this,t)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.tex&&this.tex.dispose()},Object.defineProperties(t.prototype,r),t}(Ap);fs.add("point",Vf);var $f=function(e){function t(t,r,i){e.call(this,t,r,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),t instanceof vp?(this.surface=void 0,this.volume=new id(t)):(this.surface=t,this.volume=void 0),this.init(i)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){var r=t||{};r.colorScheme=So(r.colorScheme,"uniform"),r.colorValue=So(r.colorValue,14540253),this.thresholdType=So(r.thresholdType,"sigma"),this.thresholdMin=So(r.thresholdMin,2),this.thresholdMax=So(r.thresholdMax,1/0),this.thresholdOut=So(r.thresholdOut,!1),this.dotType=So(r.dotType,"point"),this.radius=So(r.radius,.1),this.scale=So(r.scale,1),this.pointSize=So(r.pointSize,1),this.sizeAttenuation=So(r.sizeAttenuation,!0),this.sortParticles=So(r.sortParticles,!1),this.useTexture=So(r.useTexture,!1),this.alphaTest=So(r.alphaTest,.5),this.forceTransparent=So(r.forceTransparent,!1),this.edgeBleach=So(r.edgeBleach,0),e.prototype.init.call(this,r),this.build()},t.prototype.attach=function(e){var t=this;this.bufferList.forEach((function(e){t.viewer.add(e)})),this.setVisibility(this.visible),e()},t.prototype.create=function(){var e={};if(this.volume){var t,r,i=this.volume;"sigma"===this.thresholdType?(t=i.getValueForSigma(this.thresholdMin),r=i.getValueForSigma(this.thresholdMax)):(t=this.thresholdMin,r=this.thresholdMax),i.setFilter(t,r,this.thresholdOut),Object.assign(e,{position:i.getDataPosition(),color:i.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:i.getDataSize(this.radius,this.scale),picking:i.getDataPicking()})}else{var n=this.surface;Object.assign(e,{position:n.getPosition(),color:n.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:n.getSize(this.radius,this.scale),picking:n.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Uf(e,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Vf(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)},t.prototype.update=function(e){if(void 0===e&&(e={}),0!==this.bufferList.length){var t={};e.color&&(this.volume?Object.assign(t,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(t,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(e.radius||e.scale)&&(this.volume?Object.assign(t,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(t,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(t)}},t.prototype.setParameters=function(t,r,i){return void 0===r&&(r={}),t&&void 0!==t.thresholdType&&this.volume instanceof vp&&("value"===this.thresholdType&&"sigma"===t.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===t.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=t.thresholdType),t&&void 0!==t.radiusType&&("radius"===t.radiusType?this.radius=.1:this.radius=parseFloat(t.radiusType),r.radius=!0,"sphere"!==this.dotType||es&&!this.disableImpostor||(i=!0)),t&&void 0!==t.radius&&(r.radius=!0,"sphere"!==this.dotType||es&&!this.disableImpostor||(i=!0)),t&&void 0!==t.scale&&(r.scale=!0,"sphere"!==this.dotType||es&&!this.disableImpostor||(i=!0)),e.prototype.setParameters.call(this,t,r,i),this},t}(vu);hs.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),hs.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");var Hf=new Uint16Array([0,1,2,1,3,2]),Wf=new Float32Array([0,1,0,0,1,1,1,0]),qf=Object.assign({filter:"nearest",forceTransparent:!0},wp),Xf=Object.assign({filter:{updateShader:!0,uniform:!0}},Sp),Yf=function(e){function t(t,r){e.call(this,{position:t.position,index:Hf,picking:t.picking},r),this.parameterTypes=Xf,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";var i=t.imageData,n=t.width,o=t.height,a=new xr(i,n,o);a.flipY=!0,this.tex=a;for(var s=i.length,c=new Uint8Array(s),u=0;u>16&255,c[u+1]=l>>8&255,c[u+2]=255&l}var h=new xr(c,n,o);h.flipY=!0,h.minFilter=x,h.magFilter=x,this.pickingTex=h,this.addUniforms({map:{value:a},pickingMap:{value:h},mapSize:{value:new z(n,o)}}),this.geometry.setAttribute("uv",new wt(Wf,2))}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaultParameters:{configurable:!0}};return r.defaultParameters.get=function(){return qf},t.prototype.getDefines=function(t){var r=e.prototype.getDefines.call(this,t),i=this.parameters.filter;return i.startsWith("cubic")&&(r.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?r.BSPLINE_FILTER=1:i.endsWith("catmulrom")?r.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(r.MITCHELL_FILTER=1)),r},t.prototype.updateTexture=function(){var e=this.tex,t=this.parameters.filter;t.startsWith("cubic")?(e.minFilter=x,e.magFilter=x):"linear"===t?(e.minFilter=_,e.magFilter=_):(e.minFilter=x,e.magFilter=x),e.needsUpdate=!0,this.pickingTex.needsUpdate=!0},t.prototype.makeMaterial=function(){e.prototype.makeMaterial.call(this),this.updateTexture();var t=this.material;t.uniforms.map.value=this.tex,t.blending=1,t.needsUpdate=!0;var r=this.wireframeMaterial;r.uniforms.map.value=this.tex,r.blending=1,r.needsUpdate=!0;var i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=1,i.needsUpdate=!0},t.prototype.setUniforms=function(t){t&&void 0!==t.filter&&(this.updateTexture(),t.map=this.tex),e.prototype.setUniforms.call(this,t)},Object.defineProperties(t.prototype,r),t}(Ap),Zf=function(e,t){var r=t||{};this.dimension=So(r.dimension,"x"),this.positionType=So(r.positionType,"percent"),this.position=So(r.position,30),this.thresholdType=So(r.thresholdType,"sigma"),this.thresholdMin=So(r.thresholdMin,-1/0),this.thresholdMax=So(r.thresholdMax,1/0),this.normalize=So(r.normalize,!1),this.volume=e};Zf.prototype.getPositionFromCoordinate=function(e){var t,r=this.dimension,i=this.volume,n=i.matrix,o=(new Y).setFromMatrixPosition(n)[r],a=(new Y).setFromMatrixScale(n)[r];return t="x"===r?i.nx:"y"===r?i.ny:i.nz,Math.round(((e-o)/(t/100)+1)/a)},Zf.prototype.getData=function(e){e=e||{};var t,r=this.volume,i=r.data,n=r.matrix;function o(e){return Math.round(e/100*(t-1))}function a(e,t,i,n){return 3*(i*r.ny*r.nx+t*r.nx+e)+n}t="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;var s,c,u,l,h,p=new Float32Array(12),d=new Y,f=0,m=0,g=0,v=r.nx,y=r.ny,b=r.nz;function x(e,t,r,i){d.set(e,t,r).applyMatrix4(n).toArray(p,i)}"x"===this.dimension?(u=o(r.nx),l=r.ny-1,h=r.nz-1,s=r.nz,c=r.ny,v=(f=u)+1,x(u,0,0,0),x(u,l,0,3),x(u,0,h,6),x(u,l,h,9)):"y"===this.dimension?(u=r.nx-1,l=o(r.ny),h=r.nz-1,s=r.nz,c=r.nx,y=(m=l)+1,x(0,l,0,0),x(u,l,0,3),x(0,l,h,6),x(u,l,h,9)):"z"===this.dimension&&(u=r.nx-1,l=r.ny-1,h=o(r.nz),s=r.nx,c=r.ny,b=(g=h)+1,x(0,0,h,0),x(0,l,h,3),x(u,0,h,6),x(u,l,h,9));var _,w,S=0,A=0,M=new Uint8Array(s*c*4),C=new Float32Array(s*c);"sigma"===this.thresholdType?(_=r.getValueForSigma(this.thresholdMin),w=r.getValueForSigma(this.thresholdMax)):(_=this.thresholdMin,w=this.thresholdMax);var P=Object.assign({},e.colorParams,{volume:r});this.normalize&&(P.domain=[0,1]);var T,I=ss.getScheme(P),E=new Float32Array(3),D=I.getScale(),L=0,O=0;if(this.normalize){L=1/0,T=-1/0;for(var R=m;RT&&(T=B)}O=T-L}for(var F=m;F_&&G0?this.list[0]:void 0},um.prototype.forEach=function(e){return this.list.forEach(e),this},um.prototype.dispose=function(){return this.forEach((function(e){return e.dispose()}))},Object.defineProperties(um.prototype,lm);var hm=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.setParameters=function(e){return this.forEach((function(t){return t.setParameters(e)}))},t.prototype.setVisibility=function(e){return this.forEach((function(t){return t.setVisibility(e)}))},t.prototype.setSelection=function(e){return this.forEach((function(t){return t.setSelection(e)}))},t.prototype.setColor=function(e){return this.forEach((function(t){return t.setColor(e)}))},t.prototype.update=function(e){return this.forEach((function(t){return t.update(e)}))},t.prototype.build=function(e){return this.forEach((function(t){return t.build(e)}))},t.prototype.dispose=function(e){return this.forEach((function(e){return e.dispose()}))},t}(um),pm=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},Jf),dm=function(e){function t(t,r,i){var n=this;void 0===i&&(i={}),e.call(this,t,Object.assign({name:r.name},i)),this.trajectory=r,this.signals=Object.assign(this.signals,{frameChanged:new ua.Signal,playerChanged:new ua.Signal,countChanged:new ua.Signal,parametersChanged:new ua.Signal}),r.signals.frameChanged.add((function(e){n.signals.frameChanged.dispatch(e)})),r.signals.playerChanged.add((function(e){n.signals.playerChanged.dispatch(e)})),r.signals.countChanged.add((function(e){n.signals.countChanged.dispatch(e)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaultParameters:{configurable:!0},type:{configurable:!0}};return r.defaultParameters.get=function(){return pm},r.type.get=function(){return"trajectory"},t.prototype.setFrame=function(e){this.trajectory.setFrame(e)},t.prototype.setParameters=function(e){void 0===e&&(e={}),this.trajectory.setParameters(e),this.signals.parametersChanged.dispatch(e)},t.prototype.dispose=function(){this.trajectory.dispose(),e.prototype.dispose.call(this)},Object.defineProperties(t.prototype,r),t}(em),fm=function(e,t){this.name=e,this.path=t,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1},mm={type:{configurable:!0}};mm.type.get=function(){return"Frames"},Object.defineProperties(fm.prototype,mm);var gm=function(e,t){var r,i;if(this.A=new qh(3,3),this.W=new qh(1,3),this.U=new qh(3,3),this.V=new qh(3,3),this.VH=new qh(3,3),this.R=new qh(3,3),this.tmp=new qh(3,3),this.c=new qh(3,3),e instanceof _f)r=e.atomCount;else{if(!(e instanceof Float32Array))return;r=e.length/3}if(t instanceof _f)i=t.atomCount;else{if(!(t instanceof Float32Array))return;i=t.length/3}var n=Math.min(r,i),o=new qh(3,n),a=new qh(3,n);this.coords1t=new qh(n,3),this.coords2t=new qh(n,3),this.transformationMatrix=new ie,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(e,o,n,!1),this.prepCoords(t,a,n,!1),this._superpose(o,a)};gm.prototype._superpose=function(t,r){var i,n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b,x,_,w,S,A;this.mean1=Kh(t),this.mean2=Kh(r),Qh(t,this.mean1),Qh(r,this.mean2),Xh(this.coords1t,t),Xh(this.coords2t,r),Yh(this.A,this.coords2t,this.coords1t),tp(this.A,this.W,this.U,this.V),i=this.V,n=this.VH,o=i.data,a=n.data,s=o[4],c=o[8],u=o[5],l=o[7],h=o[0],p=h*s,d=h*u,f=o[3],m=o[1],g=f*m,v=o[2],y=f*v,b=o[6],w=1/(p*c-d*l-g*c+y*l+(x=b*m)*u-(_=b*v)*s),a[0]=(s*c-u*l)*w,a[1]=-(m*c-v*l)*w,a[2]=-(-m*u+v*s)*w,a[3]=-(f*c-u*b)*w,a[4]=(h*c-_)*w,a[5]=-(d-y)*w,a[6]=-(-f*l+s*b)*w,a[7]=-(h*l-x)*w,a[8]=(p-g)*w,Zh(this.R,this.U,this.VH),S=this.R,(A=S.data)[0]*A[4]*A[8]-A[0]*A[5]*A[7]-A[3]*A[1]*A[8]+A[3]*A[2]*A[7]+A[6]*A[1]*A[5]-A[6]*A[2]*A[4]<0&&(e.Debug&&is.log("R not a right handed system"),Zh(this.tmp,this.c,this.VH),Zh(this.R,this.U,this.tmp));var M=new qh(4,4),C=new qh(4,4),P=new qh(4,4),T=new qh(4,4),I=new qh(4,4),E=new qh(4,4),D=this.R.data,L=this.mean1,O=this.mean2;T.data.set([1,0,0,-L[0],0,1,0,-L[1],0,0,1,-L[2],0,0,0,1]),I.data.set([D[0],D[1],D[2],0,D[3],D[4],D[5],0,D[6],D[7],D[8],0,0,0,0,1]),E.data.set([1,0,0,O[0],0,1,0,O[1],0,0,1,O[2],0,0,0,1]),Xh(C,T),Yh(M,I,C),Xh(P,M),Yh(C,E,P),Xh(M,C),this.transformationMatrix.elements=M.data},gm.prototype.prepCoords=function(e,t,r,i){var n=0,o=t.data,a=3,s=3*r;if(i&&(s=4*r,a=4),e instanceof _f)e.eachAtom((function(e){n=r)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),i.hasFrame(this._currentFrame)){this._currentStep+=1;var n=this._currentStep/(this.parameters.interpolateStep+1),o=this._currentFrame,a=o[0],s=o[1],c=o[2],u=o[3];i.setFrameInterpolated(a,s,c,u,n,this.parameters.interpolateType),this._previousTime=this._currentTime}else i.loadFrame(this._currentFrame);else{var l=this._next();i.hasFrame(l)?(i.setFrame(l),this._previousTime=this._currentTime):i.loadFrame(l)}window.requestAnimationFrame(this._animate)}},ym.prototype._next=function(){var e,t=this.parameters;return((e="forward"===this._direction?this.traj.currentFrame+t.step:this.traj.currentFrame-t.step)>t.end||e=e.end?r=e.start:"backward"===e.direction&&t<=e.start&&(r=e.end),this.traj.setFrame(r),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}},ym.prototype.pause=function(){this._run=!1,this.signals.haltedRunning.dispatch()},ym.prototype.stop=function(){this.pause(),this.traj.setFrame(this.parameters.start)},Object.defineProperties(ym.prototype,bm);var xm=function(e,t,r){var i=this;void 0===r&&(r={}),this.signals={countChanged:new ua.Signal,frameChanged:new ua.Signal,playerChanged:new ua.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=So(r.deltaTime,0),this.timeOffset=So(r.timeOffset,0),this.centerPbc=So(r.centerPbc,!1),this.removePbc=So(r.removePbc,!1),this.removePeriodicity=So(r.removePeriodicity,!1),this.superpose=So(r.superpose,!1),this.name=e.replace(/^.*[\\/]/,""),this.trajPath=e,this.selection=new Na(So(r.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((function(){i.selectionIndices=i.structure.getAtomIndices(i.selection),i._resetCache(),i._saveInitialCoords(),i.setFrame(i._currentFrame)}))},_m={frameCount:{configurable:!0},currentFrame:{configurable:!0}};_m.frameCount.get=function(){return this._frameCount},_m.currentFrame.get=function(){return this._currentFrame},xm.prototype._init=function(e){this.setStructure(e),this._loadFrameCount(),this.setPlayer(new ym(this))},xm.prototype._loadFrameCount=function(){},xm.prototype.setStructure=function(e){this.structure=e,this.atomCount=e.atomCount,this.backboneIndices=this._getIndices(new Na("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)},xm.prototype._saveInitialCoords=function(){var e=this;this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(function(){return e._saveInitialCoords()}))},xm.prototype._saveStructureCoords=function(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position},xm.prototype.setSelection=function(e){return this.selection.setString(e),this},xm.prototype._getIndices=function(e){var t=0,r=e.test,i=[];return r&&this.structure.eachAtom((function(e){r(e)&&i.push(t),t+=1})),i},xm.prototype._makeSuperposeCoords=function(){var e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);for(var t=this.initialCoords,r=this.coords2,i=0;i0&&this.centerPbc){var n=[t[0],t[4],t[8]],o=function(e,t,r){return[qs(t,r[0],3,0,e),qs(t,r[1],3,1,e),qs(t,r[2],3,2,e)]}(this.backboneIndices,r,n);!function(e,t,r){if(0!==r[0]&&0!==r[8]&&0!==r[4])for(var i=e.length,n=r[0],o=r[1],a=r[2],s=-t[0]+n+n/2,c=-t[1]+o+o/2,u=-t[2]+a+a/2,l=0;l.5&&(e[n+o]-=t[3*o+o]*Math.round(a))}}}(r,t,a)}this.removePbc&&function(e,t){if(0!==t[0]&&0!==t[8]&&0!==t[4]){for(var r=e.length,i=3;i.9*t[3*n+n])if(o>0)for(var a=0;a<3;++a)e[i+a]-=t[3*n+a];else for(var s=0;s<3;++s)e[i+s]+=t[3*n+s]}}}(r,t)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(r),this.frameCache[e]=r,this.boxCache[e]=t,this.frameCacheSize+=1},xm.prototype._setFrameCount=function(e){e!==this._frameCount&&(this._frameCount=e,this.signals.countChanged.dispatch(e))},xm.prototype.dispose=function(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()},xm.prototype.setPlayer=function(e){this.player=e,this.signals.playerChanged.dispatch(e)},xm.prototype.getFrameTime=function(e){return this.timeOffset+e*this.deltaTime},Object.defineProperties(xm.prototype,_m);var wm=function(e){function t(t,r,i){var n=i||{};n.timeOffset=So(n.timeOffset,t.timeOffset),n.deltaTime=So(n.deltaTime,t.deltaTime),e.call(this,"",r,n),this.name=t.name,this.path=t.path,this.frames=t.coordinates,this.boxes=t.boxes,this._init(r)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={type:{configurable:!0}};return r.type.get=function(){return"frames"},t.prototype._makeAtomIndices=function(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0},t.prototype._loadFrame=function(e,t){var r,i=this.frames[e];if(this.atomIndices){var n=this.atomIndices,o=n.length;r=new Float32Array(3*o);for(var a=0;a0&&(i="( "+t.join(" ) AND ( ")+" )"),new Na(i)},r.prototype.getStructure=function(){return this.structure.getStructure()},r.prototype.eachBond=function(e,t){this.structure.eachBond(e,this.getSelection(t))},r.prototype.eachAtom=function(e,t){var r=this.getAtomProxy(),i=this.getAtomSet(t),n=this.atomStore.count;if(i.getSize()=this.V[i][n]?(t="S",this.score=this.S[i][n]):this.V[i][n]>=this.H[i][n]?(t="V",this.score=this.V[i][n]):(t="H",this.score=this.H[i][n]),e.Debug&&is.log("Alignment: SCORE",this.score),e.Debug&&is.log("Alignment: S, V, H",this.S[i][n],this.V[i][n],this.H[i][n]);i>0&&n>0;)"S"===t?this.S[i][n]===this.S[i-1][n-1]+r(i-1,n-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[n-1]+this.ali2,--i,--n,t="S"):this.S[i][n]===this.V[i][n]?t="V":this.S[i][n]===this.H[i][n]?t="H":(--i,--n):"V"===t?this.V[i][n]===this.V[i-1][n]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,t="V"):this.V[i][n]===this.S[i-1][n]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,t="S"):--i:"H"===t?this.H[i][n]===this.H[i][n-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[n-1]+this.ali2,--n,t="H"):this.H[i][n]===this.S[i][n-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[n-1]+this.ali2,--n,t="S"):--n:is.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;n>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[n-1]+this.ali2,--n;e.Debug&&is.timeEnd("Alignment.trace"),e.Debug&&is.log([this.ali1,this.ali2])};var Lm=Object.assign({sele:"",defaultAssembly:""},am),Om=function(e){function t(t,r,i){var n,o,a,s,c,u=this;void 0===i&&(i={}),e.call(this,t,r,Object.assign({name:r.name},i)),this.structure=r,this.trajList=[],this.signals=Object.assign(this.signals,{trajectoryAdded:new ua.Signal,trajectoryRemoved:new ua.Signal,defaultAssemblyChanged:new ua.Signal}),this.initSelection(this.parameters.sele),this.pickBuffer=(n=4,o=0,a=0,s=[],{has:function(e){return-1!==s.indexOf(e)},get:function(e){return s[e]},push:function(e){s[o]=e,o=(n+o+1)%n,++a},get count(){return a},get data(){return s.slice(0,Math.min(a,n))},clear:function(){a=0,o=0,s.length=0}}),this.pickDict=(c={},{has:function(e){return void 0!==c[JSON.stringify(e)]},add:function(e,t){c[JSON.stringify(e)]=t},del:function(e){delete c[JSON.stringify(e)]},get values(){return Object.keys(c).map((function(e){return c[e]}))}}),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:ns.opacity,color:ns.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",ns,!0),this.angleRepresentation=this.addRepresentation("angle",ns,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",ns,!0),this.measureRepresentations=new hm([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((function(){u.updateRepresentations({position:!0})}))}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaultParameters:{configurable:!0},type:{configurable:!0}};return r.defaultParameters.get=function(){return Lm},r.type.get=function(){return"structure"},t.prototype.initSelection=function(e){var t=this;this.selection=new Na(e),this.structureView=new Cm(this.structure,this.selection),this.selection.signals.stringChanged.add((function(){t.structureView.setSelection(t.selection),t.rebuildRepresentations(),t.rebuildTrajectories()}))},t.prototype.setSelection=function(e){return this.parameters.sele=e,this.selection.setString(e),this},t.prototype.setDefaultAssembly=function(e){if(void 0===this.structure.biomolDict[e]&&(e=""),this.parameters.defaultAssembly!==e){var t={defaultAssembly:e};this.reprList.forEach((function(e){return e.setParameters(t)})),this.measureRepresentations.setParameters(t),this.parameters.defaultAssembly=e,this.signals.defaultAssemblyChanged.dispatch(e)}return this},t.prototype.rebuildRepresentations=function(){this.reprList.forEach((function(e){e.build()})),this.measureRepresentations.build()},t.prototype.rebuildTrajectories=function(){var e=this;this.trajList.forEach((function(t){t.trajectory.setStructure(e.structureView)}))},t.prototype.updateRepresentations=function(t){e.prototype.updateRepresentations.call(this,t),this.measureRepresentations.update(t)},t.prototype.updateRepresentationMatrices=function(){e.prototype.updateRepresentationMatrices.call(this),this.measureRepresentations.setParameters({matrix:this.matrix})},t.prototype.addRepresentation=function(e,t,r){var i=this;void 0===t&&(t={}),void 0===r&&(r=!1),t.defaultAssembly=this.parameters.defaultAssembly;var n=this._addRepresentation(e,this.structureView,t,r);return r||n.signals.parametersChanged.add((function(){return i.measureUpdate()})),n},t.prototype.addTrajectory=function(e,t){void 0===e&&(e=""),void 0===t&&(t={});var r=function(e,t,r){return e&&e instanceof fm?new wm(e,t,r):!e&&t.frames?new Sm(e,t,r):e&&"function"==typeof e?new Mm(e,t,r):new Am(e,t,r)}(e,this.structureView,t),i=new dm(this.stage,r,t);return this.trajList.push(i),this.signals.trajectoryAdded.dispatch(i),i},t.prototype.removeTrajectory=function(e){var t=this.trajList.indexOf(e);-1!==t&&this.trajList.splice(t,1),e.dispose(),this.signals.trajectoryRemoved.dispatch(e)},t.prototype.dispose=function(){this.trajList.slice().forEach((function(e){return e.dispose()})),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),e.prototype.dispose.call(this)},t.prototype.autoView=function(e,t){"number"==typeof e&&(t=e,e=""),this.stage.animationControls.zoomMove(this.getCenter(e),this.getZoom(e),So(t,0))},t.prototype.getBoxUntransformed=function(e){return e?this.structureView.getBoundingBox(new Na(e)):this.structureView.boundingBox},t.prototype.getCenterUntransformed=function(e){return e&&"string"==typeof e?this.structure.atomCenter(new Na(e)):this.structure.center},t.prototype.superpose=function(e,t,r,i){return Dm(this.structureView,e.structureView,t,r,i),this.updateRepresentations({position:!0}),this},t.prototype.getMaxRepresentationRadius=function(e){var t=0,r=this.structure.getAtomProxy(e);return this.eachRepresentation((function(e){if(e.getVisibility()){var i=e.repr;t=Math.max(i.getAtomRadius(r),t)}})),t},t.prototype.measurePick=function(e){var t=this.pickBuffer.count;if(this.lastPick===e.index&&t>=1){if(t>1){var r=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,r),2===t?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((function(e){return 2===e.length}))}):3===t?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((function(e){return 3===e.length}))}):4===t&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((function(e){return 4===e.length}))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(e.index)||this.pickBuffer.push(e.index),this.lastPick=e.index;this.measureUpdate()},t.prototype.measureClear=function(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")},t.prototype.measureBuild=function(){var e=this.measureData();this.distanceRepresentation.setParameters({atomPair:e.distance}),this.angleRepresentation.setParameters({atomTriple:e.angle}),this.dihedralRepresentation.setParameters({atomQuad:e.dihedral})},t.prototype.measureUpdate=function(){var e=this,t=this.pickBuffer.data,r={};t.forEach((function(t){var i=Math.max(.1,e.getMaxRepresentationRadius(t));r[t]=i*(2.3-Jo(.1,2,i))})),this.spacefillRepresentation.setSelection(t.length?"@"+t.join(","):"none"),t.length&&this.spacefillRepresentation.setParameters({radiusData:r})},t.prototype.measureData=function(){var e=this.pickDict.values;return{distance:e.filter((function(e){return 2===e.length})),angle:e.filter((function(e){return 3===e.length})),dihedral:e.filter((function(e){return 4===e.length}))}},t.prototype.removeAllMeasurements=function(e){var t=this.pickDict,r=t.values,i=function(e){r.filter((function(t){return t.length===e})).forEach((function(e){return t.del(e.slice().sort())}))};(!e||1&e)&&i(2),(!e||2&e)&&i(3),(!e||4&e)&&i(4),this.measureBuild()},t.prototype.removeMeasurement=function(e){this.pickDict.del(e.slice().sort()),this.measureBuild()},t.prototype.addMeasurement=function(e){if(!(e.length<2||e.length>4)){var t=e.slice().sort();this.pickDict.has(t)||this.pickDict.add(t,e),this.measureBuild()}},Object.defineProperties(t.prototype,r),t}(sm);ds.add("structure",Om),ds.add("structureview",Om);var Rm=function(e){function t(t,r,i){void 0===i&&(i={}),e.call(this,t,r,Object.assign({name:r.name},i)),this.surface=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={type:{configurable:!0}};return r.type.get=function(){return"surface"},t.prototype.addRepresentation=function(e,t){return void 0===t&&(t={}),this._addRepresentation(e,this.surface,t)},t.prototype.getBoxUntransformed=function(){return this.surface.boundingBox},t.prototype.getCenterUntransformed=function(){return this.surface.center},t.prototype.dispose=function(){this.surface.dispose(),e.prototype.dispose.call(this)},Object.defineProperties(t.prototype,r),t}(sm);ds.add("surface",Rm);var km=function(e){function t(t,r,i){void 0===i&&(i={}),e.call(this,t,r,Object.assign({name:r.name},i)),this.volume=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={type:{configurable:!0}};return r.type.get=function(){return"volume"},t.prototype.addRepresentation=function(e,t){return void 0===t&&(t={}),this._addRepresentation(e,this.volume,t)},t.prototype.getBoxUntransformed=function(){return this.volume.boundingBox},t.prototype.getCenterUntransformed=function(){return this.volume.center},t.prototype.dispose=function(){this.volume.dispose(),e.prototype.dispose.call(this)},Object.defineProperties(t.prototype,r),t}(sm);ds.add("volume",km);var Nm=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.addRepresentation=function(e,t){return this.forEach((function(r){return r.addRepresentation(e,t)}))},t.prototype.autoView=function(e){return this.forEach((function(t){return t.autoView(e)}))},t}(um);function Bm(e,t){return e instanceof RegExp?null!==t.name.match(e):t.name===e}var Fm=new Y,zm={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"},Um=function(e,t){void 0===t&&(t={}),this.signals={parametersChanged:new ua.Signal,fullscreenChanged:new ua.Signal,componentAdded:new ua.Signal,componentRemoved:new ua.Signal,clicked:new ua.Signal,hovered:new ua.Signal},this.tasks=new Os,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Mc(e),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new Tc(this.viewer.renderer.domElement),this.viewerControls=new tu(this),this.trackballControls=new jc(this),this.pickingControls=new Wc(this),this.animationControls=new fu(this),this.mouseControls=new Bp(this),this.keyControls=new Up(this),this.pickingBehavior=new jp(this),this.mouseBehavior=new Gp(this),this.animationBehavior=new Vp(this),this.keyBehavior=new Hp(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=Ao(t,zm),this.setParameters(this.parameters),this.viewer.animate())};Um.prototype.setParameters=function(e){void 0===e&&(e={}),Mo(this.parameters,e);var t=e,r=this.parameters,i=this.viewer,n=this.trackballControls;return void 0!==t.quality&&this.setQuality(r.quality),void 0!==t.impostor&&this.setImpostor(r.impostor),void 0!==t.rotateSpeed&&(n.rotateSpeed=r.rotateSpeed),void 0!==t.zoomSpeed&&(n.zoomSpeed=r.zoomSpeed),void 0!==t.panSpeed&&(n.panSpeed=r.panSpeed),void 0!==t.mousePreset&&this.mouseControls.preset(r.mousePreset),this.mouseObserver.setParameters({hoverTimeout:r.hoverTimeout}),i.setClip(r.clipNear,r.clipFar,r.clipDist,r.clipMode,r.clipScale),i.setFog(void 0,r.fogNear,r.fogFar),i.setCamera(r.cameraType,r.cameraFov,r.cameraEyeSep),i.setSampling(r.sampleLevel),i.setBackground(r.backgroundColor),i.setLight(r.lightColor,r.lightIntensity,r.ambientColor,r.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this},Um.prototype.log=function(e){console.log("STAGE LOG",e),this.logList.push(e)},Um.prototype.getParameters=function(){return Object.assign({},this.parameters)},Um.prototype.defaultFileRepresentation=function(t){if(t instanceof Om){var r,i,n;t.setSelection("/0");var o=t.structure;if(o.biomolDict.BU1){var a=o.biomolDict.BU1;r=a.getAtomCount(o),i=a.getResidueCount(o),n=a.getInstanceCount(),t.setDefaultAssembly("BU1")}else r=o.getModelProxy(0).atomCount,i=o.getModelProxy(0).residueCount,n=1;var s=r;Ka&&(s*=4);var c=o.atomStore.count/o.residueStore.count<2;c&&(s*=10);var u="chainname",l="RdYlBu",h=!1;if(1===o.getChainnameCount(new Na("polymer and /0"))&&(u="residueindex",l="Spectral",h=!0),e.Debug&&console.log(s,r,n,c),i/n<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(n>5&&s>15e3||s>7e5){var p=Math.min(2,Math.max(.1,6e3/(s/n)));c&&(p=Math.min(p,.5)),t.addRepresentation("surface",{colorScheme:u,colorScale:l,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:p,useWorker:!1})}else s>25e4?t.addRepresentation("backbone",{colorScheme:u,colorScale:l,colorReverse:h,lineOnly:!0}):s>1e5?t.addRepresentation("backbone",{colorScheme:u,colorScale:l,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):s>8e4?t.addRepresentation("backbone",{colorScheme:u,colorScale:l,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:u,colorScale:l,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),s<5e4&&t.addRepresentation("base",{colorScheme:u,colorScale:l,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof Rm||t instanceof km)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)},Um.prototype.loadFile=function(e,t){var r=this;void 0===t&&(t={});var i=Object.assign({},this.defaultFileParams,t),n=Ss(e).name;this.tasks.increment(),this.log("loading file '"+n+"'");var o=So(i.ext,Ss(e).ext);return(ls.isTrajectory(o)?Promise.reject(new Error("loadFile: ext '"+o+"' is a trajectory and must be loaded into a structure component")):Ms(e,i)).then((function(e){r.log("loaded '"+n+"'");var t=r.addComponentFromObject(e,i);return i.defaultRepresentation&&r.defaultFileRepresentation(t),r.tasks.decrement(),t}),(function(e){r.tasks.decrement();var t="error loading file: '"+e+"'";throw r.log(t),t}))},Um.prototype.loadScript=function(e){var t=this,r=Ss(e).name;return this.log("loading script '"+r+"'"),Ms(e).then((function(e){t.tasks.increment(),t.log("running script '"+r+"'"),e.run(t).then((function(){t.tasks.decrement(),t.log("finished script '"+r+"'")})),t.log("called script '"+r+"'")}),(function(e){t.tasks.decrement();var i="errored script '"+r+"' \""+e+'"';throw t.log(i),i}))},Um.prototype.addComponent=function(e){e?(this.compList.push(e),this.signals.componentAdded.dispatch(e)):is.warn("Stage.addComponent: no component given")},Um.prototype.addComponentFromObject=function(e,t){void 0===t&&(t={});var r=ds.get(e.type);if(r){var i=new r(this,e,t);return this.addComponent(i),i}is.warn("no component for object type",e.type)},Um.prototype.removeComponent=function(e){var t=this.compList.indexOf(e);-1!==t&&(this.compList.splice(t,1),e.dispose(),this.signals.componentRemoved.dispatch(e))},Um.prototype.removeAllComponents=function(){var e=this;this.compList.slice().forEach((function(t){return e.removeComponent(t)}))},Um.prototype.handleResize=function(){this.viewer.handleResize()},Um.prototype.setSize=function(e,t){var r=this.viewer.container;r!==document.body&&(void 0!==e&&(r.style.width=e),void 0!==t&&(r.style.height=t),this.handleResize())},Um.prototype.toggleFullscreen=function(e){if(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled){var t=this;e=e||this.viewer.container,this.lastFullscreenElement=e,r()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(e.dataset.normalWidth=e.style.width||"",e.dataset.normalHeight=e.style.height||"",e.style.width=window.screen.width+"px",e.style.height=window.screen.height+"px",e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){t.handleResize()}),100))}else is.log("fullscreen mode (currently) not possible");function r(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function i(){if(!r()&&t.lastFullscreenElement){var e=t.lastFullscreenElement;e.style.width=e.dataset.normalWidth||"",e.style.height=e.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i),t.handleResize(),t.signals.fullscreenChanged.dispatch(!1)}}},Um.prototype.setSpin=function(e){e?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)},Um.prototype.setRock=function(e){e?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)},Um.prototype.toggleSpin=function(){this.setSpin(this.spinAnimation.paused)},Um.prototype.toggleRock=function(){this.setRock(this.rockAnimation.paused)},Um.prototype.getFocus=function(){var e=this.parameters;if("scene"!==e.clipMode)return 0;var t=e.clipNear;return"absolute"===e.clipScale&&(t=this.viewer.absoluteToRelative(t)),2*t},Um.prototype.setFocus=function(e){var t,r,i,n;"scene"===this.parameters.clipMode&&("relative"===this.parameters.clipScale?(i=50,n=function(e){return Zo(e,0,100)}(2*(r=100-(t=Zo(e/2,0,49.9)))-50)):(i=0,n=2*(r=t=this.viewer.relativeToAbsolute(e/2))),this.setParameters({clipNear:t,clipFar:r,fogNear:i,fogFar:n}))},Um.prototype.getZoomForBox=function(e){var t=e.getSize(Fm),r=Math.max(t.x,t.y,t.z),i=Math.min(t.x,t.y,t.z),n=r+Math.sqrt(i),o=Wo(this.viewer.perspectiveCamera.fov),a=this.viewer.width,s=this.viewer.height,c=s=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}ds.add("shape",jm);var Vm=function(e){function t(t){var r=this;e.call(this,t),t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=So(t.reverse,!0)),this.scalePerModel={},t.structure.eachModel((function(e){r.parameters.domain=[e.atomOffset,e.atomEnd],r.scalePerModel[e.index]=r.getScale()}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return this.scalePerModel[e.modelIndex](e.index)},t}(sa);Gm([aa],Vm.prototype,"atomColor",null),ss.add("atomindex",Vm);var $m=function(e){function t(t){if(e.call(this,t),t.scale||(this.parameters.scale="OrRd"),!t.domain){var r,i=1/0,n=-1/0;t.sele&&(r=new Na(t.sele)),t.structure.eachAtom((function(e){var t=e.bfactor;i=Math.min(i,t),n=Math.max(n,t)}),r),this.parameters.domain=[i,n]}this.bfactorScale=this.getScale()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return this.bfactorScale(e.bfactor)},t}(sa);Gm([aa],$m.prototype,"atomColor",null),ss.add("bfactor",$m);var Hm=function(e){function t(t){var r=this;e.call(this,t),this.chainidDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((function(e){var t=0,i={};e.eachChain((function(e){void 0===i[e.chainid]&&(i[e.chainid]=t,t+=1)})),r.parameters.domain=[0,t-1],r.chainidDictPerModel[e.index]=i,r.scalePerModel[e.index]=r.getScale()}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){var t=this.chainidDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainid])},t}(sa);Gm([aa],Hm.prototype,"atomColor",null),ss.add("chainid",Hm);var Wm=function(e){function t(t){var r=this;e.call(this,t),this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((function(e){r.parameters.domain=[e.chainOffset,e.chainEnd],r.scalePerModel[e.index]=r.getScale()}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return this.scalePerModel[e.modelIndex](e.chainIndex)},t}(sa);Gm([aa],Wm.prototype,"atomColor",null),ss.add("chainindex",Wm);var qm=function(e){function t(t){var r=this;e.call(this,t),this.chainnameDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((function(e){var t=0,i={};e.eachChain((function(e){void 0===i[e.chainname]&&(i[e.chainname]=t,t+=1)})),r.parameters.domain=[0,t-1],r.chainnameDictPerModel[e.index]=i,r.scalePerModel[e.index]=r.getScale()}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){var t=this.chainnameDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainname])},t}(sa);Gm([aa],qm.prototype,"atomColor",null),ss.add("chainname",qm);var Xm=function(e){function t(t){e.call(this,t),this.rsrzDict={},this.rsccDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});var r=t.structure.validation;r&&(this.rsrzDict=r.rsrzDict,this.rsccDict=r.rsccDict)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){var t=e.resno+"";e.inscode&&(t+="^"+e.inscode),e.chainname&&(t+=":"+e.chainname),t+="/"+e.modelIndex;var r=this.rsrzDict[t];if(void 0!==r)return this.rsrzScale(r);var i=this.rsccDict[t];return void 0!==i?this.rsccScale(i):9474192},t}(sa);Gm([aa],Xm.prototype,"atomColor",null),ss.add("densityfit",Xm);var Ym={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};var Zm=function(e){function t(t){var r=this;e.call(this,t),this.delta=new Y,this.hCharges=[],t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(t.structure.atomCount);var i=[];t.structure.eachAtom((function(e){var t;if(r.charges[e.index]=(null!==(t=e).partialCharge?t.partialCharge:t.isProtein()&&(Ym[t.resname]&&Ym[t.resname][t.atomname]||Ym.backbone[t.atomname])||0)*e.occupancy,"N"===e.atomname){if(e.bondCount>=3)return;if(e.bondToElementCount(1))return;var n=function(e,t){void 0===t&&(t=new Y);var r=!1,i=!1,n=!1;return t.set(2*e.x,2*e.y,2*e.z),e.eachBondedAtom((function(e){if(!r)return"H"===e.atomname?(t.set(e.x,e.y,e.z),void(r=!0)):void(i||"CA"!==e.atomname?n||"C"!==e.atomname||(n=!0,t.sub(e)):(t.sub(e),i=!0))})),r?t:i&&n?(t.normalize(),t.multiplyScalar(1.04),t.add(e),t):void 0}(e);void 0!==n&&(i.push(n),r.hCharges.push(.25*e.occupancy))}}));var n=t.structure.getBoundingBox();n.expandByScalar(1.04),this.hStore=function(e){for(var t=e.length,r=new Float32Array(t),i=new Float32Array(t),n=new Float32Array(t),o=0;o>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135)>>24}(i[e.atomname]||0):t=this.geoDict[r]||0;return 0===t?2188972:1===t?16703627:2===t?16018755:t>=3?10813478:9474192},t}(sa);Gm([aa],tg.prototype,"atomColor",null),ss.add("geoquality",tg);var rg=function(e){function t(t){e.call(this,t),this.resHF={},t.scale||(this.parameters.scale="RdYlGn");for(var r in El)this.resHF[r]=El[r][0];if(this.defaultResidueHydrophobicity=Dl[0],!t.domain){var i=1/0,n=-1/0;for(var o in this.resHF){var a=this.resHF[o];i=Math.min(i,a),n=Math.max(n,a)}this.parameters.domain=[i,0,n]}this.hfScale=this.getScale()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return this.hfScale(this.resHF[e.resname]||this.defaultResidueHydrophobicity)},t}(sa);Gm([aa],rg.prototype,"atomColor",null),ss.add("hydrophobicity",rg);var ig=function(e){function t(t){e.call(this,t),t.scale||(this.parameters.scale="rainbow"),t.domain||(this.parameters.domain=[0,t.structure.modelStore.count]),this.modelindexScale=this.getScale()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return this.modelindexScale(e.modelIndex)},t}(sa);Gm([aa],ig.prototype,"atomColor",null),ss.add("modelindex",ig);var ng=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){switch(e.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}},t}(sa);Gm([aa],ng.prototype,"atomColor",null),ss.add("moleculetype",ng);var og=function(e){function t(t){e.call(this,t),t.scale||(this.parameters.scale="PuBu"),t.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return this.occupancyScale(e.occupancy)},t}(sa);Gm([aa],og.prototype,"atomColor",null),ss.add("occupancy",og);var ag=function(e){function t(t){e.call(this,t),t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return this.partialchargeScale(e.partialCharge||0)},t}(sa);function sg(){return 16777215*Math.random()}Gm([aa],ag.prototype,"atomColor",null),ss.add("partialcharge",ag);var cg=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(){return sg()},t.prototype.volumeColor=function(){return sg()},t.prototype.positionColor=function(){return sg()},t}(sa);Gm([aa],cg.prototype,"atomColor",null),Gm([aa],cg.prototype,"volumeColor",null),Gm([aa],cg.prototype,"positionColor",null),ss.add("random",cg);var ug=function(e){function t(t){e.call(this,t),this.rciDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});var r=t.structure.validation;r&&(this.rciDict=r.rciDict)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){var t="["+e.resname+"]"+e.resno;e.chainname&&(t+=":"+e.chainname);var r=this.rciDict[t];return void 0!==r?this.rciScale(r):9474192},t}(sa);Gm([aa],ug.prototype,"atomColor",null),ss.add("randomcoilindex",ug);var lg=function(e){function t(t){var r=this;e.call(this,t),this.scalePerChain={},t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=So(t.reverse,!0)),t.structure.eachChain((function(e){r.parameters.domain=[e.residueOffset,e.residueEnd],r.scalePerChain[e.index]=r.getScale()}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return this.scalePerChain[e.chainIndex](e.residueIndex)},t}(sa);Gm([aa],lg.prototype,"atomColor",null),ss.add("residueindex",lg);var hg={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723},pg=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){return hg[e.resname]||16711935},t}(sa);Gm([aa],pg.prototype,"atomColor",null),ss.add("resname",pg);var dg=16711808,fg=10485888,mg=6291584,gg=16762880,vg=6324479,yg=16777215,bg=11403518,xg=16580962,_g=10921722,wg=function(e){function t(t){e.call(this,t),this.residueProxy=t.structure.getResidueProxy()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){var t=e.sstruc,r=this.residueProxy;return"h"===t?dg:"g"===t?fg:"i"===t?mg:"e"===t||"b"===t?gg:"t"===t?vg:(r.index=e.residueIndex,r.isDna()?bg:r.isRna()?xg:r.isSaccharide()?_g:r.isProtein()||"s"===t||"l"===t?yg:8421504)},t}(sa);Gm([aa],wg.prototype,"atomColor",null),ss.add("sstruc",wg);var Sg=function(e){function t(t){var r,i;e.call(this,t),t.scale||(this.parameters.scale="rwb"),this.atomData=null===(r=this.parameters.data)||void 0===r?void 0:r.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(e){var t,r=null===(t=this.atomData)||void 0===t?void 0:t[e.index];return void 0!==r?this.scale(r):this.parameters.value},t.prototype.bondColor=function(e,t){var r,i=null===(r=this.bondData)||void 0===r?void 0:r[e.index];return void 0!==i?this.scale(i):this.atomProxy?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value},t}(sa);Gm([aa],Sg.prototype,"atomColor",null),Gm([aa],Sg.prototype,"bondColor",null),ss.add("structuredata",Sg);var Ag=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.atomColor=function(){return this.parameters.value},t.prototype.bondColor=function(){return this.parameters.value},t.prototype.valueColor=function(){return this.parameters.value},t.prototype.volumeColor=function(){return this.parameters.value},t}(sa);Gm([aa],Ag.prototype,"atomColor",null),Gm([aa],Ag.prototype,"bondColor",null),Gm([aa],Ag.prototype,"valueColor",null),Gm([aa],Ag.prototype,"volumeColor",null),ss.add("uniform",Ag);var Mg=function(e){function t(t){e.call(this,t),this.valueScale=this.getScale()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.volumeColor=function(e){return this.valueScale(this.parameters.volume.data[e])},t}(sa);Gm([aa],Mg.prototype,"volumeColor",null),ss.add("value",Mg);var Cg=function(e){function t(t){e.call(this,t),this.vec=new Y,this.valueScale=this.getScale()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.positionColor=function(e){var t=this.parameters.volume;if(!t||!t.inverseMatrix)return this.parameters.value;var r=this.vec,i=t.data,n=t.nx,o=t.ny,a=n*o;r.copy(e),r.applyMatrix4(t.inverseMatrix);var s=Math.floor(r.x),c=Math.floor(r.y),u=Math.floor(r.z),l=(u*o+c)*n+s,h=l+1,p=l+n,d=l+a,f=p+1,m=d+1,g=p+a,v=g+1,y=i[l],b=i[h],x=i[p],_=i[d],w=i[f],S=i[m],A=i[g],M=i[v],C=r.x-s,P=r.y-c,T=r.z-u,I=Ko(y,b,C),E=Ko(_,S,C),D=Ko(x,w,C),L=Ko(A,M,C),O=Ko(I,D,P),R=Ko(E,L,P),k=Ko(O,R,T);return this.valueScale(k)},t}(sa);Gm([aa],Cg.prototype,"positionColor",null),ss.add("volume",Cg);var Pg=function(e){function t(t,r,i){var n=i||{};if(e.call(this,t,r,n),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:Jp.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new Na(n.sele),this.dataList=[],this.structure=t,this.structureView=this.structure.getView(this.selection),t.biomolDict){var o={default:"default","":t.unitcell?"AU":"FULL"};Object.keys(t.biomolDict).forEach((function(e){o[e]=e})),this.parameters.assembly={type:"select",options:o,rebuild:!0}}else this.parameters.assembly=null}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaultScale:{configurable:!0}};return r.defaultScale.get=function(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}},t.prototype.init=function(t){var r=this,i=t||{};i.colorScheme=So(i.colorScheme,"element"),this.setRadius(i.radius,i),this.radiusType=So(i.radiusType,"vdw"),this.radiusData=So(i.radiusData,{}),this.radiusSize=So(i.radiusSize,1),this.radiusScale=So(i.radiusScale,1),this.assembly=So(i.assembly,"default"),this.defaultAssembly=So(i.defaultAssembly,""),"auto"===i.quality&&(i.quality=this.getQuality()),e.prototype.init.call(this,i),this.selection.signals.stringChanged.add((function(){r.build()})),this.build()},t.prototype.setRadius=function(e,t){var r=Object.keys(Qp);return"string"==typeof e&&r.includes(e.toLowerCase())?t.radiusType=e:void 0!==e&&(t.radiusType="size",t.radiusSize=e),this},t.prototype.getAssembly=function(){var e="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[e]},t.prototype.getQuality=function(){var e,t=this.structureView,r=this.getAssembly();return e=r?r.getAtomCount(t):t.atomCount,Ka&&(e*=4),t.atomStore.count/t.residueStore.count<2&&(e*=10),e<15e3?"high":e<8e4?"medium":"low"},t.prototype.create=function(){var e=this;if(0!==this.structureView.atomCount)if(this.structureView.hasCoords()){this.needsBuild=!1;var t=this.getAssembly();if(t)t.partList.forEach((function(t,r){var i=t.getView(e.structureView);if(0!==i.atomCount){var n=e.createData(i,r);n&&(n.sview=i,n.instanceList=t.getInstanceList(),e.dataList.push(n))}}));else{var r=this.createData(this.structureView,0);r&&(r.sview=this.structureView,this.dataList.push(r))}}else this.needsBuild=!0},t.prototype.update=function(e){var t=this;!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((function(r){r.bufferList.length>0&&t.updateData(e,r)}),this):Object.assign(this.lazyProps.what,e)},t.prototype.updateData=function(e,t){this.build()},t.prototype.getColorParams=function(){return Object.assign(Object.assign({},e.prototype.getColorParams.call(this)),{structure:this.structure})},t.prototype.getRadiusParams=function(e){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}},t.prototype.getAtomParams=function(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)},t.prototype.getBondParams=function(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)},t.prototype.getAtomRadius=function(e){return this.structureView.atomSet.isSet(e.index)?new Jp(this.getRadiusParams()).atomRadius(e):0},t.prototype.setSelection=function(e,t){return this.selection.setString(e,t),this},t.prototype.setParameters=function(t,r,i){void 0===r&&(r={}),void 0===i&&(i=!1);var n=t||{};return this.setRadius(n.radius,n),void 0===n.radiusType&&void 0===n.radiusData&&void 0===n.radiusSize&&void 0===n.radiusScale||(r.radius=!0,es&&!this.disableImpostor||(i=!0)),void 0!==n.defaultAssembly&&n.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===n.assembly||"default"===n.assembly)&&(i=!0),e.prototype.setParameters.call(this,n,r,i),this},t.prototype.getParameters=function(){return Object.assign(e.prototype.getParameters.call(this),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})},t.prototype.attach=function(e){var t=this.viewer,r=this.bufferList;this.dataList.forEach((function(e){e.bufferList.forEach((function(i){r.push(i),t.add(i,e.instanceList)}))})),this.setVisibility(this.visible),e()},t.prototype.clear=function(){this.dataList.length=0,e.prototype.clear.call(this)},t.prototype.dispose=function(){this.structureView.dispose(),e.prototype.dispose.call(this)},Object.defineProperties(t.prototype,r),t}(vu),Tg=function(e){function t(t,r,i){e.call(this,t,r,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){var r=t||{};this.labelVisible=So(r.labelVisible,!0),this.labelSize=So(r.labelSize,2),this.labelColor=So(r.labelColor,16777215),this.labelFontFamily=So(r.labelFontFamily,"sans-serif"),this.labelFontStyle=So(r.labelFontstyle,"normal"),this.labelFontWeight=So(r.labelFontWeight,"bold"),this.labelsdf=So(r.labelsdf,"Chrome"===Xa),this.labelXOffset=So(r.labelXOffset,0),this.labelYOffset=So(r.labelYOffset,0),this.labelZOffset=So(r.labelZOffset,.5),this.labelAttachment=So(r.labelAttachment,"bottom-left"),this.labelBorder=So(r.labelBorder,!1),this.labelBorderColor=So(r.labelBorderColor,"lightgrey"),this.labelBorderWidth=So(r.labelBorderWidth,.15),this.labelBackground=So(r.labelBackground,!1),this.labelBackgroundColor=So(r.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=So(r.labelBackgroundMargin,.5),this.labelBackgroundOpacity=So(r.labelBackgroundOpacity,1),this.labelFixedSize=So(r.labelFixedSize,!1),this.lineOpacity=So(r.lineOpacity,1),this.linewidth=So(r.linewidth,2),e.prototype.init.call(this,r)},t.prototype.update=function(t){t.position?this.build():e.prototype.update.call(this,t)},t.prototype.updateData=function(e,t){var r={};if(e&&!e.labelSize||Object.assign(r,{size:Zs(this.n,this.labelSize)}),!e||e.labelColor){var i=new pt(this.labelColor);Object.assign(r,{color:Ks(this.n,i.r,i.g,i.b)})}this.textBuffer.setAttributes(r)},t.prototype.setParameters=function(t,r,i){return void 0===r&&(r={}),void 0===i&&(i=!1),t&&t.labelSize&&(r.labelSize=!0),t&&(t.labelColor||0===t.labelColor)&&(r.labelColor=!0,i=!0),e.prototype.setParameters.call(this,t,r,i),t&&void 0!==t.opacity&&this.textBuffer.setParameters({opacity:1}),t&&void 0!==t.labelVisible&&this.setVisibility(this.visible),this},t.prototype.setVisibility=function(t,r){return e.prototype.setVisibility.call(this,t,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),r||this.viewer.requestRender(),this},t.prototype.getLabelBufferParams=function(t){return void 0===t&&(t={}),e.prototype.getBufferParams.call(this,Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},t,{opacity:1}))},t.prototype.getAtomRadius=function(){return 0},t}(Pg);function Ig(e,t){var r=e.getAtomProxy(),i=new Na,n=t.length;if(0===n)return new Float32Array(0);var o=t[0].length,a=e.getAtomSet(),s=new Float32Array(n*o*3),c=0;return t.forEach((function(t){for(var n=!1,u=0;u 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Og={};var Rg={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024},kg=function(e){void 0===e&&(e={}),this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=Ao(e,Rg);var t=this.parameters;this.radius=t.size/8,this.padding=t.size/3;var r=this.lineHeight=t.size+2*t.outline+Math.round(t.size/4),i=this.maxWidth=t.width/4,n=this.canvas=document.createElement("canvas");n.width=i,n.height=r;var o=this.context=this.canvas.getContext("2d");o.font=t.style+" "+t.variant+" "+t.weight+" "+t.size+"px "+t.font,o.fillStyle="black",o.textAlign="left",o.textBaseline="bottom",o.lineJoin="round",this.gridOuter=new Float64Array(r*i),this.gridInner=new Float64Array(r*i),this.f=new Float64Array(Math.max(r,i)),this.d=new Float64Array(Math.max(r,i)),this.z=new Float64Array(Math.max(r,i)+1),this.v=new Int16Array(Math.max(r,i)),this.data=new Uint8Array(t.width*t.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=t.width,this.canvas2.height=t.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(var a=32;a<=126;++a)this.map(String.fromCharCode(a));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new Zn(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0};kg.prototype.map=function(e){var t=this.parameters;return void 0===this.mapped[e]&&(this.draw(e),this.currentX+this.scratchW>t.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>t.height&&console.warn("canvas to small"),this.mapped[e]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[e]},kg.prototype.get=function(e){return this.mapped[e]||this.placeholder},kg.prototype.draw=function(e){var t=this.parameters,r=this.lineHeight,i=t.outline,n=this.context,o=this.maxWidth,a=i,s=r-t.outline,c=n.measureText(e),u=Math.min(o,Math.ceil(c.width+2*a+1)),l=u*r;n.clearRect(0,0,u,r),n.fillText(e,a,s);for(var h=n.getImageData(0,0,u,r),p=h.data,d=0;d= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),hs.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Ug=Object.assign({linewidth:2},wp),jg=Object.assign({linewidth:{uniform:!0}},Sp),Gg=function(e){function t(t,r){void 0===r&&(r={}),e.call(this,t,r),this.parameterTypes=jg,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!t.color2&&t.color&&(t.color2=t.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new z},projectionMatrixInverse:{value:new ie}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(t),this.makeMapping()}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaultParameters:{configurable:!0}};return r.defaultParameters.get=function(){return Ug},t.prototype.setParameters=function(t){e.prototype.setParameters.call(this,t)},Object.defineProperties(t.prototype,r),t}(Ff);fs.add("wideline",Gg);var Vg=function(e){function t(t,r,i){e.call(this,t,r,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){var r=t||{};r.side=So(r.side,"double"),r.opacity=So(r.opacity,.5),this.atomTriple=So(r.atomTriple,[]),this.arcVisible=So(r.arcVisible,!0),this.sectorVisible=So(r.sectorVisible,!0),this.vectorVisible=So(r.vectorVisible,!0),e.prototype.init.call(this,r)},t.prototype.createData=function(e){if(e.atomCount&&this.atomTriple.length){var t=function(e,t){return function(e){for(var t=[],r=e.length/9,i=0;i radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Kg=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Qg=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),Jg=function(e){function t(t,r){void 0===r&&(r={}),e.call(this,"v3",t,r)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.mapping.get=function(){return Kg},r.mappingIndices.get=function(){return Qg},r.mappingIndicesSize.get=function(){return 12},r.mappingSize.get=function(){return 6},r.mappingItemSize.get=function(){return 3},Object.defineProperties(t.prototype,r),t}(kf),ev=Object.assign({openEnded:!1},wp),tv=Object.assign({openEnded:{updateShader:!0}},Sp),rv=function(e){function t(t,r){void 0===r&&(r={}),e.call(this,t,r),this.parameterTypes=tv,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new ie},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaultParameters:{configurable:!0}};return r.defaultParameters.get=function(){return ev},t.prototype.getDefines=function(t){var r=e.prototype.getDefines.call(this,t);return this.parameters.openEnded||(r.CAP=1),r},Object.defineProperties(t.prototype,r),t}(Jg);Object.assign({disableImpostor:!1},Xg,ev);var iv=function(e,t){return void 0===t&&(t={}),!e.color2&&e.color&&(e.color2=e.color),!es||t&&t.disableImpostor?new Zg(e,t):new rv(e,t)};fs.add("cylinder",iv);var nv=function(e){function t(t,r,i){e.call(this,t,r,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){var r=t||{};r.radiusSize=So(r.radiusSize,.5),r.colorValue=So(r.colorValue,"lightgreen"),r.useInteriorColor=So(r.useInteriorColor,!0),this.showAxes=So(r.showAxes,!0),this.showBox=So(r.showBox,!1),e.prototype.init.call(this,r)},t.prototype.getPrincipalAxes=function(){var e,t=this.getAssembly();return t&&(e=t.partList[0].getSelection()),this.structureView.getPrincipalAxes(e)},t.prototype.getAxesData=function(e){var t=this.getPrincipalAxes(),r=new pt(this.colorValue),i=0,n=0;this.showAxes&&(i+=6,n+=3),this.showBox&&(i+=8,n+=12);var o=new Float32Array(3*i),a=Ks(i,r.r,r.g,r.b),s=Zs(i,this.radiusSize),c=new Float32Array(3*n),u=new Float32Array(3*n),l=Ks(n,r.r,r.g,r.b),h=Zs(n,this.radiusSize),p=0;if(this.showAxes){var d=function(e,t){e.toArray(o,2*p),t.toArray(o,2*p+3),e.toArray(c,p),t.toArray(u,p),p+=3};d(t.begA,t.endA),d(t.begB,t.endB),d(t.begC,t.endC)}if(this.showBox){var f=new Y,m=t.getProjectedScaleForAtoms(e),g=m.d1a,v=m.d2a,y=m.d3a,b=m.d1b,x=m.d2b,_=m.d3b,w=2*p,S=function(e,r,i){f.copy(t.center).addScaledVector(t.normVecA,e).addScaledVector(t.normVecB,r).addScaledVector(t.normVecC,i),f.toArray(o,w),w+=3};S(g,v,y),S(g,v,_),S(g,x,_),S(g,x,y),S(b,x,_),S(b,x,y),S(b,v,y),S(b,v,_);var A=p,M=function(e,t){f.fromArray(o,2*p+3*e).toArray(c,A),f.fromArray(o,2*p+3*t).toArray(u,A),A+=3};M(0,1),M(0,3),M(0,6),M(1,2),M(1,7),M(2,3),M(2,4),M(3,5),M(4,5),M(4,7),M(5,6),M(6,7)}var C=new Ah(t);return{vertex:{position:o,color:a,radius:s,picking:C},edge:{position1:c,position2:u,color:l,color2:l,radius:h,picking:C}}},t.prototype.create=function(){var e=this.getAxesData(this.structureView);this.sphereBuffer=new Uf(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new iv(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})},t.prototype.createData=function(e){},t.prototype.updateData=function(e,t){var r=this.getAxesData(t.sview),i={},n={};e&&!e.position||(Object.assign(i,{position:r.vertex.position}),Object.assign(n,{position1:r.edge.position1,position2:r.edge.position2})),e&&!e.color||(Object.assign(i,{color:r.vertex.color}),Object.assign(n,{color:r.edge.color,color2:r.edge.color})),e&&!e.radius||(Object.assign(i,{radius:r.vertex.radius}),Object.assign(n,{radius:r.edge.radius})),this.sphereBuffer.setAttributes(i),this.cylinderBuffer.setAttributes(n)},t}(Pg);us.add("axes",nv);var ov=function(e){function t(t,r,i){e.call(this,t,r,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){var r=t||{};r.radiusType=So(r.radiusType,"size"),r.radiusSize=So(r.radiusSize,.15),r.useInteriorColor=So(r.useInteriorColor,!0),this.aspectRatio=So(r.aspectRatio,2),this.lineOnly=So(r.lineOnly,!1),this.cylinderOnly=So(r.cylinderOnly,!1),this.multipleBond=So(r.multipleBond,"off"),this.bondSpacing=So(r.bondSpacing,1),this.bondScale=So(r.bondScale,.4),this.linewidth=So(r.linewidth,2),e.prototype.init.call(this,r)},t.prototype.getAtomRadius=function(t){return this.aspectRatio*e.prototype.getAtomRadius.call(this,t)},t.prototype.getAtomParams=function(t,r){var i=e.prototype.getAtomParams.call(this,t,r);return i.radiusParams.scale*=this.aspectRatio,i},t.prototype.getAtomData=function(e,t,r){return e.getAtomData(this.getAtomParams(t,r))},t.prototype.getBondParams=function(t,r){return r=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},r),e.prototype.getBondParams.call(this,t,r)},t.prototype.getBondData=function(e,t,r){return e.getBondData(this.getBondParams(t,r))},t.prototype.createData=function(e){var t=[];if(this.lineOnly)this.lineBuffer=new Gg(this.getBondData(e,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),t.push(this.lineBuffer);else{var r=new iv(this.getBondData(e),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(t.push(r),!this.cylinderOnly){var i=new Uf(this.getAtomData(e),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));t.push(i)}}return{bufferList:t}},t.prototype.updateData=function(e,t){"off"!==this.multipleBond&&e&&e.radius&&(e.position=!0);var r=this.getBondData(t.sview,e);if(this.lineOnly){var i={};e&&!e.position||Object.assign(i,{position1:r.position1,position2:r.position2}),e&&!e.color||Object.assign(i,{color:r.color,color2:r.color2}),t.bufferList[0].setAttributes(i)}else{var n={};if(e&&!e.position||Object.assign(n,{position1:r.position1,position2:r.position2}),e&&!e.color||Object.assign(n,{color:r.color,color2:r.color2}),e&&!e.radius||Object.assign(n,{radius:r.radius}),t.bufferList[0].setAttributes(n),!this.cylinderOnly){var o=this.getAtomData(t.sview,e),a={};e&&!e.position||Object.assign(a,{position:o.position}),e&&!e.color||Object.assign(a,{color:o.color}),e&&!e.radius||Object.assign(a,{radius:o.radius}),t.bufferList[1].setAttributes(a)}}},t.prototype.setParameters=function(t){void 0===t&&(t={});var r=!1,i={};return(t.aspectRatio||t.bondSpacing||t.bondScale)&&(Object.assign(i,{radius:!0}),es&&!this.disableImpostor||(r=!0)),e.prototype.setParameters.call(this,t,i,r),this},t}(Pg);us.add("ball+stick",ov);var av=function(e){function t(t,r,i){e.call(this,t,r,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){var r=t||{};r.aspectRatio=So(r.aspectRatio,1),r.radiusSize=So(r.radiusSize,.25),e.prototype.init.call(this,r)},t.prototype.getAtomRadius=function(t){return t.isTrace()?e.prototype.getAtomRadius.call(this,t):0},t.prototype.getAtomData=function(e,t,r){return e.getBackboneAtomData(this.getAtomParams(t,r))},t.prototype.getBondData=function(e,t,r){return e.getBackboneBondData(this.getBondParams(t,r))},t}(ov);us.add("backbone",av);var sv=function(e){function t(t,r,i){e.call(this,t,r,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.init=function(t){var r=t||{};r.aspectRatio=So(r.aspectRatio,1),r.radiusSize=So(r.radiusSize,.3),e.prototype.init.call(this,r)},t.prototype.getAtomData=function(e,t,r){return e.getRungAtomData(this.getAtomParams(t,r))},t.prototype.getBondData=function(e,t,r){var i=this.getBondParams(t,r);return Object.assign(i.colorParams,{rung:!0}),e.getRungBondData(i)},t}(ov);us.add("base",sv);var cv=function(e,t){this.m=e,this.tension=t,this.dt=1/this.m,this.delta=1e-4,this.vec1=new Y,this.vec2=new Y,this.vDir=new Y,this.vTan=new Y,this.vNorm=new Y,this.vBin=new Y,this.m2=Math.ceil(this.m/2)};cv.prototype.interpolateToArr=function(e,t,r,i,n,o,a){o[a+0]=Qo(e.x,t.x,r.x,i.x,n,this.tension),o[a+1]=Qo(e.y,t.y,r.y,i.y,n,this.tension),o[a+2]=Qo(e.z,t.z,r.z,i.z,n,this.tension)},cv.prototype.interpolateToVec=function(e,t,r,i,n,o){o.x=Qo(e.x,t.x,r.x,i.x,n,this.tension),o.y=Qo(e.y,t.y,r.y,i.y,n,this.tension),o.z=Qo(e.z,t.z,r.z,i.z,n,this.tension)},cv.prototype.interpolatePosition=function(e,t,r,i,n,o){for(var a=0;a1&&(u=1),this.interpolateToVec(e,t,r,i,c,this.vec1),this.interpolateToVec(e,t,r,i,u,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(n,l)}},cv.prototype.vectorSubdivide=function(e,t,r,i,n){for(var o,a=t.next(),s=t.next(),c=t.next(),u=t.size,l=u-1,h=i||0,p=0;p0&&i0;Iu(w,y,S);var D=Tu(w,x)<0;if(Nu(w,x,Tu(x,b)),Iu(A,b,w),Nu(w,x,Tu(x,_)),Iu(M,_,w),0!==Ru(A)&&0!==Ru(M)){Bu(A,A),Bu(M,M);var L=o[E]=function(e,t){var r=e[0],i=e[1],n=e[2],o=t[0],a=t[1],s=t[2],c=i*s-n*a,u=n*o-r*s,l=r*a-i*o,h=Math.sqrt(c*c+u*u+l*l),p=r*o+i*a+n*s;return Math.atan2(h,p)}(A,M);s[E]=(Ws*L).toFixed(1)+String.fromCharCode(176),Pu(T,A,x),Bu(T,T),Tu(T,M)<0&&Gu(T,T),Eg(w,S,A,T,L/2),Lu(w,a,3*E);var O=Math.ceil(L/r),R=O+(t.extendLine?4:2),k=t.extendLine?36:0,N=new Float32Array(3*R),B=new Float32Array(3*R),F=new Float32Array(9*O),z=new Float32Array(k);c[E]=N,u[E]=B,l[E]=F,h[E]=z,t.extendLine&&(n?(Iu(w,m,v),Bu(w,w),Nu(C,w,1/Tu(A,w)),Eu(C,C,v)):(Nu(C,b,1/Tu(A,b)),Eu(C,C,g)),D?(Iu(w,y,g),Bu(w,w),Nu(P,w,1/Tu(M,w)),Eu(P,P,g)):(Nu(P,_,1/Tu(M,_)),Eu(P,P,v))),Eu(I,S,A);var U=0;t.extendLine?(Lu(m,N,U),Lu(C,B,U),Lu(C,N,U+=3),Lu(I,B,U),U+=3,Lu(C,z,0),Lu(I,z,3),Lu(n?v:g,z,6),Lu(n?v:g,z,9),Lu(I,z,12),Lu(S,z,15)):(Lu(S,N,U),Lu(I,B,U),U+=3);for(var j=function(e,t){var r=9*t;Lu(S,F,r),Lu(I,F,r+3),Lu(I,N,U),Eg(I,S,A,T,e),Lu(I,F,r+6),Lu(I,B,U),U+=3},G=0,V=r;V=3&&(n=xv(o)),void 0!==n&&r.push(n)}return this.frontHistogramBinBordersBuffer=s(r.map((function(e){return e.frontHistogramBinBorders})),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=s(r.map((function(e){return e.backHistogramBinBorders})),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=s(r.map((function(e){return e.adjacentBondArrows})),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=s(r.map((function(e){return e.distantBondArrows})),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=c(r.map((function(e){return e.opaqueMiddleDisc})),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=c(r.map((function(e){return e.frontHistogram})),this.getHistogramBufferParameters()),this.backHistogramBuffer=c(r.map((function(e){return e.backHistogram})),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}function a(e){for(var t=e.map((function(e){return e.length})),r=new Float32Array(oc(t)),i=0,n=0;n0&&(i-=h,o=o.subarray(0,3*i));var d=new pl(c.count,!0);return{text:n,position:o,bondSet:d,bondStore:c}},t.prototype.getBondData=function(e,t,r){var i=e.getBondData(this.getBondParams(t,r));return i.picking&&(i.picking=new Ih(i.picking.array,i.picking.structure,r.bondStore)),i},t.prototype.createData=function(e){if(e.atomCount&&this.atomPair.length){var t=this.atomPair.length,r=new pt(this.labelColor),i=this.getDistanceData(e,this.atomPair);this.textBuffer=new zg({position:i.position,size:Zs(t,this.labelSize),color:Ks(t,r.r,r.g,r.b),text:i.text},this.getLabelBufferParams());var n={bondSet:i.bondSet,bondStore:i.bondStore},o=this.getBondData(e,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new iv(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Gg($u(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:i.bondSet,bondStore:i.bondStore,position:i.position,bufferList:[this.textBuffer,this.distanceBuffer]}}},t.prototype.updateData=function(t,r){e.prototype.updateData.call(this,t,r);var i={bondSet:r.bondSet,bondStore:r.bondStore},n=this.getBondData(r.sview,t,i),o={};t&&!t.color||Object.assign(o,{color:n.color,color2:n.color2}),t&&!t.radius||Object.assign(o,{radius:n.radius}),this.distanceBuffer.setAttributes(o)},t.prototype.setParameters=function(t){return e.prototype.setParameters.call(this,t,{},!1),this.useCylinder||(t&&t.lineOpacity&&this.distanceBuffer.setParameters({opacity:t.lineOpacity}),t&&void 0!==t.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),t&&t.linewidth&&this.distanceBuffer.setParameters({linewidth:t.linewidth})),this},t}(Tg);function wv(e){return 2*(e.position.length/3)*3}us.add("distance",_v);var Sv=Object.assign({scale:1,color:"grey"},wp),Av=function(e){function t(t,r){void 0===r&&(r={}),e.call(this,{position:new Float32Array(wv(t)),color:new Float32Array(wv(t))},r),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";var i=new pt(this.parameters.color),n=this.geometry.attributes;Ks(wv(t)/3,i.r,i.g,i.b,n.color.array),this.setAttributes(t)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaultParameters:{configurable:!0}};return r.defaultParameters.get=function(){return Sv},t.prototype.setAttributes=function(e){void 0===e&&(e={});var t,r,i,n=this.geometry.attributes;e.position&&e.vector&&(t=e.position,r=e.vector,i=n.position.array,n.position.needsUpdate=!0);var o=this.size/2,a=this.parameters.scale;if(t&&r)for(var s=0;s radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),hs.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Pv=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Tv=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]),Iv=function(e){function t(t,r){void 0===r&&(r={}),e.call(this,"v3",t,r)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.mapping.get=function(){return Pv},r.mappingIndices.get=function(){return Tv},r.mappingIndicesSize.get=function(){return 36},r.mappingSize.get=function(){return 8},r.mappingItemSize.get=function(){return 3},Object.defineProperties(t.prototype,r),t}(kf),Ev=Object.assign({shrink:.14},wp),Dv=Object.assign({shrink:{uniform:!0}},Sp),Lv=function(e){function t(t,r){void 0===r&&(r={}),e.call(this,t,r),this.parameterTypes=Dv,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new ie},modelViewProjectionMatrixInverse:{value:new ie},modelViewMatrixInverseTranspose:{value:new ie},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaultParameters:{configurable:!0}};return r.defaultParameters.get=function(){return Ev},Object.defineProperties(t.prototype,r),t}(Iv);Object.assign({disableImpostor:!1},Xg,Ev);var Ov=function(e,t){return void 0===t&&(t={}),!es||t&&t.disableImpostor?(e.radius=function(e,t){for(var r=e.length,i=new Float32Array(r),n=0;n0;)i[s]=arguments[s+3];for(var c=a(e,t,r),u=0;uu?p[m]=-1:(c=Math.sqrt(u-s),p[m]=Math.floor(c)),++m;f[g]=h,d[g]=p}}function M(r){var i,n,o,s,h,m,y,x,_,w,S,A,M,C,P,T,I,E,D=3*r,L=r;i=Math.floor(.5+a*(e[D]+p[0])),n=Math.floor(.5+a*(e[D+1]+p[1])),o=Math.floor(.5+a*(e[D+2]+p[2]));var O,R=t[L],k=d[R],N=0,B=u*l,F=f[R];for(w=0;w=c||C>=u||P>=l)){var z=M*B+C*l+P;if(g)if(1&v[z]){if(1&v[z]){var U=b[z];U!==D&&y*y+x*x+_*_<(s=i+y-Math.floor(.5+a*(e[U]+p[0])))*s+(h=n+x-Math.floor(.5+a*(e[U+1]+p[1])))*h+(m=o+_-Math.floor(.5+a*(e[U+2]+p[2])))*m&&(b[z]=r)}}else v[z]|=1,b[z]=r;else v[z]|=1}N++}}function C(t){var r,i;for(console.time("EDTSurface fillvoxels"),r=0,i=v.length;r=c||S>=u||A>=l)){var B=w*N+S*l+A;if(2&v[B]){if(g){var F=b[B];y*y+x*x+_*_<(s=Math.floor(.5+a*(e[F]+p[0])))*s+(h=Math.floor(.5+a*(e[F+1]+p[1])))*h+(m=Math.floor(.5+a*(e[F+2]+p[2])))*m&&(b[B]=r)}}else v[B]|=2,g&&(b[B]=r)}R++}}function T(){var e,t,r,i;console.time("EDTSurface fastdistancemap");var n,o=Fv(c,u,l,Uint16Array,3),a=u*l,h=m*m,p=0;for(e=0;e0);var w,S=s*s,A=new Uint16Array(3);for(e=0;e=S)||(v[n]|=4,g&&2&v[n]&&(o.toArray(e,t,r,A),w=A[0]*a+A[1]*l+A[2],b[n]=b[w])));console.timeEnd("EDTSurface fastdistancemap")}function I(e,t,r,i){var n,o,a,s,h,p,d,f,m,g,b,x,_=new Uint16Array(3),w=0;if(0===r)return w;var A=-1,M=-1,C=-1,P=u*l;for(d=0,m=r;d-1&&M-1&&C-1&&(1&v[b=A*P+l*M+C]&&!(2&v[b])?(t.fromArray(A,M,C,_),g=(s=A-_[0])*s+(h=M-_[1])*h+(p=C-_[2])*p,y[b]=g,v[b]|=2,v[b]|=4,i[w]=A,i[w+1]=M,i[w+2]=C,w+=3):1&v[b]&&2&v[b]&&(g=(s=A-_[0])*s+(h=M-_[1])*h+(p=C-_[2])*p)-1&&M-1&&C-1&&(1&v[b=A*P+l*M+C]&&!(2&v[b])?(t.fromArray(A,M,C,_),g=(s=A-_[0])*s+(h=M-_[1])*h+(p=C-_[2])*p,y[b]=g,v[b]|=2,v[b]|=4,i[w]=A,i[w+1]=M,i[w+2]=C,w+=3):1&v[b]&&2&v[b]&&(g=(s=A-_[0])*s+(h=M-_[1])*h+(p=C-_[2])*p)-1&&M-1&&C-1&&(1&v[b=A*P+l*M+C]&&!(2&v[b])?(t.fromArray(A,M,C,_),g=(s=A-_[0])*s+(h=M-_[1])*h+(p=C-_[2])*p,y[b]=g,v[b]|=2,v[b]|=4,i[w]=A,i[w+1]=M,i[w+2]=C,w+=3):1&v[b]&&2&v[b]&&(g=(s=A-_[0])*s+(h=M-_[1])*h+(p=C-_[2])*p)-1&&a-1&&h-1&&sE&&(E=R)}return{neighbourListLength:27*E+1,withinRadii:function(n,o,a,s,h){for(var p=0,d=f(n,c),m=f(o,u),g=f(a,l),v=Math.max(0,d-1),_=Math.max(0,m-1),S=Math.max(0,g-1),A=Math.min(y,d+2),M=Math.min(b,m+2),I=Math.min(x,g+2),E=v;Ep&&(p=l[O]);var R;R=dp(I,E,p,f,0),f=R.scaleFactor,v=R.dim,y=R.matrix,T=Math.max(5,2+Math.floor(d*f)),b=Zs(v[0]*v[1]*v[2],-1001),x=new Int32Array(b.length),_=new Float32Array(v[0]),w=new Float32Array(v[1]),S=new Float32Array(v[2]),B(_,I[0],1/f),B(w,I[1],1/f),B(S,I[2],1/f),function(){var e=0,t=2*Math.PI/g;M=new Float32Array(g),A=new Float32Array(g);for(var r=0;r=0;){if(o!==i&&o!==n&&z(o,e,t,r))return D=o,o;o=P[++a]}return D=-1,-1}function z(t,r,i,n){var o=3*t,a=h[t],s=e[o]-r,c=e[o+1]-i,u=e[o+2]-n;return s*s+c*c+u*u0&&h=0;)e0)continue;var ye=void 0,be=void 0,xe=void 0,_e=void 0,we=0;if(z){if(we=10===(_e=l.split(Ky)).length?1:0,y=_e[2],X&&"CA"!==y)continue;ye=parseFloat(_e[6-we]),be=parseFloat(_e[7-we]),xe=parseFloat(_e[8-we])}else{if(y=l.substr(12,4).trim(),X&&"CA"!==y)continue;ye=parseFloat(l.substr(30,8)),be=parseFloat(l.substr(38,8)),xe=parseFloat(l.substr(46,8))}if(q){var Se=3*a;if(o[Se+0]=ye,o[Se+1]=be,o[Se+2]=xe,a+=1,K)continue}var Ae=void 0;z?(p=parseInt(_e[1]),Ae="",b="H"===l[0]?1:0,d=we?"":_e[4],f=parseInt(_e[5-we]),v="",m=_e[3],_="",g=1):(p=parseInt(l.substr(6,5),$),V&&99999===p&&($=16),b="H"===l[0]?1:0,d=l[21].trim(),f=parseInt(l.substr(22,4),H),V&&9999===f&&(H=16),v=l[26].trim(),m=l.substr(17,4).trim()||"MOL",x=parseFloat(l.substr(60,6)),_=l[16].trim(),g=parseFloat(l.substr(54,6)),t||(U?(Ae=l.substr(76,3).trim())in $l&&(Ae=$l[Ae]):(Ae=l.substr(76,2).trim(),d||(d=l.substr(72,4).trim())),w=parseInt((l.substr(79,1)+l.substr(78,1)).trim()))),pe.growIfFull(),pe.atomTypeId[me]=he.add(y,Ae),pe.x[me]=ye,pe.y[me]=be,pe.z[me]=xe,pe.serial[me]=p,pe.altloc[me]=_.charCodeAt(0),pe.occupancy[me]=isNaN(g)?0:g,z?(pe.partialCharge[me]=parseFloat(_e[9-we]),pe.radius[me]=parseFloat(_e[10-we])):(pe.bfactor[me]=isNaN(x)?0:x,U&&(pe.partialCharge[me]=parseFloat(l.substr(70,6))),isFinite(w)&&(pe.formalCharge||pe.addField("formalCharge",1,"int8"),pe.formalCharge[me]=w));var Me=Qy(f,d,v);!b||oe[Me]||Yy.includes(m)?O||R===d||(L=(D+=1).toString()):R===d&&N===m&&(Fl.includes(m)||k===f&&B===v)||(L=(D+=1).toString(),k=f,N=m,B=v),G.addAtom(ge,d,L,m,f,b,void 0,v),J[p]=me,me+=1,O=!1,R=d}else if("CONECT"===h){var Ce=J[parseInt(l.substr(6,5))],Pe=[11,16,21,26],Te={};if(void 0===Ce)continue;for(var Ie=0;Ie<4;++Ie){var Ee=parseInt(l.substr(Pe[Ie],5));if(!Number.isNaN(Ee)&&void 0!==(Ee=J[Ee]))if(Ce0)continue;var ae=ne[c].replace(rb,"");if(P&&"CA"!==ae)continue;var se=parseFloat(ne[y]),ce=parseFloat(ne[b]),ue=parseFloat(ne[x]);if(C){var le=3*r;if(t[le+0]=se,t[le+1]=ce,t[le+2]=ue,r+=1,q>0)continue}var he=ne[u],pe=parseInt(ne[-1!==a?a:s]),de=ne[v];de="?"===de?"":de;var fe=ne[o],me=ne[l],ge="H"===ne[d][0]?1:0,ve=ne[m],ye=parseFloat(ne[_]),be=parseFloat(ne[w]),xe=ne[p];if(xe="."===xe?"":xe,$.growIfFull(),$.atomTypeId[W]=V.add(ae,ve),$.x[W]=se,$.y[W]=ce,$.z[W]=ue,$.serial[W]=parseInt(ne[f]),$.bfactor[W]=isNaN(ye)?0:ye,$.occupancy[W]=isNaN(be)?0:be,$.altloc[W]=xe.charCodeAt(0),A.addAtom(q,fe,me,he,pe,ge,void 0,de),e.Debug){var _e=E[me];void 0!==_e&&_e!==fe&&e.Debug&&is.warn(_e,fe)}E[me]=fe;var we=ne[h];D[we]||(D[we]=new Set),D[we].add(S.chainStore.count-1),W+=1}else{var Se=n.match(tb),Ae=Se.length;F===B.length&&(F=0);for(var Me=0;Med*d)return i.growIfFull(),i.atomTypeId[f]=i.atomTypeId[e],i.x[f]=h.x,i.y[f]=h.y,i.z[f]=h.z,i.occupancy[f]=i.occupancy[e],i.serial[f]=f,i.altloc[f]="A".charCodeAt(0),r.addAtom(0,"","","HET",1,!0),void(f+=1)}}}))},y=0;y0){o=o.split("(");var c=s(o[0]),u=s(o[1]);Object.keys(c).forEach((function(e){Object.keys(u).forEach((function(t){var r=new ie;r.multiplyMatrices(c[e],u[t]),i[e+"x"+t]=r}))}))}else i=s(o);var l=[];for(var h in i)l.push(i[h]);var p=e;/^(0|[1-9][0-9]*)$/.test(p)&&(p="BU"+p);for(var d=a.asym_id_list[t].split(","),f=0,m=d.length;fS){var A=w;w=S,S=A;var M=m;m=x,x=M}if(0!==w&&0!==S)for(var C=0;Cb)continue}p=P.substr(5,5).trim(),d=parseInt(P.substr(0,5)),f=parseInt(P.substr(15,5)),_.growIfFull(),_.atomTypeId[w]=x.add(h),_.x[w]=E,_.y[w]=D,_.z[w]=L,_.serial[w]=f,n.addAtom(S,"","",p,d,0,"l"),w+=1}}}(0,e.length,e)})),n.finalize(),i.finalizeAtoms(),Bd(i),Fd(i),i.finalizeBonds(),Rd(i),e.Debug&&is.timeEnd("GroParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Vy);ls.add("gro",lb);var hb=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function pb(e,t,r){return t?new e(t.buffer,t.byteOffset,t.byteLength/(r||1)):void 0}function db(e){return pb(DataView,e)}function fb(e){return pb(Int8Array,e)}function mb(e){return pb(Int32Array,e,4)}function gb(e,t){var r=e.length/2;t||(t=new Int16Array(r));for(var i=0,n=0;io&&++s;t=new Int32Array(s)}for(r=0,i=0;rn){for(var o=[],a=0;a0&&(p.biomolDict.NCS=ce)}var le=d.unitCell;le&&Array.isArray(le)&&le[0]?p.unitcell=new qy({a:le[0],b:le[1],c:le[2],alpha:le[3],beta:le[4],gamma:le[5],spacegroup:d.spaceGroup}):p.unitcell=void 0,Gd(p,!0),jd(p,!0),p.finalizeAtoms(),p.finalizeBonds(),Vd(p),e.Debug&&is.timeEnd("MmtfParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Vy);ls.add("mmtf",Tb);var Ib=/\s+/,Eb={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0},Db=function(t){function r(){t.apply(this,arguments)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"mol2"},r.prototype._parse=function(){e.Debug&&is.time("Mol2Parser._parse "+this.name);var t,r,i=this.structure,n=this.structureBuilder,o=this.firstModelOnly,a=this.asTrajectory,s=i.frames,c=!1,u=i.atomMap,l=i.atomStore;l.resize(Math.round(this.streamer.data.length/60)),l.addField("partialCharge",1,"float32");var h=0,p=0,d=0,f=-1,m=0,g=0,v=i.getAtomProxy(),y=i.getAtomProxy();this.streamer.eachChunkOfLines((function(e){!function(e,b,x){for(var _=e;_MOLECULE"===w?(g=1,p=0,++f):"@ATOM"===w?(g=2,d=l.count,a&&(r=0,t=new Float32Array(3*m),s.push(t),f>0&&(c=!0))):g="@BOND"===w?3:0;else if(1===g){if(0===p)i.title=w,i.id=w;else if(1===p){var S=w.split(Ib);m=parseInt(S[0])}++p}else if(2===g){var A=w.split(Ib);if(o&&f>0)continue;var M=parseFloat(A[2]),C=parseFloat(A[3]),P=parseFloat(A[4]);if(a){var T=3*r;if(t[T+0]=M,t[T+1]=C,t[T+2]=P,r+=1,c)continue}var I=A[0],E=A[1],D=A[5].split(".")[0],L=A[6]?parseInt(A[6]):1,O=A[7]?A[7]:"",R=A[8]?parseFloat(A[8]):0;l.growIfFull(),l.atomTypeId[h]=u.add(E,D),l.x[h]=M,l.y[h]=C,l.z[h]=P,l.serial[h]=I,l.partialCharge[h]=R,n.addAtom(f,"","",O,L,1),h+=1}else if(3===g){if(o&&f>0)continue;if(a&&f>0)continue;var k=w.split(Ib);v.index=parseInt(k[1])-1+d,y.index=parseInt(k[2])-1+d;var N=Eb[k[3]];i.bondStore.addBond(v,y,N)}}}(0,e.length,e)})),n.finalize(),i.finalizeAtoms(),Bd(i),jd(i,!0),Gd(i,!0),i.finalizeBonds(),qd(i),Rd(i),e.Debug&&is.timeEnd("Mol2Parser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Vy);ls.add("mol2",Db);var Lb=function(e){function t(){e.apply(this,arguments)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={type:{configurable:!0}};return r.type.get=function(){return"pdbqt"},Object.defineProperties(t.prototype,r),t}(Jy);ls.add("pdbqt",Lb);var Ob=function(e){function t(){e.apply(this,arguments)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={type:{configurable:!0}};return r.type.get=function(){return"pqr"},Object.defineProperties(t.prototype,r),t}(Jy);ls.add("pqr",Ob);var Rb=/> +<(.+)>/,kb=function(t){function r(){t.apply(this,arguments)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"sdf"},r.prototype._parse=function(){e.Debug&&is.time("SdfParser._parse "+this.name);var t=this.structure,r=this.structureBuilder,i=this.firstModelOnly,n=this.asTrajectory,o=this.streamer.peekLines(2);t.id=o[0].trim(),t.title=o[1].trim();var a,s,c=t.frames,u=!1,l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/50)),h.addField("formalCharge",1,"int8");var p,d,f,m,g,v,y,b,x,_,w,S,A,M,C=t.getAtomProxy(),P=t.getAtomProxy(),T=0,I=0,E=0,D=0,L=[],O=!1,R={};t.extraData.sdf=L;var k=!1,N=!1,B=!1,F=[],z=[],U=new Map;this.streamer.eachChunkOfLines((function(e){!function(e,o,j){for(var G=e;G-1)?U.clear():(d=parseInt(V.substr(0,3)),f=parseInt(V.substr(3,3)),y=(v=g=(m=4)+d)+f,n&&(s=0,a=new Float32Array(3*d),c.push(a),E>0&&(u=!0)));else if(k&&"COUNTS"===F[0])d=parseInt(F[1]),n&&(s=0,a=new Float32Array(3*d),c.push(a),E>0&&(u=!0));else if(k&&2==F.length)"ATOM"===F[1]?"BEGIN"===F[0]?N=!0:"END"===F[0]&&(N=!1):"BOND"===F[1]&&("BEGIN"===F[0]?B=!0:"END"===F[0]&&(B=!1));else if(N||!k&&I>=m&&I0)continue;var $=0;if(k){if(b=parseFloat(F[2]),x=parseFloat(F[3]),_=parseFloat(F[4]),S=F[1],A=parseInt(F[0]),U.set(A,T),w=S+A,F.length>6){var H=F.slice(6).find((function(e){return 0===e.indexOf("CHG=")}));H&&($=parseInt(H.substring(4)))}}else b=parseFloat(V.substr(0,10)),x=parseFloat(V.substr(10,10)),_=parseFloat(V.substr(20,10)),S=V.substr(31,3).trim(),w=S+(T-D+1);if(n){var W=3*s;if(a[W+0]=b,a[W+1]=x,a[W+2]=_,s+=1,u)continue}h.growIfFull(),h.atomTypeId[T]=l.add(w,S),h.x[T]=b,h.y[T]=x,h.z[T]=_,h.serial[T]=k?A:T,h.formalCharge[T]=$,r.addAtom(E,"","","HET",1,1),T+=1}else if(B||!k&&I>=v&&I0)continue;if(n&&E>0)continue;k?(C.index=U.get(parseInt(F[2])),P.index=U.get(parseInt(F[3])),M=parseInt(F[1])):(C.index=parseInt(V.substr(0,3))-1+D,P.index=parseInt(V.substr(3,3))-1+D,M=parseInt(V.substr(6,3))),t.bondStore.addBond(C,P,M)}else if("M CHG"===V.substr(0,6))for(var q=parseInt(V.substr(6,3)),X=0,Y=10;X"===V.charAt(0)&&(p=V.match(Rb))?(O=p[1],R[O]=[]):!1!==O&&V&&R[O].push(V);++I}}}(0,e.length,e)})),r.finalize(),t.finalizeAtoms(),t.finalizeBonds(),qd(t),e.Debug&&is.timeEnd("SdfParser._parse "+this.name)},r.prototype._postProcess=function(){qd(this.structure)},Object.defineProperties(r.prototype,i),r}(Vy);ls.add("sdf",kb),ls.add("sd",kb),ls.add("mol",kb);function Nb(e,t,r){return parseInt(e.substr(t,r).trim())}var Bb=function(t){function r(){t.apply(this,arguments)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"prmtop"},r.prototype._parse=function(){e.Debug&&is.time("PrmtopParser._parse "+this.name);var t=this.structure,r=this.structureBuilder,i=t.atomMap,n=t.atomStore;n.addField("partialCharge",1,"float32"),n.addField("radius",1,"float32");var o,a,s,c,u,l=[],h={},p=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];p.forEach((function(e){h[e]=0}));var d,f,m,g,v,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(e){!function(e,t,r){for(var i=e;i0)is.error("dcd format with fixed atoms unsupported, aborting");else{for(var v=a.NATOM,y=4*v,b=0,x=a.NSET;b=1&&(i.timeOffset=(a.ISTART-1)*i.deltaTime),e.Debug&&is.timeEnd("DcdParser._parse "+this.name)}},Object.defineProperties(r.prototype,i),r}($b);function Wb(e,t){if(e)throw new TypeError("Not a valid NetCDF v3.x file: "+t)}function qb(e){e.offset%4!=0&&e.skip(4-e.offset%4)}function Xb(e){var t=e.readUint32(),r=e.readChars(t);return qb(e),r}ls.add("dcd",Hb);var Yb=1,Zb=2,Kb=3,Qb=4,Jb=5,ex=6;function tx(e){switch(Number(e)){case Yb:return"byte";case Zb:return"char";case Kb:return"short";case Qb:return"int";case Jb:return"float";case ex:return"double";default:return"undefined"}}function rx(e){switch(Number(e)){case Yb:case Zb:return 1;case Kb:return 2;case Qb:case Jb:return 4;case ex:return 8;default:return-1}}function ix(e){switch(String(e)){case"byte":return Yb;case"char":return Zb;case"short":return Kb;case"int":return Qb;case"float":return Jb;case"double":return ex;default:return-1}}function nx(e,t){if(1!==e){for(var r=new Array(e),i=0;i6,"non valid type "+d);var f=e.readUint32(),m=e.readUint32();2===r&&(Wb(m>0,"offsets larger than 4GB not supported"),m=e.readUint32()),l[0]===t&&(o+=f),i[s]={name:c,dimensions:l,attributes:p,type:tx(d),size:f,offset:m,record:l[0]===t}}return{variables:i,recordStep:o}}(e,i.recordId,t);return r.variables=n.variables,r.recordDimension.recordStep=n.recordStep,r}function sx(e){var t,r=e.readUint32();if(0===r)return Wb(0!==e.readUint32(),"wrong empty tag for list of attributes"),[];Wb(12!==r,"wrong tag for list of attributes");var i=e.readUint32();t=new Array(i);for(var n=0;n6,"non valid type "+a);var s=e.readUint32(),c=ox(e,a,s);qb(e),t[n]={name:o,type:tx(a),value:c}}return t}var cx=function(e){var t=new Ds(e);t.setBigEndian(),Wb("CDF"!==t.readChars(3),"should start with CDF");var r=t.readByte();Wb(r>2,"unknown version"),this.header=ax(t,r),this.buffer=t},ux={version:{configurable:!0},recordDimension:{configurable:!0},dimensions:{configurable:!0},globalAttributes:{configurable:!0},variables:{configurable:!0}};ux.version.get=function(){return 1===this.header.version?"classic format":"64-bit offset format"},ux.recordDimension.get=function(){return this.header.recordDimension},ux.dimensions.get=function(){return this.header.dimensions},ux.globalAttributes.get=function(){return this.header.globalAttributes},ux.variables.get=function(){return this.header.variables},cx.prototype.hasDataVariable=function(e){return-1!==this.header.variables.findIndex((function(t){return t.name===e}))},cx.prototype.getDataVariable=function(e){var t;return Wb(void 0===(t="string"==typeof e?this.header.variables.find((function(t){return t.name===e})):e),"variable not found"),this.buffer.seek(t.offset),t.record?function(e,t,r){for(var i=ix(t.type),n=t.size?t.size/rx(i):1,o=r.length,a=new Array(o),s=r.recordStep,c=0;c=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),e.Debug&&is.timeEnd("NctrajParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}($b);ls.add("nctraj",lx),ls.add("ncdf",lx),ls.add("nc",lx);var hx=function(t){function r(){t.apply(this,arguments)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"trr"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){e.Debug&&is.time("TrrParser._parse "+this.name);for(var t=Bo(this.streamer.data),r=new DataView(t),i=this.frames,n=i.coordinates,o=i.boxes,a=i.times,s=0;;){s+=8;var c=r.getInt32(s);s+=4,s+=c;var u=r.getInt32(s+8),l=r.getInt32(s+12),h=r.getInt32(s+16),p=r.getInt32(s+28),d=r.getInt32(s+32),f=r.getInt32(s+36),m=r.getInt32(s+40);s+=52;var g=u/9,v=3*m;if(8===g?a.push(r.getFloat64(s)):a.push(r.getFloat32(s)),s+=2*g,u){var y=new Float32Array(9);if(8===g)for(var b=0;b<9;++b)y[b]=10*r.getFloat64(s),s+=8;else for(var x=0;x<9;++x)y[x]=10*r.getFloat32(s),s+=4;o.push(y)}if(s+=l,s+=h,p){var _=void 0;if(8===g){_=new Float32Array(v);for(var w=0;w>8&65280|M>>24&255}_=new Float32Array(t,s,v);for(var C=0;C=t.byteLength)break}a.length>=1&&(i.timeOffset=a[0]),a.length>=2&&(i.deltaTime=a[1]-a[0]),e.Debug&&is.timeEnd("TrrParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}($b);ls.add("trr",hx);var px=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function dx(e){for(var t=1,r=0;e>=t&&r<32;)r++,t<<=1;return r}var fx=new Uint8Array(32);function mx(e,t){var r=1,i=0;fx[0]=1;for(var n=0;n>=8;for(;0!==a;)fx[o++]=255&a,a>>=8;r=o}var s=1;for(r--;fx[r]>=s;)i++,s*=2;return i+8*r}function gx(e,t,r,i){for(var n=(1<=8;)c|=(a=a<<8|t[s++])>>o<0&&(o>(o-=r)&(1<8;)vx[s++]=gx(e,t,8,a),i-=8;i>0&&(vx[s++]=gx(e,t,i,a));for(var c=r-1;c>0;c--){for(var u=0,l=s-1;l>=0;l--){var h=(u=u<<8|vx[l])/n[c]|0;vx[l]=h,u-=h*n[c]}o[c]=u}o[0]=vx[0]|vx[1]<<8|vx[2]<<16|vx[3]<<24}var bx=function(t){function r(){t.apply(this,arguments)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"xtc"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){e.Debug&&is.time("XtcParser._parse "+this.name);for(var t=Bo(this.streamer.data),r=new DataView(t),i=this.frames,n=i.coordinates,o=i.boxes,a=i.times,s=new Int32Array(6),c=new Int32Array(3),u=new Int32Array(3),l=new Uint32Array(3),h=new Float32Array(3),p=new Float32Array(3),d=0,f=new Int32Array(3),m=new Uint32Array(f.buffer);;){var g=void 0,v=r.getInt32(d+4);d+=12;var y=3*v;a.push(r.getFloat32(d)),d+=4;for(var b=new Float32Array(9),x=0;x<9;++x)b[x]=10*r.getFloat32(d),d+=4;if(o.push(b),v<=9){g=new Float32Array(v);for(var _=0;_16777215?(u[0]=dx(c[0]),u[1]=dx(c[1]),u[2]=dx(c[2]),M=0):M=mx(3,c);var C=r.getInt32(d);d+=4;var P=C-1,T=px[P=9>P?9:P]/2|0,I=px[C]/2|0;l[0]=l[1]=l[2]=px[C];var E=4*Math.ceil(r.getInt32(d)/4);d+=4;var D=1/A,L=0,O=0,R=new Uint8Array(t,d);for(h[0]=h[1]=h[2]=0;O0){h[0]=h[1]=h[2]=0;for(var N=0;N9?px[C-1]/2|0:0):k>0&&(T=I,I=px[C]/2|0),l[0]=l[1]=l[2]=px[C],0===l[0]||0===l[1]||0===l[2])return void console.error("(xdrfile error) Undefined error.")}d+=E}for(var F=0;F=t.byteLength)break}a.length>=1&&(i.timeOffset=a[0]),a.length>=2&&(i.deltaTime=a[1]-a[0]),e.Debug&&is.timeEnd("XtcParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}($b);ls.add("xtc",bx);var xx=function(e){function t(t,r){var i=r||{};e.call(this,t,i),this.volume=new vp(this.name,this.path),this.voxelSize=So(i.voxelSize,1)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={type:{configurable:!0},__objName:{configurable:!0}};return r.type.get=function(){return"volume"},r.__objName.get=function(){return"volume"},t.prototype._afterParse=function(){this.volume.setMatrix(this.getMatrix()),e.prototype._afterParse.call(this)},t.prototype.getMatrix=function(){return new ie},Object.defineProperties(t.prototype,r),t}(jy),_x=/\s+/,wx=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,Sx=.529177210859,Ax=function(t){function r(){t.apply(this,arguments)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"cube"},r.prototype._parse=function(){e.Debug&&is.time("CubeParser._parse "+this.name);var t=this.volume,r=this.streamer.peekLines(6),i={},n=Sx*this.voxelSize;function o(e,t){var i=r[e].trim().split(_x)[t];return parseFloat(i)}i.atomCount=Math.abs(o(2,0)),i.originX=o(2,1)*Sx,i.originY=o(2,2)*Sx,i.originZ=o(2,3)*Sx,i.NVX=o(3,0),i.NVY=o(4,0),i.NVZ=o(5,0),i.basisX=new Y(o(3,1),o(3,2),o(3,3)).multiplyScalar(n),i.basisY=new Y(o(4,1),o(4,2),o(4,3)).multiplyScalar(n),i.basisZ=new Y(o(5,1),o(5,2),o(5,3)).multiplyScalar(n);var a=new Float32Array(i.NVX*i.NVY*i.NVZ),s=0,c=0,u=o(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(e){!function(e,t,r){for(var n=e;n=i.atomCount+6+u)for(var l=o.match(wx),h=0,p=l.length;h>8&255}n.xStart=a[0],n.yStart=a[1],n.zStart=a[2],n.xExtent=a[3],n.yExtent=a[4],n.zExtent=a[5],n.xRate=a[6],n.yRate=a[7],n.zRate=a[8];var p=1/a[17],d=p*this.voxelSize;n.xlen=a[9]*d,n.ylen=a[10]*d,n.zlen=a[11]*d,n.alpha=a[12]*p,n.beta=a[13]*p,n.gamma=a[14]*p,t=a[15]/100,r=a[16],n.gamma=a[14]*p}i.header=n,e.Debug&&is.log(n,t,r);for(var f=new Float32Array(n.xExtent*n.yExtent*n.zExtent),m=512,g=Math.ceil(n.xExtent/8),v=Math.ceil(n.yExtent/8),y=Math.ceil(n.zExtent/8),b=0;bo){var n=r[i].trim();if(""!==n)for(var l=n.split(Cx),h=0,p=l.length;h=o&&(m-o)%d!=0&&f=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},addVertex:function(e,t,r){var i=this.vertices,n=this.object.geometry.vertices;n.push(i[e+0]),n.push(i[e+1]),n.push(i[e+2]),n.push(i[t+0]),n.push(i[t+1]),n.push(i[t+2]),n.push(i[r+0]),n.push(i[r+1]),n.push(i[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var i=this.normals,n=this.object.geometry.normals;n.push(i[e+0]),n.push(i[e+1]),n.push(i[e+2]),n.push(i[t+0]),n.push(i[t+1]),n.push(i[t+2]),n.push(i[r+0]),n.push(i[r+1]),n.push(i[r+2])},addFace:function(e,t,r,i,n,o,a,s){var c,u=this.vertices.length,l=this.parseVertexIndex(e,u),h=this.parseVertexIndex(t,u),p=this.parseVertexIndex(r,u);if(void 0===i?this.addVertex(l,h,p):(c=this.parseVertexIndex(i,u),this.addVertex(l,h,c),this.addVertex(h,p,c)),void 0!==n){var d=this.normals.length;l=this.parseNormalIndex(n,d),h=n===o?l:this.parseNormalIndex(o,d),p=n===a?l:this.parseNormalIndex(a,d),void 0===i?this.addNormal(l,h,p):(c=this.parseNormalIndex(s,d),this.addNormal(l,h,c),this.addNormal(h,p,c))}},addLineGeometry:function(e){this.object.geometry.type="Line";for(var t=this.vertices.length,r=0,i=e.length;r0?b.setAttribute("normal",new wt(new Float32Array(y.normals),3)):b.computeVertexNormals(),v.push(b)}}return v}};var Xx=function(e){function t(){e.apply(this,arguments)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={type:{configurable:!0}};return r.type.get=function(){return"obj"},t.prototype.getLoader=function(){return new qx},Object.defineProperties(t.prototype,r),t}(Wx);ls.add("obj",Xx);var Yx=function(){this.propertyNameMapping={}};Yx.prototype={constructor:Yx,setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),r="",i=0;i=i.elements[a].count&&(a++,s=0);var l=this.parseASCIIElement(i.elements[a].properties,u);this.handleElement(r,i.elements[a].name,l),s++}}return this.postProcess(r)},postProcess:function(e){if(e.useColor){for(var t=0;t/g,""),{declaration:t(),root:r()};function t(){if(n(/^<\?xml\s*/)){for(var e={attributes:{}};!o()&&!a("?>");){var t=i();if(!t)return e;e.attributes[t.name]=t.value}return n(/\?>\s*/),e}}function r(){var e=n(i_);if(e){for(var t,s={name:e[1],attributes:{},children:[]};!(o()||a(">")||a("?>")||a("/>"));){var c=i();if(!c)return s;s.attributes[c.name]=c.value}if(n(/^\s*\/>\s*/))return s;for(n(/\??>\s*/),s.content=function(){var e=n(n_);if(e)return e[1];return""}();t=r();)s.children.push(t);return n(/^<\/[\w-:.]+>\s*/),s}}function i(){var e,t=n(o_);if(t)return{name:t[1],value:(e=t[2],e.replace(r_,""))}}function n(t){var r=e.match(t);if(r)return e=e.slice(r[0].length),r}function o(){return 0===e.length}function a(t){return 0===e.indexOf(t)}}var s_=function(t){function r(e,r){var i=r||{};t.call(this,e,i),this.useDomParser=So(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},__objName:{configurable:!0},isXml:{configurable:!0}};return i.type.get=function(){return"xml"},i.__objName.get=function(){return"xml"},i.isXml.get=function(){return!0},r.prototype.__xmlParser=function(e){return a_(e)},r.prototype.__domParser=function(e){return(new window.DOMParser).parseFromString(e,"text/xml")},r.prototype._parse=function(){e.Debug&&is.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),e.Debug&&is.timeEnd("XmlParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(jy);function c_(e,t){var r=e.getNamedItem(t);return null!==r?r.value:""}function u_(e,t,r){void 0===r&&(r=!1);var i=c_(e,"icode").trim(),n=c_(e,"chain").trim(),o=c_(e,"altcode"),a=c_(e,"resnum");return i&&(a+="^"+i),n&&(a+=":"+n),t&&(a+="."+t),r&&o.trim()&&(a+="%"+o),a+="/"+(parseInt(c_(e,"model"))-1)}function l_(e){var t=c_(e,"chain").trim(),r="["+c_(e,"rescode")+"]"+c_(e,"resnum");return t&&(r+=":"+t),r}function h_(e,t,r){void 0===e[t]?e[t]=r:e[t]|=r}function p_(e,t){return null!==e&&e.value===t}function d_(e,t,r){for(var i=0,n=t.getElementsByTagName("clash"),o=0,a=n.length;o0&&(i+=1),t.getElementsByTagName("bond-outlier").length>0&&(i+=1),t.getElementsByTagName("plane-outlier").length>0&&(i+=1),p_(r.getNamedItem("rota"),"OUTLIER")&&(i+=1),p_(r.getNamedItem("rama"),"OUTLIER")&&(i+=1),p_(r.getNamedItem("RNApucker"),"outlier")&&(i+=1),i}ls.add("xml",s_);var f_=function(e,t){this.name=e,this.path=t,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"},m_={type:{configurable:!0}};m_.type.get=function(){return"validation"},f_.prototype.fromXml=function(t){e.Debug&&is.time("Validation.fromXml");var r=this.rsrzDict,i=this.rsccDict,n=this.rciDict,o=this.clashDict,a=this.clashArray,s=this.geoDict,c=this.geoAtomDict,u=this.atomDict,l=t.getElementsByTagName("Entry");if(1===l.length){var h=l[0].getElementsByTagName("chemical_shift_list");if(1===h.length)for(var p=h[0].getElementsByTagName("random_coil_index"),d=0,f=p.length;d0&&(s[B]=F)}else{var z=k.getElementsByTagName("clash"),U=k.getElementsByTagName("mog-bond-outlier"),j=k.getElementsByTagName("mog-angle-outlier");if(U.length>0||j.length>0||z.length>0){var G={};c[B]=G;for(var V=0,$=z.length;V<$;++V){var H=z[V].attributes;o[c_(H,"cid")]&&h_(G,c_(H,"atom"),1)}for(var W=0,q=U.length;W>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(n=n+t[i++]|0)|0}while(--a);n%=65521,o%=65521}return n|o<<16|0}ls.add("validation",g_);var x_=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();function __(e,t,r,i){var n=x_,o=i+r;e^=-1;for(var a=i;a>>8^n[255&(e^t[a])];return-1^e}function w_(e,t){var r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b,x,_,w,S,A,M,C;r=e.state,i=e.next_in,M=e.input,n=i+(e.avail_in-5),o=e.next_out,C=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,l=r.whave,h=r.wnext,p=r.window,d=r.hold,f=r.bits,m=r.lencode,g=r.distcode,v=(1<>>=x=b>>>24,f-=x,0===(x=b>>>16&255))C[o++]=65535&b;else{if(!(16&x)){if(0==(64&x)){b=m[(65535&b)+(d&(1<>>=x,f-=x),f<15&&(d+=M[i++]<>>=x=b>>>24,f-=x,!(16&(x=b>>>16&255))){if(0==(64&x)){b=g[(65535&b)+(d&(1<c){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=x,f-=x,w>(x=o-a)){if((x=w-x)>l&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=0,A=p,0===h){if(S+=u-x,x<_){_-=x;do{C[o++]=p[S++]}while(--x);S=o-w,A=C}}else if(h2;)C[o++]=A[S++],C[o++]=A[S++],C[o++]=A[S++],_-=3;_&&(C[o++]=A[S++],_>1&&(C[o++]=A[S++]))}else{S=o-w;do{C[o++]=C[S++],C[o++]=C[S++],C[o++]=C[S++],_-=3}while(_>2);_&&(C[o++]=C[S++],_>1&&(C[o++]=C[S++]))}break}}break}}while(i>3,d&=(1<<(f-=_<<3))-1,e.next_in=i,e.next_out=o,e.avail_in=i=1&&0===E[_];_--);if(w>_&&(w=_),0===_)return n[o++]=20971520,n[o++]=20971520,s.bits=1,0;for(x=1;x<_&&0===E[x];x++);for(w0&&(0===e||1!==_))return-1;for(D[1]=0,y=1;y852||2===e&&C>592)return 1;for(;;){f=y-A,a[b]d?(m=L[O+a[b]],g=T[I+a[b]]):(m=96,g=0),c=1<>A)+(u-=c)]=f<<24|m<<16|g|0}while(0!==u);for(c=1<>=1;if(0!==c?(P&=c-1,P+=c):P=0,b++,0==--E[y]){if(y===_)break;y=t[r+a[b]]}if(y>w&&(P&h)!==l){for(0===A&&(A=w),p+=x,M=1<<(S=y-A);S+A<_&&!((M-=E[S+A])<=0);)S++,M<<=1;if(C+=1<852||2===e&&C>592)return 1;n[l=P&h]=w<<24|S<<16|p-o|0}}return 0!==P&&(n[p+P]=y-A<<24|64<<16|0),s.bits=w,0}var I_=-2,E_=12,D_=30;function L_(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function O_(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function R_(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,0):I_}(e)):I_}function k_(e,t){var r,i;return e?(i=new O_,e.state=i,i.window=null,r=function(e,t){var r,i;return e&&e.state?(i=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?I_:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,R_(e))):I_}(e,t),0!==r&&(e.state=null),r):I_}var N_,B_,F_=!0;function z_(e){if(F_){var t;for(N_=new Int32Array(512),B_=new Int32Array(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(T_(1,e.lens,0,288,N_,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;T_(2,e.lens,0,32,B_,0,e.work,{bits:5}),F_=!1}e.lencode=N_,e.lenbits=9,e.distcode=B_,e.distbits=5}function U_(e,t,r,i){var n,o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(y_(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((n=o.wsize-o.wnext)>i&&(n=i),y_(o.window,t,r-i,n,o.wnext),(i-=n)?(y_(o.window,t,r-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,r.check=__(r.check,P,2,0),u=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=D_;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=D_;break}if(l-=4,w=8+(15&(u>>>=4)),0===r.wbits)r.wbits=w;else if(w>r.wbits){e.msg="invalid window size",r.mode=D_;break}r.dmax=1<>8&1),512&r.flags&&(P[0]=255&u,P[1]=u>>>8&255,r.check=__(r.check,P,2,0)),u=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===s)break e;s--,u+=i[o++]<>>8&255,P[2]=u>>>16&255,P[3]=u>>>24&255,r.check=__(r.check,P,4,0)),u=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===s)break e;s--,u+=i[o++]<>8),512&r.flags&&(P[0]=255&u,P[1]=u>>>8&255,r.check=__(r.check,P,2,0)),u=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===s)break e;s--,u+=i[o++]<>>8&255,r.check=__(r.check,P,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>s&&(d=s),d&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),y_(r.head.extra,i,o,d,w)),512&r.flags&&(r.check=__(r.check,i,d,o)),s-=d,o+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;d=0;do{w=i[o+d++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w))}while(w&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=E_;break;case 10:for(;l<32;){if(0===s)break e;s--,u+=i[o++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===s)break e;s--,u+=i[o++]<>>=1)){case 0:r.mode=14;break;case 1:if(z_(r),r.mode=20,6===t){u>>>=2,l-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=D_}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=i[o++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=D_;break}if(r.length=65535&u,u=0,l=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>s&&(d=s),d>c&&(d=c),0===d)break e;y_(n,i,o,d,a),s-=d,o+=d,c-=d,a+=d,r.length-=d;break}r.mode=E_;break;case 17:for(;l<14;){if(0===s)break e;s--,u+=i[o++]<>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=D_;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,l-=3}for(;r.have<19;)r.lens[T[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},S=T_(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,S){e.msg="invalid code lengths set",r.mode=D_;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,y=65535&C,!((g=C>>>24)<=l);){if(0===s)break e;s--,u+=i[o++]<>>=g,l-=g,r.lens[r.have++]=y;else{if(16===y){for(M=g+2;l>>=g,l-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=D_;break}w=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===y){for(M=g+3;l>>=g)),u>>>=3,l-=3}else{for(M=g+7;l>>=g)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=D_;break}for(;d--;)r.lens[r.have++]=w}}if(r.mode===D_)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=D_;break}if(r.lenbits=9,A={bits:r.lenbits},S=T_(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,S){e.msg="invalid literal/lengths set",r.mode=D_;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},S=T_(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,S){e.msg="invalid distances set",r.mode=D_;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,w_(e,p),a=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,u=r.hold,l=r.bits,r.mode===E_&&(r.back=-1);break}for(r.back=0;v=(C=r.lencode[u&(1<>>16&255,y=65535&C,!((g=C>>>24)<=l);){if(0===s)break e;s--,u+=i[o++]<>b)])>>>16&255,y=65535&C,!(b+(g=C>>>24)<=l);){if(0===s)break e;s--,u+=i[o++]<>>=b,l-=b,r.back+=b}if(u>>>=g,l-=g,r.back+=g,r.length=y,0===v){r.mode=26;break}if(32&v){r.back=-1,r.mode=E_;break}if(64&v){e.msg="invalid literal/length code",r.mode=D_;break}r.extra=15&v,r.mode=22;case 22:if(r.extra){for(M=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;v=(C=r.distcode[u&(1<>>16&255,y=65535&C,!((g=C>>>24)<=l);){if(0===s)break e;s--,u+=i[o++]<>b)])>>>16&255,y=65535&C,!(b+(g=C>>>24)<=l);){if(0===s)break e;s--,u+=i[o++]<>>=b,l-=b,r.back+=b}if(u>>>=g,l-=g,r.back+=g,64&v){e.msg="invalid distance code",r.mode=D_;break}r.offset=y,r.extra=15&v,r.mode=24;case 24:if(r.extra){for(M=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=D_;break}r.mode=25;case 25:if(0===c)break e;if(d=p-c,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=D_;break}d>r.wnext?(d-=r.wnext,f=r.wsize-d):f=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=n,f=a-r.offset,d=r.length;d>c&&(d=c),c-=d,r.length-=d;do{n[a++]=m[f++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;n[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===s)break e;s--,u|=i[o++]<=252?6:W_>=248?5:W_>=240?4:W_>=224?3:W_>=192?2:1;function q_(e){var t,r,i,n,o,a=e.length,s=0;for(n=0;n>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t}function X_(e,t){var r,i,n,o,a=t||e.length,s=new Array(2*a);for(i=0,r=0;r4)s[i++]=65533,r+=o-1;else{for(n&=2===o?31:3===o?15:7;o>1&&r1?s[i++]=65533:n<65536?s[i++]=n:(n-=65536,s[i++]=55296|n>>10&1023,s[i++]=56320|1023&n)}return function(e,t){if(t<65537&&(e.subarray&&$_||!e.subarray&&V_))return String.fromCharCode.apply(null,v_(e,t));for(var r="",i=0;ie.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+H_[e[r]]>t?r:t}H_[254]=H_[254]=1;var Z_={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function K_(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Q_(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var J_=Object.prototype.toString;function ew(e){if(!(this instanceof ew))return new ew(e);this.options=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])}}return e}({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new K_,this.strm.avail_out=0;var r,i,n,o=k_(this.strm,t.windowBits);if(0!==o)throw new Error(Z_[o]);this.header=new Q_,r=this.strm,i=this.header,r&&r.state&&(0==(2&(n=r.state).wrap)||(n.head=i,i.done=!1))}ew.prototype.push=function(e,t){var r,i,n,o,a,s,c=this.strm,u=this.options.chunkSize,l=this.options.dictionary,h=!1;if(this.ended)return!1;i=t===~~t?t:!0===t?4:0,"string"==typeof e?c.input=function(e){for(var t=new Uint8Array(e.length),r=0,i=t.length;r0||0===c.avail_out)&&1!==r);return 1===r&&(i=4),4===i?(r=function(e){if(!e||!e.state)return I_;var t=e.state;return t.window&&(t.window=null),e.state=null,0}(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==i||(this.onEnd(0),c.avail_out=0,!0)},ew.prototype.onData=function(e){this.chunks.push(e)},ew.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(e){var t,r,i,n,o,a;for(i=0,t=0,r=e.length;t0;)r[i]=arguments[i+1];e.Debug&&is.time("concatStructures");var n=new _f(t,""),o=new Id(n),a=n.atomStore,s=n.atomMap;a.addField("formalCharge",1,"int8"),a.addField("partialCharge",1,"float32");var c={},u=0,l=0,h=0;r.forEach((function(e){e.eachAtom((function(e){a.growIfFull(),a.atomTypeId[u]=s.add(e.atomname,e.element),a.x[u]=e.x,a.y[u]=e.y,a.z[u]=e.z,a.serial[u]=e.serial,a.formalCharge[u]=e.formalCharge,a.partialCharge[u]=e.partialCharge,a.altloc[u]=e.altloc,a.occupancy[u]=e.occupancy,a.bfactor[u]=e.bfactor,o.addAtom(e.modelIndex+h,e.chainname,e.chainid,e.resname,e.resno,1===e.hetero,e.sstruc,e.inscode),c[e.index+l]=u,u+=1})),l+=e.atomStore.count,h+=e.modelStore.count}));var p=n.bondStore,d=n.getAtomProxy(),f=n.getAtomProxy();return l=0,r.forEach((function(e){e.eachBond((function(e){d.index=c[e.atomIndex1+l],f.index=c[e.atomIndex2+l],p.addBond(d,f,e.bondOrder)})),l+=e.atomStore.count})),o.finalize(),Gd(n,!0),jd(n,!0),n.finalizeAtoms(),n.finalizeBonds(),qd(n),e.Debug&&is.timeEnd("concatStructures"),n},e.download=Io,e.flatten=function e(t,r){r=So(r,[]);for(var i=0;it?(a&&(clearTimeout(a),a=null),s=u,o=e.apply(i,n),a||(i=n=null)):a||!1===r.trailing||(a=setTimeout(c,l)),o}},e.uniqueArray=Oo,Object.defineProperty(e,"__esModule",{value:!0})})); + * Kdtree + * @class + * @author Alexander Rose , 2016 + * @author Roman Bolzern , 2013 + * @author I4DS http://www.fhnw.ch/i4ds, 2013 + * @license MIT License + * @description + * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place + * provides fast nearest neighbour search + * + * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs + * + * Further information (including mathematical properties) + * http://en.wikipedia.org/wiki/Binary_tree + * http://en.wikipedia.org/wiki/K-d_tree + * + * @example + * points: [x, y, z, x, y, z, x, y, z, ...] + * metric: function(a, b){ + * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2); + * } + * + * @param {Float32Array} points - points + * @param {Function} metric - metric + */class Gm{constructor(e,t){this.points=e,this.metric=t,this.maxDepth=0,this.currentNode=0;const i=e.length/3,n=new Uint32Array(i);for(let e=0;ethis.maxDepth&&(this.maxDepth=e);const r=n-i;if(0===r)return-1;const s=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===r)return o[s]=i,o[s+1]=-1,o[s+2]=-1,o[s+3]=t,s;const a=this.indices,c=this.points,l=i+Math.floor(r/2),h=e%3;let u,d,f,m,p,g=i,v=n-1;for(;v>g;){for(f=g+v>>1,m=c[3*a[f]+h],d=a[f],a[f]=a[v],a[v]=d,p=g,u=g;u-e[1])),r=this.nodes,s=this.points,o=this.indices,a=c=>{let l,h;const u=this.getNodeDepth(c)%3,d=3*o[r[c]],f=[s[d+0],s[d+1],s[d+2]],m=this.metric(e,f);function p(e,i){n.push([e,i]),n.size()>t&&n.pop()}const g=r[c+1],v=r[c+2];if(-1===v&&-1===g)return void((n.size()s[3*o[r[e]]+n])throw new Error("left child is > parent!");i+=this.verify(a,t+1)}if(-1!==c){if(s[3*o[r[c]]+n]0}isBackbone(){const e=this.residueType.backboneIndexList;return e.length>0&&e.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const e=this.residueType.backboneType;return 4===e||5===e||6===e}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const e=this.residueType.moleculeType;return 4===e||5===e}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return od.includes(this.sstruc)}isSheet(){return ad.includes(this.sstruc)}isTurn(){return cd.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let e=!1;return 1!==this.number||(e=!this.hasBondToElement(6)),e}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(e){const t=this.atomStore,i=e.atomStore,n=this.index,r=e.index,s=t.x[n]-i.x[r],o=t.y[n]-i.y[r],a=t.z[n]-i.z[r],c=s*s+o*o+a*a;return Math.sqrt(c)}connectedTo(e){const t=this.atomStore,i=e.atomStore,n=this.index,r=e.index;if(t.altloc&&i.altloc){const e=t.altloc[n],s=i.altloc[r];if(0!==e&&0!==s&&32!==e&&32!==s&&e!==s)return!1}const s=t.x[n]-i.x[r],o=t.y[n]-i.y[r],a=t.z[n]-i.z[r],c=s*s+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+e.covalent,h=l+.3,u=l-.5;return cu*u}positionFromArray(e,t=0){return this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this}positionToArray(e=[],t=0){const i=this.index,n=this.atomStore;return e[t+0]=n.x[i],e[t+1]=n.y[i],e[t+2]=n.z[i],e}positionToVector3(e){return void 0===e&&(e=new Zt),e.x=this.x,e.y=this.y,e.z=this.z,e}positionFromVector3(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}positionAdd(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}positionSub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}getResidueBonds(e=!1){const t=this.residueAtomOffset,i=this.index-this.residueAtomOffset,n=this.residueType.getBonds(),r=n.atomIndices1,s=n.atomIndices2;let o,a,c,l;for(e||(l=[]),o=r.indexOf(i);-1!==o;){if(c=s[o]+t,!l)return c;l.push(c),o=r.indexOf(i,o+1)}for(a=s.indexOf(i);-1!==a;){if(c=r[a]+t,!l)return c;l.push(c),a=s.indexOf(i,a+1)}return l}qualifiedName(e=!1){var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chainname&&(t+=":"+this.chainname),this.atomname&&(t+="."+this.atomname),this.altloc&&(t+="%"+this.altloc),this.structure.modelStore.count>1&&(t+="/"+this.modelIndex),t}clone(){return new Vm(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function Hm(e,t){const i=e[0]-t[0],n=e[1]-t[1],r=e[2]-t[2];return i*i+n*n+r*r}function jm(e,t){return Math.sqrt(Hm(e,t))}const Wm=new Float32Array(3);class qm{constructor(t,i=!1){e.Debug&&il.time("Kdtree build");const n=i?Hm:jm,r=new Float32Array(3*t.atomCount),s=new Uint32Array(t.atomCount);let o=0;t.eachAtom((function(e){r[o+0]=e.x,r[o+1]=e.y,r[o+2]=e.z,s[o/3]=e.index,o+=3})),this.atomIndices=s,this.points=r,this.kdtree=new Gm(r,n),e.Debug&&il.timeEnd("Kdtree build")}nearest(e,t,i){e instanceof Zt?e.toArray(Wm):e instanceof Vm&&e.positionToArray(Wm);const n=this.kdtree.nearest(Wm,t,i),r=this.kdtree.indices,s=this.kdtree.nodes,o=this.atomIndices,a=[];for(let e=0,t=n.length;e":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Ym={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","F 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ","F 4/m -3 2/c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Zm=/^[1-9]$/;function Km(e){let t="";return e.length>0&&(t=":"+za(e).join(" OR :")),new $c(t)}class Qm{constructor(e=""){this.name=e,this.partList=[]}get type(){return"Assembly"}addPart(e,t){const i=new Jm(e,t);return this.partList.push(i),i}getAtomCount(e){return this.partList.reduce(((t,i)=>t+i.getAtomCount(e)),0)}getResidueCount(e){return this.partList.reduce(((t,i)=>t+i.getResidueCount(e)),0)}getInstanceCount(){let e=0;return this.partList.forEach((function(t){e+=t.matrixList.length})),e}isIdentity(e){if(1!==this.partList.length)return!1;const t=this.partList[0];if(1!==t.matrixList.length)return!1;if(!(new ri).equals(t.matrixList[0]))return!1;let i=[];return e.eachChain((function(e){i.push(e.chainname)})),i=za(i),t.chainList.length===i.length}getBoundingBox(e){const t=new Ni;return this.partList.forEach((function(i){const n=i.getBoundingBox(e);t.expandByPoint(n.min),t.expandByPoint(n.max)})),t}getCenter(e){return this.getBoundingBox(e).getCenter(new Zt)}getSelection(){let e=[];return this.partList.forEach((function(t){e=e.concat(t.chainList)})),Km(e)}}class Jm{constructor(e=[],t=[]){this.matrixList=e,this.chainList=t}get type(){return"AssemblyPart"}_getCount(e,t){let i=0;return e.eachChain((e=>{(0===this.chainList.length||this.chainList.includes(e.chainname))&&(i+=e[t])})),this.matrixList.length*i}getAtomCount(e){return this._getCount(e,"atomCount")}getResidueCount(e){return this._getCount(e,"residueCount")}getBoundingBox(e){const t=new Ni,i=new Ni,n=this.getSelection(),r=e.getBoundingBox(n);return this.matrixList.forEach((function(e){i.copy(r).applyMatrix4(e),t.expandByPoint(i.min),t.expandByPoint(i.max)})),t}getSelection(){return Km(this.chainList)}getView(e){const t=this.getSelection();return t?e.getView(t):e}getInstanceList(){const e=[];for(let t=0,i=this.matrixList.length;t0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=r,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=e,this.currentChainid=i,this.currentResname=n,this.currentResno=r,this.currentInscode=a,this.currentHetero=s}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function tp(t,i){if(!i)return;e.Debug&&il.time("assignSecondaryStructure");const n=[];t.eachModel((function(e){e.eachChain((function(e){n.push(e.chainname)}))}));const r=n.slice().sort(),s=[];r.forEach((function(e){s.push(n.indexOf(e))}));const o=i.helices.filter((function(e){return Na(r,e[0])>=0}));o.sort((function(e,t){const i=e[0],n=t[0],o=e[1],a=t[1];if(i===n)return o===a?0:o=0}));c.sort((function(e,t){const i=e[0],n=t[0];if(i===n)return 0;const o=Na(r,i),a=Na(r,n);return s[o]=e.residueCount)continue;o.index=s+r,a.index=s+r+t,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[t-2])>n)return!1}return!0},i=function(e,i){return t(e,i,[5.45,5.18,6.37],2.1)},n=function(e,i){return t(e,i,[6.1,10.4,13],1.42)};return function(t){e.Debug&&il.time("calculateSecondaryStructure"),t.eachPolymer((function(e){if(e.residueCount<4)return;if(e.isCg())!function(e){const t=e.residueStore,i=e.residueIndexStart,n=new Um(e).position,r=new Zt,s=new Zt;for(let o=0,a=e.residueCount;o1&&n.bending[o]<20&&(t.sstruc[i+o]="h".charCodeAt(0),t.sstruc[i+o+1]="h".charCodeAt(0))}}(e);else{if(!e.isProtein())return;!function(e){const t=e.residueStore,r=e.residueIndexStart;for(let s=0,o=e.residueCount;s=t;)i=Math.floor(i/t),r+=np[i%t],n+=1;return n>=5&&il.warn("chainname overflow"),r}function sp(t,i=!1){e.Debug&&il.time("calculateChainnames");let n=!0;if(t.eachChain((function(e){e.chainname&&(n=!1)})),n){const e=t.modelStore,n=t.chainStore,r=t.residueStore,s=function(t,i,s,o){const a=n.count;for(let e=0;e500)return void il.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName());const r=e.getBonds(),s=r.atomIndices1,h=r.atomIndices2,u=r.bondOrders,d=s.length;for(let t=0;t{u.forEach((i=>{e.push(t.clone().multiply(i))}))})),l.addPart(e)}else l.addPart(h);const d=new Zt,f=new Qm("SUPERCELL"),m=Array.prototype.concat.call(c(d.set(1,0,0)),c(d.set(0,1,0)),c(d.set(0,0,1)),c(d.set(-1,0,0)),c(d.set(0,-1,0)),c(d.set(0,0,-1)),c(d.set(1,1,0)),c(d.set(1,0,1)),c(d.set(0,1,1)),c(d.set(-1,-1,0)),c(d.set(-1,0,-1)),c(d.set(0,-1,-1)),c(d.set(1,-1,-1)),c(d.set(1,1,-1)),c(d.set(1,-1,1)),c(d.set(-1,1,1)),c(d.set(-1,-1,1)),c(d.set(-1,1,-1)),c(d.set(0,1,-1)),c(d.set(0,-1,1)),c(d.set(1,0,-1)),c(d.set(-1,0,1)),c(d.set(1,-1,0)),c(d.set(-1,1,0)),c(),c(d.set(1,1,1)),c(d.set(-1,-1,-1)));if(t.biomolDict.NCS){const e=[];m.forEach((function(t){u.forEach((function(i){e.push(t.clone().multiply(i))}))})),f.addPart(e)}else f.addPart(m);t.biomolDict.UNITCELL=l,t.biomolDict.SUPERCELL=f,e.Debug&&il.timeEnd("buildUnitcellAssembly")}const dp=["H","C","O","N","S","P"],fp=["NA","CL","FE"];function mp(e){let t=e.toUpperCase(),i=0,n=0;for(let e=0;e0)break;++i}else n=e+1;(i>0||n=3&&-1!==dp.indexOf(t[0])?t[0]:""}function pp(e){const t=e.bondHash,i=t.countArray,n=t.offsetArray,r=t.indexArray,s=e.getBondProxy();e.eachResidue((function(e){const t=e.residueType;if(void 0!==t.bonds)return;var o=e.atomOffset,a=[],c=[],l=[],h={};const u=o+e.atomCount;e.eachAtom((function(e){const t=e.index,d=n[t];for(let e=0,n=i[t];e=u)continue;let i=s.atomIndex2;if(i=u)continue;if(t>i){const e=i;i=t,t=e}const n=t+"|"+i;void 0===h[n]&&(h[n]=!0,a.push(t-o),c.push(i-o),l.push(s.bondOrder))}})),t.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}const gp=[3,11,19,37,55,87],vp=[4,12,20,38,56,88],yp=[6,15,16,34],xp=[1,7,8,9,17,35,53],bp=[2,10,18,36,54,86],_p=[13,30,31,48,49,50,80,81,82,83,84,85,112],wp=[5,14,32,33,51,52,85],Sp=[9,17,35,53,85];class Ap{constructor(e,t,i){this.structure=e,this.atomname=t,i=i||mp(t),this.element=i,this.number=ld[i]||0,this.vdw=hd[this.number]||2,this.covalent=ud[this.number]||1.6}getDefaultValence(){const e=dd[this.number];return e?e[0]:-1}getValenceList(){return dd[this.number]||[]}getOuterShellElectronCount(){return fd[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return wp.includes(this.number)}isHalogen(){return Sp.includes(this.number)}isDiatomicNonmetal(){return xp.includes(this.number)}isPolyatomicNonmetal(){return yp.includes(this.number)}isAlkaliMetal(){return gp.includes(this.number)}isAlkalineEarthMetal(){return vp.includes(this.number)}isNobleGas(){return bp.includes(this.number)}isTransitionMetal(){const e=this.number;return e>=21&&e<=29||e>=39&&e<=47||e>=72&&e<=79||e>=104&&e<=108}isPostTransitionMetal(){return _p.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class Mp{constructor(e){this.structure=e,this.dict={},this.list=[],this.structure=e}add(e,t){const i=function(e,t){return e+"|"+t}(e=e.toUpperCase(),t=t?t.toUpperCase():mp(e));let n=this.dict[i];if(void 0===n){const r=new Ap(this.structure,e,t);n=this.list.length,this.dict[i]=n,this.list.push(r)}return n}get(e){return this.list[e]}}class Cp{constructor(e,t,i,n,r,s){this.structure=e,this.bondReferenceAtomIndices=[],this.resname=t,this.atomTypeIdList=i,this.hetero=n?1:0,this.chemCompType=r,this.bonds=s,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=Pd[this.backboneType],a=Pd[this.backboneStartType],c=Pd[this.backboneEndType],l=this.getAtomIndexByName(o.trace);this.traceAtomIndex=Ia(l,-1);const h=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=Ia(h,-1);const u=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=Ia(u,-1);const d=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=Ia(d,-1);const f=this.getAtomIndexByName(c.backboneEnd);let m;this.backboneEndAtomIndex=Ia(f,-1),m=bd.includes(t)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=Ia(m,-1)}getBackboneIndexList(){const e=[];let t;switch(this.moleculeType){case 3:t=Md;break;case 4:case 5:t=Cd;break;default:return e}const i=this.structure.atomMap,n=this.atomTypeIdList;for(let r=0,s=this.atomCount;r500)e.Debug&&il.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(s>50){const e=new qm(t,!0),i=t.isCg()?1.2:2.3;for(let t=o;t=0||Ep(e,t);this.rings={atomRings:e.atomRings,rings:e.rings}}isAromatic(e){return this.aromaticAtoms=this.getAromatic(e),1===this.aromaticAtoms[e.index-e.residueAtomOffset]}calculateAromatic(e){const t=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,n=i.map((t=>function(e){if(e.some((e=>!Pp.includes(e.number))))return!1;let t=0;const i=new Mf(3,e.length),n=i.data;e.forEach((e=>{n[t+0]=e.x,n[t+1]=e.y,n[t+2]=e.z,t+=3}));return new Dm(i).vecC.length()this.structure.getAtomProxy(t+e.atomOffset)))))),r=this.aromaticRings=[];i.forEach(((e,i)=>{n[i]&&(r.push(e),e.forEach((e=>t[e]=1)))}))}assignBondReferenceAtomIndices(){const e=this.getBondGraph(),t=this.getRings(),i=t.atomRings,n=t.rings,r=this.bonds,s=r.atomIndices1,o=r.atomIndices2,a=r.bondOrders,c=this.bondReferenceAtomIndices,l=r.atomIndices1.length;c.length=0;for(let t=0;t1)for(let i=0;i1)for(let i=0;i=0;e--)m[p++]=o[e];const g=e.rings.length;for(let t=0;t0?s[c]!==t&&s[t]!==c&&Ip(e,t,c):(n[c]=1,r[a++]=c,s[c]=t)}}}const Dp=4;class Lp{constructor(e){this.structure=e,this.dict={},this.list=[]}add(e,t,i,n="",r){const s=function(e,t,i,n=""){return e+"|"+t.join(",")+"|"+(i?1:0)+"|"+n}(e=e.toUpperCase(),t,i,n);let o=this.dict[s];if(void 0===o){const a=new Cp(this.structure,e,t,i,n,r);o=this.list.length,this.dict[s]=o,this.list.push(a)}return o}get(e){return this.list[e]}}class Rp{constructor(e,t=0){this.structure=e,this.index=t,this.bondStore=e.bondStore,this._v12=new Zt,this._v13=new Zt,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(e){this.bondStore.atomIndex1[this.index]=e}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(e){this.bondStore.atomIndex2[this.index]=e}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(e){this.bondStore.bondOrder[this.index]=e}getOtherAtomIndex(e){return e===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(e){return this.structure.getAtomProxy(this.getOtherAtomIndex(e.index))}getReferenceAtomIndex(){const e=this._ap1,t=this._ap2;if(e.index=this.atomIndex1,t.index=this.atomIndex2,e.residueIndex!==t.residueIndex)return;const i=e.index-e.residueAtomOffset,n=t.index-t.residueAtomOffset,r=e.residueType.getBondReferenceAtomIndex(i,n);if(void 0!==r)return r+e.residueAtomOffset;console.warn("No reference atom found",e.index,t.index)}calculateShiftDir(e=new Zt){const t=this._ap1,i=this._ap2,n=this._ap3,r=this._v12,s=this._v13;t.index=this.atomIndex1,i.index=this.atomIndex2;const o=this.getReferenceAtomIndex();r.subVectors(t,i).normalize(),void 0!==o?(n.index=o,s.subVectors(t,n)):s.copy(t),s.normalize();let a=r.dot(s);return 1-Math.abs(a)<1e-5&&(s.set(1,0,0),a=r.dot(s),1-Math.abs(a)<1e-5&&(s.set(0,1,0),a=r.dot(s))),e.copy(s.sub(r.multiplyScalar(a))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new Rp(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class kp{constructor(e,t=0){this.structure=e,this.index=t,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueMap=e.residueMap,this.atomMap=e.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(e){this.residueStore.chainIndex[this.index]=e}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(e){this.residueStore.atomOffset[this.index]=e}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(e){this.residueStore.atomCount[this.index]=e}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(e){this.residueStore.resno[this.index]=e}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(e){this.residueStore.setSstruc(this.index,e)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(e){this.residueStore.setInscode(this.index,e)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.x[t];return e/this.atomCount}get y(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.y[t];return e/this.atomCount}get z(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.z[t];return e/this.atomCount}eachAtom(e,t){const i=this.atomCount,n=this.atomOffset,r=this.structure._ap,s=n+i;if(t&&t.atomOnlyTest){const i=t.atomOnlyTest;for(let t=n;t0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return od.includes(this.sstruc)}isSheet(){return ad.includes(this.sstruc)}isTurn(){return cd.includes(this.sstruc)&&this.isProtein()}getAtomType(e){return this.atomMap.get(this.atomStore.atomTypeId[e])}getResname1(){return gd[this.resname.toUpperCase()]||"X"}getBackboneType(e){switch(e){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(e){let t=this.residueType.getAtomIndexByName(e);return void 0!==t&&(t+=this.atomOffset),t}hasAtomWithName(e){return this.residueType.hasAtomWithName(e)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const e=this.atomCount,t=this.atomOffset,i=new Array(e);for(let n=0;n=t){const t=Ia(e,this.structure.getResidueProxy());if(t.index=i,t.connectedTo(this))return t}else if(i===t-1){const i=this.chainStore.residueCount[this.chainIndex],n=Ia(e,this.structure.getResidueProxy());if(n.index=t+i-1,n.connectedTo(this))return n}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(e=!1){let t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chain&&(t+=":"+this.chainname),t+="/"+this.modelIndex,t}clone(){return new kp(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class Op{constructor(e,t,i){this.structure=e,this.residueIndexStart=t,this.residueIndexEnd=i,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueCount=i-t+1;const n=this.structure.getResidueProxy(this.residueIndexStart),r=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==n.getPreviousConnectedResidue();const s=r.getNextConnectedResidue();this.isNextConnected=void 0!==s,this.isNextNextConnected=void 0!==s&&void 0!==s.getNextConnectedResidue(),this.isCyclic=r.connectedTo(n),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(e){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(e)}getAtomIndexByType(e,t){this.isCyclic?-1===e?e=this.residueCount-1:e===this.residueCount&&(e=0):(-1!==e||this.isPrevConnected||(e+=1),e!==this.residueCount||this.isNextNextConnected||(e-=1));const i=this.__residueProxy;let n;switch(i.index=this.residueIndexStart+e,t){case"trace":n=i.traceAtomIndex;break;case"direction1":n=i.direction1AtomIndex;break;case"direction2":n=i.direction2AtomIndex;break;default:n=i.getAtomIndexByName(t)}return n}eachAtom(e,t){this.eachResidue((function(i){i.eachAtom(e,t)}))}eachAtomN(e,t,i){const n=this.residueCount,r=new Array(e);for(let t=0;t1&&e(new Op(s,i,l.index)),i=n)):(o!==ed&&l.index-i>1&&e(new Op(s,i,l.index)),i=n)}n-i>1&&this.structure.getResidueProxy(i).backboneEndType&&e(new Op(s,i,n))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new Bp(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class Np{constructor(e,t=0){this.structure=e,this.index=t,this.modelStore=e.modelStore,this.chainStore=e.chainStore,this.residueStore=e.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(e){this.modelStore.chainOffset[this.index]=e}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(e){this.modelStore.chainCount[this.index]=e}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(e,t){this.eachChain((function(i){i.eachAtom(e,t)}),t)}eachResidue(e,t){this.eachChain((function(i){i.eachResidue(e,t)}),t)}eachPolymer(e,t){if(t&&t.chainOnlyTest){const i=t.chainOnlyTest;this.eachChain((function(n){i(n)&&n.eachPolymer(e,t)}))}else this.eachChain((function(i){i.eachPolymer(e,t)}))}eachChain(e,t){const i=this.chainCount,n=this.chainOffset,r=this.structure._cp,s=n+i;if(t&&t.test){const i=t.chainOnlyTest;if(i)for(let t=n;t{const i=3*t;a.index=e,l&&a.positionToArray(l,i),h&&s.atomColorToArray(a,h,i),u&&(u.array[t]=e),d&&(d[t]=r.atomRadius(a)),f&&(f[t]=e)})),o}getBondData(e){const t=Object.assign({},e);t.colorParams&&(t.colorParams.structure=this.getStructure());const i=t.what,n=Ia(t.bondSet,this.bondSet),r=Ia(t.multipleBond,"off"),s="off"!==r,o="offset"===r,a=Ia(t.bondScale,.4),c=Ia(t.bondSpacing,1);let l,h;const u={},d=this.getBondProxy();t.bondStore&&(d.bondStore=t.bondStore);const f=this.getAtomProxy(),m=this.getAtomProxy();let p;if(s){const e=d.bondStore.bondOrder;p=0,n.forEach((function(t){p+=e[t]}))}else p=n.getSize();i&&!i.position||(u.position1=new Float32Array(3*p),u.position2=new Float32Array(3*p)),i&&!i.color||!t.colorParams||(u.color=new Float32Array(3*p),u.color2=new Float32Array(3*p),h=al.getScheme(t.colorParams)),i&&!i.picking||(u.picking=new df(new Float32Array(p),this.getStructure(),t.bondStore)),(!i||i.radius||s&&i.position)&&(l=new Tm(t.radiusParams)),i&&!i.radius||(u.radius=new Float32Array(p),t.radius2&&(u.radius2=new Float32Array(p)));const{position1:g,position2:v,color:y,color2:x,picking:b,radius:_,radius2:w}=u;let S,A,M,C,P,T,I=0;const E=new Zt,D=new Zt,L=new Zt;return n.forEach((e=>{if(A=3*I,d.index=e,f.index=d.atomIndex1,m.index=d.atomIndex2,C=d.bondOrder,g)if(s&&C>1){const e=l.atomRadius(f);T=e*a/(.5*C),d.calculateShiftDir(L),o?(P=2*c*e,L.multiplyScalar(P),L.negate(),D.subVectors(m,f).multiplyScalar(Math.max(.1,P/1.88)),f.positionToArray(g,A),m.positionToArray(v,A),C>=2&&(E.addVectors(f,L).add(D).toArray(g,A+3),E.addVectors(m,L).sub(D).toArray(v,A+3),C>=3&&(E.subVectors(f,L).add(D).toArray(g,A+6),E.subVectors(m,L).sub(D).toArray(v,A+6)))):(P=(c-a)*e,L.multiplyScalar(P),2===C?(E.addVectors(f,L).toArray(g,A),E.subVectors(f,L).toArray(g,A+3),E.addVectors(m,L).toArray(v,A),E.subVectors(m,L).toArray(v,A+3)):3===C?(f.positionToArray(g,A),E.addVectors(f,L).toArray(g,A+3),E.subVectors(f,L).toArray(g,A+6),m.positionToArray(v,A),E.addVectors(m,L).toArray(v,A+3),E.subVectors(m,L).toArray(v,A+6)):(f.positionToArray(g,A),m.positionToArray(v,A)))}else f.positionToArray(g,A),m.positionToArray(v,A);if(y&&x&&(h.bondColorToArray(d,1,y,A),h.bondColorToArray(d,0,x,A),s&&C>1))for(S=1;S1))for(S=1;S1))for(T=_[I]*a/(o?1:.5*C),S=o?1:0;S1))for(T=w[I]*a/(o?1:.5*C),S=o?1:0;S{const t=e.x,i=e.y,l=e.z;to&&(o=t),i>a&&(a=i),l>c&&(c=l)}),t),i.min.set(n,r,s),i.max.set(o,a,c),e.Debug&&il.timeEnd("getBoundingBox"),i}getPrincipalAxes(t){e.Debug&&il.time("getPrincipalAxes");let i=0;const n=new Mf(3,this.atomCount),r=n.data;return this.eachAtom((e=>{r[i+0]=e.x,r[i+1]=e.y,r[i+2]=e.z,i+=3}),t),e.Debug&&il.timeEnd("getPrincipalAxes"),new Dm(n)}atomCenter(e){return e?this.getBoundingBox(e).getCenter(new Zt):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const e=this.atomStore;this._hasCoords=0!==Zl(e.x)||0!==Yl(e.x)||0!==Zl(e.y)||0!==Yl(e.y)||0!==Zl(e.z)||0!==Yl(e.z)||e.count/this.modelStore.count==1}return this._hasCoords}getSequence(e){const t=[],i=this.getResidueProxy();return this.eachAtom((function(e){i.index=e.residueIndex,e.index===i.traceAtomIndex&&t.push(i.getResname1())}),e),t}getAtomIndices(e){if(e&&e.string){const t=[];return this.eachAtom((function(e){t.push(e.index)}),e),new Uint32Array(t)}{const e={what:{index:!0}};return this.getAtomData(e).index}}getChainnameCount(e){const t=new Set;return this.eachChain((function(e){e.residueCount&&t.add(e.chainname)}),e),t.size}updatePosition(e,t=!0){let i=0;this.eachAtom((function(t){t.positionFromArray(e,i),i+=3}),void 0),this._hasCoords=void 0,t&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new ju(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const zp=new Ni,Up=[Fu,ku,zu,Nu,Uu,Ou,Ru,Bu,Gu,$u,Vu,Hu],$p={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class Gp{constructor(e="shape",t={}){this.boundingBox=new Ni,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=e,this.parameters=Ea(t,$p),Up.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)]=[]})),this._primitiveData[e.getShapeKey("name")]=[]}))}addBuffer(e){this.bufferList.push(e);const t=e.geometry;return t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox),this}addMesh(e,t,i,n,r){let s;e=Xa(e),t=Xa(t),Array.isArray(i)&&(i=Ga(i,e.length)),n&&(n=Xa(n)),s=void 0===n||0==n.length?{position:e,color:t,index:i}:{position:e,color:t,index:i,normal:n};const o=new vf(this,Object.assign({serial:this.meshCount,name:r},s)),a=new nm(Object.assign({picking:o},s));return this.bufferList.push(a),zp.setFromArray(e),this.boundingBox.union(zp),this.meshCount+=1,this}addSphere(e,t,i,n){return Ru.objectToShape(this,{position:e,color:t,radius:i,name:n}),this}addEllipsoid(e,t,i,n,r,s){return Uu.objectToShape(this,{position:e,color:t,radius:i,majorAxis:n,minorAxis:r,name:s}),this}addTorus(e,t,i,n,r,s){return $u.objectToShape(this,{position:e,color:t,radius:i,majorAxis:n,minorAxis:r,name:s}),this}addCylinder(e,t,i,n,r){return Nu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addCone(e,t,i,n,r){return zu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addArrow(e,t,i,n,r){return Fu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addBox(e,t,i,n,r,s){return ku.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addOctahedron(e,t,i,n,r,s){return Ou.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addTetrahedron(e,t,i,n,r,s){return Bu.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addText(e,t,i,n){return Gu.objectToShape(this,{position:e,color:t,size:i,text:n}),this}addPoint(e,t,i){return Vu.objectToShape(this,{position:e,color:t,name:i}),this}addWideline(e,t,i,n,r){return this.parameters.linewidth=n,Hu.objectToShape(this,{position1:e,position2:t,color:i,name:r}),this}addLabel(e,t,i,n){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(e,t,i,n)}getBufferList(){const e=[];return Up.forEach((t=>{this._primitiveData[t.getShapeKey("color")].length&&e.push(t.bufferFromShape(this,this.parameters))})),this.bufferList.concat(e)}dispose(){this.bufferList.forEach((function(e){e.dispose()})),this.bufferList.length=0,Up.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)].length=0})),this._primitiveData[e.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new Zt)),this._center}get type(){return"Shape"}}class Vp extends tu{constructor(e,t,i){Array.isArray(e)||(e=[e]),super(e,t,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}init(e){super.init(e),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e),e.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),e()}}const Hp=new ri,jp=new Ut;class Wp extends nm{constructor(e,t={},i){super(function(e,t){const i=t.attributes.position.array,n=t.index?t.index.array:void 0,r=e.position.length/3,s=i.length/3,o=r*s,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return n&&(h=Ga(r*n.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:e.primitiveId||jl(r,s),picking:e.picking}}(e,i),t),this.updateNormals=!1;const n=i.attributes.position.array,r=i.attributes.normal.array,s=i.index?i.index.array:void 0;this.geoPosition=n,this.geoNormal=r,this.geoIndex=s,this.positionCount=e.position.length/3,this.geoPositionCount=n.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(e),s){const e=this.geometry.getIndex();if(!e)return void il.error("Index is null");this.meshIndex=e.array,this.makeIndex()}}setAttributes(e={},t=!1){const i=this.geometry.attributes;let n,r,s,o,a,c,l,h,u;const d=this.updateNormals;e.position&&(n=e.position,s=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(d||t)&&(o=this.geoNormal,u=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),e.color&&(r=e.color,h=this.meshColor,i.color.needsUpdate=!0);const f=this.positionCount,m=this.geoPositionCount;for(let e=0;e 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Zp extends im{constructor(e,t,i={}){super(t,i),this.index=Ga(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:Hl(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(e){const t={};for(const i in e){const n=e[i];t[i]={type:n.type,value:null}}super.addAttributes(t)}getAttributeIndex(e){return 3*e*this.mappingSize}setAttributes(e){e&&!e.position&&e.position1&&e.position2&&(e.position=Ul(e.position1,e.position2));const t=this.size,i=this.mappingSize,n=this.geometry.attributes;let r,s,o,a,c,l,h;for(const u in e)if("index"!==u&&"picking"!==u){s=e[u],r=n[u],o=r.itemSize,a=r.array;for(let e=0;e0&&this.parameters.alphaTest<=1&&(t.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),t}setUniforms(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),super.setUniforms(e)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}ml.add("point",sg);class og extends tu{constructor(e,t,i){super(e,t,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Zf?(this.surface=void 0,this.volume=new Lm(e)):(this.surface=e,this.volume=void 0),this.init(i)}init(e){var t=e||{};t.colorScheme=Ia(t.colorScheme,"uniform"),t.colorValue=Ia(t.colorValue,14540253),this.thresholdType=Ia(t.thresholdType,"sigma"),this.thresholdMin=Ia(t.thresholdMin,2),this.thresholdMax=Ia(t.thresholdMax,1/0),this.thresholdOut=Ia(t.thresholdOut,!1),this.dotType=Ia(t.dotType,"point"),this.radius=Ia(t.radius,.1),this.scale=Ia(t.scale,1),this.pointSize=Ia(t.pointSize,1),this.sizeAttenuation=Ia(t.sizeAttenuation,!0),this.sortParticles=Ia(t.sortParticles,!1),this.useTexture=Ia(t.useTexture,!1),this.alphaTest=Ia(t.alphaTest,.5),this.forceTransparent=Ia(t.forceTransparent,!1),this.edgeBleach=Ia(t.edgeBleach,0),super.init(t),this.build()}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){var e={};if(this.volume){var t,i,n=this.volume;"sigma"===this.thresholdType?(t=n.getValueForSigma(this.thresholdMin),i=n.getValueForSigma(this.thresholdMax)):(t=this.thresholdMin,i=this.thresholdMax),n.setFilter(t,i,this.thresholdOut),Object.assign(e,{position:n.getDataPosition(),color:n.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:n.getDataSize(this.radius,this.scale),picking:n.getDataPicking()})}else{var r=this.surface;Object.assign(e,{position:r.getPosition(),color:r.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:r.getSize(this.radius,this.scale),picking:r.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new tg(e,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new sg(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(e={}){if(0===this.bufferList.length)return;const t={};e.color&&(this.volume?Object.assign(t,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(t,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(e.radius||e.scale)&&(this.volume?Object.assign(t,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(t,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(t)}setParameters(e,t={},i){return e&&void 0!==e.thresholdType&&this.volume instanceof Zf&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=parseFloat(e.radiusType),t.radius=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(t.radius=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(t.scale=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),super.setParameters(e,t,i),this}}ul.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),ul.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const ag=new Uint16Array([0,1,2,1,3,2]),cg=new Float32Array([0,1,0,0,1,1,1,0]),lg=Object.assign({filter:"nearest",forceTransparent:!0},em),hg=Object.assign({filter:{updateShader:!0,uniform:!0}},tm);class ug extends im{constructor(e,t){super({position:e.position,index:ag,picking:e.picking},t),this.parameterTypes=hg,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:i,width:n,height:r}=e,s=new Ar(i,n,r);s.flipY=!0,this.tex=s;const o=i.length,a=new Uint8Array(o);for(let e=0;e>16&255,a[e+1]=t>>8&255,a[e+2]=255&t}const c=new Ar(a,n,r);c.flipY=!0,c.minFilter=re,c.magFilter=re,this.pickingTex=c,this.addUniforms({map:{value:s},pickingMap:{value:c},mapSize:{value:new zt(n,r)}}),this.geometry.setAttribute("uv",new An(cg,2))}get defaultParameters(){return lg}getDefines(e){const t=super.getDefines(e),i=this.parameters.filter;return i.startsWith("cubic")&&(t.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?t.BSPLINE_FILTER=1:i.endsWith("catmulrom")?t.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(t.MITCHELL_FILTER=1)),t}updateTexture(){const e=this.tex,t=this.parameters.filter;t.startsWith("cubic")?(e.minFilter=re,e.magFilter=re):"linear"===t?(e.minFilter=ae,e.magFilter=ae):(e.minFilter=re,e.magFilter=re),e.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const e=this.material;e.uniforms.map.value=this.tex,e.blending=u,e.needsUpdate=!0;const t=this.wireframeMaterial;t.uniforms.map.value=this.tex,t.blending=u,t.needsUpdate=!0;const i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=u,i.needsUpdate=!0}setUniforms(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),super.setUniforms(e)}}class dg{constructor(e,t){const i=t||{};this.dimension=Ia(i.dimension,"x"),this.positionType=Ia(i.positionType,"percent"),this.position=Ia(i.position,30),this.thresholdType=Ia(i.thresholdType,"sigma"),this.thresholdMin=Ia(i.thresholdMin,-1/0),this.thresholdMax=Ia(i.thresholdMax,1/0),this.normalize=Ia(i.normalize,!1),this.volume=e}getPositionFromCoordinate(e){const t=this.dimension,i=this.volume,n=i.matrix,r=(new Zt).setFromMatrixPosition(n)[t],s=(new Zt).setFromMatrixScale(n)[t];let o;return o="x"===t?i.nx:"y"===t?i.ny:i.nz,Math.round(((e-r)/(o/100)+1)/s)}getData(e){e=e||{};const t=this.volume,i=t.data,n=t.matrix;let r;function s(e){return Math.round(e/100*(r-1))}function o(e,i,n,r){return 3*(n*t.ny*t.nx+i*t.nx+e)+r}r="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const a=new Float32Array(12),c=new Zt;let l,h,u,d,f,m=0,p=0,g=0,v=t.nx,y=t.ny,x=t.nz;function b(e,t,i,r){c.set(e,t,i).applyMatrix4(n).toArray(a,r)}"x"===this.dimension?(u=s(t.nx),d=t.ny-1,f=t.nz-1,l=t.nz,h=t.ny,m=u,v=m+1,b(u,0,0,0),b(u,d,0,3),b(u,0,f,6),b(u,d,f,9)):"y"===this.dimension?(u=t.nx-1,d=s(t.ny),f=t.nz-1,l=t.nz,h=t.nx,p=d,y=p+1,b(0,d,0,0),b(u,d,0,3),b(0,d,f,6),b(u,d,f,9)):"z"===this.dimension&&(u=t.nx-1,d=t.ny-1,f=s(t.nz),l=t.nx,h=t.ny,g=f,x=g+1,b(0,0,f,0),b(0,d,f,3),b(u,0,f,6),b(u,d,f,9));let _=0,w=0;const S=new Uint8Array(l*h*4),A=new Float32Array(l*h);let M,C;"sigma"===this.thresholdType?(M=t.getValueForSigma(this.thresholdMin),C=t.getValueForSigma(this.thresholdMax)):(M=this.thresholdMin,C=this.thresholdMax);const P=Object.assign({},e.colorParams,{volume:t});this.normalize&&(P.domain=[0,1]);const T=al.getScheme(P),I=new Float32Array(3),E=T.getScale();let D,L=0,R=0;if(this.normalize){L=1/0,D=-1/0;for(let e=p;eD&&(D=r)}R=D-L}for(let e=p;eM&&s{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){const e=new dg(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),t=new ug(e.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(t)}}function mg(e){il.error(`makeRepresentation: representation type ${e} unknown`)}const pg={name:"some element",status:""};class gg{constructor(e,t={}){this.stage=e,this.signals={statusChanged:new mc.Signal,nameChanged:new mc.Signal,disposed:new mc.Signal},this.parameters=Ea(t,this.defaultParameters),this.uuid=ec()}get defaultParameters(){return pg}get name(){return this.parameters.name}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}dispose(){this.signals.disposed.dispatch()}}const vg=Object.assign({visible:!0},pg);class yg extends gg{constructor(e,t,i={},n){super(e,Object.assign({name:t.type},i)),this.parent=n,this.signals=Object.assign({visibilityChanged:new mc.Signal,parametersChanged:new mc.Signal},this.signals),this.setRepresentation(t)}get defaultParameters(){return vg}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(e){this._disposeRepresentation(),this.repr=e,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(e){return this.parameters.visible=e,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(e){return this.repr.update(e),this}build(e){return this.repr.build(e),this}setSelection(e){const t=this.repr;return t.setSelection&&t.setSelection(e),this}setParameters(e){return this.repr.setParameters(e),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(e){return this.repr.setColor(e),this}}const xg=new ri,bg=new Zt,_g={name:"",status:"",visible:!0};class wg{constructor(e,t,i={}){this.stage=e,this.object=t,this.signals={representationAdded:new mc.Signal,representationRemoved:new mc.Signal,visibilityChanged:new mc.Signal,matrixChanged:new mc.Signal,statusChanged:new mc.Signal,nameChanged:new mc.Signal,disposed:new mc.Signal},this.reprList=[],this.annotationList=[],this.matrix=new ri,this.position=new Zt,this.quaternion=new qt,this.scale=new Zt(1,1,1),this.transform=new ri,this.parameters=Ea(i,this.defaultParameters),this.uuid=ec(),this.viewer=e.viewer,this.controls=new Cm(this)}get defaultParameters(){return _g}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(e){return Array.isArray(e)?this.position.fromArray(e):this.position.copy(e),this.updateMatrix(),this}setRotation(e){if(Array.isArray(e))if(3===e.length){const t=(new ai).fromArray(e);this.quaternion.setFromEuler(t)}else this.quaternion.fromArray(e);else e instanceof ai?this.quaternion.setFromEuler(e):this.quaternion.copy(e);return this.updateMatrix(),this}setScale(e){return this.scale.set(e,e,e),this.updateMatrix(),this}setTransform(e){return this.transform.copy(e),this.updateMatrix(),this}updateMatrix(){const e=this.getCenterUntransformed(bg);this.matrix.makeTranslation(-e.x,-e.y,-e.z),xg.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(xg),xg.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(xg);const t=this.position;xg.makeTranslation(t.x+e.x,t.y+e.y,t.z+e.z),this.matrix.premultiply(xg),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((e=>{e.setParameters({matrix:this.matrix})}))}addAnnotation(e,t,i){const n=new wm(this,e,t,i);return this.annotationList.push(n),n}eachAnnotation(e){this.annotationList.slice().forEach(e)}removeAnnotation(e){const t=this.annotationList.indexOf(e);-1!==t&&(this.annotationList.splice(t,1),e.dispose())}removeAllAnnotations(){this.eachAnnotation((e=>e.dispose())),this.annotationList.length=0}_addRepresentation(t,i,n,r=!1){const s=n||{},o=this.stage.getParameters();s.matrix=this.matrix.clone(),s.quality=s.quality||o.quality,s.disableImpostor=Ia(s.disableImpostor,!o.impostor),s.useWorker=Ia(s.useWorker,o.workerDefault),s.visible=Ia(s.visible,!0);const a=Object.assign({},s,{visible:this.parameters.visible&&s.visible}),c=function(t,i,n,r){var s;if(e.Debug&&il.time("makeRepresentation "+t),i instanceof Fp){if(!(s=ll.get(t)))return void mg(t)}else if(i instanceof Xf)if("surface"===t)s=lm;else{if("dot"!==t)return void mg(t);s=og}else if(i instanceof Zf)if("surface"===t)s=lm;else if("dot"===t)s=og;else{if("slice"!==t)return void mg(t);s=fg}else if(i instanceof Gp)s=Vp,i=i.getBufferList();else{if("buffer"!==t)return void il.error("makeRepresentation: object "+i+" unknown");s=Vp}const o=new s(i,n,r);return e.Debug&&il.timeEnd("makeRepresentation "+t),o}(t,i,this.viewer,a),l=new yg(this.stage,c,s,this);return r||(this.reprList.push(l),this.signals.representationAdded.dispatch(l)),l}addBufferRepresentation(e,t){return this._addRepresentation.call(this,"buffer",e,t)}hasRepresentation(e){return-1!==this.reprList.indexOf(e)}eachRepresentation(e){this.reprList.slice().forEach(e)}removeRepresentation(e){const t=this.reprList.indexOf(e);-1!==t&&(this.reprList.splice(t,1),e.dispose(),this.signals.representationRemoved.dispatch(e))}updateRepresentations(e){this.reprList.forEach((t=>t.update(e))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((e=>e.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(e){return this.parameters.visible=e,this.eachRepresentation((e=>e.updateVisibility())),this.eachAnnotation((e=>e.updateVisibility())),this.signals.visibilityChanged.dispatch(e),this}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}getBox(...e){return this.getBoxUntransformed(...e).clone().applyMatrix4(this.matrix)}getCenter(...e){return this.getCenterUntransformed(...e).clone().applyMatrix4(this.matrix)}getZoom(...e){return this.stage.getZoomForBox(this.getBox(...e))}getBoxUntransformed(...e){return new Ni}getCenterUntransformed(...e){return this.getBoxUntransformed().getCenter(new Zt)}autoView(e){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),Ia(e,0))}}class Sg{constructor(e=[]){this.list=e;const t=e.length;for(let i=0;i0?this.list[0]:void 0}forEach(e){return this.list.forEach(e),this}dispose(){return this.forEach((e=>e.dispose()))}}class Ag extends Sg{setParameters(e){return this.forEach((t=>t.setParameters(e)))}setVisibility(e){return this.forEach((t=>t.setVisibility(e)))}setSelection(e){return this.forEach((t=>t.setSelection(e)))}setColor(e){return this.forEach((t=>t.setColor(e)))}update(e){return this.forEach((t=>t.update(e)))}build(e){return this.forEach((t=>t.build(e)))}dispose(e){return this.forEach((e=>e.dispose()))}}const Mg=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},pg);class Cg extends gg{constructor(e,t,i={}){super(e,Object.assign({name:t.name},i)),this.trajectory=t,this.signals=Object.assign(this.signals,{frameChanged:new mc.Signal,playerChanged:new mc.Signal,countChanged:new mc.Signal,parametersChanged:new mc.Signal}),t.signals.frameChanged.add((e=>{this.signals.frameChanged.dispatch(e)})),t.signals.playerChanged.add((e=>{this.signals.playerChanged.dispatch(e)})),t.signals.countChanged.add((e=>{this.signals.countChanged.dispatch(e)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return Mg}get type(){return"trajectory"}setFrame(e){this.trajectory.setFrame(e)}setParameters(e={}){this.trajectory.setParameters(e),this.signals.parametersChanged.dispatch(e)}dispose(){this.trajectory.dispose(),super.dispose()}}class Pg{constructor(e,t){this.name=e,this.path=t,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class Tg{constructor(e,t){let i,n;if(this.A=new Mf(3,3),this.W=new Mf(1,3),this.U=new Mf(3,3),this.V=new Mf(3,3),this.VH=new Mf(3,3),this.R=new Mf(3,3),this.tmp=new Mf(3,3),this.c=new Mf(3,3),e instanceof Fp)i=e.atomCount;else{if(!(e instanceof Float32Array))return;i=e.length/3}if(t instanceof Fp)n=t.atomCount;else{if(!(t instanceof Float32Array))return;n=t.length/3}const r=Math.min(i,n),s=new Mf(3,r),o=new Mf(3,r);this.coords1t=new Mf(r,3),this.coords2t=new Mf(r,3),this.transformationMatrix=new ri,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(e,s,r,!1),this.prepCoords(t,o,r,!1),this._superpose(s,o)}_superpose(t,i){this.mean1=If(t),this.mean2=If(i),Ef(t,this.mean1),Ef(i,this.mean2),Cf(this.coords1t,t),Cf(this.coords2t,i),Pf(this.A,this.coords2t,this.coords1t),Of(this.A,this.W,this.U,this.V),function(e,t){const i=e.data,n=t.data,r=i[4],s=i[8],o=i[5],a=i[7],c=i[0],l=c*r,h=c*o,u=i[3],d=i[1],f=u*d,m=i[2],p=u*m,g=i[6],v=g*d,y=g*m,x=1/(l*s-h*a-f*s+p*a+v*o-y*r);n[0]=(r*s-o*a)*x,n[1]=-(d*s-m*a)*x,n[2]=-(-d*o+m*r)*x,n[3]=-(u*s-o*g)*x,n[4]=(c*s-y)*x,n[5]=-(h-p)*x,n[6]=-(-u*a+r*g)*x,n[7]=-(c*a-v)*x,n[8]=(l-f)*x}(this.V,this.VH),Tf(this.R,this.U,this.VH),function(e){const t=e.data;return t[0]*t[4]*t[8]-t[0]*t[5]*t[7]-t[3]*t[1]*t[8]+t[3]*t[2]*t[7]+t[6]*t[1]*t[5]-t[6]*t[2]*t[4]}(this.R)<0&&(e.Debug&&il.log("R not a right handed system"),Tf(this.tmp,this.c,this.VH),Tf(this.R,this.U,this.tmp));const n=new Mf(4,4),r=new Mf(4,4),s=new Mf(4,4),o=new Mf(4,4),a=new Mf(4,4),c=new Mf(4,4),l=this.R.data,h=this.mean1,u=this.mean2;o.data.set([1,0,0,-h[0],0,1,0,-h[1],0,0,1,-h[2],0,0,0,1]),a.data.set([l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]),c.data.set([1,0,0,u[0],0,1,0,u[1],0,0,1,u[2],0,0,0,1]),Cf(r,o),Pf(n,a,r),Cf(s,n),Pf(r,c,s),Cf(n,r),this.transformationMatrix.elements=n.data}prepCoords(e,t,i,n){let r=0;const s=t.data;let o=3,a=3*i;if(n&&(a=4*i,o=4),e instanceof Fp)e.eachAtom((function(e){r{e!==this&&this.pause()}),this);const i=Ia(e.frameCount,1);this.traj=e,this.parameters=Ea(t,Ig),this.parameters.end=Math.min(Ia(t.end,i-1),i-1),this.parameters.step=Ia(t.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,e.signals.countChanged.add((e=>{this.parameters.end=Math.min(Ia(this.parameters.end,e-1),e-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(e={}){Da(this.parameters,e),void 0!==e.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const e=this._currentTime-this._previousTime,t=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/t,n=this.traj;if(n&&n.frameCount&&!n.inProgress&&e>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),n.hasFrame(this._currentFrame)){this._currentStep+=1;const e=this._currentStep/(this.parameters.interpolateStep+1),[t,i,r,s]=this._currentFrame;n.setFrameInterpolated(t,i,r,s,e,this.parameters.interpolateType),this._previousTime=this._currentTime}else n.loadFrame(this._currentFrame);else{const e=this._next();n.hasFrame(e)?(n.setFrame(e),this._previousTime=this._currentTime):n.loadFrame(e)}window.requestAnimationFrame(this._animate)}_next(){const e=this.parameters;let t;return t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step,(t>e.end||t=e.end?i=e.start:"backward"===e.direction&&t<=e.start&&(i=e.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class Dg{constructor(e,t,i={}){this.signals={countChanged:new mc.Signal,frameChanged:new mc.Signal,playerChanged:new mc.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=Ia(i.deltaTime,0),this.timeOffset=Ia(i.timeOffset,0),this.centerPbc=Ia(i.centerPbc,!1),this.removePbc=Ia(i.removePbc,!1),this.removePeriodicity=Ia(i.removePeriodicity,!1),this.superpose=Ia(i.superpose,!1),this.name=e.replace(/^.*[\\/]/,""),this.trajPath=e,this.selection=new $c(Ia(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(e){this.setStructure(e),this._loadFrameCount(),this.setPlayer(new Eg(this))}_loadFrameCount(){}setStructure(e){this.structure=e,this.atomCount=e.atomCount,this.backboneIndices=this._getIndices(new $c("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(e){return this.selection.setString(e),this}_getIndices(e){let t=0;const i=e.test,n=[];return i&&this.structure.eachAtom((e=>{i(e)&&n.push(t),t+=1})),n}_makeSuperposeCoords(){const e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);const t=this.initialCoords,i=this.coords2;for(let n=0;n!!this.frameCache[e])):!!this.frameCache[e]}setFrame(e,t){return void 0===e||(this.inProgress=!0,-1===e||this.frameCache[e]?(this._updateStructure(e),t&&t()):this.loadFrame(e,(()=>{this._updateStructure(e),t&&t()}))),this}_interpolate(e,t,i,n,r,s){const o=this.frameCache;let a;a="spline"===s?function(e,t,i,n,r){const s=e.length,o=new Float32Array(s);for(let a=0;a{this._interpolate(e,t,i,n,r,s),o&&o()})):(this._interpolate(e,t,i,n,r,s),o&&o()),this}loadFrame(e,t){Array.isArray(e)?e.forEach((e=>{this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e]})))})):this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e],t&&t()})))}_loadFrame(e,t){il.error("Trajectory._loadFrame not implemented",e,t)}_updateStructure(e){this._disposed?console.error("updateStructure: traj disposed"):(-1===e?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[e]),this.structure.trajectory={name:this.trajPath,frame:e},this._currentFrame=e,this.inProgress=!1,this.signals.frameChanged.dispatch(e))}_doSuperpose(e){const t=3*this.selectionIndices.length,i=this.coords1,n=this.coords2;for(let n=0;n0&&this.centerPbc){const e=[t[0],t[4],t[8]],n=function(e,t,i){return[zl(t,i[0],3,0,e),zl(t,i[1],3,1,e),zl(t,i[2],3,2,e)]}(this.backboneIndices,i,e);!function(e,t,i){if(0===i[0]||0===i[8]||0===i[4])return;const n=e.length,r=i[0],s=i[1],o=i[2],a=-t[0]+r+r/2,c=-t[1]+s+s/2,l=-t[2]+o+o/2;for(let t=0;t.5&&(e[r+n]-=t[3*n+n]*Math.round(s))}}(i,t,e)}this.removePbc&&function(e,t){if(0===t[0]||0===t[8]||0===t[4])return;const i=e.length;for(let n=3;n.9*t[3*i+i])if(r>0)for(let r=0;r<3;++r)e[n+r]-=t[3*i+r];else for(let r=0;r<3;++r)e[n+r]+=t[3*i+r]}}(i,t)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[e]=i,this.boxCache[e]=t,this.frameCacheSize+=1}_setFrameCount(e){e!==this._frameCount&&(this._frameCount=e,this.signals.countChanged.dispatch(e))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(e){this.player=e,this.signals.playerChanged.dispatch(e)}getFrameTime(e){return this.timeOffset+e*this.deltaTime}}class Lg extends Dg{constructor(e,t,i){const n=i||{};n.timeOffset=Ia(n.timeOffset,e.timeOffset),n.deltaTime=Ia(n.deltaTime,e.deltaTime),super("",t,n),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(t)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(e,t){let i;const n=this.frames[e];if(this.atomIndices){const e=this.atomIndices,t=e.length;i=new Float32Array(3*t);for(let r=0;r{const e=n.response;if(!e)return void il.error(`empty arrayBuffer for '${r}'`);const s=new Int32Array(e,0,1)[0],o=new Float32Array(e,8,9),a=new Float32Array(e,44);this._process(t,o,a,s),"function"==typeof i&&i()}),!1),n.send(s)}_loadFrameCount(){const t=new XMLHttpRequest,i=e.TrajectoryDatasource.getCountUrl(this.trajPath);t.open("GET",i,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class Og extends Dg{constructor(e,t,i){super("",t,i),this.requestCallback=e,this._init(t)}get type(){return"callback"}_makeAtomIndices(){const e=[];if("StructureView"===this.structure.type){const t=this.structure.getAtomIndices(),i=t.length;let n=t[0],r=t[0];for(let s=1;s{this._process(e,i,n,r),"function"==typeof t&&t()}),e,this.atomIndices)}_loadFrameCount(){this.requestCallback((e=>this._setFrameCount(e)))}}Fp.prototype.getView=function(e){return new Bg(this,e)};class Bg extends Fp{constructor(e,t){super(),this.structure=e,this.selection=t,this.center=new Zt,this.boundingBox=new Ni,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(e){this.structure._hasCoords=e}refresh(){e.Debug&&il.time("StructureView.refresh"),this.atomSetCache={};const t=this.structure;if(this.selection.isAllSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=t.atomSet.clone(),this.bondSet=t.bondSet.clone();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.clone()}this.atomCount=t.atomCount,this.bondCount=t.bondCount,this.boundingBox.copy(t.boundingBox),this.center.copy(t.center)}else if(this.selection.isNoneSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=new Yu(t.atomCount),this.bondSet=new Yu(t.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Yu(t.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),t.atomSet&&(this.atomSet=this.atomSet.intersection(t.atomSet)),this.bondSet=this.getBondSet();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new Zt)}e.Debug&&il.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(e){this.selection=e,this.refresh()}getSelection(e){const t=[];e&&e.string&&t.push(e.string);const i=this.structure.getSelection();i&&i.string&&t.push(i.string),this.selection&&this.selection.string&&t.push(this.selection.string);let n="";return t.length>0&&(n=`( ${t.join(" ) AND ( ")} )`),new $c(n)}getStructure(){return this.structure.getStructure()}eachBond(e,t){this.structure.eachBond(e,this.getSelection(t))}eachAtom(e,t){const i=this.getAtomProxy(),n=this.getAtomSet(t),r=this.atomStore.count;if(n.getSize()=this.V[n][r]?(i="S",this.score=this.S[n][r]):this.V[n][r]>=this.H[n][r]?(i="V",this.score=this.V[n][r]):(i="H",this.score=this.H[n][r]),e.Debug&&il.log("Alignment: SCORE",this.score),e.Debug&&il.log("Alignment: S, V, H",this.S[n][r],this.V[n][r],this.H[n][r]);n>0&&r>0;)"S"===i?this.S[n][r]===this.S[n-1][r-1]+t(n-1,r-1)?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--n,--r,i="S"):this.S[n][r]===this.V[n][r]?i="V":this.S[n][r]===this.H[n][r]?i="H":(--n,--r):"V"===i?this.V[n][r]===this.V[n-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n,i="V"):this.V[n][r]===this.S[n-1][r]+this.gap(0)?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n,i="S"):--n:"H"===i?this.H[n][r]===this.H[n][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,i="H"):this.H[n][r]===this.S[n][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,i="S"):--r:il.error("Alignment: no matrix");for(;n>0;)this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;e.Debug&&il.timeEnd("Alignment.trace"),e.Debug&&il.log([this.ali1,this.ali2])}}function $g(e,t,i=!1,n="",r=""){let s,o,a,c,l;if(i){let i=e,h=t;n&&r&&(i=e.getView(new $c(n)),h=t.getView(new $c(r)));const u=i.getSequence(),d=h.getSequence(),f=new Ug(u.join(""),d.join(""));let m,p;f.calc(),f.trace(),s=0,o=0,a=f.ali1.length;const g=[],v=[];for(let e=0;ee[t]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:nl.opacity,color:nl.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",nl,!0),this.angleRepresentation=this.addRepresentation("angle",nl,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",nl,!0),this.measureRepresentations=new Ag([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return Gg}get type(){return"structure"}initSelection(e){this.selection=new $c(e),this.structureView=new Bg(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(e){return this.parameters.sele=e,this.selection.setString(e),this}setDefaultAssembly(e){if(void 0===this.structure.biomolDict[e]&&(e=""),this.parameters.defaultAssembly!==e){const t={defaultAssembly:e};this.reprList.forEach((e=>e.setParameters(t))),this.measureRepresentations.setParameters(t),this.parameters.defaultAssembly=e,this.signals.defaultAssemblyChanged.dispatch(e)}return this}rebuildRepresentations(){this.reprList.forEach((e=>{e.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((e=>{e.trajectory.setStructure(this.structureView)}))}updateRepresentations(e){super.updateRepresentations(e),this.measureRepresentations.update(e)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(e,t={},i=!1){t.defaultAssembly=this.parameters.defaultAssembly;const n=this._addRepresentation(e,this.structureView,t,i);return i||n.signals.parametersChanged.add((()=>this.measureUpdate())),n}addTrajectory(e="",t={}){const i=function(e,t,i){let n;return n=e&&e instanceof Pg?new Lg(e,t,i):!e&&t.frames?new Rg(e,t,i):e&&"function"==typeof e?new Og(e,t,i):new kg(e,t,i),n}(e,this.structureView,t),n=new Cg(this.stage,i,t);return this.trajList.push(n),this.signals.trajectoryAdded.dispatch(n),n}removeTrajectory(e){const t=this.trajList.indexOf(e);-1!==t&&this.trajList.splice(t,1),e.dispose(),this.signals.trajectoryRemoved.dispatch(e)}dispose(){this.trajList.slice().forEach((e=>e.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(e,t){"number"==typeof e&&(t=e,e=""),this.stage.animationControls.zoomMove(this.getCenter(e),this.getZoom(e),Ia(t,0))}getBoxUntransformed(e){let t;return t=e?this.structureView.getBoundingBox(new $c(e)):this.structureView.boundingBox,t}getCenterUntransformed(e){return e&&"string"==typeof e?this.structure.atomCenter(new $c(e)):this.structure.center}superpose(e,t,i,n){return $g(this.structureView,e.structureView,t,i,n),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(e){let t=0;const i=this.structure.getAtomProxy(e);return this.eachRepresentation((e=>{if(e.getVisibility()){const n=e.repr;t=Math.max(n.getAtomRadius(i),t)}})),t}measurePick(e){const t=this.pickBuffer.count;if(this.lastPick===e.index&&t>=1){if(t>1){const e=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,e),2===t?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((e=>2===e.length))}):3===t?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((e=>3===e.length))}):4===t&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((e=>4===e.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(e.index)||this.pickBuffer.push(e.index),this.lastPick=e.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const e=this.measureData();this.distanceRepresentation.setParameters({atomPair:e.distance}),this.angleRepresentation.setParameters({atomTriple:e.angle}),this.dihedralRepresentation.setParameters({atomQuad:e.dihedral})}measureUpdate(){const e=this.pickBuffer.data,t={};e.forEach((e=>{const i=Math.max(.1,this.getMaxRepresentationRadius(e));t[e]=i*(2.3-rc(.1,2,i))})),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:t})}measureData(){const e=this.pickDict.values;return{distance:e.filter((e=>2===e.length)),angle:e.filter((e=>3===e.length)),dihedral:e.filter((e=>4===e.length))}}removeAllMeasurements(e){const t=this.pickDict,i=t.values,n=function(e){i.filter((t=>t.length===e)).forEach((e=>t.del(e.slice().sort())))};(!e||1&e)&&n(2),(!e||2&e)&&n(3),(!e||4&e)&&n(4),this.measureBuild()}removeMeasurement(e){this.pickDict.del(e.slice().sort()),this.measureBuild()}addMeasurement(e){if(e.length<2||e.length>4)return;const t=e.slice().sort();this.pickDict.has(t)||this.pickDict.add(t,e),this.measureBuild()}}fl.add("structure",Vg),fl.add("structureview",Vg);class Hg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.surface=t}get type(){return"surface"}addRepresentation(e,t={}){return this._addRepresentation(e,this.surface,t)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}fl.add("surface",Hg);class jg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.volume=t}get type(){return"volume"}addRepresentation(e,t={}){return this._addRepresentation(e,this.volume,t)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}fl.add("volume",jg);class Wg extends Sg{addRepresentation(e,t){return this.forEach((i=>i.addRepresentation(e,t)))}autoView(e){return this.forEach((t=>t.autoView(e)))}}function qg(e,t){return e instanceof RegExp?null!==t.name.match(e):t.name===e}const Xg=new Zt,Yg={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Zg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.shape=t}get type(){return"shape"}addRepresentation(e,t={}){return this._addRepresentation(e,this.shape,t)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Kg(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o}fl.add("shape",Zg);class Qg extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=Ia(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel((e=>{this.parameters.domain=[e.atomOffset,e.atomEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.index)}}Kg([uc],Qg.prototype,"atomColor",null),al.add("atomindex",Qg);class Jg extends dc{constructor(e){if(super(e),e.scale||(this.parameters.scale="OrRd"),!e.domain){let t,i=1/0,n=-1/0;e.sele&&(t=new $c(e.sele)),e.structure.eachAtom((function(e){const t=e.bfactor;i=Math.min(i,t),n=Math.max(n,t)}),t),this.parameters.domain=[i,n]}this.bfactorScale=this.getScale()}atomColor(e){return this.bfactorScale(e.bfactor)}}Kg([uc],Jg.prototype,"atomColor",null),al.add("bfactor",Jg);class ev extends dc{constructor(e){super(e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainid]&&(i[e.chainid]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainidDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainidDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainid])}}Kg([uc],ev.prototype,"atomColor",null),al.add("chainid",ev);class tv extends dc{constructor(e){super(e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{this.parameters.domain=[e.chainOffset,e.chainEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.chainIndex)}}Kg([uc],tv.prototype,"atomColor",null),al.add("chainindex",tv);class iv extends dc{constructor(e){super(e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainname]&&(i[e.chainname]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainnameDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainnameDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainname])}}Kg([uc],iv.prototype,"atomColor",null),al.add("chainname",iv);class nv extends dc{constructor(e){super(e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const t=e.structure.validation;t&&(this.rsrzDict=t.rsrzDict,this.rsccDict=t.rsccDict)}atomColor(e){let t=e.resno+"";e.inscode&&(t+="^"+e.inscode),e.chainname&&(t+=":"+e.chainname),t+="/"+e.modelIndex;const i=this.rsrzDict[t];if(void 0!==i)return this.rsrzScale(i);const n=this.rsccDict[t];return void 0!==n?this.rsccScale(n):9474192}}Kg([uc],nv.prototype,"atomColor",null),al.add("densityfit",nv);const rv={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class sv extends dc{constructor(e){super(e),this.delta=new Zt,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);const t=[];e.structure.eachAtom((e=>{var i;if(this.charges[e.index]=(null!==(i=e).partialCharge?i.partialCharge:i.isProtein()&&(rv[i.resname]&&rv[i.resname][i.atomname]||rv.backbone[i.atomname])||0)*e.occupancy,"N"===e.atomname){if(e.bondCount>=3)return;if(e.bondToElementCount(1))return;const i=function(e,t=new Zt){let i=!1,n=!1,r=!1;return t.set(2*e.x,2*e.y,2*e.z),e.eachBondedAtom((function(e){if(!i)return"H"===e.atomname?(t.set(e.x,e.y,e.z),void(i=!0)):void(n||"CA"!==e.atomname?r||"C"!==e.atomname||(r=!0,t.sub(e)):(t.sub(e),n=!0))})),i?t:n&&r?(t.normalize(),t.multiplyScalar(1.04),t.add(e),t):void 0}(e);void 0!==i&&(t.push(i),this.hCharges.push(.25*e.occupancy))}}));const i=e.structure.getBoundingBox();i.expandByScalar(1.04),this.hStore=function(e){const t=e.length,i=new Float32Array(t),n=new Float32Array(t),r=new Float32Array(t);for(let t=0;t{const r=t[e];0!==r&&(n+=r/i)})),this.hHash.eachWithin(e.x,e.y,e.z,12,((e,t)=>{const r=i[e];0!==r&&(n+=r/t)})),this.scale(332*n)}}Kg([uc],sv.prototype,"positionColor",null),al.add("electrostatic",sv);const ov={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class av extends dc{constructor(e){e.value=Ia(e.value,ov.C),super(e)}atomColor(e){const t=e.element;return"C"===t?this.parameters.value:ov[t]||16777215}}Kg([uc],av.prototype,"atomColor",null),al.add("element",av);class cv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="Spectral"),e.domain||(this.parameters.domain=[0,e.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(e){return this.entityindexScale(e.entityIndex)}}Kg([uc],cv.prototype,"atomColor",null),al.add("entityindex",cv);class lv extends dc{atomColor(e){const t=e.entity;switch(t?t.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Kg([uc],lv.prototype,"atomColor",null),al.add("entitytype",lv);class hv extends dc{constructor(e){super(e),this.geoAtomDict={},this.geoDict={};const t=e.structure.validation;t&&(this.geoAtomDict=t.geoAtomDict,this.geoDict=t.geoDict)}atomColor(e){let t,i=e.resno+"";e.inscode&&(i+="^"+e.inscode),e.chainname&&(i+=":"+e.chainname),i+="/"+e.modelIndex;const n=this.geoAtomDict[i];if(void 0!==n){const i=n[e.atomname]||0;r=i,t=16843009*((r=(858993459&(r-=r>>1&1431655765))+(r>>2&858993459))+(r>>4)&252645135)>>24}else t=this.geoDict[i]||0;var r;return 0===t?2188972:1===t?16703627:2===t?16018755:t>=3?10813478:9474192}}Kg([uc],hv.prototype,"atomColor",null),al.add("geoquality",hv);class uv extends dc{constructor(e){super(e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(const e in md)this.resHF[e]=md[e][0];if(this.defaultResidueHydrophobicity=pd[0],!e.domain){let e=1/0,t=-1/0;for(const i in this.resHF){const n=this.resHF[i];e=Math.min(e,n),t=Math.max(t,n)}this.parameters.domain=[e,0,t]}this.hfScale=this.getScale()}atomColor(e){return this.hfScale(this.resHF[e.resname]||this.defaultResidueHydrophobicity)}}Kg([uc],uv.prototype,"atomColor",null),al.add("hydrophobicity",uv);class dv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(e){return this.modelindexScale(e.modelIndex)}}Kg([uc],dv.prototype,"atomColor",null),al.add("modelindex",dv);class fv extends dc{atomColor(e){switch(e.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Kg([uc],fv.prototype,"atomColor",null),al.add("moleculetype",fv);class mv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(e){return this.occupancyScale(e.occupancy)}}Kg([uc],mv.prototype,"atomColor",null),al.add("occupancy",mv);class pv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(e){return this.partialchargeScale(e.partialCharge||0)}}function gv(){return 16777215*Math.random()}Kg([uc],pv.prototype,"atomColor",null),al.add("partialcharge",pv);class vv extends dc{atomColor(){return gv()}volumeColor(){return gv()}positionColor(){return gv()}}Kg([uc],vv.prototype,"atomColor",null),Kg([uc],vv.prototype,"volumeColor",null),Kg([uc],vv.prototype,"positionColor",null),al.add("random",vv);class yv extends dc{constructor(e){super(e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const t=e.structure.validation;t&&(this.rciDict=t.rciDict)}atomColor(e){let t=`[${e.resname}]${e.resno}`;e.chainname&&(t+=":"+e.chainname);const i=this.rciDict[t];return void 0!==i?this.rciScale(i):9474192}}Kg([uc],yv.prototype,"atomColor",null),al.add("randomcoilindex",yv);class xv extends dc{constructor(e){super(e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=Ia(e.reverse,!0)),e.structure.eachChain((e=>{this.parameters.domain=[e.residueOffset,e.residueEnd],this.scalePerChain[e.index]=this.getScale()}))}atomColor(e){return this.scalePerChain[e.chainIndex](e.residueIndex)}}Kg([uc],xv.prototype,"atomColor",null),al.add("residueindex",xv);const bv={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class _v extends dc{atomColor(e){return bv[e.resname]||16711935}}Kg([uc],_v.prototype,"atomColor",null),al.add("resname",_v);const wv=16711808,Sv=10485888,Av=6291584,Mv=16762880,Cv=6324479,Pv=16777215,Tv=11403518,Iv=16580962,Ev=10921722;class Dv extends dc{constructor(e){super(e),this.residueProxy=e.structure.getResidueProxy()}atomColor(e){const t=e.sstruc,i=this.residueProxy;return"h"===t?wv:"g"===t?Sv:"i"===t?Av:"e"===t||"b"===t?Mv:"t"===t?Cv:(i.index=e.residueIndex,i.isDna()?Tv:i.isRna()?Iv:i.isSaccharide()?Ev:i.isProtein()||"s"===t||"l"===t?Pv:8421504)}}Kg([uc],Dv.prototype,"atomColor",null),al.add("sstruc",Dv);class Lv extends dc{constructor(e){var t,i;super(e),e.scale||(this.parameters.scale="rwb"),this.atomData=null===(t=this.parameters.data)||void 0===t?void 0:t.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(e){var t;const i=null===(t=this.atomData)||void 0===t?void 0:t[e.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(e,t){var i;const n=null===(i=this.bondData)||void 0===i?void 0:i[e.index];return void 0!==n?this.scale(n):this.atomProxy?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Kg([uc],Lv.prototype,"atomColor",null),Kg([uc],Lv.prototype,"bondColor",null),al.add("structuredata",Lv);class Rv extends dc{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Kg([uc],Rv.prototype,"atomColor",null),Kg([uc],Rv.prototype,"bondColor",null),Kg([uc],Rv.prototype,"valueColor",null),Kg([uc],Rv.prototype,"volumeColor",null),al.add("uniform",Rv);class kv extends dc{constructor(e){super(e),this.valueScale=this.getScale()}volumeColor(e){return this.valueScale(this.parameters.volume.data[e])}}Kg([uc],kv.prototype,"volumeColor",null),al.add("value",kv);class Ov extends dc{constructor(e){super(e),this.vec=new Zt,this.valueScale=this.getScale()}positionColor(e){const t=this.parameters.volume;if(!t||!t.inverseMatrix)return this.parameters.value;const i=this.vec,n=t.data,r=t.nx,s=t.ny,o=r*s;i.copy(e),i.applyMatrix4(t.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*s+c)*r+a,u=h+1,d=h+r,f=h+o,m=d+1,p=f+1,g=d+o,v=g+1,y=n[h],x=n[u],b=n[d],_=n[f],w=n[m],S=n[p],A=n[g],M=n[v],C=i.x-a,P=i.y-c,T=i.z-l,I=ic(y,x,C),E=ic(_,S,C),D=ic(b,w,C),L=ic(A,M,C),R=ic(I,D,P),k=ic(E,L,P),O=ic(R,k,T);return this.valueScale(O)}}Kg([uc],Ov.prototype,"positionColor",null),al.add("volume",Ov);class Bv extends tu{constructor(e,t,i){const n=i||{};if(super(e,t,n),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:Tm.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new $c(n.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){const t={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach((function(e){t[e]=e})),this.parameters.assembly={type:"select",options:t,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(e){const t=e||{};t.colorScheme=Ia(t.colorScheme,"element"),this.setRadius(t.radius,t),this.radiusType=Ia(t.radiusType,"vdw"),this.radiusData=Ia(t.radiusData,{}),this.radiusSize=Ia(t.radiusSize,1),this.radiusScale=Ia(t.radiusScale,1),this.assembly=Ia(t.assembly,"default"),this.defaultAssembly=Ia(t.defaultAssembly,""),"auto"===t.quality&&(t.quality=this.getQuality()),super.init(t),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(e,t){const i=Object.keys(Pm);return"string"==typeof e&&i.includes(e.toLowerCase())?t.radiusType=e:void 0!==e&&(t.radiusType="size",t.radiusSize=e),this}getAssembly(){const e="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[e]}getQuality(){let e;const t=this.structureView,i=this.getAssembly();e=i?i.getAtomCount(t):t.atomCount,Kc&&(e*=4);return t.atomStore.count/t.residueStore.count<2&&(e*=10),e<15e3?"high":e<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const e=this.getAssembly();if(e)e.partList.forEach(((e,t)=>{const i=e.getView(this.structureView);if(0===i.atomCount)return;const n=this.createData(i,t);n&&(n.sview=i,n.instanceList=e.getInstanceList(),this.dataList.push(n))}));else{const e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}update(e){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((t=>{t.bufferList.length>0&&this.updateData(e,t)}),this):Object.assign(this.lazyProps.what,e)}updateData(e,t){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(e){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getBondParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getAtomRadius(e){if(this.structureView.atomSet.isSet(e.index)){return new Tm(this.getRadiusParams()).atomRadius(e)}return 0}setSelection(e,t){return this.selection.setString(e,t),this}setParameters(e,t={},i=!1){const n=e||{};return this.setRadius(n.radius,n),void 0===n.radiusType&&void 0===n.radiusData&&void 0===n.radiusSize&&void 0===n.radiusScale||(t.radius=!0,el&&!this.disableImpostor||(i=!0)),void 0!==n.defaultAssembly&&n.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===n.assembly||"default"===n.assembly)&&(i=!0),super.setParameters(n,t,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(e){const t=this.viewer,i=this.bufferList;this.dataList.forEach((function(e){e.bufferList.forEach((function(n){i.push(n),t.add(n,e.instanceList)}))})),this.setVisibility(this.visible),e()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class Nv extends Bv{constructor(e,t,i){super(e,t,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(e){const t=e||{};this.labelVisible=Ia(t.labelVisible,!0),this.labelSize=Ia(t.labelSize,2),this.labelColor=Ia(t.labelColor,16777215),this.labelFontFamily=Ia(t.labelFontFamily,"sans-serif"),this.labelFontStyle=Ia(t.labelFontstyle,"normal"),this.labelFontWeight=Ia(t.labelFontWeight,"bold"),this.labelsdf=Ia(t.labelsdf,"Chrome"===Yc),this.labelXOffset=Ia(t.labelXOffset,0),this.labelYOffset=Ia(t.labelYOffset,0),this.labelZOffset=Ia(t.labelZOffset,.5),this.labelAttachment=Ia(t.labelAttachment,"bottom-left"),this.labelBorder=Ia(t.labelBorder,!1),this.labelBorderColor=Ia(t.labelBorderColor,"lightgrey"),this.labelBorderWidth=Ia(t.labelBorderWidth,.15),this.labelBackground=Ia(t.labelBackground,!1),this.labelBackgroundColor=Ia(t.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=Ia(t.labelBackgroundMargin,.5),this.labelBackgroundOpacity=Ia(t.labelBackgroundOpacity,1),this.labelFixedSize=Ia(t.labelFixedSize,!1),this.lineOpacity=Ia(t.lineOpacity,1),this.linewidth=Ia(t.linewidth,2),super.init(t)}update(e){e.position?this.build():super.update(e)}updateData(e,t){const i={};if(e&&!e.labelSize||Object.assign(i,{size:Gl(this.n,this.labelSize)}),!e||e.labelColor){const e=new mn(this.labelColor);Object.assign(i,{color:Vl(this.n,e.r,e.g,e.b)})}this.textBuffer.setAttributes(i)}setParameters(e,t={},i=!1){return e&&e.labelSize&&(t.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(t.labelColor=!0,i=!0),super.setParameters(e,t,i),e&&void 0!==e.opacity&&this.textBuffer.setParameters({opacity:1}),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),t||this.viewer.requestRender(),this}getLabelBufferParams(e={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))}getAtomRadius(){return 0}}function Fv(e,t){const i=e.getAtomProxy(),n=new $c,r=t.length;if(0===r)return new Float32Array(0);const s=t[0].length,o=e.getAtomSet(),a=new Float32Array(r*s*3);let c=0;return t.forEach((function(t){let r=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Gv={};const Vv={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class Hv{constructor(e={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=Ea(e,Vv);const t=this.parameters;this.radius=t.size/8,this.padding=t.size/3;const i=this.lineHeight=t.size+2*t.outline+Math.round(t.size/4),n=this.maxWidth=t.width/4,r=this.canvas=document.createElement("canvas");r.width=n,r.height=i;const s=this.context=this.canvas.getContext("2d");s.font=`${t.style} ${t.variant} ${t.weight} ${t.size}px ${t.font}`,s.fillStyle="black",s.textAlign="left",s.textBaseline="bottom",s.lineJoin="round",this.gridOuter=new Float64Array(i*n),this.gridInner=new Float64Array(i*n),this.f=new Float64Array(Math.max(i,n)),this.d=new Float64Array(Math.max(i,n)),this.z=new Float64Array(Math.max(i,n)+1),this.v=new Int16Array(Math.max(i,n)),this.data=new Uint8Array(t.width*t.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=t.width,this.canvas2.height=t.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let e=32;e<=126;++e)this.map(String.fromCharCode(e));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new na(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(e){const t=this.parameters;return void 0===this.mapped[e]&&(this.draw(e),this.currentX+this.scratchW>t.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>t.height&&console.warn("canvas to small"),this.mapped[e]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[e]}get(e){return this.mapped[e]||this.placeholder}draw(e){const t=this.parameters,i=this.lineHeight,n=t.outline,r=this.context,s=this.maxWidth,o=n,a=i-t.outline,c=r.measureText(e),l=Math.min(s,Math.ceil(c.width+2*o+1)),h=l*i;r.clearRect(0,0,l,i),r.fillText(e,o,a);const u=r.getImageData(0,0,l,i),d=u.data;for(let e=0;e= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),ul.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Yv=Object.assign({linewidth:2},em),Zv=Object.assign({linewidth:{uniform:!0}},tm);class Kv extends Jp{constructor(e,t={}){super(e,t),this.parameterTypes=Zv,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new zt},projectionMatrixInverse:{value:new ri}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Yv}setParameters(e){super.setParameters(e)}}ml.add("wideline",Kv);class Qv extends Nv{constructor(e,t,i){super(e,t,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(e){const t=e||{};t.side=Ia(t.side,"double"),t.opacity=Ia(t.opacity,.5),this.atomTriple=Ia(t.atomTriple,[]),this.arcVisible=Ia(t.arcVisible,!0),this.sectorVisible=Ia(t.sectorVisible,!0),this.vectorVisible=Ia(t.vectorVisible,!0),super.init(t)}createData(e){if(!e.atomCount||!this.atomTriple.length)return;const t=function(e,t){return function(e){const t=[],i=e.length/9;for(let n=0;n radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const oy=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),ay=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class cy extends Zp{constructor(e,t={}){super("v3",e,t)}get mapping(){return oy}get mappingIndices(){return ay}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const ly=Object.assign({openEnded:!1},em),hy=Object.assign({openEnded:{updateShader:!0}},tm);class uy extends cy{constructor(e,t={}){super(e,t),this.parameterTypes=hy,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new ri},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return ly}getDefines(e){const t=cy.prototype.getDefines.call(this,e);return this.parameters.openEnded||(t.CAP=1),t}}Object.assign({disableImpostor:!1},ny,ly);const dy=class{constructor(e,t={}){return!e.color2&&e.color&&(e.color2=e.color),!el||t&&t.disableImpostor?new sy(e,t):new uy(e,t)}};ml.add("cylinder",dy);class fy extends Bv{constructor(e,t,i){super(e,t,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(e){const t=e||{};t.radiusSize=Ia(t.radiusSize,.5),t.colorValue=Ia(t.colorValue,"lightgreen"),t.useInteriorColor=Ia(t.useInteriorColor,!0),this.showAxes=Ia(t.showAxes,!0),this.showBox=Ia(t.showBox,!1),super.init(t)}getPrincipalAxes(){let e;const t=this.getAssembly();return t&&(e=t.partList[0].getSelection()),this.structureView.getPrincipalAxes(e)}getAxesData(e){const t=this.getPrincipalAxes(),i=new mn(this.colorValue);let n=0,r=0;this.showAxes&&(n+=6,r+=3),this.showBox&&(n+=8,r+=12);const s=new Float32Array(3*n),o=Vl(n,i.r,i.g,i.b),a=Gl(n,this.radiusSize),c=new Float32Array(3*r),l=new Float32Array(3*r),h=Vl(r,i.r,i.g,i.b),u=Gl(r,this.radiusSize);let d=0;if(this.showAxes){const e=function(e,t){e.toArray(s,2*d),t.toArray(s,2*d+3),e.toArray(c,d),t.toArray(l,d),d+=3};e(t.begA,t.endA),e(t.begB,t.endB),e(t.begC,t.endC)}if(this.showBox){const i=new Zt,{d1a:n,d2a:r,d3a:o,d1b:a,d2b:h,d3b:u}=t.getProjectedScaleForAtoms(e);let f=2*d;const m=function(e,n,r){i.copy(t.center).addScaledVector(t.normVecA,e).addScaledVector(t.normVecB,n).addScaledVector(t.normVecC,r),i.toArray(s,f),f+=3};m(n,r,o),m(n,r,u),m(n,h,u),m(n,h,o),m(a,h,u),m(a,h,o),m(a,r,o),m(a,r,u);let p=d;const g=function(e,t){i.fromArray(s,2*d+3*e).toArray(c,p),i.fromArray(s,2*d+3*t).toArray(l,p),p+=3};g(0,1),g(0,3),g(0,6),g(1,2),g(1,7),g(2,3),g(2,4),g(3,5),g(4,5),g(4,7),g(5,6),g(6,7)}const f=new uf(t);return{vertex:{position:s,color:o,radius:a,picking:f},edge:{position1:c,position2:l,color:h,color2:h,radius:u,picking:f}}}create(){const e=this.getAxesData(this.structureView);this.sphereBuffer=new tg(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new dy(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(e){}updateData(e,t){const i=this.getAxesData(t.sview),n={},r={};e&&!e.position||(Object.assign(n,{position:i.vertex.position}),Object.assign(r,{position1:i.edge.position1,position2:i.edge.position2})),e&&!e.color||(Object.assign(n,{color:i.vertex.color}),Object.assign(r,{color:i.edge.color,color2:i.edge.color})),e&&!e.radius||(Object.assign(n,{radius:i.vertex.radius}),Object.assign(r,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(n),this.cylinderBuffer.setAttributes(r)}}ll.add("axes",fy);class my extends Bv{constructor(e,t,i){super(e,t,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(e){var t=e||{};t.radiusType=Ia(t.radiusType,"size"),t.radiusSize=Ia(t.radiusSize,.15),t.useInteriorColor=Ia(t.useInteriorColor,!0),this.aspectRatio=Ia(t.aspectRatio,2),this.lineOnly=Ia(t.lineOnly,!1),this.cylinderOnly=Ia(t.cylinderOnly,!1),this.multipleBond=Ia(t.multipleBond,"off"),this.bondSpacing=Ia(t.bondSpacing,1),this.bondScale=Ia(t.bondScale,.4),this.linewidth=Ia(t.linewidth,2),super.init(t)}getAtomRadius(e){return this.aspectRatio*super.getAtomRadius(e)}getAtomParams(e,t){var i=super.getAtomParams(e,t);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(e,t,i){return e.getAtomData(this.getAtomParams(t,i))}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},t),super.getBondParams(e,t)}getBondData(e,t,i){return e.getBondData(this.getBondParams(t,i))}createData(e){const t=[];if(this.lineOnly)this.lineBuffer=new Kv(this.getBondData(e,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),t.push(this.lineBuffer);else{const i=new dy(this.getBondData(e),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(t.push(i),!this.cylinderOnly){const i=new tg(this.getAtomData(e),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));t.push(i)}}return{bufferList:t}}updateData(e,t){"off"!==this.multipleBond&&e&&e.radius&&(e.position=!0);const i=this.getBondData(t.sview,e);if(this.lineOnly){const n={};e&&!e.position||Object.assign(n,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(n,{color:i.color,color2:i.color2}),t.bufferList[0].setAttributes(n)}else{var n={};if(e&&!e.position||Object.assign(n,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(n,{color:i.color,color2:i.color2}),e&&!e.radius||Object.assign(n,{radius:i.radius}),t.bufferList[0].setAttributes(n),!this.cylinderOnly){var r=this.getAtomData(t.sview,e),s={};e&&!e.position||Object.assign(s,{position:r.position}),e&&!e.color||Object.assign(s,{color:r.color}),e&&!e.radius||Object.assign(s,{radius:r.radius}),t.bufferList[1].setAttributes(s)}}}setParameters(e={}){let t=!1;const i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),el&&!this.disableImpostor||(t=!0)),super.setParameters(e,i,t),this}}ll.add("ball+stick",my);class py extends my{constructor(e,t,i){super(e,t,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(e){var t=e||{};t.aspectRatio=Ia(t.aspectRatio,1),t.radiusSize=Ia(t.radiusSize,.25),super.init(t)}getAtomRadius(e){return e.isTrace()?super.getAtomRadius(e):0}getAtomData(e,t,i){return e.getBackboneAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){return e.getBackboneBondData(this.getBondParams(t,i))}}ll.add("backbone",py);class gy extends my{constructor(e,t,i){super(e,t,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(e){let t=e||{};t.aspectRatio=Ia(t.aspectRatio,1),t.radiusSize=Ia(t.radiusSize,.3),super.init(t)}getAtomData(e,t,i){return e.getRungAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){let n=this.getBondParams(t,i);return Object.assign(n.colorParams,{rung:!0}),e.getRungBondData(n)}}ll.add("base",gy);class vy{constructor(e,t){this.m=e,this.tension=t,this.dt=1/this.m,this.delta=1e-4,this.vec1=new Zt,this.vec2=new Zt,this.vDir=new Zt,this.vTan=new Zt,this.vNorm=new Zt,this.vBin=new Zt,this.m2=Math.ceil(this.m/2)}interpolateToArr(e,t,i,n,r,s,o){s[o+0]=nc(e.x,t.x,i.x,n.x,r,this.tension),s[o+1]=nc(e.y,t.y,i.y,n.y,r,this.tension),s[o+2]=nc(e.z,t.z,i.z,n.z,r,this.tension)}interpolateToVec(e,t,i,n,r,s){s.x=nc(e.x,t.x,i.x,n.x,r,this.tension),s.y=nc(e.y,t.y,i.y,n.y,r,this.tension),s.z=nc(e.z,t.z,i.z,n.z,r,this.tension)}interpolatePosition(e,t,i,n,r,s){for(var o=0;o1&&(l=1),this.interpolateToVec(e,t,i,n,c,this.vec1),this.interpolateToVec(e,t,i,n,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(r,h)}}vectorSubdivide(e,t,i,n,r){let s,o=t.next(),a=t.next(),c=t.next();const l=t.size,h=l-1;let u=n||0;for(let n=0;n0&&n{if(e.residueCount<4)return;i.push(e);const n=this.getSpline(e),r=this.getAspectRatio(e),s=n.getSubdividedPosition(),o=n.getSubdividedOrientation(),a=n.getSubdividedColor(this.getColorParams()),c=n.getSubdividedPicking(),l=n.getSubdividedSize(this.getRadiusParams());t.push(new wy(Object.assign({},s,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:r,capped:this.capped})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&il.time(this.type+" repr update"),t=t||{};for(var n=0,r=i.polymerList.length;n0;fu(w,y,S);const r=du(w,b)<0;if(bu(w,b,du(b,x)),fu(A,x,w),bu(w,b,du(b,_)),fu(M,_,w),0===yu(A)||0===yu(M))continue;_u(A,A),_u(M,M);const L=s[E]=Pu(A,M);a[E]=(Fl*L).toFixed(1)+String.fromCharCode(176),uu(T,A,b),_u(T,T),du(T,M)<0&&Cu(T,T),zv(w,S,A,T,L/2),gu(w,o,3*E);const R=Math.ceil(L/i),k=R+(t.extendLine?4:2),O=t.extendLine?36:0,B=new Float32Array(3*k),N=new Float32Array(3*k),F=new Float32Array(9*R),z=new Float32Array(O);c[E]=B,l[E]=N,h[E]=F,u[E]=z,t.extendLine&&(n?(fu(w,p,v),_u(w,w),bu(C,w,1/du(A,w)),mu(C,C,v)):(bu(C,x,1/du(A,x)),mu(C,C,g)),r?(fu(w,y,g),_u(w,w),bu(P,w,1/du(M,w)),mu(P,P,g)):(bu(P,_,1/du(M,_)),mu(P,P,v))),mu(I,S,A);let U=0;t.extendLine?(gu(p,B,U),gu(C,N,U),U+=3,gu(C,B,U),gu(I,N,U),U+=3,gu(C,z,0),gu(I,z,3),gu(n?v:g,z,6),gu(n?v:g,z,9),gu(I,z,12),gu(S,z,15)):(gu(S,B,U),gu(I,N,U),U+=3);const $=function(e,t){const i=9*t;gu(S,F,i),gu(I,F,i+3),gu(I,B,U),zv(I,S,A,T,e),gu(I,F,i+6),gu(I,N,U),U+=3};let G=0;for(let e=i;e{const t=Cy(i,e);Object.assign(e,t)})),t.side=Ia(t.side,"double"),t.opacity=Ia(t.opacity,.5),t.radiusType=Ia(t.radiusType,"size"),t.radiusSize=Ia(t.radiusSize,.15),super.init(t)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(e){if(!e.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((t=>t.atomPositions=Fv(e,[t.atomQuad])));const t=this.scaleBinToSectorArea?function(e){return Math.sqrt(e)}:function(e){return e};function i(e){const t=e.map((e=>e.length)),i=new Float32Array(Kl(t));let n=0;for(let t=0;te.startPoints))),position2:i(e.map((e=>e.endPoints))),color:i(e.map((e=>e.startColors))),color2:i(e.map((e=>e.endColors)))},t)}function r(e,t){return new nm({position:i(e.map((e=>e.triangles))),color:i(e.map((e=>e.triangleColors)))},t)}this.histogramsData.forEach((e=>e.histogram360Scaled=e.histogram360.map(t)));const s=[];for(let e=0;e=3&&(t=Iy(i)),void 0!==t&&s.push(t)}return this.frontHistogramBinBordersBuffer=n(s.map((e=>e.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=n(s.map((e=>e.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=n(s.map((e=>e.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=n(s.map((e=>e.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=r(s.map((e=>e.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=r(s.map((e=>e.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=r(s.map((e=>e.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(e){return super.setParameters(e,{},!1),e&&void 0!==e.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),t||this.viewer.requestRender(),this}}function Iy(e){const t=e.atomPositions,i=e.histogram360Scaled,n=i.length<=180?360:2*i.length,r={triangles:new Float32Array(3*n*3),triangleColors:Py(e.opaqueMiddleDiscColor,3*n)},s={triangles:new Float32Array(3*i.length*3),triangleColors:Py(e.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:Py(e.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:Py(e.histogramBinBorderColor,i.length),endColors:Py(e.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:Py(e.histogramBinBorderColor,i.length),endColors:Py(e.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:Py(e.adjacentBondArrowColor,i.length),endColors:Py(e.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:Py(e.distantBondArrowColor,i.length),endColors:Py(e.distantBondArrowColor,i.length)},u=hu(),d=hu(),f=hu(),m=hu(),p=hu(),g=hu(),v=hu(),y=hu(),x=hu(),b=hu(),_=hu(),w=hu(),S=hu(),A=hu(),M=hu(),C=hu(),P=[u,d,f,m];for(let e=0;e{let d=t[0],f=t[1];if("number"==typeof d&&Number.isInteger(d)&&"number"==typeof f&&Number.isInteger(f)){if(!u.get(d)||!u.get(f))return void(h+=1);c.index=d,l.index=f}else{s.setString(d),o.setString(f);var m=e.getAtomIndices(s),p=e.getAtomIndices(o);if(!m.length||!p.length)return void(h+=1);c.index=m[0],l.index=p[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":n[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":n[i]=(g/10).toFixed(2)+" nm";break;default:n[i]=g.toFixed(2)}var v=3*i;r[v+0]=(c.x+l.x)/2,r[v+1]=(c.y+l.y)/2,r[v+2]=(c.z+l.z)/2})),h>0&&(i-=h,r=r.subarray(0,3*i));var d=new Yu(a.count,!0);return{text:n,position:r,bondSet:d,bondStore:a}}getBondData(e,t,i){const n=e.getBondData(this.getBondParams(t,i));return n.picking&&(n.picking=new pf(n.picking.array,n.picking.structure,i.bondStore)),n}createData(e){if(!e.atomCount||!this.atomPair.length)return;const t=this.atomPair.length,i=new mn(this.labelColor),n=this.getDistanceData(e,this.atomPair);this.textBuffer=new Xv({position:n.position,size:Gl(t,this.labelSize),color:Vl(t,i.r,i.g,i.b),text:n.text},this.getLabelBufferParams());const r={bondSet:n.bondSet,bondStore:n.bondStore},s=this.getBondData(e,{position:!0,color:!0,picking:!0,radius:this.useCylinder},r);return this.useCylinder?this.distanceBuffer=new dy(s,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Kv(Iu(s),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:n.bondSet,bondStore:n.bondStore,position:n.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(e,t){super.updateData(e,t);const i={bondSet:t.bondSet,bondStore:t.bondStore},n=this.getBondData(t.sview,e,i),r={};e&&!e.color||Object.assign(r,{color:n.color,color2:n.color2}),e&&!e.radius||Object.assign(r,{radius:n.radius}),this.distanceBuffer.setAttributes(r)}setParameters(e){return super.setParameters(e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this}}function Dy(e){return 2*(e.position.length/3)*3}ll.add("distance",Ey);const Ly=Object.assign({scale:1,color:"grey"},em);class Ry extends im{constructor(e,t={}){super({position:new Float32Array(Dy(e)),color:new Float32Array(Dy(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const i=new mn(this.parameters.color),n=this.geometry.attributes;Vl(Dy(e)/3,i.r,i.g,i.b,n.color.array),this.setAttributes(e)}get defaultParameters(){return Ly}setAttributes(e={}){const t=this.geometry.attributes;let i,n,r;e.position&&e.vector&&(i=e.position,n=e.vector,r=t.position.array,t.position.needsUpdate=!0);const s=this.size/2,o=this.parameters.scale;if(i&&n)for(let e=0;e{if(e.residueCount<4)return;i.push(e);const n=new zm(e),r=n.getPosition(),s=n.getColor(this.getColorParams()),o=n.getSize(this.getRadiusParams()),a=n.getPicking();t.push(new tg({position:r.center,color:s.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new Ry({position:r.center,vector:r.axis},this.getBufferParams({color:"skyblue",scale:1})),new Ry({position:r.center,vector:r.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&il.time(this.type+" repr update"),t=t||{};for(let e=0,n=i.polymerList.length;e radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),ul.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const By=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Ny=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class Fy extends Zp{constructor(e,t={}){super("v3",e,t)}get mapping(){return By}get mappingIndices(){return Ny}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const zy=Object.assign({shrink:.14},em),Uy=Object.assign({shrink:{uniform:!0}},tm);class $y extends Fy{constructor(e,t={}){super(e,t),this.parameterTypes=Uy,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new ri},modelViewProjectionMatrixInverse:{value:new ri},modelViewMatrixInverseTranspose:{value:new ri},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return zy}}Object.assign({disableImpostor:!1},ny,zy);const Gy=class{constructor(e,t={}){return!el||t&&t.disableImpostor?(e.radius=function(e,t){const i=e.length,n=new Float32Array(i);for(let r=0;ra.push(n.atomLabel(e)))))}else if("residue"===this.labelGrouping){t&&!t.position||(c=[]),t&&!t.color||(h=[]),t&&!t.radius||(l=[]),t&&!t.text||(a=[]),i.colorParams&&(i.colorParams.structure=e.getStructure());const u=al.getScheme(i.colorParams),d=new Tm(i.radiusParams),f=e.getAtomProxy();let m=0;e.eachResidue((e=>{const i=3*m;e.isProtein()||e.isNucleic()?(f.index=e.traceAtomIndex,t&&!t.position||f.positionToArray(c,i)):(f.index=e.atomOffset,t&&!t.position||e.positionToArray(c,i)),t&&!t.color||u.atomColorToArray(f,h,i),t&&!t.radius||(l[m]=d.atomRadius(f)),t&&!t.text||a.push(n.atomLabel(f)),++m})),t&&!t.position||(r=new Float32Array(c)),t&&!t.color||(o=new Float32Array(h)),t&&!t.radius||(s=new Float32Array(l))}return{position:r,size:s,color:o,text:a}}createData(e){return{bufferList:[new Xv(this.getTextData(e,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(e,t){t.bufferList[0].setAttributes(this.getTextData(t.sview,e))}getAtomRadius(){return 0}}function Wy(e){const t=e.getAtomSet(),i=e.getBondSet(),n=e.getBondProxy();return i.forEach((function(e){n.index=e,t.clear(n.atomIndex1),t.clear(n.atomIndex2)})),t}ll.add("label",jy);class qy extends Bv{constructor(e,t,i){super(e,t,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.multipleBond=Ia(t.multipleBond,"off"),this.bondSpacing=Ia(t.bondSpacing,1),this.linewidth=Ia(t.linewidth,2),this.lines=Ia(t.lines,!0),this.crosses=Ia(t.crosses,"lone"),this.crossSize=Ia(t.crossSize,.4),super.init(t)}getAtomRadius(e){return.1}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},t),super.getBondParams(e,t)}_crossData(e,t){if(e&&!e.position&&!e.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Wy(t)});const n=t.getAtomData(this.getAtomParams(e,i)),r={},s=n.position,o=n.color,a=n.picking,c=(s||o).length,l=3*c;let h=new Float32Array(0),u=new Float32Array(0),d=new Float32Array(0),f=new Float32Array(0),m=0,p=new Float32Array(0);e&&!e.position||(h=r.position1=new Float32Array(l),u=r.position2=new Float32Array(l),m=this.crossSize/2),e&&!e.color||(d=r.color=new Float32Array(l),f=r.color2=new Float32Array(l)),e&&!e.picking||(p=new Float32Array(3*n.picking.array.length));for(let t=0;tl?d[p]=-1:(c=Math.sqrt(l-a),d[p]=Math.floor(c)),++p;m[g]=u,f[g]=d}}function T(i){var n,r,s,a,u,p,y,b,_,w,A,M,C,P,T,I,E,D,L=3*i,R=i;n=Math.floor(.5+o*(e[L]+d[0])),r=Math.floor(.5+o*(e[L+1]+d[1])),s=Math.floor(.5+o*(e[L+2]+d[2]));var k,O=t[R],B=f[O],N=0,F=l*h,z=m[O];for(w=0;w=c||P>=l||T>=h)){var U=C*F+P*h+T;if(g)if(v[U]&S){if(v[U]&S){var $=x[U];$!==L&&y*y+b*b+_*_<(a=n+y-Math.floor(.5+o*(e[$]+d[0])))*a+(u=r+b-Math.floor(.5+o*(e[$+1]+d[1])))*u+(p=s+_-Math.floor(.5+o*(e[$+2]+d[2])))*p&&(x[U]=i)}}else v[U]|=S,x[U]=i;else v[U]|=S}N++}}function I(t){var i,n;for(console.time("EDTSurface fillvoxels"),i=0,n=v.length;i=c||S>=l||M>=h)){var F=w*N+S*h+M;if(v[F]&A){if(g){var z=x[F];y*y+b*b+_*_<(a=Math.floor(.5+o*(e[z]+d[0])))*a+(u=Math.floor(.5+o*(e[z+1]+d[1])))*u+(p=Math.floor(.5+o*(e[z+2]+d[2])))*p&&(x[F]=i)}}else v[F]|=A,g&&(x[F]=i)}O++}}function D(){var e,t,i,n;console.time("EDTSurface fastdistancemap");var r,s=Xy(c,l,h,Uint16Array,3),o=l*h,u=p*p,d=0;for(e=0;e0);var w,C=a*a,P=new Uint16Array(3);for(e=0;e=C)||(v[r]|=M,g&&v[r]&A&&(s.toArray(e,t,i,P),w=P[0]*o+P[1]*h+P[2],x[r]=x[w])));console.timeEnd("EDTSurface fastdistancemap")}function L(e,t,i,n){var r,s,o,a,u,d,f,m,p,g,x,b,_=new Uint16Array(3),w=0;if(0===i)return w;var P=-1,T=-1,I=-1,E=l*h;for(f=0,p=i;f-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&o-1&&u-1&&aE&&(E=k)}return{neighbourListLength:27*E+1,withinRadii:function(r,s,o,a,u){for(var d=0,f=m(r,c),p=m(s,l),g=m(o,h),v=Math.max(0,f-1),_=Math.max(0,p-1),S=Math.max(0,g-1),A=Math.min(y,f+2),M=Math.min(x,p+2),I=Math.min(b,g+2),E=v;Ed&&(d=h[e]);!function(){const e=qf(c,l,d,m,0);m=e.scaleFactor,v=e.dim,y=e.matrix,R=Math.max(5,2+Math.floor(f*m)),x=Gl(v[0]*v[1]*v[2],-1001),b=new Int32Array(x.length),_=new Float32Array(v[0]),w=new Float32Array(v[1]),S=new Float32Array(v[2]),O(_,c[0],1/m),O(w,c[1],1/m),O(S,c[2],1/m)}(),function(){var e=0,t=2*Math.PI/g;M=new Float32Array(g),A=new Float32Array(g);for(var i=0;i=0;){if(s!==n&&s!==r&&N(s,e,t,i))return T=s,s;s=P[++o]}return T=-1,-1}function N(t,i,n,r){var s=3*t,o=u[t],a=e[s]-i,c=e[s+1]-n,l=e[s+2]-r;return a*a+c*c+l*l0&&d=0;)e{t(this._makeSurface(e.data.sd,i))}),(e=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",e),this.worker.terminate(),this.worker=void 0;const n=this.getSurface(i);t(n)}))}else{const e=this.getSurface(i);t(e)}}dispose(){this.worker&&this.worker.terminate()}}class Jy extends Bv{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(e){const t=e||{};t.colorScheme=Ia(t.colorScheme,"uniform"),t.colorValue=Ia(t.colorValue,14540253),t.disablePicking=Ia(t.disablePicking,!0),this.surfaceType=Ia(t.surfaceType,"ms"),this.probeRadius=Ia(t.probeRadius,1.4),this.smooth=Ia(t.smooth,2),this.scaleFactor=Ia(t.scaleFactor,2),this.cutoff=Ia(t.cutoff,0),this.contour=Ia(t.contour,!1),this.background=Ia(t.background,!1),this.opaqueBack=Ia(t.opaqueBack,!0),this.filterSele=Ia(t.filterSele,""),this.colorVolume=Ia(t.colorVolume,void 0),this.useWorker=Ia(t.useWorker,!0),super.init(e)}prepareData(e,t,i){let n=this.__infoList[t];if(n||(n={},this.__infoList[t]=n),n.molsurf&&n.sele===e.selection.string)i(t);else{if(this.filterSele){const n=e.structure.getView(new $c(this.filterSele)),r=n.boundingBox.getSize(new Zt),s=Math.max(r.x,r.y,r.z),o=e.getAtomSetWithinPoint(n.center,s/2+6);if(0===(e=e.getView(new $c(e.getAtomSetWithinSelection(o,3).toSeleString()))).atomCount)return void i(t)}n.sele=e.selection.string,n.molsurf=new Qy(e);const r=this.getSurfaceParams(),s=e=>{n.surface=e,i(t)};this.useWorker?n.molsurf.getSurfaceWorker(r,s):s(n.molsurf.getSurface(r))}}prepare(e){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void e();const t=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,e()},i="default"===this.assembly?this.defaultAssembly:this.assembly,n=this.structure.biomolDict[i];n?n.partList.forEach(((e,i)=>{const r=e.getView(this.structureView);this.prepareData(r,i,(e=>{e===n.partList.length-1&&t()}))})):this.prepareData(this.structureView,0,t)}createData(e,t){const i=this.__infoList[t],n=i.surface;if(!n)return;const r={position:n.getPosition(),color:n.getColor(this.getColorParams()),index:n.getFilteredIndex(this.filterSele,e)},s=[];if(n.contour){const e=new cm(r,this.getBufferParams({wireframe:!1}));s.push(e)}else{Object.assign(r,{normal:n.getNormal(),picking:n.getPicking(e.getStructure())});const t=new rm(r,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const e=new am(t);s.push(e)}else s.push(t)}return{bufferList:s,info:i}}updateData(e,t){const i={};if(e.position||e.radius)return this.__forceNewMolsurf=!0,void this.build();e.color&&(i.color=t.info.surface.getColor(this.getColorParams())),e.index&&(i.index=t.info.surface.getFilteredIndex(this.filterSele,t.sview)),t.bufferList[0].setAttributes(i)}setParameters(e,t={},i){return e&&e.filterSele&&(t.index=!0),e&&void 0!==e.colorVolume&&(t.color=!0),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),this}getSurfaceParams(e={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},e)}getColorParams(){const e=super.getColorParams();return e.volume=this.colorVolume,e}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}ll.add("surface",Jy);class ex extends Bv{constructor(e,t,i){super(e,t,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.pointSize=Ia(t.pointSize,1),this.sizeAttenuation=Ia(t.sizeAttenuation,!0),this.sortParticles=Ia(t.sortParticles,!1),this.useTexture=Ia(t.useTexture,!1),this.alphaTest=Ia(t.alphaTest,.5),this.forceTransparent=Ia(t.forceTransparent,!1),this.edgeBleach=Ia(t.edgeBleach,0),super.init(t)}createData(e){var t=e.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new sg(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),n={};e&&!e.position||Object.assign(n,{position:i.position}),e&&!e.color||Object.assign(n,{color:i.color}),t.bufferList[0].setAttributes(n)}getAtomRadius(){return.1}}ll.add("point",ex),ul.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const tx=new Uint16Array([0,1,2,1,3,2]);function ix(e){return 3*(4*(e.position.length/3-1))}class nx extends nm{constructor(e,t={}){super({position:new Float32Array(ix(e)),color:new Float32Array(ix(e)),index:Ga(ix(e),ix(e)/3),normal:new Float32Array(ix(e)),picking:e.picking},t),this.vertexShader="Ribbon.vert";const i=e.position.length/3-1,n=4*i,r=3*n;this.addAttributes({dir:{type:"v3",value:new Float32Array(r)}}),this.addAttributes({size:{type:"f",value:new Float32Array(n)}}),e.primitiveId=Hl(i),this.setAttributes(e),this.makeIndex()}setAttributes(e={}){const t=this.size/4,i=this.geometry.attributes;let n,r,s,o,a,c,l,h,u,d,f,m,p,g,v,y,x,b,_;e.position&&(n=e.position,l=i.position.array,i.position.needsUpdate=!0),e.normal&&(r=e.normal,h=i.normal.array,i.normal.needsUpdate=!0),e.size&&(s=e.size,u=i.size.array,i.size.needsUpdate=!0),e.dir&&(o=e.dir,d=i.dir.array,i.dir.needsUpdate=!0),e.color&&(a=e.color,f=i.color.array,i.color.needsUpdate=!0),e.primitiveId&&(c=e.primitiveId,m=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let w=s?s[0]:null;for(p=0;p{if(!(e.residueCount<4)){i.push(e);var n=new yy(e,this.getSplineParams()),r=n.getSubdividedPosition(),s=n.getSubdividedOrientation(),o=n.getSubdividedColor(this.getColorParams()),a=n.getSubdividedPicking(),c=n.getSubdividedSize(this.getRadiusParams());t.push(new nx({position:r.position,normal:s.binormal,dir:s.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,n=t.polymerList.length;for(i=0;i{if(e.residueCount<4||e.isNucleic())return;const r=new Um(e),s=r.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t+=s.size.length,i.push(s),n.push(r)}),e.getSelection());const r={begin:new Float32Array(3*t),end:new Float32Array(3*t),size:new Float32Array(t),color:new Float32Array(3*t),picking:{}};let s=new Float32Array(t),o=0;i.forEach((function(e){r.begin.set(e.begin,3*o),r.end.set(e.end,3*o),r.size.set(e.size,o),r.color.set(e.color,3*o),s.set(e.picking.array,o),o+=e.size.length})),t&&(r.picking=new hf(s,e.getStructure()));return{bufferList:[new dy({position1:r.begin,position2:r.end,color:r.color,color2:r.color,radius:r.size,picking:r.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:n,axisData:r}}updateData(e,t){if((e=e||{}).position)this.build();else{var i={};if(e.color||e.radius){var n=0;t.helixbundleList.forEach((i=>{var r=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e.color&&t.axisData.color.set(r.color,3*n),(e.radius||e.scale)&&t.axisData.size.set(r.size,n),n+=r.size.length})),e.color&&Object.assign(i,{color:t.axisData.color,color2:t.axisData.color}),(e.radius||e.scale)&&Object.assign(i,{radius:t.axisData.size})}t.bufferList[0].setAttributes(i)}}}ll.add("rocket",sx);class ox extends Sy{constructor(e,t,i){super(e,t,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(e){var t=e||{};t.aspectRatio=1,t.tension=Ia(t.tension,.5),t.radiusScale=Ia(t.radiusScale,5),t.smoothSheet=!1,this.smooth=Ia(t.smooth,2),super.init(t)}getSpline(e){var t=new zm(e);return new yy(e,this.getSplineParams({directional:!1,positionIterator:t.getCenterIterator(this.smooth)}))}}ll.add("rope",ox);class ax extends Bv{constructor(e,t,i){super(e,t,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(e){var t=e||{};t.useInteriorColor=Ia(t.useInteriorColor,!0),super.init(t)}createData(e){return{bufferList:[new tg(e.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),n={};e&&!e.position||Object.assign(n,{position:i.position}),e&&!e.color||Object.assign(n,{color:i.color}),e&&!e.radius||Object.assign(n,{radius:i.radius}),t.bufferList[0].setAttributes(n)}}function cx(e){return 3*(e.position.length/3-1)*2}ll.add("spacefill",ax);class lx extends im{constructor(e,t={}){super({position:new Float32Array(cx(e)),color:new Float32Array(cx(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(e)}setAttributes(e){let t,i,n,r;const s=this.geometry.attributes;if(e.position&&(t=e.position,n=s.position.array,s.position.needsUpdate=!0),e.color&&(i=e.color,r=s.color.array,s.color.needsUpdate=!0),!t&&!i)return void il.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let e=0;e{if(!(e.residueCount<4)){i.push(e);var n=new yy(e,this.getSplineParams()),r=n.getSubdividedPosition(),s=n.getSubdividedColor(this.getColorParams());t.push(new lx(Object.assign({},r,s),this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,n=t.polymerList.length;for(i=0;i{e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox)}))}}const _x=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},em);class wx{constructor(e,t={}){this.group=new ko,this.wireframeGroup=new ko,this.pickingGroup=new ko,this.visible=!0,this.parameters=Ea(t,this.defaultParameters),this.splitPosition=new Float32Array(e.position1.length),this.cylinderRadius=new Float32Array(e.radius.length);const i=this.makeAttributes(e),n={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new dy(i.cylinder,n),this.coneBuffer=new xx(i.cone,n),this.geometry=new bx([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=Ia(t.matrix,new ri),this.picking=e.picking}get defaultParameters(){return _x}set matrix(e){im.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(e={}){const t=this.splitPosition,i=this.cylinderRadius,n=this.parameters.aspectRatio;let r,s;const o={},a={};if(e.radius){for(r=0,s=i.length;r(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){e.Debug&&il.log(this[this.__objName])}}class Kx extends Zx{constructor(e,t){var i=t||{};super(e,i),this.firstModelOnly=Ia(i.firstModelOnly,!1),this.asTrajectory=Ia(i.asTrajectory,!1),this.cAlphaOnly=Ia(i.cAlphaOnly,!1),this.structure=new Fp(this.name,this.path),this.structureBuilder=new ep(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class Qx{constructor(e,t,i="",n,r=[]){this.structure=e,this.index=t,this.description=i,this.entityType=function(e){switch(e=e.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(n||""),this.chainIndexList=r,r.forEach((function(i){e.chainStore.entityIndex[i]=t}))}get type(){return function(e){switch(e){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(e){const t=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){t.index=i,e(t)}))}}const Jx={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class eb{constructor(e=Jx){this.cartToFrac=new ri,this.fracToCart=new ri,this.a=e.a,this.b=e.b,this.c=e.c,this.alpha=e.alpha,this.beta=e.beta,this.gamma=e.gamma,this.spacegroup=e.spacegroup;const t=Ka(this.alpha),i=Ka(this.beta),n=Ka(this.gamma),r=Math.cos(t),s=Math.cos(i),o=Math.cos(n),a=Math.sin(i),c=Math.sin(n);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-r*r-s*s-o*o+2*r*s*o),void 0===e.cartToFrac){const e=this.a*this.b*c/this.volume,t=(s*o-r)/(a*c);this.fracToCart.set(this.a,0,0,0,this.b*o,this.b*c,0,0,this.c*s,-this.c*a*t,1/e,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(e.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(e){const t=new Float32Array(24);if(e.unitcell){const i=e.unitcell,n=e.center.clone().applyMatrix4(i.cartToFrac).floor(),r=new Zt;let s=0;const o=function(e,o,a){r.set(e,o,a).add(n).applyMatrix4(i.fracToCart).toArray(t,s),s+=3};o(0,0,0),o(1,0,0),o(0,1,0),o(0,0,1),o(1,1,0),o(1,0,1),o(0,1,1),o(1,1,1)}return t}getCenter(e){return function(e,t=new Zt){const i=e.length;for(let n=0;n0)continue;let e,i,n,r,a,g=0;if(s){if(r=A.split(rb),g=10===r.length?1:0,L=r[2],m&&"CA"!==L)continue;e=parseFloat(r[6-g]),i=parseFloat(r[7-g]),n=parseFloat(r[8-g])}else{if(L=A.substr(12,4).trim(),m&&"CA"!==L)continue;e=parseFloat(A.substr(30,8)),i=parseFloat(A.substr(38,8)),n=parseFloat(A.substr(46,8))}if(f){const t=3*y;if(v[t+0]=e,v[t+1]=i,v[t+2]=n,y+=1,x)continue}s?(C=parseInt(r[1]),a="",R="H"===A[0]?1:0,P=g?"":r[4],T=parseInt(r[5-g]),D="",I=r[3],O="",E=1):(C=parseInt(A.substr(6,5),h),l&&99999===C&&(h=16),R="H"===A[0]?1:0,P=A[21].trim(),T=parseInt(A.substr(22,4),u),l&&9999===T&&(u=16),D=A[26].trim(),I=A.substr(17,4).trim()||"MOL",k=parseFloat(A.substr(60,6)),O=A[16].trim(),E=parseFloat(A.substr(54,6)),t||(o?(a=A.substr(76,3).trim(),a in Td&&(a=Td[a])):(a=A.substr(76,2).trim(),P||(P=A.substr(72,4).trim())),B=parseInt((A.substr(79,1)+A.substr(78,1)).trim()))),ue.growIfFull(),ue.atomTypeId[me]=he.add(L,a),ue.x[me]=e,ue.y[me]=i,ue.z[me]=n,ue.serial[me]=C,ue.altloc[me]=O.charCodeAt(0),ue.occupancy[me]=isNaN(E)?0:E,s?(ue.partialCharge[me]=parseFloat(r[9-g]),ue.radius[me]=parseFloat(r[10-g])):(ue.bfactor[me]=isNaN(k)?0:k,o&&(ue.partialCharge[me]=parseFloat(A.substr(70,6))),isFinite(B)&&(ue.formalCharge||ue.addField("formalCharge",1,"int8"),ue.formalCharge[me]=B));const b=sb(T,P,D);!R||Z[b]||ib.includes(I)?ee||te===P||(Q+=1,J=Q.toString()):te===P&&ne===I&&(wd.includes(I)||ie===T&&re===D)||(Q+=1,J=Q.toString(),ie=T,ne=I,re=D),c.addAtom(pe,P,J,I,T,R,void 0,D),V[C]=me,me+=1,ee=!1,te=P}else if("CONECT"===M){const e=V[parseInt(A.substr(6,5))],t=[11,16,21,26],i={};if(void 0===e)continue;for(let n=0;n<4;++n){let r=parseInt(A.substr(t[n],5));if(!Number.isNaN(r)&&(r=V[r],void 0!==r))if(e0)continue;const L=n[c].replace(lb,"");if(P&&"CA"!==L)continue;const R=parseFloat(n[y]),k=parseFloat(n[x]),O=parseFloat(n[b]);if(C){const e=3*i;if(t[e+0]=R,t[e+1]=k,t[e+2]=O,i+=1,q>0)continue}const B=n[l],N=parseInt(n[-1!==o?o:a]);let F=n[v];F="?"===F?"":F;const z=n[s],U=n[h],X="H"===n[f][0]?1:0,Y=n[p],Z=parseFloat(n[_]),K=parseFloat(n[w]);let Q=n[d];if(Q="."===Q?"":Q,H.growIfFull(),H.atomTypeId[W]=V.add(L,Y),H.x[W]=R,H.y[W]=k,H.z[W]=O,H.serial[W]=parseInt(n[m]),H.bfactor[W]=isNaN(Z)?0:Z,H.occupancy[W]=isNaN(K)?0:K,H.altloc[W]=Q.charCodeAt(0),A.addAtom(q,z,U,B,N,X,void 0,F),e.Debug){const t=E[U];void 0!==t&&t!==z&&e.Debug&&il.warn(t,z)}E[U]=z;const J=n[u];D[J]||(D[J]=new Set),D[J].add(S.chainStore.count-1),W+=1}else{const e=r.match(cb),t=e.length;F===N.length&&(F=0);for(let i=0;ih*h)return n.growIfFull(),n.atomTypeId[u]=n.atomTypeId[e],n.x[u]=c.x,n.y[u]=c.y,n.z[u]=c.z,n.occupancy[u]=n.occupancy[e],n.serial[u]=u,n.altloc[u]="A".charCodeAt(0),i.addAtom(0,"","","HET",1,!0),void(u+=1)}}}))}}(I,S,A),A.finalize(),S.finalizeAtoms(),op(S),S.finalizeBonds();else{var X=function(e,t,i){var n,r,s,o,a=[],c=[],l=e.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(db(l,"id"),n=0,r=l.beg_auth_seq_id.length;n0){s=s.split("(");var c=a(s[0]),l=a(s[1]);Object.keys(c).forEach((function(e){Object.keys(l).forEach((function(t){var i=new ri;i.multiplyMatrices(c[e],l[t]),n[e+"x"+t]=i}))}))}else n=a(s);var h=[];for(var u in n)h.push(n[u]);var d=e;/^(0|[1-9][0-9]*)$/.test(d)&&(d="BU"+d);for(var f=o.asym_id_list[t].split(","),m=0,p=f.length;mS){var A=w;w=S,S=A;var M=p;p=b,b=M}if(0!==w&&0!==S)for(var C=0;Cx)continue}d=P.substr(5,5).trim(),f=parseInt(P.substr(0,5)),m=parseInt(P.substr(15,5)),_.growIfFull(),_.atomTypeId[w]=b.add(u),_.x[w]=E,_.y[w]=D,_.z[w]=L,_.serial[w]=m,r.addAtom(S,"","",d,f,0,"l"),w+=1}}}(0,e.length,e)})),r.finalize(),n.finalizeAtoms(),sp(n),op(n),n.finalizeBonds(),ip(n),e.Debug&&il.timeEnd("GroParser._parse "+this.name)}});var vb=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function yb(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function xb(e){return yb(DataView,e)}function bb(e){return yb(Int8Array,e)}function _b(e){return yb(Int32Array,e,4)}function wb(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var n=0,r=0;ns&&++a;t=new Int32Array(a)}for(i=0,n=0;ir){for(var s=[],o=0;o0&&(o.biomolDict[e]=t)}const k=a.unitCell;k&&Array.isArray(k)&&k[0]?o.unitcell=new eb({a:k[0],b:k[1],c:k[2],alpha:k[3],beta:k[4],gamma:k[5],spacegroup:a.spaceGroup}):o.unitcell=void 0,hp(o,!0),lp(o,!0),o.finalizeAtoms(),o.finalizeBonds(),up(o),e.Debug&&il.timeEnd("MmtfParser._parse "+this.name)}});const kb=/\s+/,Ob={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};hl.add("mol2",class extends Kx{get type(){return"mol2"}_parse(){e.Debug&&il.time("Mol2Parser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=this.firstModelOnly,r=this.asTrajectory,s=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/60)),h.addField("partialCharge",1,"float32");let u=0,d=0,f=0,m=-1,p=0,g=0;const v=t.getAtomProxy(),y=t.getAtomProxy();this.streamer.eachChunkOfLines((function(e){!function(e,x,b){for(let _=e;_MOLECULE"===e?(g=1,d=0,++m):"@ATOM"===e?(g=2,f=h.count,r&&(a=0,o=new Float32Array(3*p),s.push(o),m>0&&(c=!0))):g="@BOND"===e?3:0;else if(1===g){if(0===d)t.title=e,t.id=e;else if(1===d){const t=e.split(kb);p=parseInt(t[0])}++d}else if(2===g){const t=e.split(kb);if(n&&m>0)continue;const s=parseFloat(t[2]),d=parseFloat(t[3]),f=parseFloat(t[4]);if(r){const e=3*a;if(o[e+0]=s,o[e+1]=d,o[e+2]=f,a+=1,c)continue}const p=t[0],g=t[1],v=t[5].split(".")[0],y=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",b=t[8]?parseFloat(t[8]):0;h.growIfFull(),h.atomTypeId[u]=l.add(g,v),h.x[u]=s,h.y[u]=d,h.z[u]=f,h.serial[u]=p,h.partialCharge[u]=b,i.addAtom(m,"","",x,y,1),u+=1}else if(3===g){if(n&&m>0)continue;if(r&&m>0)continue;const i=e.split(kb);v.index=parseInt(i[1])-1+f,y.index=parseInt(i[2])-1+f;const s=Ob[i[3]];t.bondStore.addBond(v,y,s)}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),sp(t),lp(t,!0),hp(t,!0),t.finalizeBonds(),pp(t),ip(t),e.Debug&&il.timeEnd("Mol2Parser._parse "+this.name)}});hl.add("pdbqt",class extends ob{get type(){return"pdbqt"}});hl.add("pqr",class extends ob{get type(){return"pqr"}});const Bb=/> +<(.+)>/;class Nb extends Kx{get type(){return"sdf"}_parse(){e.Debug&&il.time("SdfParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=this.firstModelOnly,r=this.asTrajectory,s=this.streamer.peekLines(2);t.id=s[0].trim(),t.title=s[1].trim();const o=t.frames;let a,c,l=!1;const h=t.atomMap,u=t.atomStore;u.resize(Math.round(this.streamer.data.length/50)),u.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),f=t.getAtomProxy();let m=0,p=0,g=0,v=0;const y=[];let x,b,_,w,S,A,M,C,P,T,I,E,D,L,R=!1,k={};t.extraData.sdf=y;let O=!1,B=!1,N=!1,F=[],z=[];const U=new Map;this.streamer.eachChunkOfLines((function(e){!function(e,s,$){for(let G=e;G-1,O?U.clear():(b=parseInt(e.substr(0,3)),_=parseInt(e.substr(3,3)),w=4,S=w+b,A=S,M=A+_,r&&(c=0,a=new Float32Array(3*b),o.push(a),g>0&&(l=!0)));else if(O&&"COUNTS"===F[0])b=parseInt(F[1]),r&&(c=0,a=new Float32Array(3*b),o.push(a),g>0&&(l=!0));else if(O&&2==F.length)"ATOM"===F[1]?"BEGIN"===F[0]?B=!0:"END"===F[0]&&(B=!1):"BOND"===F[1]&&("BEGIN"===F[0]?N=!0:"END"===F[0]&&(N=!1));else if(B||!O&&p>=w&&p0)continue;let t=0;if(O){if(C=parseFloat(F[2]),P=parseFloat(F[3]),T=parseFloat(F[4]),E=F[1],D=parseInt(F[0]),U.set(D,m),I=E+D,F.length>6){let e=F.slice(6).find((e=>0===e.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else C=parseFloat(e.substr(0,10)),P=parseFloat(e.substr(10,10)),T=parseFloat(e.substr(20,10)),E=e.substr(31,3).trim(),I=E+(m-v+1);if(r){const e=3*c;if(a[e+0]=C,a[e+1]=P,a[e+2]=T,c+=1,l)continue}u.growIfFull(),u.atomTypeId[m]=h.add(I,E),u.x[m]=C,u.y[m]=P,u.z[m]=T,u.serial[m]=O?D:m,u.formalCharge[m]=t,i.addAtom(g,"","","HET",1,1),m+=1}else if(N||!O&&p>=A&&p0)continue;if(r&&g>0)continue;O?(d.index=U.get(parseInt(F[2])),f.index=U.get(parseInt(F[3])),L=parseInt(F[1])):(d.index=parseInt(e.substr(0,3))-1+v,f.index=parseInt(e.substr(3,3))-1+v,L=parseInt(e.substr(6,3))),t.bondStore.addBond(d,f,L)}else if("M CHG"===e.substr(0,6)){const t=parseInt(e.substr(6,3));for(let i=0,n=10;i"===e.charAt(0)&&(x=e.match(Bb))?(R=x[1],k[R]=[]):!1!==R&&e&&k[R].push(e);++p}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),t.finalizeBonds(),pp(t),e.Debug&&il.timeEnd("SdfParser._parse "+this.name)}_postProcess(){pp(this.structure)}}hl.add("sdf",Nb),hl.add("sd",Nb),hl.add("mol",Nb);function Fb(e,t,i){return parseInt(e.substr(t,i).trim())}class zb extends Kx{get type(){return"prmtop"}_parse(){e.Debug&&il.time("PrmtopParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=t.atomMap,r=t.atomStore;r.addField("partialCharge",1,"float32"),r.addField("radius",1,"float32");const s=[],o={},a=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let c,l,h,u,d;a.forEach((e=>{o[e]=0}));let f,m,p,g,v,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let n=e;n0)return void il.error("dcd format with fixed atoms unsupported, aborting");const p=o.NATOM,g=4*p;for(let e=0,n=o.NSET;e=1&&(n.timeOffset=(o.ISTART-1)*n.deltaTime),e.Debug&&il.timeEnd("DcdParser._parse "+this.name)}});const Xb={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Yb(e){switch(Number(e)){case Xb.BYTE:return"byte";case Xb.CHAR:return"char";case Xb.SHORT:return"short";case Xb.INT:return"int";case Xb.FLOAT:return"float";case Xb.DOUBLE:return"double";default:return"undefined"}}function Zb(e){switch(Number(e)){case Xb.BYTE:case Xb.CHAR:return 1;case Xb.SHORT:return 2;case Xb.INT:case Xb.FLOAT:return 4;case Xb.DOUBLE:return 8;default:return-1}}function Kb(e){switch(String(e)){case"byte":return Xb.BYTE;case"char":return Xb.CHAR;case"short":return Xb.SHORT;case"int":return Xb.INT;case"float":return Xb.FLOAT;case"double":return Xb.DOUBLE;default:return-1}}function Qb(e,t){if(1!==e){const i=new Array(e);for(let n=0;n6,"non valid type "+h);const u=e.readUint32();let d=e.readUint32();2===i&&(jb(d>0,"offsets larger than 4GB not supported"),d=e.readUint32()),c[0]===t&&(s+=u),r[n]={name:o,dimensions:c,attributes:l,type:Yb(h),size:u,offset:d,record:c[0]===t}}}return{variables:r,recordStep:s}}(e,n.recordId,t);return i.variables=r.variables,i.recordDimension.recordStep=r.recordStep,i}function s_(e){let t;const i=e.readUint32();if(i===e_)return jb(e.readUint32()!==e_,"wrong empty tag for list of attributes"),[];{jb(i!==n_,"wrong tag for list of attributes");const n=e.readUint32();t=new Array(n);for(let i=0;i6,"non valid type "+r);const s=e.readUint32(),o=Jb(e,r,s);Wb(e),t[i]={name:n,type:Yb(r),value:o}}}return t}class o_{constructor(e){const t=new Il(e);t.setBigEndian(),jb("CDF"!==t.readChars(3),"should start with CDF");const i=t.readByte();jb(i>2,"unknown version"),this.header=r_(t,i),this.buffer=t}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(e){return-1!==this.header.variables.findIndex((function(t){return t.name===e}))}getDataVariable(e){let t;return t="string"==typeof e?this.header.variables.find((function(t){return t.name===e})):e,jb(void 0===t,"variable not found"),this.buffer.seek(t.offset),t.record?function(e,t,i){const n=Kb(t.type),r=t.size?t.size/Zb(n):1,s=i.length,o=new Array(s),a=i.recordStep;for(let t=0;t=1&&(i.timeOffset=s[0]),s.length>=2&&(i.deltaTime=s[1]-s[0]),e.Debug&&il.timeEnd("NctrajParser._parse "+this.name)}}hl.add("nctraj",a_),hl.add("ncdf",a_),hl.add("nc",a_);hl.add("trr",class extends Hb{get type(){return"trr"}get isBinary(){return!0}_parse(){e.Debug&&il.time("TrrParser._parse "+this.name);const t=Va(this.streamer.data),i=new DataView(t),n=this.frames,r=n.coordinates,s=n.boxes,o=n.times;let a=0;for(;;){a+=8;const e=i.getInt32(a);a+=4,a+=e;const n=i.getInt32(a+8),c=i.getInt32(a+12),l=i.getInt32(a+16),h=i.getInt32(a+28),u=i.getInt32(a+32),d=i.getInt32(a+36),f=i.getInt32(a+40);a+=52;const m=n/9,p=3*f;if(8===m?o.push(i.getFloat64(a)):o.push(i.getFloat32(a)),a+=2*m,n){const e=new Float32Array(9);if(8===m)for(let t=0;t<9;++t)e[t]=10*i.getFloat64(a),a+=8;else for(let t=0;t<9;++t)e[t]=10*i.getFloat32(a),a+=4;s.push(e)}if(a+=c,a+=l,h){let e;if(8===m){e=new Float32Array(p);for(let t=0;t>8&65280|t>>24&255}e=new Float32Array(t,a,p);for(let t=0;t=t.byteLength)break}o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),e.Debug&&il.timeEnd("TrrParser._parse "+this.name)}});const c_=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function l_(e){let t=1,i=0;for(;e>=t&&i<32;)i++,t<<=1;return i}const h_=new Uint8Array(32);function u_(e,t){let i=1,n=0;h_[0]=1;for(let n=0;n>=8;for(;0!==r;)h_[e++]=255&r,r>>=8;i=e}let r=1;for(i--;h_[i]>=r;)n++,r*=2;return n+8*i}function d_(e,t,i,n){const r=(1<=8;)o=o<<8|t[a++],c|=o>>s<0&&(s>s&(1<8;)f_[a++]=d_(e,t,8,o),n-=8;n>0&&(f_[a++]=d_(e,t,n,o));for(let e=i-1;e>0;e--){let t=0;for(let i=a-1;i>=0;i--){t=t<<8|f_[i];const n=t/r[e]|0;f_[i]=n,t-=n*r[e]}s[e]=t}s[0]=f_[0]|f_[1]<<8|f_[2]<<16|f_[3]<<24}hl.add("xtc",class extends Hb{get type(){return"xtc"}get isBinary(){return!0}_parse(){e.Debug&&il.time("XtcParser._parse "+this.name);const t=Va(this.streamer.data),i=new DataView(t),n=this.frames,r=n.coordinates,s=n.boxes,o=n.times,a=new Int32Array(6),c=new Int32Array(3),l=new Int32Array(3),h=new Uint32Array(3),u=new Float32Array(3),d=new Float32Array(3);let f=0;const m=new Int32Array(3),p=new Uint32Array(m.buffer);for(;;){let e;const n=i.getInt32(f+4);f+=12;const g=3*n;o.push(i.getFloat32(f)),f+=4;const v=new Float32Array(9);for(let e=0;e<9;++e)v[e]=10*i.getFloat32(f),f+=4;if(s.push(v),n<=9){e=new Float32Array(n);for(let t=0;t16777215?(l[0]=l_(c[0]),l[1]=l_(c[1]),l[2]=l_(c[2]),o=0):o=u_(3,c);let v=i.getInt32(f);f+=4;let y=v-1;y=9>y?9:y;let x=c_[y]/2|0,b=c_[v]/2|0;h[0]=h[1]=h[2]=c_[v];let _=4*Math.ceil(i.getInt32(f)/4);f+=4;const w=1/s;let S=0,A=0;const M=new Uint8Array(t,f);for(u[0]=u[1]=u[2]=0;A0){u[0]=u[1]=u[2]=0;for(let t=0;t9?c_[v-1]/2|0:0):t>0&&(x=b,b=c_[v]/2|0),h[0]=h[1]=h[2]=c_[v],0===h[0]||0===h[1]||0===h[2])return void console.error("(xdrfile error) Undefined error.")}f+=_}for(let t=0;t=t.byteLength)break}o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),e.Debug&&il.timeEnd("XtcParser._parse "+this.name)}});class p_ extends Zx{constructor(e,t){const i=t||{};super(e,i),this.volume=new Zf(this.name,this.path),this.voxelSize=Ia(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new ri}}const g_=/\s+/,v_=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,y_=.529177210859;class x_ extends p_{get type(){return"cube"}_parse(){e.Debug&&il.time("CubeParser._parse "+this.name);const t=this.volume,i=this.streamer.peekLines(6),n={},r=y_*this.voxelSize;function s(e,t){var n=i[e].trim().split(g_)[t];return parseFloat(n)}n.atomCount=Math.abs(s(2,0)),n.originX=s(2,1)*y_,n.originY=s(2,2)*y_,n.originZ=s(2,3)*y_,n.NVX=s(3,0),n.NVY=s(4,0),n.NVZ=s(5,0),n.basisX=new Zt(s(3,1),s(3,2),s(3,3)).multiplyScalar(r),n.basisY=new Zt(s(4,1),s(4,2),s(4,3)).multiplyScalar(r),n.basisZ=new Zt(s(5,1),s(5,2),s(5,3)).multiplyScalar(r);const o=new Float32Array(n.NVX*n.NVY*n.NVZ);let a=0,c=0;const l=s(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r=n.atomCount+6+l){const t=e.match(v_);for(let e=0,i=t.length;e>8&255}i.xStart=o[0],i.yStart=o[1],i.zStart=o[2],i.xExtent=o[3],i.yExtent=o[4],i.zExtent=o[5],i.xRate=o[6],i.yRate=o[7],i.zRate=o[8];const e=1/o[17],t=e*this.voxelSize;i.xlen=o[9]*t,i.ylen=o[10]*t,i.zlen=o[11]*t,i.alpha=o[12]*e,i.beta=o[13]*e,i.gamma=o[14]*e,n=o[15]/100,r=o[16],i.gamma=o[14]*e}t.header=i,e.Debug&&il.log(i,n,r);const l=new Float32Array(i.xExtent*i.yExtent*i.zExtent);let h=512;const u=Math.ceil(i.xExtent/8),d=Math.ceil(i.yExtent/8),f=Math.ceil(i.zExtent/8);for(var m=0;ms){const e=i[n].trim();if(""!==e){const t=e.split(__);for(let e=0,i=t.length;e=s&&(p-s)%f!=0&&m=0?i-1:i+t/3)},parseNormalIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},addVertex:function(e,t,i){var n=this.vertices,r=this.object.geometry.vertices;r.push(n[e+0]),r.push(n[e+1]),r.push(n[e+2]),r.push(n[t+0]),r.push(n[t+1]),r.push(n[t+2]),r.push(n[i+0]),r.push(n[i+1]),r.push(n[i+2])},addVertexLine:function(e){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[e+0]),i.push(t[e+1]),i.push(t[e+2])},addNormal:function(e,t,i){var n=this.normals,r=this.object.geometry.normals;r.push(n[e+0]),r.push(n[e+1]),r.push(n[e+2]),r.push(n[t+0]),r.push(n[t+1]),r.push(n[t+2]),r.push(n[i+0]),r.push(n[i+1]),r.push(n[i+2])},addFace:function(e,t,i,n,r,s,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(e,l),u=this.parseVertexIndex(t,l),d=this.parseVertexIndex(i,l);if(void 0===n?this.addVertex(h,u,d):(c=this.parseVertexIndex(n,l),this.addVertex(h,u,c),this.addVertex(u,d,c)),void 0!==r){var f=this.normals.length;h=this.parseNormalIndex(r,f),u=r===s?h:this.parseNormalIndex(s,f),d=r===o?h:this.parseNormalIndex(o,f),void 0===n?this.addNormal(h,u,d):(c=this.parseNormalIndex(a,f),this.addNormal(h,u,c),this.addNormal(u,d,c))}},addLineGeometry:function(e){this.object.geometry.type="Line";for(var t=this.vertices.length,i=0,n=e.length;i0?x.setAttribute("normal",new An(new Float32Array(y.normals),3)):x.computeVertexNormals(),v.push(x)}}return v}};hl.add("obj",class extends z_{get type(){return"obj"}getLoader(){return new U_}});const $_=function(){this.propertyNameMapping={}};$_.prototype={constructor:$_,setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),i="",n=0;n=n.elements[o].count&&(o++,a=0);var h=this.parseASCIIElement(n.elements[o].properties,l);this.handleElement(i,n.elements[o].name,h),a++}}return this.postProcess(i)},postProcess:function(e){if(e.useColor){for(var t=0;t{const r=n.length;for(let s=0;s/g,""),{declaration:t(),root:i()};function t(){if(!r(/^<\?xml\s*/))return;const e={attributes:{}};for(;!s()&&!o("?>");){const t=n();if(!t)return e;e.attributes[t.name]=t.value}return r(/\?>\s*/),e}function i(){const e=r(H_);if(!e)return;const t={name:e[1],attributes:{},children:[]};for(;!(s()||o(">")||o("?>")||o("/>"));){const e=n();if(!e)return t;t.attributes[e.name]=e.value}if(r(/^\s*\/>\s*/))return t;let a;for(r(/\??>\s*/),t.content=function(){const e=r(j_);return e?e[1]:""}();a=i();)t.children.push(a);return r(/^<\/[\w-:.]+>\s*/),t}function n(){const e=r(W_);var t;if(e)return{name:e[1],value:(t=e[2],t.replace(V_,""))}}function r(t){const i=e.match(t);if(i)return e=e.slice(i[0].length),i}function s(){return 0===e.length}function o(t){return 0===e.indexOf(t)}}class X_ extends Zx{constructor(e,t){const i=t||{};super(e,i),this.useDomParser=Ia(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(e){return q_(e)}__domParser(e){return(new window.DOMParser).parseFromString(e,"text/xml")}_parse(){e.Debug&&il.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),e.Debug&&il.timeEnd("XmlParser._parse "+this.name)}}function Y_(e,t){const i=e.getNamedItem(t);return null!==i?i.value:""}function Z_(e,t,i=!1){const n=Y_(e,"icode").trim(),r=Y_(e,"chain").trim(),s=Y_(e,"altcode");let o=Y_(e,"resnum");return n&&(o+="^"+n),r&&(o+=":"+r),t&&(o+="."+t),i&&s.trim()&&(o+="%"+s),o+="/"+(parseInt(Y_(e,"model"))-1),o}function K_(e){const t=Y_(e,"chain").trim();let i=`[${Y_(e,"rescode")}]${Y_(e,"resnum")}`;return t&&(i+=`:${t}`),i}function Q_(e,t,i){void 0===e[t]?e[t]=i:e[t]|=i}function J_(e,t){return null!==e&&e.value===t}function ew(e,t,i){let n=0;const r=t.getElementsByTagName("clash");for(let t=0,i=r.length;t0&&(n+=1);t.getElementsByTagName("bond-outlier").length>0&&(n+=1);return t.getElementsByTagName("plane-outlier").length>0&&(n+=1),J_(i.getNamedItem("rota"),"OUTLIER")&&(n+=1),J_(i.getNamedItem("rama"),"OUTLIER")&&(n+=1),J_(i.getNamedItem("RNApucker"),"outlier")&&(n+=1),n}hl.add("xml",X_);class tw{constructor(e,t){this.name=e,this.path=t,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){e.Debug&&il.time("Validation.fromXml");const i=this.rsrzDict,n=this.rsccDict,r=this.rciDict,s=this.clashDict,o=this.clashArray,a=this.geoDict,c=this.geoAtomDict,l=this.atomDict,h=t.getElementsByTagName("Entry");if(1===h.length){const e=h[0].getElementsByTagName("chemical_shift_list");if(1===e.length){const t=e[0].getElementsByTagName("random_coil_index");for(let e=0,i=t.length;e0&&(a[n]=e)}else{const e=t.getElementsByTagName("clash"),i=t.getElementsByTagName("mog-bond-outlier"),r=t.getElementsByTagName("mog-angle-outlier");if(i.length>0||r.length>0||e.length>0){const t={};c[n]=t;for(let i=0,n=e.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+t[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16|0}hl.add("validation",class extends X_{constructor(e,t){super(e,t||{}),this.useDomParser=!0,this.validation=new tw(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),e.Debug&&il.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),e.Debug&&il.timeEnd("ValidationParser._parse "+this.name)}});var sw=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();function ow(e,t,i,n){var r=sw,s=n+i;e^=-1;for(var o=n;o>>8^r[255&(e^t[o])];return-1^e}var aw=30,cw=12;function lw(e,t){var i,n,r,s,o,a,c,l,h,u,d,f,m,p,g,v,y,x,b,_,w,S,A,M,C;i=e.state,n=e.next_in,M=e.input,r=n+(e.avail_in-5),s=e.next_out,C=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,u=i.wnext,d=i.window,f=i.hold,m=i.bits,p=i.lencode,g=i.distcode,v=(1<>>=b=x>>>24,m-=b,0===(b=x>>>16&255))C[s++]=65535&x;else{if(!(16&b)){if(0==(64&b)){x=p[(65535&x)+(f&(1<>>=b,m-=b),m<15&&(f+=M[n++]<>>=b=x>>>24,m-=b,!(16&(b=x>>>16&255))){if(0==(64&b)){x=g[(65535&x)+(f&(1<c){e.msg="invalid distance too far back",i.mode=aw;break e}if(f>>>=b,m-=b,w>(b=s-o)){if((b=w-b)>h&&i.sane){e.msg="invalid distance too far back",i.mode=aw;break e}if(S=0,A=d,0===u){if(S+=l-b,b<_){_-=b;do{C[s++]=d[S++]}while(--b);S=s-w,A=C}}else if(u2;)C[s++]=A[S++],C[s++]=A[S++],C[s++]=A[S++],_-=3;_&&(C[s++]=A[S++],_>1&&(C[s++]=A[S++]))}else{S=s-w;do{C[s++]=C[S++],C[s++]=C[S++],C[s++]=C[S++],_-=3}while(_>2);_&&(C[s++]=C[S++],_>1&&(C[s++]=C[S++]))}break}}break}}while(n>3,f&=(1<<(m-=_<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n=1&&0===E[_];_--);if(w>_&&(w=_),0===_)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(b=1;b<_&&0===E[b];b++);for(w0&&(e===fw||1!==_))return-1;for(D[1]=0,y=1;yuw||e===pw&&C>dw)return 1;for(;;){m=y-A,o[x]f?(p=L[R+o[x]],g=T[I+o[x]]):(p=96,g=0),c=1<>A)+(l-=c)]=m<<24|p<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(P&=c-1,P+=c):P=0,x++,0==--E[y]){if(y===_)break;y=t[i+o[x]]}if(y>w&&(P&u)!==h){for(0===A&&(A=w),d+=b,M=1<<(S=y-A);S+A<_&&!((M-=E[S+A])<=0);)S++,M<<=1;if(C+=1<uw||e===pw&&C>dw)return 1;r[h=P&u]=w<<24|S<<16|d-s|0}}return 0!==P&&(r[d+P]=y-A<<24|64<<16|0),a.bits=w,0}var _w=1,ww=2,Sw=0,Aw=-2,Mw=1,Cw=12,Pw=30,Tw=852,Iw=592;function Ew(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Dw(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Lw(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Mw,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Tw),t.distcode=t.distdyn=new Int32Array(Iw),t.sane=1,t.back=-1,Sw):Aw}(e)):Aw}function Rw(e,t){var i,n;return e?(n=new Dw,e.state=n,n.window=null,i=function(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Aw:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Lw(e))):Aw}(e,t),i!==Sw&&(e.state=null),i):Aw}var kw,Ow,Bw=!0;function Nw(e){if(Bw){var t;for(kw=new Int32Array(512),Ow=new Int32Array(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(bw(_w,e.lens,0,288,kw,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;bw(ww,e.lens,0,32,Ow,0,e.work,{bits:5}),Bw=!1}e.lencode=kw,e.lenbits=9,e.distcode=Ow,e.distbits=5}function Fw(e,t,i,n){var r,s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(nw(s.window,t,i-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):((r=s.wsize-s.wnext)>n&&(r=n),nw(s.window,t,i-n,r,s.wnext),(n-=r)?(nw(s.window,t,i-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,i.check=ow(i.check,P,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=Pw;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=Pw;break}if(h-=4,w=8+(15&(l>>>=4)),0===i.wbits)i.wbits=w;else if(w>i.wbits){e.msg="invalid window size",i.mode=Pw;break}i.dmax=1<>8&1),512&i.flags&&(P[0]=255&l,P[1]=l>>>8&255,i.check=ow(i.check,P,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,P[2]=l>>>16&255,P[3]=l>>>24&255,i.check=ow(i.check,P,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&(P[0]=255&l,P[1]=l>>>8&255,i.check=ow(i.check,P,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=ow(i.check,P,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((f=i.length)>a&&(f=a),f&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),nw(i.head.extra,n,s,f,w)),512&i.flags&&(i.check=ow(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;f=0;do{w=n[s+f++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Cw;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1)){case 0:i.mode=14;break;case 1:if(Nw(i),i.mode=20,6===t){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=Pw}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=Pw;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(f=i.length){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;nw(r,n,s,f,o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=Cw;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Pw;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},S=bw(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,S){e.msg="invalid code lengths set",i.mode=Pw;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=g,h-=g,i.lens[i.have++]=y;else{if(16===y){for(M=g+2;h>>=g,h-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=Pw;break}w=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===y){for(M=g+3;h>>=g)),l>>>=3,h-=3}else{for(M=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Pw;break}for(;f--;)i.lens[i.have++]=w}}if(i.mode===Pw)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Pw;break}if(i.lenbits=9,A={bits:i.lenbits},S=bw(_w,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,S){e.msg="invalid literal/lengths set",i.mode=Pw;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},S=bw(ww,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,S){e.msg="invalid distances set",i.mode=Pw;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,lw(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===Cw&&(i.back=-1);break}for(i.back=0;v=(C=i.lencode[l&(1<>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>x)])>>>16&255,y=65535&C,!(x+(g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=y,0===v){i.mode=26;break}if(32&v){i.back=-1,i.mode=Cw;break}if(64&v){e.msg="invalid literal/length code",i.mode=Pw;break}i.extra=15&v,i.mode=22;case 22:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;v=(C=i.distcode[l&(1<>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>x)])>>>16&255,y=65535&C,!(x+(g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&v){e.msg="invalid distance code",i.mode=Pw;break}i.offset=y,i.extra=15&v,i.mode=24;case 24:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Pw;break}i.mode=25;case 25:if(0===c)break e;if(f=d-c,i.offset>f){if((f=i.offset-f)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Pw;break}f>i.wnext?(f-=i.wnext,m=i.wsize-f):m=i.wnext-f,f>i.length&&(f=i.length),p=i.window}else p=r,m=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=p[m++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;r[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<=252?6:Hw>=248?5:Hw>=240?4:Hw>=224?3:Hw>=192?2:1;function jw(e){var t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t}function Ww(e,t){var i,n,r,s,o=t||e.length,a=new Array(2*o);for(n=0,i=0;i4)a[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i1?a[n++]=65533:r<65536?a[n++]=r:(r-=65536,a[n++]=55296|r>>10&1023,a[n++]=56320|1023&r)}return function(e,t){if(t<65537&&(e.subarray&&Gw||!e.subarray&&$w))return String.fromCharCode.apply(null,iw(e,t));for(var i="",n=0;ne.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Vw[e[i]]>t?i:t}Vw[254]=Vw[254]=1;var Xw=0,Yw={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Zw(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Kw(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Qw=Object.prototype.toString;function Jw(e){if(!(this instanceof Jw))return new Jw(e);this.options=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var n in i)i.hasOwnProperty(n)&&(e[n]=i[n])}}return e}({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zw,this.strm.avail_out=0;var i,n,r,s=Rw(this.strm,t.windowBits);if(s!==Xw)throw new Error(Yw[s]);this.header=new Kw,i=this.strm,n=this.header,i&&i.state&&(0==(2&(r=i.state).wrap)||(r.head=n,n.done=!1))}Jw.prototype.push=function(e,t){var i,n,r,s,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,u=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?c.input=function(e){for(var t=new Uint8Array(e.length),i=0,n=t.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(n=4),4===n?(i=function(e){if(!e||!e.state)return Aw;var t=e.state;return t.window&&(t.window=null),e.state=null,Sw}(this.strm),this.onEnd(i),this.ended=!0,i===Xw):2!==n||(this.onEnd(Xw),c.avail_out=0,!0)},Jw.prototype.onData=function(e){this.chunks.push(e)},Jw.prototype.onEnd=function(e){e===Xw&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(e){var t,i,n,r,s,o;for(n=0,t=0,i=e.length;tObject.assign(Object.assign({},e),{[t]:t})),{})}}const mS={backgroundColor:{type:"color"},quality:fS("auto","low","medium","high"),sampleLevel:dS(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:uS(1,10,0),zoomSpeed:uS(1,10,0),panSpeed:uS(1,10,0),clipNear:dS(1,100,0),clipFar:dS(1,100,0),clipDist:hS(200,0),clipMode:fS("scene","camera"),clipScale:fS("relative","absolute"),fogNear:dS(1,100,0),fogFar:dS(1,100,0),cameraType:fS("perspective","orthographic","stereo"),cameraEyeSep:uS(3,1,.01),cameraFov:dS(1,120,15),lightColor:{type:"color"},lightIntensity:uS(2,10,0),ambientColor:{type:"color"},ambientIntensity:uS(2,10,0),hoverTimeout:hS(1e4,-1),tooltip:{type:"boolean"},mousePreset:fS(...Object.keys(um))};e.AngleRepresentation=Qv,e.ArrowBuffer=wx,e.Assembly=Qm,e.AxesRepresentation=fy,e.BackboneRepresentation=py,e.BallAndStickRepresentation=my,e.BaseRepresentation=gy,e.Box3=Ni,e.BoxBuffer=Px,e.BufferRepresentation=Vp,e.CartoonRepresentation=Sy,e.Collection=Sg,e.Color=mn,e.Colormaker=dc,e.ColormakerRegistry=al,e.Component=wg,e.ComponentCollection=Wg,e.ConeBuffer=xx,e.ContactRepresentation=Ay,e.Counter=El,e.CylinderBuffer=dy,e.DatasourceRegistry=cl,e.DecompressorRegistry=dl,e.DihedralHistogramRepresentation=Ty,e.DihedralRepresentation=My,e.DistanceRepresentation=Ey,e.EllipsoidBuffer=Rx,e.Euler=ai,e.Frames=Pg,e.HelixorientRepresentation=ky,e.HyperballRepresentation=Vy,e.Kdtree=qm,e.KeyActions=mm,e.LabelRepresentation=jy,e.LeftMouseButton=1,e.LicoriceRepresentation=Oy,e.LineRepresentation=qy,e.Matrix3=Ut,e.Matrix4=ri,e.MdsrvDatasource=class extends eS{constructor(e=""){super(),this.baseUrl=e}getListing(e=""){let t=`${this.baseUrl}dir/${e}`;return"/"!==t[t.length-1]&&(t+="/"),Ml(t,{ext:"json"}).then((t=>({path:e,data:t.data})))}getUrl(e){const t=Sl(e);return`${this.baseUrl}file/${t.path}${t.query}`}getCountUrl(e){const t=Sl(e);return`${this.baseUrl}traj/numframes/${t.path}${t.query}`}getFrameUrl(e,t){const i=Sl(e);return`${this.baseUrl}traj/frame/${t}/${i.path}${i.query}`}getFrameParams(e,t){return`atomIndices=${t.join(";")}`}getPathUrl(e,t){const i=Sl(e);return`${this.baseUrl}traj/path/${t}/${i.path}${i.query}`}getExt(e){return Sl(e).ext}},e.MeasurementDefaultParams=nl,e.MeshBuffer=nm,e.MiddleMouseButton=2,e.MolecularSurface=Qy,e.MolecularSurfaceRepresentation=Jy,e.MouseActions=hm,e.OctahedronBuffer=Fx,e.ParserRegistry=hl,e.PdbWriter=class extends Pl{constructor(e,t){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";const i=Object.assign({},t);this.renumberSerial=Ia(i.renumberSerial,!0),this.remarks=function(e){return Array.isArray(e)?e:[e]}(Ia(i.remarks,[])),this.structure=e,this._records=[]}_writeRecords(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()}_writeTitle(){this._records.push(Cl.sprintf("TITLE %-74s",this.structure.name))}_writeRemarks(){this.remarks.forEach((e=>{this._records.push(Cl.sprintf("REMARK %-73s",e))})),this.structure.trajectory&&(this._records.push(Cl.sprintf("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(Cl.sprintf("REMARK %-73s",`Frame ${this.structure.trajectory.frame}`)))}_writeAtoms(){let e=1,t=1,i=" ",n=" ";const r=this.structure.modelStore.count>1;this.structure.eachModel((s=>{r&&this._records.push(Cl.sprintf("MODEL %4d%-66s",t++,"")),s.eachAtom((t=>{const r=t.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",s=this.renumberSerial?e:t.serial;let o=t.atomname;(1===o.length||o.length<4&&1===t.element.length&&o[0]===t.element)&&(o=" "+o),t.formalCharge?(i=Math.abs(t.formalCharge).toPrecision(1),n=t.formalCharge>0?"+":"-"):(i=" ",n=" "),this._records.push(Cl.sprintf(r,s,o,t.resname,Ia(t.chainname," "),t.resno,t.x,t.y,t.z,Ia(t.occupancy,1),Ia(t.bfactor,0),"",Ia(t.element,""),i,n)),e+=1}),this.structure.getSelection()),r&&this._records.push(Cl.sprintf("%-80s","ENDMDL"))})),this._records.push(Cl.sprintf("%-80s","END"))}getString(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()}getData(){return this._writeRecords(),this._records.join("\n")}},e.PickingProxy=Rh,e.Plane=Qi,e.PointBuffer=sg,e.PointRepresentation=ex,e.Quaternion=qt,e.Queue=eu,e.RepresentationCollection=Ag,e.RepresentationElement=yg,e.RepresentationRegistry=ll,e.RibbonRepresentation=rx,e.RightMouseButton=3,e.RocketRepresentation=sx,e.RopeRepresentation=ox,e.ScriptExtensions=sl,e.SdfWriter=class extends Pl{constructor(e){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=e,this._records=[]}get idString(){return this.structure.id}get titleString(){return" "+this.structure.title}get countsString(){return Cl.sprintf("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)}get chargeLines(){const e=[];this.structure.eachAtom((t=>{null!=t.formalCharge&&0!==t.formalCharge&&e.push([t.index,t.formalCharge])}));const t=[];for(let i=0;i{this._records.push(this.formatAtom(e))})),this.structure.eachBond((e=>{this._records.push(this.formatBond(e))})),this.chargeLines.forEach((e=>{this._records.push(e)})),this._records.push("M END")}_writeFooter(){this._records.push("$$$$")}getData(){return this._writeRecords(),this._records.join("\n")}},e.Selection=$c,e.Shape=Gp,e.ShapeComponent=Zg,e.Signal=mc.Signal,e.SpacefillRepresentation=ax,e.SpatialHash=ju,e.SphereBuffer=tg,e.Stage=class{constructor(e,t={}){this.signals={parametersChanged:new mc.Signal,fullscreenChanged:new mc.Signal,componentAdded:new mc.Signal,componentRemoved:new mc.Signal,clicked:new mc.Signal,hovered:new mc.Signal},this.tasks=new El,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new vh(e),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new xh(this.viewer.renderer.domElement),this.viewerControls=new Vh(this),this.trackballControls=new Dh(this),this.pickingControls=new kh(this),this.animationControls=new Jh(this),this.mouseControls=new fm(this),this.keyControls=new gm(this),this.pickingBehavior=new vm(this),this.mouseBehavior=new ym(this),this.animationBehavior=new xm(this),this.keyBehavior=new _m(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=Ea(t,Yg),this.setParameters(this.parameters),this.viewer.animate())}setParameters(e={}){Da(this.parameters,e);const t=e,i=this.parameters,n=this.viewer,r=this.trackballControls;return void 0!==t.quality&&this.setQuality(i.quality),void 0!==t.impostor&&this.setImpostor(i.impostor),void 0!==t.rotateSpeed&&(r.rotateSpeed=i.rotateSpeed),void 0!==t.zoomSpeed&&(r.zoomSpeed=i.zoomSpeed),void 0!==t.panSpeed&&(r.panSpeed=i.panSpeed),void 0!==t.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),n.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),n.setFog(void 0,i.fogNear,i.fogFar),n.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),n.setSampling(i.sampleLevel),n.setBackground(i.backgroundColor),n.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(e){console.log("STAGE LOG",e),this.logList.push(e)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof Vg){let i,n,r;t.setSelection("/0");const s=t.structure;if(s.biomolDict.BU1){const e=s.biomolDict.BU1;i=e.getAtomCount(s),n=e.getResidueCount(s),r=e.getInstanceCount(),t.setDefaultAssembly("BU1")}else i=s.getModelProxy(0).atomCount,n=s.getModelProxy(0).residueCount,r=1;let o=i;Kc&&(o*=4);const a=s.atomStore.count/s.residueStore.count<2;a&&(o*=10);let c="chainname",l="RdYlBu",h=!1;if(1===s.getChainnameCount(new $c("polymer and /0"))&&(c="residueindex",l="Spectral",h=!0),e.Debug&&console.log(o,i,r,a),n/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&o>15e3||o>7e5){let e=Math.min(2,Math.max(.1,6e3/(o/r)));a&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:c,colorScale:l,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else o>25e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,lineOnly:!0}):o>1e5?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):o>8e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),o<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:l,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof Hg||t instanceof jg)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(e,t={}){const i=Object.assign({},this.defaultFileParams,t),n=Sl(e).name;this.tasks.increment(),this.log(`loading file '${n}'`);const r=Ia(i.ext,Sl(e).ext);let s;return s=hl.isTrajectory(r)?Promise.reject(new Error(`loadFile: ext '${r}' is a trajectory and must be loaded into a structure component`)):Ml(e,i),s.then((e=>{this.log(`loaded '${n}'`);const t=this.addComponentFromObject(e,i);return i.defaultRepresentation&&this.defaultFileRepresentation(t),this.tasks.decrement(),t}),(e=>{this.tasks.decrement();const t=`error loading file: '${e}'`;throw this.log(t),t}))}loadScript(e){const t=Sl(e).name;return this.log(`loading script '${t}'`),Ml(e).then((e=>{this.tasks.increment(),this.log(`running script '${t}'`),e.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${t}'`)})),this.log(`called script '${t}'`)}),(e=>{this.tasks.decrement();const i=`errored script '${t}' "${e}"`;throw this.log(i),i}))}addComponent(e){e?(this.compList.push(e),this.signals.componentAdded.dispatch(e)):il.warn("Stage.addComponent: no component given")}addComponentFromObject(e,t={}){const i=fl.get(e.type);if(i){const n=new i(this,e,t);return this.addComponent(n),n}il.warn("no component for object type",e.type)}removeComponent(e){const t=this.compList.indexOf(e);-1!==t&&(this.compList.splice(t,1),e.dispose(),this.signals.componentRemoved.dispatch(e))}removeAllComponents(){this.compList.slice().forEach((e=>this.removeComponent(e)))}handleResize(){this.viewer.handleResize()}setSize(e,t){const i=this.viewer.container;i!==document.body&&(void 0!==e&&(i.style.width=e),void 0!==t&&(i.style.height=t),this.handleResize())}toggleFullscreen(e){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void il.log("fullscreen mode (currently) not possible");const t=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function n(){if(!i()&&t.lastFullscreenElement){const e=t.lastFullscreenElement;e.style.width=e.dataset.normalWidth||"",e.style.height=e.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",n),document.removeEventListener("mozfullscreenchange",n),document.removeEventListener("webkitfullscreenchange",n),document.removeEventListener("MSFullscreenChange",n),t.handleResize(),t.signals.fullscreenChanged.dispatch(!1)}}e=e||this.viewer.container,this.lastFullscreenElement=e,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(e.dataset.normalWidth=e.style.width||"",e.dataset.normalHeight=e.style.height||"",e.style.width=window.screen.width+"px",e.style.height=window.screen.height+"px",e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",n),document.addEventListener("mozfullscreenchange",n),document.addEventListener("webkitfullscreenchange",n),document.addEventListener("MSFullscreenChange",n),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){t.handleResize()}),100))}setSpin(e){e?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(e){e?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const e=this.parameters;if("scene"!==e.clipMode)return 0;let t=e.clipNear;return"absolute"===e.clipScale&&(t=this.viewer.absoluteToRelative(t)),2*t}setFocus(e){if("scene"!==this.parameters.clipMode)return;let t,i,n,r;"relative"===this.parameters.clipScale?(t=tc(e/2,0,49.9),i=100-t,n=50,r=function(e){return tc(e,0,100)}(2*i-50)):(t=this.viewer.relativeToAbsolute(e/2),i=t,n=0,r=2*i),this.setParameters({clipNear:t,clipFar:i,fogNear:n,fogFar:r})}getZoomForBox(e){const t=e.getSize(Xg),i=Math.max(t.x,t.y,t.z),n=Math.min(t.x,t.y,t.z);let r=i+Math.sqrt(n);const s=Ka(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(e).then((e=>{this.tasks.decrement(),t(e)})).catch((e=>{this.tasks.decrement(),i(e)}))}))}))}setImpostor(e){this.parameters.impostor=e;const t=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!t.includes(i.getType()))return;const n=i.getParameters();n.disableImpostor=!e,i.build(n)}))}setQuality(e){this.parameters.quality=e;const t=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(n){const r=n.getParameters();if(!t.includes(n.getType())){if(!i.includes(n.getType()))return;if(!r.disableImpostor)return void(n.repr.quality=e)}r.quality=e,n.build(r)}))}eachComponent(e,t){this.compList.slice().forEach((i=>{void 0!==t&&t!==i.type||e(i)}))}eachRepresentation(e,t){this.eachComponent((i=>{i.reprList.slice().forEach((n=>{void 0!==t&&t!==n.getType()||e(n,i)}))}))}getComponentsByName(e){const t=[];return this.eachComponent((i=>{(void 0===e||qg(e,i))&&t.push(i)})),new Wg(t)}getComponentsByObject(e){const t=[];return this.eachComponent((i=>{i.object===e&&t.push(i)})),new Wg(t)}getRepresentationsByName(e){const t=[];return this.eachRepresentation(((i,n)=>{(void 0===e||qg(e,i))&&t.push(i)})),new Ag(t)}measureClear(){this.eachComponent((e=>e.measureClear()),"structure")}measureUpdate(){this.eachComponent((e=>e.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}},e.StaticDatasource=class extends eS{constructor(e=""){super(),this.baseUrl=e}getUrl(e){const t=Sl(e);let i=this.baseUrl+t.path;return lS.test(this.baseUrl)||(i=function(e){const t=window.location,i=t.pathname,n=i.substring(0,i.lastIndexOf("/")+1);return t.origin+n+e}(i)),i}getExt(e){return Sl(e).ext}},e.StlWriter=class extends Pl{constructor(e){super(),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=e}getData(){const e=this.surface.index.length/3,t=new Il(2*e+3*e*4*4+80+4);t.skip(80),t.writeUint32(e);const i=new Zt,n=new Zt,r=new Zt,s=new Zt;for(let o=0;o{e.eachAtom((e=>{s.growIfFull(),s.atomTypeId[c]=o.add(e.atomname,e.element),s.x[c]=e.x,s.y[c]=e.y,s.z[c]=e.z,s.serial[c]=e.serial,s.formalCharge[c]=e.formalCharge,s.partialCharge[c]=e.partialCharge,s.altloc[c]=e.altloc,s.occupancy[c]=e.occupancy,s.bfactor[c]=e.bfactor,r.addAtom(e.modelIndex+h,e.chainname,e.chainid,e.resname,e.resno,1===e.hetero,e.sstruc,e.inscode),a[e.index+l]=c,c+=1})),l+=e.atomStore.count,h+=e.modelStore.count}));const u=n.bondStore,d=n.getAtomProxy(),f=n.getAtomProxy();return l=0,i.forEach((e=>{e.eachBond((e=>{d.index=a[e.atomIndex1+l],f.index=a[e.atomIndex2+l],u.addBond(d,f,e.bondOrder)})),l+=e.atomStore.count})),r.finalize(),hp(n,!0),lp(n,!0),n.finalizeAtoms(),n.finalizeBonds(),pp(n),e.Debug&&il.timeEnd("concatStructures"),n},e.download=Oa,e.flatten=function e(t,i){i=Ia(i,[]);for(let n=0;nt?(o&&(clearTimeout(o),o=null),a=l,s=e.apply(n,r),o||(n=r=null)):o||!1===i.trailing||(o=setTimeout(c,h)),s}},e.uniqueArray=za,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ngl.js.map diff --git a/dist/ngl.js.map b/dist/ngl.js.map index 1f632af4..bdb3f58e 100644 --- a/dist/ngl.js.map +++ b/dist/ngl.js.map @@ -1 +1 @@ -{"version":3,"file":"ngl.js","sources":["../src/polyfills.js","../node_modules/promise-polyfill/src/index.js","../node_modules/promise-polyfill/src/finally.js","../node_modules/promise-polyfill/src/allSettled.js","../node_modules/three/src/constants.js","../node_modules/three/src/core/EventDispatcher.js","../node_modules/three/src/math/MathUtils.js","../node_modules/three/src/extras/ImageUtils.js","../node_modules/three/src/math/Vector2.js","../node_modules/three/src/math/Matrix3.js","../node_modules/three/src/textures/Texture.js","../node_modules/three/src/math/Vector4.js","../node_modules/three/src/renderers/WebGLRenderTarget.js","../node_modules/three/src/math/Quaternion.js","../node_modules/three/src/math/Vector3.js","../node_modules/three/src/math/Matrix4.js","../node_modules/three/src/math/Euler.js","../node_modules/three/src/core/Layers.js","../node_modules/three/src/core/Object3D.js","../node_modules/three/src/scenes/Scene.js","../node_modules/three/src/math/Box3.js","../node_modules/three/src/math/Sphere.js","../node_modules/three/src/math/Ray.js","../node_modules/three/src/math/Plane.js","../node_modules/three/src/math/Triangle.js","../node_modules/three/src/math/Color.js","../node_modules/three/src/core/Face3.js","../node_modules/three/src/materials/Material.js","../node_modules/three/src/materials/MeshBasicMaterial.js","../node_modules/three/src/core/BufferAttribute.js","../node_modules/three/src/core/DirectGeometry.js","../node_modules/three/src/utils.js","../node_modules/three/src/core/BufferGeometry.js","../node_modules/three/src/objects/Mesh.js","../node_modules/three/src/core/Geometry.js","../node_modules/three/src/geometries/BoxGeometry.js","../node_modules/three/src/renderers/shaders/UniformsUtils.js","../node_modules/three/src/materials/ShaderMaterial.js","../node_modules/three/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js","../node_modules/three/src/cameras/Camera.js","../node_modules/three/src/cameras/PerspectiveCamera.js","../node_modules/three/src/textures/DataTexture.js","../node_modules/three/src/math/Frustum.js","../node_modules/three/src/renderers/shaders/UniformsLib.js","../node_modules/three/src/renderers/webgl/WebGLAnimation.js","../node_modules/three/src/renderers/webgl/WebGLAttributes.js","../node_modules/three/src/geometries/PlaneGeometry.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/common.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/packing.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/background_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/background_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/cube_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/cube_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/depth_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/depth_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/equirect_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/equirect_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/linedashed_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/linedashed_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshbasic_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshlambert_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshtoon_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshtoon_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphong_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphong_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphysical_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/normal_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/normal_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/points_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/points_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/shadow_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/shadow_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/sprite_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/sprite_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib.js","../node_modules/three/src/renderers/webgl/WebGLBackground.js","../node_modules/three/src/renderers/webgl/WebGLBindingStates.js","../node_modules/three/src/renderers/webgl/WebGLBufferRenderer.js","../node_modules/three/src/renderers/webgl/WebGLCapabilities.js","../node_modules/three/src/renderers/webgl/WebGLClipping.js","../node_modules/three/src/renderers/webgl/WebGLExtensions.js","../node_modules/three/src/renderers/webgl/WebGLGeometries.js","../node_modules/three/src/renderers/webgl/WebGLIndexedBufferRenderer.js","../node_modules/three/src/renderers/webgl/WebGLInfo.js","../node_modules/three/src/renderers/webgl/WebGLMorphtargets.js","../node_modules/three/src/renderers/webgl/WebGLObjects.js","../node_modules/three/src/textures/CubeTexture.js","../node_modules/three/src/textures/DataTexture2DArray.js","../node_modules/three/src/textures/DataTexture3D.js","../node_modules/three/src/renderers/webgl/WebGLUniforms.js","../node_modules/three/src/renderers/webgl/WebGLShader.js","../node_modules/three/src/renderers/webgl/WebGLProgram.js","../node_modules/three/src/renderers/webgl/WebGLPrograms.js","../node_modules/three/src/renderers/webgl/WebGLProperties.js","../node_modules/three/src/renderers/webgl/WebGLRenderLists.js","../node_modules/three/src/renderers/webgl/WebGLLights.js","../node_modules/three/src/renderers/webgl/WebGLRenderStates.js","../node_modules/three/src/materials/MeshDepthMaterial.js","../node_modules/three/src/materials/MeshDistanceMaterial.js","../node_modules/three/src/renderers/webgl/WebGLShadowMap.js","../node_modules/three/src/renderers/shaders/ShaderLib/vsm_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/vsm_frag.glsl.js","../node_modules/three/src/renderers/webgl/WebGLState.js","../node_modules/three/src/renderers/webgl/WebGLTextures.js","../node_modules/three/src/renderers/webgl/WebGLUtils.js","../node_modules/three/src/cameras/ArrayCamera.js","../node_modules/three/src/objects/Group.js","../node_modules/three/src/renderers/webxr/WebXRController.js","../node_modules/three/src/renderers/webxr/WebXRManager.js","../node_modules/three/src/renderers/webgl/WebGLMaterials.js","../node_modules/three/src/renderers/WebGLRenderer.js","../node_modules/three/src/scenes/Fog.js","../node_modules/three/src/materials/LineBasicMaterial.js","../node_modules/three/src/objects/Line.js","../node_modules/three/src/objects/LineSegments.js","../node_modules/three/src/materials/PointsMaterial.js","../node_modules/three/src/objects/Points.js","../node_modules/three/src/textures/CanvasTexture.js","../node_modules/three/src/geometries/PolyhedronGeometry.js","../node_modules/three/src/geometries/TetrahedronGeometry.js","../node_modules/three/src/geometries/OctahedronGeometry.js","../node_modules/three/src/geometries/IcosahedronGeometry.js","../node_modules/three/src/geometries/TorusGeometry.js","../node_modules/three/src/geometries/CylinderGeometry.js","../node_modules/three/src/geometries/ConeGeometry.js","../node_modules/three/src/lights/Light.js","../node_modules/three/src/lights/LightShadow.js","../node_modules/three/src/lights/SpotLightShadow.js","../node_modules/three/src/lights/SpotLight.js","../node_modules/three/src/cameras/OrthographicCamera.js","../node_modules/three/src/lights/AmbientLight.js","../node_modules/three/src/cameras/StereoCamera.js","../node_modules/three/src/core/Uniform.js","../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../node_modules/chroma-js/chroma.js","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../node_modules/signals/dist/signals.js","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/parser/parser-registry.ts","../src/worker/worker-utils.ts","../src/worker/worker-registry.ts","../src/globals.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../node_modules/sprintf-js/src/sprintf.js","../src/writer/writer.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/utils/io-buffer.ts","../src/writer/stl-writer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/stage/mouse-observer.ts","../src/constants.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/parser/dcd-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../src/parser/validation-parser.ts","../lib/pako_inflate.es6.js","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/datasource/mdsrv-datasource.ts","../src/ui/parameters.ts","../src/ngl.ts"],"sourcesContent":["/**\n * @file shims\n * @private\n * @author Alexander Rose \n */\n\n/// ///////////\n// Polyfills\n\nif (typeof window !== 'undefined') {\n (function () {\n 'use strict'\n // Console-polyfill. MIT license.\n // https://github.com/paulmillr/console-polyfill\n // Make it safe to do console.log() always.\n\n window.console = window.console || {}\n var con = window.console\n var prop, method\n var empty = {}\n var dummy = function () {}\n var properties = 'memory'.split(',')\n var methods = (\n 'assert,clear,count,debug,dir,dirxml,error,exception,group,' +\n 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +\n 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn'\n ).split(',')\n\n while ((prop = properties.pop())) if (!con[prop]) con[prop] = empty\n while ((method = methods.pop())) if (!con[method]) con[method] = dummy\n })()\n}\n\nif (typeof window !== 'undefined' && typeof window.HTMLCanvasElement !== 'undefined' && !window.HTMLCanvasElement.prototype.toBlob) {\n // http://code.google.com/p/chromium/issues/detail?id=67587#57\n Object.defineProperty(window.HTMLCanvasElement.prototype, 'toBlob', {\n\n value: function (callback, type, quality) {\n var bin = window.atob(this.toDataURL(type, quality).split(',')[ 1 ])\n var len = bin.length\n var len32 = len >> 2\n var a8 = new Uint8Array(len)\n var a32 = new Uint32Array(a8.buffer, 0, len32)\n\n for (var i = 0, j = 0; i < len32; i++) {\n a32[i] = (\n bin.charCodeAt(j++) |\n bin.charCodeAt(j++) << 8 |\n bin.charCodeAt(j++) << 16 |\n bin.charCodeAt(j++) << 24\n )\n }\n\n var tailLength = len & 3\n\n while (tailLength--) {\n a8[ j ] = bin.charCodeAt(j++)\n }\n\n callback(new window.Blob([ a8 ], { 'type': type || 'image/png' }))\n }\n\n })\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt\nMath.cbrt = Math.cbrt || function (x) {\n var y = Math.pow(Math.abs(x), 1 / 3)\n return x < 0 ? -y : y\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\nif (!Math.sign) {\n Math.sign = function (x) {\n // If x is NaN, the result is NaN.\n // If x is -0, the result is -0.\n // If x is +0, the result is +0.\n // If x is negative and not -0, the result is -1.\n // If x is positive and not +0, the result is +1.\n x = +x // convert to a number\n if (x === 0 || isNaN(x)) {\n return Number(x)\n }\n return x > 0 ? 1 : -1\n }\n}\n\nif (!Number.isInteger) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\n Number.isInteger = function isInteger (nVal) {\n return typeof nVal === 'number' && isFinite(nVal) && nVal > -9007199254740992 && nVal < 9007199254740992 && Math.floor(nVal) === nVal\n }\n}\n\nif (!Number.isNaN) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN\n Number.isNaN = function isNaN (value) {\n return value !== value // eslint-disable-line no-self-compare\n }\n}\n\nif (!Object.assign) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n Object.defineProperty(Object, 'assign', {\n\n enumerable: false,\n configurable: true,\n writable: true,\n\n value: function (target/*, firstSource */) {\n 'use strict'\n if (target === undefined || target === null) { throw new TypeError('Cannot convert first argument to object') }\n\n var to = Object(target)\n\n var hasPendingException = false\n var pendingException\n\n for (var i = 1; i < arguments.length; i++) {\n var nextSource = arguments[i]\n if (nextSource === undefined || nextSource === null) { continue }\n\n var keysArray = Object.keys(Object(nextSource))\n for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {\n var nextKey = keysArray[nextIndex]\n try {\n var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey)\n if (desc !== undefined && desc.enumerable) { to[nextKey] = nextSource[nextKey] }\n } catch (e) {\n if (!hasPendingException) {\n hasPendingException = true\n pendingException = e\n }\n }\n }\n\n if (hasPendingException) { throw pendingException }\n }\n\n return to\n }\n\n })\n}\n\nif (!String.prototype.startsWith) {\n /*! https://mths.be/startswith v0.2.0 by @mathias */\n\n (function () {\n 'use strict' // needed to support `apply`/`call` with `undefined`/`null`\n var defineProperty = (function () {\n // IE 8 only supports `Object.defineProperty` on DOM elements\n var result\n try {\n var object = {}\n var $defineProperty = Object.defineProperty\n result = $defineProperty(object, object, object) && $defineProperty\n } catch (error) {} // eslint-disable-line no-empty\n return result\n }())\n var toString = {}.toString\n var startsWith = function (search) {\n if (this === null) {\n throw TypeError()\n }\n var string = String(this)\n if (search && toString.call(search) === '[object RegExp]') {\n throw TypeError()\n }\n var stringLength = string.length\n var searchString = String(search)\n var searchLength = searchString.length\n var position = arguments.length > 1 ? arguments[1] : undefined\n // `ToInteger`\n var pos = position ? Number(position) : 0\n if (Number.isNaN(pos)) {\n pos = 0\n }\n var start = Math.min(Math.max(pos, 0), stringLength)\n // Avoid the `indexOf` call if no match is possible\n if (searchLength + start > stringLength) {\n return false\n }\n var index = -1\n while (++index < searchLength) {\n if (string.charCodeAt(start + index) !== searchString.charCodeAt(index)) {\n return false\n }\n }\n return true\n }\n if (defineProperty) {\n defineProperty(String.prototype, 'startsWith', {\n 'value': startsWith,\n 'configurable': true,\n 'writable': true\n })\n } else {\n // eslint-disable-next-line no-extend-native\n String.prototype.startsWith = startsWith\n }\n }())\n}\n\nif (!String.prototype.endsWith) {\n // eslint-disable-next-line no-extend-native\n String.prototype.endsWith = function (searchString, position) {\n var subjectString = this.toString()\n if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {\n position = subjectString.length\n }\n position -= searchString.length\n var lastIndex = subjectString.indexOf(searchString, position)\n return lastIndex !== -1 && lastIndex === position\n }\n}\n\nif (!String.prototype.repeat) {\n // eslint-disable-next-line no-extend-native\n String.prototype.repeat = function (count) {\n 'use strict'\n if (this === null) {\n throw new TypeError('can\\'t convert ' + this + ' to object')\n }\n var str = '' + this\n count = +count\n if (Number.isNaN(count)) {\n count = 0\n }\n if (count < 0) {\n throw new RangeError('repeat count must be non-negative')\n }\n if (count === Infinity) {\n throw new RangeError('repeat count must be less than infinity')\n }\n count = Math.floor(count)\n if (str.length === 0 || count === 0) {\n return ''\n }\n // Ensuring count is a 31-bit integer allows us to heavily optimize the\n // main part. But anyway, most current (August 2014) browsers can't handle\n // strings 1 << 28 chars or longer, so:\n if (str.length * count >= 1 << 28) {\n throw new RangeError('repeat count must not overflow maximum string size')\n }\n var rpt = ''\n for (;;) {\n if ((count & 1) === 1) {\n rpt += str\n }\n count >>>= 1\n if (count === 0) {\n break\n }\n str += str\n }\n // Could we try:\n // return Array(count + 1).join(this);\n return rpt\n }\n}\n\nif (!String.prototype.includes) {\n // eslint-disable-next-line no-extend-native\n String.prototype.includes = function (search, start) {\n 'use strict'\n if (typeof start !== 'number') {\n start = 0\n }\n\n if (start + search.length > this.length) {\n return false\n } else {\n return this.indexOf(search, start) !== -1\n }\n }\n}\n\nif (!Array.prototype.includes) {\n // eslint-disable-next-line no-extend-native\n Array.prototype.includes = function (searchElement /*, fromIndex */) {\n 'use strict'\n if (this == null) {\n throw new TypeError('Array.prototype.includes called on null or undefined')\n }\n\n var O = Object(this)\n var len = parseInt(O.length, 10) || 0\n if (len === 0) {\n return false\n }\n var n = parseInt(arguments[1], 10) || 0\n var k\n if (n >= 0) {\n k = n\n } else {\n k = len + n\n if (k < 0) { k = 0 }\n }\n var currentElement\n while (k < len) {\n currentElement = O[k]\n if (searchElement === currentElement ||\n (Number.isNaN(searchElement) && Number.isNaN(currentElement))\n ) {\n return true\n }\n k++\n }\n return false\n }\n}\n\n// Production steps of ECMA-262, Edition 6, 22.1.2.1\n// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from\nif (!Array.from) {\n Array.from = (function () {\n var toStr = Object.prototype.toString\n var isCallable = function (fn) {\n return typeof fn === 'function' || toStr.call(fn) === '[object Function]'\n }\n var toInteger = function (value) {\n var number = Number(value)\n if (isNaN(number)) { return 0 }\n if (number === 0 || !isFinite(number)) { return number }\n return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number))\n }\n var maxSafeInteger = Math.pow(2, 53) - 1\n var toLength = function (value) {\n var len = toInteger(value)\n return Math.min(Math.max(len, 0), maxSafeInteger)\n }\n\n // The length property of the from method is 1.\n return function from (arrayLike/*, mapFn, thisArg */) {\n // 1. Let C be the this value.\n var C = this\n\n // 2. Let items be ToObject(arrayLike).\n var items = Object(arrayLike)\n\n // 3. ReturnIfAbrupt(items).\n if (arrayLike == null) {\n throw new TypeError('Array.from requires an array-like object - not null or undefined')\n }\n\n // 4. If mapfn is undefined, then let mapping be false.\n var mapFn = arguments.length > 1 ? arguments[1] : void undefined\n var T\n if (typeof mapFn !== 'undefined') {\n // 5. else\n // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.\n if (!isCallable(mapFn)) {\n throw new TypeError('Array.from: when provided, the second argument must be a function')\n }\n\n // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.\n if (arguments.length > 2) {\n T = arguments[2]\n }\n }\n\n // 10. Let lenValue be Get(items, \"length\").\n // 11. Let len be ToLength(lenValue).\n var len = toLength(items.length)\n\n // 13. If IsConstructor(C) is true, then\n // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.\n // 14. a. Else, Let A be ArrayCreate(len).\n var A = isCallable(C) ? Object(new C(len)) : new Array(len)\n\n // 16. Let k be 0.\n var k = 0\n // 17. Repeat, while k < len… (also steps a - h)\n var kValue\n while (k < len) {\n kValue = items[k]\n if (mapFn) {\n A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k)\n } else {\n A[k] = kValue\n }\n k += 1\n }\n // 18. Let putStatus be Put(A, \"length\", len, true).\n A.length = len\n // 20. Return A.\n return A\n }\n }())\n}\n\nif (typeof window !== 'undefined') {\n (function () {\n // http://paulirish.com/2011/requestanimationframe-for-smart-animating/\n // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating\n\n // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel\n\n // MIT license\n\n var lastTime = 0\n var vendors = [ 'ms', 'moz', 'webkit', 'o' ]\n\n for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {\n window.requestAnimationFrame = (\n window[ vendors[ x ] + 'RequestAnimationFrame' ]\n )\n\n window.cancelAnimationFrame = (\n window[ vendors[ x ] + 'CancelAnimationFrame' ] ||\n window[ vendors[ x ] + 'CancelRequestAnimationFrame' ]\n )\n }\n\n if (!window.requestAnimationFrame) {\n window.requestAnimationFrame = function (callback/*, element */) {\n var currTime = new Date().getTime()\n var timeToCall = Math.max(0, 16 - (currTime - lastTime))\n\n var id = window.setTimeout(function () {\n var time = currTime + timeToCall\n callback(time)\n }, timeToCall)\n\n lastTime = currTime + timeToCall\n\n return id\n }\n }\n\n if (!window.cancelAnimationFrame) {\n window.cancelAnimationFrame = function (id) {\n clearTimeout(id)\n }\n }\n }())\n}\n\nif (Function.prototype.name === undefined && Object.defineProperty !== undefined) {\n // Missing in IE9-11.\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name\n\n // eslint-disable-next-line no-extend-native\n Object.defineProperty(Function.prototype, 'name', {\n\n get: function () {\n return this.toString().match(/^\\s*function\\s*(\\S*)\\s*\\(/)[ 1 ]\n }\n\n })\n}\n\nif (typeof window !== 'undefined') {\n if (window.performance === undefined) {\n /* global self */\n self.performance = {}\n }\n\n if (window.performance.now === undefined) {\n (function () {\n var start = Date.now()\n\n window.performance.now = function () {\n return Date.now() - start\n }\n })()\n }\n}\n\nif (Object.defineProperty !== undefined) {\n // Missing in IE < 13\n // MIT license\n // Copyright (c) 2016 Financial Times\n // https://github.com/Financial-Times/polyfill-service\n if (Number.MAX_SAFE_INTEGER === undefined) {\n Object.defineProperty(Number, 'MAX_SAFE_INTEGER', {\n enumerable: false,\n configurable: false,\n writable: false,\n value: Math.pow(2, 53) - 1\n })\n }\n if (Number.MIN_SAFE_INTEGER === undefined) {\n Object.defineProperty(Number, 'MIN_SAFE_INTEGER', {\n enumerable: false,\n configurable: false,\n writable: false,\n value: -(Math.pow(2, 53) - 1)\n })\n }\n}\n","import promiseFinally from './finally';\nimport allSettled from './allSettled';\n\n// Store setTimeout reference so promise-polyfill will be unaffected by\n// other code modifying setTimeout (like sinon.useFakeTimers())\nvar setTimeoutFunc = setTimeout;\n\nfunction isArray(x) {\n return Boolean(x && typeof x.length !== 'undefined');\n}\n\nfunction noop() {}\n\n// Polyfill for Function.prototype.bind\nfunction bind(fn, thisArg) {\n return function() {\n fn.apply(thisArg, arguments);\n };\n}\n\n/**\n * @constructor\n * @param {Function} fn\n */\nfunction Promise(fn) {\n if (!(this instanceof Promise))\n throw new TypeError('Promises must be constructed via new');\n if (typeof fn !== 'function') throw new TypeError('not a function');\n /** @type {!number} */\n this._state = 0;\n /** @type {!boolean} */\n this._handled = false;\n /** @type {Promise|undefined} */\n this._value = undefined;\n /** @type {!Array} */\n this._deferreds = [];\n\n doResolve(fn, this);\n}\n\nfunction handle(self, deferred) {\n while (self._state === 3) {\n self = self._value;\n }\n if (self._state === 0) {\n self._deferreds.push(deferred);\n return;\n }\n self._handled = true;\n Promise._immediateFn(function() {\n var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;\n if (cb === null) {\n (self._state === 1 ? resolve : reject)(deferred.promise, self._value);\n return;\n }\n var ret;\n try {\n ret = cb(self._value);\n } catch (e) {\n reject(deferred.promise, e);\n return;\n }\n resolve(deferred.promise, ret);\n });\n}\n\nfunction resolve(self, newValue) {\n try {\n // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure\n if (newValue === self)\n throw new TypeError('A promise cannot be resolved with itself.');\n if (\n newValue &&\n (typeof newValue === 'object' || typeof newValue === 'function')\n ) {\n var then = newValue.then;\n if (newValue instanceof Promise) {\n self._state = 3;\n self._value = newValue;\n finale(self);\n return;\n } else if (typeof then === 'function') {\n doResolve(bind(then, newValue), self);\n return;\n }\n }\n self._state = 1;\n self._value = newValue;\n finale(self);\n } catch (e) {\n reject(self, e);\n }\n}\n\nfunction reject(self, newValue) {\n self._state = 2;\n self._value = newValue;\n finale(self);\n}\n\nfunction finale(self) {\n if (self._state === 2 && self._deferreds.length === 0) {\n Promise._immediateFn(function() {\n if (!self._handled) {\n Promise._unhandledRejectionFn(self._value);\n }\n });\n }\n\n for (var i = 0, len = self._deferreds.length; i < len; i++) {\n handle(self, self._deferreds[i]);\n }\n self._deferreds = null;\n}\n\n/**\n * @constructor\n */\nfunction Handler(onFulfilled, onRejected, promise) {\n this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;\n this.onRejected = typeof onRejected === 'function' ? onRejected : null;\n this.promise = promise;\n}\n\n/**\n * Take a potentially misbehaving resolver function and make sure\n * onFulfilled and onRejected are only called once.\n *\n * Makes no guarantees about asynchrony.\n */\nfunction doResolve(fn, self) {\n var done = false;\n try {\n fn(\n function(value) {\n if (done) return;\n done = true;\n resolve(self, value);\n },\n function(reason) {\n if (done) return;\n done = true;\n reject(self, reason);\n }\n );\n } catch (ex) {\n if (done) return;\n done = true;\n reject(self, ex);\n }\n}\n\nPromise.prototype['catch'] = function(onRejected) {\n return this.then(null, onRejected);\n};\n\nPromise.prototype.then = function(onFulfilled, onRejected) {\n // @ts-ignore\n var prom = new this.constructor(noop);\n\n handle(this, new Handler(onFulfilled, onRejected, prom));\n return prom;\n};\n\nPromise.prototype['finally'] = promiseFinally;\n\nPromise.all = function(arr) {\n return new Promise(function(resolve, reject) {\n if (!isArray(arr)) {\n return reject(new TypeError('Promise.all accepts an array'));\n }\n\n var args = Array.prototype.slice.call(arr);\n if (args.length === 0) return resolve([]);\n var remaining = args.length;\n\n function res(i, val) {\n try {\n if (val && (typeof val === 'object' || typeof val === 'function')) {\n var then = val.then;\n if (typeof then === 'function') {\n then.call(\n val,\n function(val) {\n res(i, val);\n },\n reject\n );\n return;\n }\n }\n args[i] = val;\n if (--remaining === 0) {\n resolve(args);\n }\n } catch (ex) {\n reject(ex);\n }\n }\n\n for (var i = 0; i < args.length; i++) {\n res(i, args[i]);\n }\n });\n};\n\nPromise.allSettled = allSettled;\n\nPromise.resolve = function(value) {\n if (value && typeof value === 'object' && value.constructor === Promise) {\n return value;\n }\n\n return new Promise(function(resolve) {\n resolve(value);\n });\n};\n\nPromise.reject = function(value) {\n return new Promise(function(resolve, reject) {\n reject(value);\n });\n};\n\nPromise.race = function(arr) {\n return new Promise(function(resolve, reject) {\n if (!isArray(arr)) {\n return reject(new TypeError('Promise.race accepts an array'));\n }\n\n for (var i = 0, len = arr.length; i < len; i++) {\n Promise.resolve(arr[i]).then(resolve, reject);\n }\n });\n};\n\n// Use polyfill for setImmediate for performance gains\nPromise._immediateFn =\n // @ts-ignore\n (typeof setImmediate === 'function' &&\n function(fn) {\n // @ts-ignore\n setImmediate(fn);\n }) ||\n function(fn) {\n setTimeoutFunc(fn, 0);\n };\n\nPromise._unhandledRejectionFn = function _unhandledRejectionFn(err) {\n if (typeof console !== 'undefined' && console) {\n console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console\n }\n};\n\nexport default Promise;\n","/**\n * @this {Promise}\n */\nfunction finallyConstructor(callback) {\n var constructor = this.constructor;\n return this.then(\n function(value) {\n // @ts-ignore\n return constructor.resolve(callback()).then(function() {\n return value;\n });\n },\n function(reason) {\n // @ts-ignore\n return constructor.resolve(callback()).then(function() {\n // @ts-ignore\n return constructor.reject(reason);\n });\n }\n );\n}\n\nexport default finallyConstructor;\n","function allSettled(arr) {\n var P = this;\n return new P(function(resolve, reject) {\n if (!(arr && typeof arr.length !== 'undefined')) {\n return reject(\n new TypeError(\n typeof arr +\n ' ' +\n arr +\n ' is not iterable(cannot read property Symbol(Symbol.iterator))'\n )\n );\n }\n var args = Array.prototype.slice.call(arr);\n if (args.length === 0) return resolve([]);\n var remaining = args.length;\n\n function res(i, val) {\n if (val && (typeof val === 'object' || typeof val === 'function')) {\n var then = val.then;\n if (typeof then === 'function') {\n then.call(\n val,\n function(val) {\n res(i, val);\n },\n function(e) {\n args[i] = { status: 'rejected', reason: e };\n if (--remaining === 0) {\n resolve(args);\n }\n }\n );\n return;\n }\n }\n args[i] = { status: 'fulfilled', value: val };\n if (--remaining === 0) {\n resolve(args);\n }\n }\n\n for (var i = 0; i < args.length; i++) {\n res(i, args[i]);\n }\n });\n}\n\nexport default allSettled;\n","export const REVISION = '118';\nexport const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };\nexport const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };\nexport const CullFaceNone = 0;\nexport const CullFaceBack = 1;\nexport const CullFaceFront = 2;\nexport const CullFaceFrontBack = 3;\nexport const FrontFaceDirectionCW = 0;\nexport const FrontFaceDirectionCCW = 1;\nexport const BasicShadowMap = 0;\nexport const PCFShadowMap = 1;\nexport const PCFSoftShadowMap = 2;\nexport const VSMShadowMap = 3;\nexport const FrontSide = 0;\nexport const BackSide = 1;\nexport const DoubleSide = 2;\nexport const FlatShading = 1;\nexport const SmoothShading = 2;\nexport const NoBlending = 0;\nexport const NormalBlending = 1;\nexport const AdditiveBlending = 2;\nexport const SubtractiveBlending = 3;\nexport const MultiplyBlending = 4;\nexport const CustomBlending = 5;\nexport const AddEquation = 100;\nexport const SubtractEquation = 101;\nexport const ReverseSubtractEquation = 102;\nexport const MinEquation = 103;\nexport const MaxEquation = 104;\nexport const ZeroFactor = 200;\nexport const OneFactor = 201;\nexport const SrcColorFactor = 202;\nexport const OneMinusSrcColorFactor = 203;\nexport const SrcAlphaFactor = 204;\nexport const OneMinusSrcAlphaFactor = 205;\nexport const DstAlphaFactor = 206;\nexport const OneMinusDstAlphaFactor = 207;\nexport const DstColorFactor = 208;\nexport const OneMinusDstColorFactor = 209;\nexport const SrcAlphaSaturateFactor = 210;\nexport const NeverDepth = 0;\nexport const AlwaysDepth = 1;\nexport const LessDepth = 2;\nexport const LessEqualDepth = 3;\nexport const EqualDepth = 4;\nexport const GreaterEqualDepth = 5;\nexport const GreaterDepth = 6;\nexport const NotEqualDepth = 7;\nexport const MultiplyOperation = 0;\nexport const MixOperation = 1;\nexport const AddOperation = 2;\nexport const NoToneMapping = 0;\nexport const LinearToneMapping = 1;\nexport const ReinhardToneMapping = 2;\nexport const CineonToneMapping = 3;\nexport const ACESFilmicToneMapping = 4;\nexport const CustomToneMapping = 5;\n\nexport const UVMapping = 300;\nexport const CubeReflectionMapping = 301;\nexport const CubeRefractionMapping = 302;\nexport const EquirectangularReflectionMapping = 303;\nexport const EquirectangularRefractionMapping = 304;\nexport const CubeUVReflectionMapping = 306;\nexport const CubeUVRefractionMapping = 307;\nexport const RepeatWrapping = 1000;\nexport const ClampToEdgeWrapping = 1001;\nexport const MirroredRepeatWrapping = 1002;\nexport const NearestFilter = 1003;\nexport const NearestMipmapNearestFilter = 1004;\nexport const NearestMipMapNearestFilter = 1004;\nexport const NearestMipmapLinearFilter = 1005;\nexport const NearestMipMapLinearFilter = 1005;\nexport const LinearFilter = 1006;\nexport const LinearMipmapNearestFilter = 1007;\nexport const LinearMipMapNearestFilter = 1007;\nexport const LinearMipmapLinearFilter = 1008;\nexport const LinearMipMapLinearFilter = 1008;\nexport const UnsignedByteType = 1009;\nexport const ByteType = 1010;\nexport const ShortType = 1011;\nexport const UnsignedShortType = 1012;\nexport const IntType = 1013;\nexport const UnsignedIntType = 1014;\nexport const FloatType = 1015;\nexport const HalfFloatType = 1016;\nexport const UnsignedShort4444Type = 1017;\nexport const UnsignedShort5551Type = 1018;\nexport const UnsignedShort565Type = 1019;\nexport const UnsignedInt248Type = 1020;\nexport const AlphaFormat = 1021;\nexport const RGBFormat = 1022;\nexport const RGBAFormat = 1023;\nexport const LuminanceFormat = 1024;\nexport const LuminanceAlphaFormat = 1025;\nexport const RGBEFormat = RGBAFormat;\nexport const DepthFormat = 1026;\nexport const DepthStencilFormat = 1027;\nexport const RedFormat = 1028;\nexport const RedIntegerFormat = 1029;\nexport const RGFormat = 1030;\nexport const RGIntegerFormat = 1031;\nexport const RGBIntegerFormat = 1032;\nexport const RGBAIntegerFormat = 1033;\n\nexport const RGB_S3TC_DXT1_Format = 33776;\nexport const RGBA_S3TC_DXT1_Format = 33777;\nexport const RGBA_S3TC_DXT3_Format = 33778;\nexport const RGBA_S3TC_DXT5_Format = 33779;\nexport const RGB_PVRTC_4BPPV1_Format = 35840;\nexport const RGB_PVRTC_2BPPV1_Format = 35841;\nexport const RGBA_PVRTC_4BPPV1_Format = 35842;\nexport const RGBA_PVRTC_2BPPV1_Format = 35843;\nexport const RGB_ETC1_Format = 36196;\nexport const RGB_ETC2_Format = 37492;\nexport const RGBA_ETC2_EAC_Format = 37496;\nexport const RGBA_ASTC_4x4_Format = 37808;\nexport const RGBA_ASTC_5x4_Format = 37809;\nexport const RGBA_ASTC_5x5_Format = 37810;\nexport const RGBA_ASTC_6x5_Format = 37811;\nexport const RGBA_ASTC_6x6_Format = 37812;\nexport const RGBA_ASTC_8x5_Format = 37813;\nexport const RGBA_ASTC_8x6_Format = 37814;\nexport const RGBA_ASTC_8x8_Format = 37815;\nexport const RGBA_ASTC_10x5_Format = 37816;\nexport const RGBA_ASTC_10x6_Format = 37817;\nexport const RGBA_ASTC_10x8_Format = 37818;\nexport const RGBA_ASTC_10x10_Format = 37819;\nexport const RGBA_ASTC_12x10_Format = 37820;\nexport const RGBA_ASTC_12x12_Format = 37821;\nexport const RGBA_BPTC_Format = 36492;\nexport const SRGB8_ALPHA8_ASTC_4x4_Format = 37840;\nexport const SRGB8_ALPHA8_ASTC_5x4_Format = 37841;\nexport const SRGB8_ALPHA8_ASTC_5x5_Format = 37842;\nexport const SRGB8_ALPHA8_ASTC_6x5_Format = 37843;\nexport const SRGB8_ALPHA8_ASTC_6x6_Format = 37844;\nexport const SRGB8_ALPHA8_ASTC_8x5_Format = 37845;\nexport const SRGB8_ALPHA8_ASTC_8x6_Format = 37846;\nexport const SRGB8_ALPHA8_ASTC_8x8_Format = 37847;\nexport const SRGB8_ALPHA8_ASTC_10x5_Format = 37848;\nexport const SRGB8_ALPHA8_ASTC_10x6_Format = 37849;\nexport const SRGB8_ALPHA8_ASTC_10x8_Format = 37850;\nexport const SRGB8_ALPHA8_ASTC_10x10_Format = 37851;\nexport const SRGB8_ALPHA8_ASTC_12x10_Format = 37852;\nexport const SRGB8_ALPHA8_ASTC_12x12_Format = 37853;\nexport const LoopOnce = 2200;\nexport const LoopRepeat = 2201;\nexport const LoopPingPong = 2202;\nexport const InterpolateDiscrete = 2300;\nexport const InterpolateLinear = 2301;\nexport const InterpolateSmooth = 2302;\nexport const ZeroCurvatureEnding = 2400;\nexport const ZeroSlopeEnding = 2401;\nexport const WrapAroundEnding = 2402;\nexport const NormalAnimationBlendMode = 2500;\nexport const AdditiveAnimationBlendMode = 2501;\nexport const TrianglesDrawMode = 0;\nexport const TriangleStripDrawMode = 1;\nexport const TriangleFanDrawMode = 2;\nexport const LinearEncoding = 3000;\nexport const sRGBEncoding = 3001;\nexport const GammaEncoding = 3007;\nexport const RGBEEncoding = 3002;\nexport const LogLuvEncoding = 3003;\nexport const RGBM7Encoding = 3004;\nexport const RGBM16Encoding = 3005;\nexport const RGBDEncoding = 3006;\nexport const BasicDepthPacking = 3200;\nexport const RGBADepthPacking = 3201;\nexport const TangentSpaceNormalMap = 0;\nexport const ObjectSpaceNormalMap = 1;\n\nexport const ZeroStencilOp = 0;\nexport const KeepStencilOp = 7680;\nexport const ReplaceStencilOp = 7681;\nexport const IncrementStencilOp = 7682;\nexport const DecrementStencilOp = 7683;\nexport const IncrementWrapStencilOp = 34055;\nexport const DecrementWrapStencilOp = 34056;\nexport const InvertStencilOp = 5386;\n\nexport const NeverStencilFunc = 512;\nexport const LessStencilFunc = 513;\nexport const EqualStencilFunc = 514;\nexport const LessEqualStencilFunc = 515;\nexport const GreaterStencilFunc = 516;\nexport const NotEqualStencilFunc = 517;\nexport const GreaterEqualStencilFunc = 518;\nexport const AlwaysStencilFunc = 519;\n\nexport const StaticDrawUsage = 35044;\nexport const DynamicDrawUsage = 35048;\nexport const StreamDrawUsage = 35040;\nexport const StaticReadUsage = 35045;\nexport const DynamicReadUsage = 35049;\nexport const StreamReadUsage = 35041;\nexport const StaticCopyUsage = 35046;\nexport const DynamicCopyUsage = 35050;\nexport const StreamCopyUsage = 35042;\n","/**\n * https://github.com/mrdoob/eventdispatcher.js/\n */\n\nfunction EventDispatcher() {}\n\nObject.assign( EventDispatcher.prototype, {\n\n\taddEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) this._listeners = {};\n\n\t\tconst listeners = this._listeners;\n\n\t\tif ( listeners[ type ] === undefined ) {\n\n\t\t\tlisteners[ type ] = [];\n\n\t\t}\n\n\t\tif ( listeners[ type ].indexOf( listener ) === - 1 ) {\n\n\t\t\tlisteners[ type ].push( listener );\n\n\t\t}\n\n\t},\n\n\thasEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) return false;\n\n\t\tconst listeners = this._listeners;\n\n\t\treturn listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;\n\n\t},\n\n\tremoveEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) return;\n\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[ type ];\n\n\t\tif ( listenerArray !== undefined ) {\n\n\t\t\tconst index = listenerArray.indexOf( listener );\n\n\t\t\tif ( index !== - 1 ) {\n\n\t\t\t\tlistenerArray.splice( index, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tdispatchEvent: function ( event ) {\n\n\t\tif ( this._listeners === undefined ) return;\n\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[ event.type ];\n\n\t\tif ( listenerArray !== undefined ) {\n\n\t\t\tevent.target = this;\n\n\t\t\t// Make a copy, in case listeners are removed while iterating.\n\t\t\tconst array = listenerArray.slice( 0 );\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\tarray[ i ].call( this, event );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\n\nexport { EventDispatcher };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author thezwap\n */\n\nconst _lut = [];\n\nfor ( let i = 0; i < 256; i ++ ) {\n\n\t_lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );\n\n}\n\nconst MathUtils = {\n\n\tDEG2RAD: Math.PI / 180,\n\tRAD2DEG: 180 / Math.PI,\n\n\tgenerateUUID: function () {\n\n\t\t// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136\n\n\t\tconst d0 = Math.random() * 0xffffffff | 0;\n\t\tconst d1 = Math.random() * 0xffffffff | 0;\n\t\tconst d2 = Math.random() * 0xffffffff | 0;\n\t\tconst d3 = Math.random() * 0xffffffff | 0;\n\t\tconst uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +\n\t\t\t_lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' +\n\t\t\t_lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] +\n\t\t\t_lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ];\n\n\t\t// .toUpperCase() here flattens concatenated strings to save heap memory space.\n\t\treturn uuid.toUpperCase();\n\n\t},\n\n\tclamp: function ( value, min, max ) {\n\n\t\treturn Math.max( min, Math.min( max, value ) );\n\n\t},\n\n\t// compute euclidian modulo of m % n\n\t// https://en.wikipedia.org/wiki/Modulo_operation\n\n\teuclideanModulo: function ( n, m ) {\n\n\t\treturn ( ( n % m ) + m ) % m;\n\n\t},\n\n\t// Linear mapping from range to range \n\n\tmapLinear: function ( x, a1, a2, b1, b2 ) {\n\n\t\treturn b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );\n\n\t},\n\n\t// https://en.wikipedia.org/wiki/Linear_interpolation\n\n\tlerp: function ( x, y, t ) {\n\n\t\treturn ( 1 - t ) * x + t * y;\n\n\t},\n\n\t// http://en.wikipedia.org/wiki/Smoothstep\n\n\tsmoothstep: function ( x, min, max ) {\n\n\t\tif ( x <= min ) return 0;\n\t\tif ( x >= max ) return 1;\n\n\t\tx = ( x - min ) / ( max - min );\n\n\t\treturn x * x * ( 3 - 2 * x );\n\n\t},\n\n\tsmootherstep: function ( x, min, max ) {\n\n\t\tif ( x <= min ) return 0;\n\t\tif ( x >= max ) return 1;\n\n\t\tx = ( x - min ) / ( max - min );\n\n\t\treturn x * x * x * ( x * ( x * 6 - 15 ) + 10 );\n\n\t},\n\n\t// Random integer from interval\n\n\trandInt: function ( low, high ) {\n\n\t\treturn low + Math.floor( Math.random() * ( high - low + 1 ) );\n\n\t},\n\n\t// Random float from interval\n\n\trandFloat: function ( low, high ) {\n\n\t\treturn low + Math.random() * ( high - low );\n\n\t},\n\n\t// Random float from <-range/2, range/2> interval\n\n\trandFloatSpread: function ( range ) {\n\n\t\treturn range * ( 0.5 - Math.random() );\n\n\t},\n\n\tdegToRad: function ( degrees ) {\n\n\t\treturn degrees * MathUtils.DEG2RAD;\n\n\t},\n\n\tradToDeg: function ( radians ) {\n\n\t\treturn radians * MathUtils.RAD2DEG;\n\n\t},\n\n\tisPowerOfTwo: function ( value ) {\n\n\t\treturn ( value & ( value - 1 ) ) === 0 && value !== 0;\n\n\t},\n\n\tceilPowerOfTwo: function ( value ) {\n\n\t\treturn Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );\n\n\t},\n\n\tfloorPowerOfTwo: function ( value ) {\n\n\t\treturn Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );\n\n\t},\n\n\tsetQuaternionFromProperEuler: function ( q, a, b, c, order ) {\n\n\t\t// Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles\n\n\t\t// rotations are applied to the axes in the order specified by 'order'\n\t\t// rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'\n\t\t// angles are in radians\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\n\t\tconst c2 = cos( b / 2 );\n\t\tconst s2 = sin( b / 2 );\n\n\t\tconst c13 = cos( ( a + c ) / 2 );\n\t\tconst s13 = sin( ( a + c ) / 2 );\n\n\t\tconst c1_3 = cos( ( a - c ) / 2 );\n\t\tconst s1_3 = sin( ( a - c ) / 2 );\n\n\t\tconst c3_1 = cos( ( c - a ) / 2 );\n\t\tconst s3_1 = sin( ( c - a ) / 2 );\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYX':\n\t\t\t\tq.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZY':\n\t\t\t\tq.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXZ':\n\t\t\t\tq.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZX':\n\t\t\t\tq.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXY':\n\t\t\t\tq.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYZ':\n\t\t\t\tq.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t}\n\n};\n\n\nexport { MathUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n */\n\nlet _canvas;\n\nconst ImageUtils = {\n\n\tgetDataURL: function ( image ) {\n\n\t\tif ( /^data:/i.test( image.src ) ) {\n\n\t\t\treturn image.src;\n\n\t\t}\n\n\t\tif ( typeof HTMLCanvasElement == 'undefined' ) {\n\n\t\t\treturn image.src;\n\n\t\t}\n\n\t\tlet canvas;\n\n\t\tif ( image instanceof HTMLCanvasElement ) {\n\n\t\t\tcanvas = image;\n\n\t\t} else {\n\n\t\t\tif ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t\t\t_canvas.width = image.width;\n\t\t\t_canvas.height = image.height;\n\n\t\t\tconst context = _canvas.getContext( '2d' );\n\n\t\t\tif ( image instanceof ImageData ) {\n\n\t\t\t\tcontext.putImageData( image, 0, 0 );\n\n\t\t\t} else {\n\n\t\t\t\tcontext.drawImage( image, 0, 0, image.width, image.height );\n\n\t\t\t}\n\n\t\t\tcanvas = _canvas;\n\n\t\t}\n\n\t\tif ( canvas.width > 2048 || canvas.height > 2048 ) {\n\n\t\t\treturn canvas.toDataURL( 'image/jpeg', 0.6 );\n\n\t\t} else {\n\n\t\t\treturn canvas.toDataURL( 'image/png' );\n\n\t\t}\n\n\t}\n\n};\n\nexport { ImageUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author philogb / http://blog.thejit.org/\n * @author egraether / http://egraether.com/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n */\n\nfunction Vector2( x = 0, y = 0 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\n}\n\nObject.defineProperties( Vector2.prototype, {\n\n\t\"width\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.x = value;\n\n\t\t}\n\n\t},\n\n\t\"height\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.y = value;\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Vector2.prototype, {\n\n\tisVector2: true,\n\n\tset: function ( x, y ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( v ) {\n\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tdivide: function ( v ) {\n\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tconst x = this.x, y = this.y;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];\n\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];\n\n\t\treturn this;\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y;\n\n\t},\n\n\tcross: function ( v ) {\n\n\t\treturn this.x * v.y - this.y * v.x;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tangle: function () {\n\n\t\t// computes the angle in radians with respect to the positive x-axis\n\n\t\tconst angle = Math.atan2( - this.y, - this.x ) + Math.PI;\n\n\t\treturn angle;\n\n\t},\n\n\tdistanceTo: function ( v ) {\n\n\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t},\n\n\tdistanceToSquared: function ( v ) {\n\n\t\tconst dx = this.x - v.x, dy = this.y - v.y;\n\t\treturn dx * dx + dy * dy;\n\n\t},\n\n\tmanhattanDistanceTo: function ( v ) {\n\n\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\n\t\treturn this;\n\n\t},\n\n\trotateAround: function ( center, angle ) {\n\n\t\tconst c = Math.cos( angle ), s = Math.sin( angle );\n\n\t\tconst x = this.x - center.x;\n\t\tconst y = this.y - center.y;\n\n\t\tthis.x = x * c - y * s + center.x;\n\t\tthis.y = x * s + y * c + center.y;\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector2 };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n * @author tschw\n */\n\nfunction Matrix3() {\n\n\tthis.elements = [\n\n\t\t1, 0, 0,\n\t\t0, 1, 0,\n\t\t0, 0, 1\n\n\t];\n\n\tif ( arguments.length > 0 ) {\n\n\t\tconsole.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );\n\n\t}\n\n}\n\nObject.assign( Matrix3.prototype, {\n\n\tisMatrix3: true,\n\n\tset: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;\n\t\tte[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;\n\t\tte[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;\n\n\t\treturn this;\n\n\t},\n\n\tidentity: function () {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0,\n\t\t\t0, 1, 0,\n\t\t\t0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().fromArray( this.elements );\n\n\t},\n\n\tcopy: function ( m ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];\n\t\tte[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];\n\t\tte[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\txAxis.setFromMatrix3Column( this, 0 );\n\t\tyAxis.setFromMatrix3Column( this, 1 );\n\t\tzAxis.setFromMatrix3Column( this, 2 );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrix4: function ( m ) {\n\n\t\tconst me = m.elements;\n\n\t\tthis.set(\n\n\t\t\tme[ 0 ], me[ 4 ], me[ 8 ],\n\t\t\tme[ 1 ], me[ 5 ], me[ 9 ],\n\t\t\tme[ 2 ], me[ 6 ], me[ 10 ]\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( this, m );\n\n\t},\n\n\tpremultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( m, this );\n\n\t},\n\n\tmultiplyMatrices: function ( a, b ) {\n\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\n\t\tconst a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];\n\t\tconst a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];\n\t\tconst a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];\n\n\t\tconst b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];\n\t\tconst b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];\n\t\tconst b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];\n\n\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;\n\t\tte[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;\n\t\tte[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;\n\n\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;\n\t\tte[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;\n\t\tte[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;\n\n\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;\n\t\tte[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;\n\t\tte[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;\n\t\tte[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;\n\t\tte[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;\n\n\t\treturn this;\n\n\t},\n\n\tdeterminant: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],\n\t\t\td = te[ 3 ], e = te[ 4 ], f = te[ 5 ],\n\t\t\tg = te[ 6 ], h = te[ 7 ], i = te[ 8 ];\n\n\t\treturn a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;\n\n\t},\n\n\tgetInverse: function ( matrix, throwOnDegenerate ) {\n\n\t\tif ( throwOnDegenerate !== undefined ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.\" );\n\n\t\t}\n\n\t\tconst me = matrix.elements,\n\t\t\tte = this.elements,\n\n\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],\n\t\t\tn12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],\n\t\t\tn13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],\n\n\t\t\tt11 = n33 * n22 - n32 * n23,\n\t\t\tt12 = n32 * n13 - n33 * n12,\n\t\t\tt13 = n23 * n12 - n22 * n13,\n\n\t\t\tdet = n11 * t11 + n21 * t12 + n31 * t13;\n\n\t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n\t\tconst detInv = 1 / det;\n\n\t\tte[ 0 ] = t11 * detInv;\n\t\tte[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;\n\t\tte[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;\n\n\t\tte[ 3 ] = t12 * detInv;\n\t\tte[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;\n\t\tte[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;\n\n\t\tte[ 6 ] = t13 * detInv;\n\t\tte[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;\n\t\tte[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;\n\n\t\treturn this;\n\n\t},\n\n\ttranspose: function () {\n\n\t\tlet tmp;\n\t\tconst m = this.elements;\n\n\t\ttmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;\n\t\ttmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;\n\t\ttmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;\n\n\t\treturn this;\n\n\t},\n\n\tgetNormalMatrix: function ( matrix4 ) {\n\n\t\treturn this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();\n\n\t},\n\n\ttransposeIntoArray: function ( r ) {\n\n\t\tconst m = this.elements;\n\n\t\tr[ 0 ] = m[ 0 ];\n\t\tr[ 1 ] = m[ 3 ];\n\t\tr[ 2 ] = m[ 6 ];\n\t\tr[ 3 ] = m[ 1 ];\n\t\tr[ 4 ] = m[ 4 ];\n\t\tr[ 5 ] = m[ 7 ];\n\t\tr[ 6 ] = m[ 2 ];\n\t\tr[ 7 ] = m[ 5 ];\n\t\tr[ 8 ] = m[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\tsetUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {\n\n\t\tconst c = Math.cos( rotation );\n\t\tconst s = Math.sin( rotation );\n\n\t\tthis.set(\n\t\t\tsx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,\n\t\t\t- sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,\n\t\t\t0, 0, 1\n\t\t);\n\n\t},\n\n\tscale: function ( sx, sy ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;\n\t\tte[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;\n\n\t\treturn this;\n\n\t},\n\n\trotate: function ( theta ) {\n\n\t\tconst c = Math.cos( theta );\n\t\tconst s = Math.sin( theta );\n\n\t\tconst te = this.elements;\n\n\t\tconst a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];\n\t\tconst a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];\n\n\t\tte[ 0 ] = c * a11 + s * a21;\n\t\tte[ 3 ] = c * a12 + s * a22;\n\t\tte[ 6 ] = c * a13 + s * a23;\n\n\t\tte[ 1 ] = - s * a11 + c * a21;\n\t\tte[ 4 ] = - s * a12 + c * a22;\n\t\tte[ 7 ] = - s * a13 + c * a23;\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( tx, ty ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];\n\t\tte[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( matrix ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) {\n\n\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) {\n\n\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tconst te = this.elements;\n\n\t\tarray[ offset ] = te[ 0 ];\n\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\tarray[ offset + 2 ] = te[ 2 ];\n\n\t\tarray[ offset + 3 ] = te[ 3 ];\n\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\tarray[ offset + 5 ] = te[ 5 ];\n\n\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\tarray[ offset + 7 ] = te[ 7 ];\n\t\tarray[ offset + 8 ] = te[ 8 ];\n\n\t\treturn array;\n\n\t}\n\n} );\n\n\nexport { Matrix3 };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n */\n\nimport { EventDispatcher } from '../core/EventDispatcher.js';\nimport {\n\tMirroredRepeatWrapping,\n\tClampToEdgeWrapping,\n\tRepeatWrapping,\n\tLinearEncoding,\n\tUnsignedByteType,\n\tRGBAFormat,\n\tLinearMipmapLinearFilter,\n\tLinearFilter,\n\tUVMapping\n} from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { ImageUtils } from '../extras/ImageUtils.js';\n\nlet textureId = 0;\n\nfunction Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\tObject.defineProperty( this, 'id', { value: textureId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\n\tthis.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;\n\tthis.mipmaps = [];\n\n\tthis.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;\n\n\tthis.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;\n\tthis.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;\n\n\tthis.magFilter = magFilter !== undefined ? magFilter : LinearFilter;\n\tthis.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter;\n\n\tthis.anisotropy = anisotropy !== undefined ? anisotropy : 1;\n\n\tthis.format = format !== undefined ? format : RGBAFormat;\n\tthis.internalFormat = null;\n\tthis.type = type !== undefined ? type : UnsignedByteType;\n\n\tthis.offset = new Vector2( 0, 0 );\n\tthis.repeat = new Vector2( 1, 1 );\n\tthis.center = new Vector2( 0, 0 );\n\tthis.rotation = 0;\n\n\tthis.matrixAutoUpdate = true;\n\tthis.matrix = new Matrix3();\n\n\tthis.generateMipmaps = true;\n\tthis.premultiplyAlpha = false;\n\tthis.flipY = true;\n\tthis.unpackAlignment = 4;\t// valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)\n\n\t// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.\n\t//\n\t// Also changing the encoding after already used by a Material will not automatically make the Material\n\t// update. You need to explicitly call Material.needsUpdate to trigger it to recompile.\n\tthis.encoding = encoding !== undefined ? encoding : LinearEncoding;\n\n\tthis.version = 0;\n\tthis.onUpdate = null;\n\n}\n\nTexture.DEFAULT_IMAGE = undefined;\nTexture.DEFAULT_MAPPING = UVMapping;\n\nTexture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Texture,\n\n\tisTexture: true,\n\n\tupdateMatrix: function () {\n\n\t\tthis.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\n\t\tthis.image = source.image;\n\t\tthis.mipmaps = source.mipmaps.slice( 0 );\n\n\t\tthis.mapping = source.mapping;\n\n\t\tthis.wrapS = source.wrapS;\n\t\tthis.wrapT = source.wrapT;\n\n\t\tthis.magFilter = source.magFilter;\n\t\tthis.minFilter = source.minFilter;\n\n\t\tthis.anisotropy = source.anisotropy;\n\n\t\tthis.format = source.format;\n\t\tthis.internalFormat = source.internalFormat;\n\t\tthis.type = source.type;\n\n\t\tthis.offset.copy( source.offset );\n\t\tthis.repeat.copy( source.repeat );\n\t\tthis.center.copy( source.center );\n\t\tthis.rotation = source.rotation;\n\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrix.copy( source.matrix );\n\n\t\tthis.generateMipmaps = source.generateMipmaps;\n\t\tthis.premultiplyAlpha = source.premultiplyAlpha;\n\t\tthis.flipY = source.flipY;\n\t\tthis.unpackAlignment = source.unpackAlignment;\n\t\tthis.encoding = source.encoding;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\tif ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {\n\n\t\t\treturn meta.textures[ this.uuid ];\n\n\t\t}\n\n\t\tconst output = {\n\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Texture',\n\t\t\t\tgenerator: 'Texture.toJSON'\n\t\t\t},\n\n\t\t\tuuid: this.uuid,\n\t\t\tname: this.name,\n\n\t\t\tmapping: this.mapping,\n\n\t\t\trepeat: [ this.repeat.x, this.repeat.y ],\n\t\t\toffset: [ this.offset.x, this.offset.y ],\n\t\t\tcenter: [ this.center.x, this.center.y ],\n\t\t\trotation: this.rotation,\n\n\t\t\twrap: [ this.wrapS, this.wrapT ],\n\n\t\t\tformat: this.format,\n\t\t\ttype: this.type,\n\t\t\tencoding: this.encoding,\n\n\t\t\tminFilter: this.minFilter,\n\t\t\tmagFilter: this.magFilter,\n\t\t\tanisotropy: this.anisotropy,\n\n\t\t\tflipY: this.flipY,\n\n\t\t\tpremultiplyAlpha: this.premultiplyAlpha,\n\t\t\tunpackAlignment: this.unpackAlignment\n\n\t\t};\n\n\t\tif ( this.image !== undefined ) {\n\n\t\t\t// TODO: Move to THREE.Image\n\n\t\t\tconst image = this.image;\n\n\t\t\tif ( image.uuid === undefined ) {\n\n\t\t\t\timage.uuid = MathUtils.generateUUID(); // UGH\n\n\t\t\t}\n\n\t\t\tif ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {\n\n\t\t\t\tlet url;\n\n\t\t\t\tif ( Array.isArray( image ) ) {\n\n\t\t\t\t\t// process array of images e.g. CubeTexture\n\n\t\t\t\t\turl = [];\n\n\t\t\t\t\tfor ( let i = 0, l = image.length; i < l; i ++ ) {\n\n\t\t\t\t\t\turl.push( ImageUtils.getDataURL( image[ i ] ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// process single image\n\n\t\t\t\t\turl = ImageUtils.getDataURL( image );\n\n\t\t\t\t}\n\n\t\t\t\tmeta.images[ image.uuid ] = {\n\t\t\t\t\tuuid: image.uuid,\n\t\t\t\t\turl: url\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\toutput.image = image.uuid;\n\n\t\t}\n\n\t\tif ( ! isRootObject ) {\n\n\t\t\tmeta.textures[ this.uuid ] = output;\n\n\t\t}\n\n\t\treturn output;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t},\n\n\ttransformUv: function ( uv ) {\n\n\t\tif ( this.mapping !== UVMapping ) return uv;\n\n\t\tuv.applyMatrix3( this.matrix );\n\n\t\tif ( uv.x < 0 || uv.x > 1 ) {\n\n\t\t\tswitch ( this.wrapS ) {\n\n\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\tuv.x = uv.x < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\tif ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\tuv.x = Math.ceil( uv.x ) - uv.x;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( uv.y < 0 || uv.y > 1 ) {\n\n\t\t\tswitch ( this.wrapT ) {\n\n\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\tuv.y = uv.y < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\tif ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\tuv.y = Math.ceil( uv.y ) - uv.y;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.flipY ) {\n\n\t\t\tuv.y = 1 - uv.y;\n\n\t\t}\n\n\t\treturn uv;\n\n\t}\n\n} );\n\nObject.defineProperty( Texture.prototype, \"needsUpdate\", {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\n\nexport { Texture };\n","/**\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Vector4( x = 0, y = 0, z = 0, w = 1 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\tthis.z = z;\n\tthis.w = w;\n\n}\n\nObject.defineProperties( Vector4.prototype, {\n\n\t\"width\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.z = value;\n\n\t\t}\n\n\t},\n\n\t\"height\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.w;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.w = value;\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Vector4.prototype, {\n\n\tisVector4: true,\n\n\tset: function ( x, y, z, w ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t\tthis.w = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\t\tthis.w = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetZ: function ( z ) {\n\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetW: function ( w ) {\n\n\t\tthis.w = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tcase 2: this.z = value; break;\n\t\t\tcase 3: this.w = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tcase 2: return this.z;\n\t\t\tcase 3: return this.w;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y, this.z, this.w );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\t\tthis.w = ( v.w !== undefined ) ? v.w : 1;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\t\tthis.w += v.w;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\t\tthis.w += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\t\tthis.w = a.w + b.w;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\t\tthis.w += v.w * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\t\tthis.w -= v.w;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\t\tthis.w -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\t\tthis.w = a.w - b.w;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\t\tthis.w *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z, w = this.w;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;\n\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;\n\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;\n\t\tthis.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tsetAxisAngleFromQuaternion: function ( q ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm\n\n\t\t// q is assumed to be normalized\n\n\t\tthis.w = 2 * Math.acos( q.w );\n\n\t\tconst s = Math.sqrt( 1 - q.w * q.w );\n\n\t\tif ( s < 0.0001 ) {\n\n\t\t\tthis.x = 1;\n\t\t\tthis.y = 0;\n\t\t\tthis.z = 0;\n\n\t\t} else {\n\n\t\t\tthis.x = q.x / s;\n\t\t\tthis.y = q.y / s;\n\t\t\tthis.z = q.z / s;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetAxisAngleFromRotationMatrix: function ( m ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tlet angle, x, y, z; // variables for result\n\t\tconst epsilon = 0.01,\t\t// margin to allow for rounding errors\n\t\t\tepsilon2 = 0.1,\t\t// margin to distinguish between 0 and 180 degrees\n\n\t\t\tte = m.elements,\n\n\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\tif ( ( Math.abs( m12 - m21 ) < epsilon ) &&\n\t\t ( Math.abs( m13 - m31 ) < epsilon ) &&\n\t\t ( Math.abs( m23 - m32 ) < epsilon ) ) {\n\n\t\t\t// singularity found\n\t\t\t// first check for identity matrix which must have +1 for all terms\n\t\t\t// in leading diagonal and zero in other terms\n\n\t\t\tif ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m13 + m31 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m23 + m32 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {\n\n\t\t\t\t// this singularity is identity matrix so angle = 0\n\n\t\t\t\tthis.set( 1, 0, 0, 0 );\n\n\t\t\t\treturn this; // zero angle, arbitrary axis\n\n\t\t\t}\n\n\t\t\t// otherwise this singularity is angle = 180\n\n\t\t\tangle = Math.PI;\n\n\t\t\tconst xx = ( m11 + 1 ) / 2;\n\t\t\tconst yy = ( m22 + 1 ) / 2;\n\t\t\tconst zz = ( m33 + 1 ) / 2;\n\t\t\tconst xy = ( m12 + m21 ) / 4;\n\t\t\tconst xz = ( m13 + m31 ) / 4;\n\t\t\tconst yz = ( m23 + m32 ) / 4;\n\n\t\t\tif ( ( xx > yy ) && ( xx > zz ) ) {\n\n\t\t\t\t// m11 is the largest diagonal term\n\n\t\t\t\tif ( xx < epsilon ) {\n\n\t\t\t\t\tx = 0;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tx = Math.sqrt( xx );\n\t\t\t\t\ty = xy / x;\n\t\t\t\t\tz = xz / x;\n\n\t\t\t\t}\n\n\t\t\t} else if ( yy > zz ) {\n\n\t\t\t\t// m22 is the largest diagonal term\n\n\t\t\t\tif ( yy < epsilon ) {\n\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0;\n\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t} else {\n\n\t\t\t\t\ty = Math.sqrt( yy );\n\t\t\t\t\tx = xy / y;\n\t\t\t\t\tz = yz / y;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// m33 is the largest diagonal term so base result on this\n\n\t\t\t\tif ( zz < epsilon ) {\n\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tz = Math.sqrt( zz );\n\t\t\t\t\tx = xz / z;\n\t\t\t\t\ty = yz / z;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.set( x, y, z, angle );\n\n\t\t\treturn this; // return 180 deg rotation\n\n\t\t}\n\n\t\t// as we have reached here there are no singularities so we can handle normally\n\n\t\tlet s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +\n\t\t\t( m13 - m31 ) * ( m13 - m31 ) +\n\t\t\t( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize\n\n\t\tif ( Math.abs( s ) < 0.001 ) s = 1;\n\n\t\t// prevent divide by zero, should not happen if matrix is orthogonal and should be\n\t\t// caught by singularity test above, but I've left it in just in case\n\n\t\tthis.x = ( m32 - m23 ) / s;\n\t\tthis.y = ( m13 - m31 ) / s;\n\t\tthis.z = ( m21 - m12 ) / s;\n\t\tthis.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );\n\n\t\treturn this;\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\t\tthis.z = Math.min( this.z, v.z );\n\t\tthis.w = Math.min( this.w, v.w );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\t\tthis.z = Math.max( this.z, v.z );\n\t\tthis.w = Math.max( this.w, v.w );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\t\tthis.w = Math.max( min.w, Math.min( max.w, this.w ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\t\tthis.z = Math.max( minVal, Math.min( maxVal, this.z ) );\n\t\tthis.w = Math.max( minVal, Math.min( maxVal, this.w ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\t\tthis.z = Math.floor( this.z );\n\t\tthis.w = Math.floor( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\t\tthis.z = Math.ceil( this.z );\n\t\tthis.w = Math.ceil( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\t\tthis.z = Math.round( this.z );\n\t\tthis.w = Math.round( this.w );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\t\tthis.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\t\tthis.z = - this.z;\n\t\tthis.w = - this.w;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\tthis.z += ( v.z - this.z ) * alpha;\n\t\tthis.w += ( v.w - this.w ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\t\tthis.w = v1.w + ( v2.w - v1.w ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\t\tthis.z = array[ offset + 2 ];\n\t\tthis.w = array[ offset + 3 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\t\tarray[ offset + 2 ] = this.z;\n\t\tarray[ offset + 3 ] = this.w;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\t\tthis.z = attribute.getZ( index );\n\t\tthis.w = attribute.getW( index );\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\t\tthis.w = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector4 };\n","import { EventDispatcher } from '../core/EventDispatcher.js';\nimport { Texture } from '../textures/Texture.js';\nimport { LinearFilter } from '../constants.js';\nimport { Vector4 } from '../math/Vector4.js';\n\n/**\n * @author szimek / https://github.com/szimek/\n * @author alteredq / http://alteredqualia.com/\n * @author Marius Kintel / https://github.com/kintel\n */\n\n/*\n In options, we can specify:\n * Texture parameters for an auto-generated target texture\n * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers\n*/\nfunction WebGLRenderTarget( width, height, options ) {\n\n\tthis.width = width;\n\tthis.height = height;\n\n\tthis.scissor = new Vector4( 0, 0, width, height );\n\tthis.scissorTest = false;\n\n\tthis.viewport = new Vector4( 0, 0, width, height );\n\n\toptions = options || {};\n\n\tthis.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );\n\n\tthis.texture.image = {};\n\tthis.texture.image.width = width;\n\tthis.texture.image.height = height;\n\n\tthis.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;\n\tthis.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;\n\n\tthis.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;\n\tthis.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;\n\tthis.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;\n\n}\n\nWebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: WebGLRenderTarget,\n\n\tisWebGLRenderTarget: true,\n\n\tsetSize: function ( width, height ) {\n\n\t\tif ( this.width !== width || this.height !== height ) {\n\n\t\t\tthis.width = width;\n\t\t\tthis.height = height;\n\n\t\t\tthis.texture.image.width = width;\n\t\t\tthis.texture.image.height = height;\n\n\t\t\tthis.dispose();\n\n\t\t}\n\n\t\tthis.viewport.set( 0, 0, width, height );\n\t\tthis.scissor.set( 0, 0, width, height );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.width = source.width;\n\t\tthis.height = source.height;\n\n\t\tthis.viewport.copy( source.viewport );\n\n\t\tthis.texture = source.texture.clone();\n\n\t\tthis.depthBuffer = source.depthBuffer;\n\t\tthis.stencilBuffer = source.stencilBuffer;\n\t\tthis.depthTexture = source.depthTexture;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { WebGLRenderTarget };\n","/**\n * @author mikael emtinger / http://gomo.se/\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n */\n\nimport { MathUtils } from './MathUtils.js';\n\nfunction Quaternion( x = 0, y = 0, z = 0, w = 1 ) {\n\n\tthis._x = x;\n\tthis._y = y;\n\tthis._z = z;\n\tthis._w = w;\n\n}\n\nObject.assign( Quaternion, {\n\n\tslerp: function ( qa, qb, qm, t ) {\n\n\t\treturn qm.copy( qa ).slerp( qb, t );\n\n\t},\n\n\tslerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {\n\n\t\t// fuzz-free, array-based Quaternion SLERP operation\n\n\t\tlet x0 = src0[ srcOffset0 + 0 ],\n\t\t\ty0 = src0[ srcOffset0 + 1 ],\n\t\t\tz0 = src0[ srcOffset0 + 2 ],\n\t\t\tw0 = src0[ srcOffset0 + 3 ];\n\n\t\tconst x1 = src1[ srcOffset1 + 0 ],\n\t\t\ty1 = src1[ srcOffset1 + 1 ],\n\t\t\tz1 = src1[ srcOffset1 + 2 ],\n\t\t\tw1 = src1[ srcOffset1 + 3 ];\n\n\t\tif ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {\n\n\t\t\tlet s = 1 - t,\n\n\t\t\t\tcos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,\n\n\t\t\t\tdir = ( cos >= 0 ? 1 : - 1 ),\n\t\t\t\tsqrSin = 1 - cos * cos;\n\n\t\t\t// Skip the Slerp for tiny steps to avoid numeric problems:\n\t\t\tif ( sqrSin > Number.EPSILON ) {\n\n\t\t\t\tconst sin = Math.sqrt( sqrSin ),\n\t\t\t\t\tlen = Math.atan2( sin, cos * dir );\n\n\t\t\t\ts = Math.sin( s * len ) / sin;\n\t\t\t\tt = Math.sin( t * len ) / sin;\n\n\t\t\t}\n\n\t\t\tconst tDir = t * dir;\n\n\t\t\tx0 = x0 * s + x1 * tDir;\n\t\t\ty0 = y0 * s + y1 * tDir;\n\t\t\tz0 = z0 * s + z1 * tDir;\n\t\t\tw0 = w0 * s + w1 * tDir;\n\n\t\t\t// Normalize in case we just did a lerp:\n\t\t\tif ( s === 1 - t ) {\n\n\t\t\t\tconst f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );\n\n\t\t\t\tx0 *= f;\n\t\t\t\ty0 *= f;\n\t\t\t\tz0 *= f;\n\t\t\t\tw0 *= f;\n\n\t\t\t}\n\n\t\t}\n\n\t\tdst[ dstOffset ] = x0;\n\t\tdst[ dstOffset + 1 ] = y0;\n\t\tdst[ dstOffset + 2 ] = z0;\n\t\tdst[ dstOffset + 3 ] = w0;\n\n\t},\n\n\tmultiplyQuaternionsFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {\n\n\t\tconst x0 = src0[ srcOffset0 ];\n\t\tconst y0 = src0[ srcOffset0 + 1 ];\n\t\tconst z0 = src0[ srcOffset0 + 2 ];\n\t\tconst w0 = src0[ srcOffset0 + 3 ];\n\n\t\tconst x1 = src1[ srcOffset1 ];\n\t\tconst y1 = src1[ srcOffset1 + 1 ];\n\t\tconst z1 = src1[ srcOffset1 + 2 ];\n\t\tconst w1 = src1[ srcOffset1 + 3 ];\n\n\t\tdst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;\n\t\tdst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;\n\t\tdst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;\n\t\tdst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;\n\n\t\treturn dst;\n\n\t}\n\n} );\n\nObject.defineProperties( Quaternion.prototype, {\n\n\tx: {\n\n\t\tget: function () {\n\n\t\t\treturn this._x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._x = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\ty: {\n\n\t\tget: function () {\n\n\t\t\treturn this._y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._y = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tz: {\n\n\t\tget: function () {\n\n\t\t\treturn this._z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._z = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tw: {\n\n\t\tget: function () {\n\n\t\t\treturn this._w;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._w = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Quaternion.prototype, {\n\n\tisQuaternion: true,\n\n\tset: function ( x, y, z, w ) {\n\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._w = w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this._x, this._y, this._z, this._w );\n\n\t},\n\n\tcopy: function ( quaternion ) {\n\n\t\tthis._x = quaternion.x;\n\t\tthis._y = quaternion.y;\n\t\tthis._z = quaternion.z;\n\t\tthis._w = quaternion.w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromEuler: function ( euler, update ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tthrow new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\tconst x = euler._x, y = euler._y, z = euler._z, order = euler.order;\n\n\t\t// http://www.mathworks.com/matlabcentral/fileexchange/\n\t\t// \t20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\n\t\t//\tcontent/SpinCalc.m\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\n\t\tconst c1 = cos( x / 2 );\n\t\tconst c2 = cos( y / 2 );\n\t\tconst c3 = cos( z / 2 );\n\n\t\tconst s1 = sin( x / 2 );\n\t\tconst s2 = sin( y / 2 );\n\t\tconst s3 = sin( z / 2 );\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t\tif ( update !== false ) this._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromAxisAngle: function ( axis, angle ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm\n\n\t\t// assumes axis is normalized\n\n\t\tconst halfAngle = angle / 2, s = Math.sin( halfAngle );\n\n\t\tthis._x = axis.x * s;\n\t\tthis._y = axis.y * s;\n\t\tthis._z = axis.z * s;\n\t\tthis._w = Math.cos( halfAngle );\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromRotationMatrix: function ( m ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tconst te = m.elements,\n\n\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],\n\n\t\t\ttrace = m11 + m22 + m33;\n\n\t\tif ( trace > 0 ) {\n\n\t\t\tconst s = 0.5 / Math.sqrt( trace + 1.0 );\n\n\t\t\tthis._w = 0.25 / s;\n\t\t\tthis._x = ( m32 - m23 ) * s;\n\t\t\tthis._y = ( m13 - m31 ) * s;\n\t\t\tthis._z = ( m21 - m12 ) * s;\n\n\t\t} else if ( m11 > m22 && m11 > m33 ) {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );\n\n\t\t\tthis._w = ( m32 - m23 ) / s;\n\t\t\tthis._x = 0.25 * s;\n\t\t\tthis._y = ( m12 + m21 ) / s;\n\t\t\tthis._z = ( m13 + m31 ) / s;\n\n\t\t} else if ( m22 > m33 ) {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );\n\n\t\t\tthis._w = ( m13 - m31 ) / s;\n\t\t\tthis._x = ( m12 + m21 ) / s;\n\t\t\tthis._y = 0.25 * s;\n\t\t\tthis._z = ( m23 + m32 ) / s;\n\n\t\t} else {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );\n\n\t\t\tthis._w = ( m21 - m12 ) / s;\n\t\t\tthis._x = ( m13 + m31 ) / s;\n\t\t\tthis._y = ( m23 + m32 ) / s;\n\t\t\tthis._z = 0.25 * s;\n\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromUnitVectors: function ( vFrom, vTo ) {\n\n\t\t// assumes direction vectors vFrom and vTo are normalized\n\n\t\tconst EPS = 0.000001;\n\n\t\tlet r = vFrom.dot( vTo ) + 1;\n\n\t\tif ( r < EPS ) {\n\n\t\t\tr = 0;\n\n\t\t\tif ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {\n\n\t\t\t\tthis._x = - vFrom.y;\n\t\t\t\tthis._y = vFrom.x;\n\t\t\t\tthis._z = 0;\n\t\t\t\tthis._w = r;\n\n\t\t\t} else {\n\n\t\t\t\tthis._x = 0;\n\t\t\t\tthis._y = - vFrom.z;\n\t\t\t\tthis._z = vFrom.y;\n\t\t\t\tthis._w = r;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3\n\n\t\t\tthis._x = vFrom.y * vTo.z - vFrom.z * vTo.y;\n\t\t\tthis._y = vFrom.z * vTo.x - vFrom.x * vTo.z;\n\t\t\tthis._z = vFrom.x * vTo.y - vFrom.y * vTo.x;\n\t\t\tthis._w = r;\n\n\t\t}\n\n\t\treturn this.normalize();\n\n\t},\n\n\tangleTo: function ( q ) {\n\n\t\treturn 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) );\n\n\t},\n\n\trotateTowards: function ( q, step ) {\n\n\t\tconst angle = this.angleTo( q );\n\n\t\tif ( angle === 0 ) return this;\n\n\t\tconst t = Math.min( 1, step / angle );\n\n\t\tthis.slerp( q, t );\n\n\t\treturn this;\n\n\t},\n\n\tinverse: function () {\n\n\t\t// quaternion is assumed to have unit length\n\n\t\treturn this.conjugate();\n\n\t},\n\n\tconjugate: function () {\n\n\t\tthis._x *= - 1;\n\t\tthis._y *= - 1;\n\t\tthis._z *= - 1;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );\n\n\t},\n\n\tnormalize: function () {\n\n\t\tlet l = this.length();\n\n\t\tif ( l === 0 ) {\n\n\t\t\tthis._x = 0;\n\t\t\tthis._y = 0;\n\t\t\tthis._z = 0;\n\t\t\tthis._w = 1;\n\n\t\t} else {\n\n\t\t\tl = 1 / l;\n\n\t\t\tthis._x = this._x * l;\n\t\t\tthis._y = this._y * l;\n\t\t\tthis._z = this._z * l;\n\t\t\tthis._w = this._w * l;\n\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( q, p ) {\n\n\t\tif ( p !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );\n\t\t\treturn this.multiplyQuaternions( q, p );\n\n\t\t}\n\n\t\treturn this.multiplyQuaternions( this, q );\n\n\t},\n\n\tpremultiply: function ( q ) {\n\n\t\treturn this.multiplyQuaternions( q, this );\n\n\t},\n\n\tmultiplyQuaternions: function ( a, b ) {\n\n\t\t// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\n\t\tconst qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;\n\t\tconst qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;\n\n\t\tthis._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;\n\t\tthis._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;\n\t\tthis._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;\n\t\tthis._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tslerp: function ( qb, t ) {\n\n\t\tif ( t === 0 ) return this;\n\t\tif ( t === 1 ) return this.copy( qb );\n\n\t\tconst x = this._x, y = this._y, z = this._z, w = this._w;\n\n\t\t// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/\n\n\t\tlet cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;\n\n\t\tif ( cosHalfTheta < 0 ) {\n\n\t\t\tthis._w = - qb._w;\n\t\t\tthis._x = - qb._x;\n\t\t\tthis._y = - qb._y;\n\t\t\tthis._z = - qb._z;\n\n\t\t\tcosHalfTheta = - cosHalfTheta;\n\n\t\t} else {\n\n\t\t\tthis.copy( qb );\n\n\t\t}\n\n\t\tif ( cosHalfTheta >= 1.0 ) {\n\n\t\t\tthis._w = w;\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;\n\n\t\tif ( sqrSinHalfTheta <= Number.EPSILON ) {\n\n\t\t\tconst s = 1 - t;\n\t\t\tthis._w = s * w + t * this._w;\n\t\t\tthis._x = s * x + t * this._x;\n\t\t\tthis._y = s * y + t * this._y;\n\t\t\tthis._z = s * z + t * this._z;\n\n\t\t\tthis.normalize();\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst sinHalfTheta = Math.sqrt( sqrSinHalfTheta );\n\t\tconst halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );\n\t\tconst ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,\n\t\t\tratioB = Math.sin( t * halfTheta ) / sinHalfTheta;\n\n\t\tthis._w = ( w * ratioA + this._w * ratioB );\n\t\tthis._x = ( x * ratioA + this._x * ratioB );\n\t\tthis._y = ( y * ratioA + this._y * ratioB );\n\t\tthis._z = ( z * ratioA + this._z * ratioB );\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( quaternion ) {\n\n\t\treturn ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis._x = array[ offset ];\n\t\tthis._y = array[ offset + 1 ];\n\t\tthis._z = array[ offset + 2 ];\n\t\tthis._w = array[ offset + 3 ];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this._x;\n\t\tarray[ offset + 1 ] = this._y;\n\t\tarray[ offset + 2 ] = this._z;\n\t\tarray[ offset + 3 ] = this._w;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index ) {\n\n\t\tthis._x = attribute.getX( index );\n\t\tthis._y = attribute.getY( index );\n\t\tthis._z = attribute.getZ( index );\n\t\tthis._w = attribute.getW( index );\n\n\t\treturn this;\n\n\t},\n\n\t_onChange: function ( callback ) {\n\n\t\tthis._onChangeCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\t_onChangeCallback: function () {}\n\n} );\n\n\nexport { Quaternion };\n","import { MathUtils } from './MathUtils.js';\nimport { Quaternion } from './Quaternion.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author kile / http://kile.stravaganza.org/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n\nconst _vector = new Vector3();\nconst _quaternion = new Quaternion();\n\nfunction Vector3( x = 0, y = 0, z = 0 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\tthis.z = z;\n\n}\n\nObject.assign( Vector3.prototype, {\n\n\tisVector3: true,\n\n\tset: function ( x, y, z ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetZ: function ( z ) {\n\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tcase 2: this.z = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tcase 2: return this.z;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y, this.z );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );\n\t\t\treturn this.multiplyVectors( v, w );\n\n\t\t}\n\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\t\tthis.z *= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyVectors: function ( a, b ) {\n\n\t\tthis.x = a.x * b.x;\n\t\tthis.y = a.y * b.y;\n\t\tthis.z = a.z * b.z;\n\n\t\treturn this;\n\n\t},\n\n\tapplyEuler: function ( euler ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tconsole.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\treturn this.applyQuaternion( _quaternion.setFromEuler( euler ) );\n\n\t},\n\n\tapplyAxisAngle: function ( axis, angle ) {\n\n\t\treturn this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;\n\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;\n\t\tthis.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;\n\n\t\treturn this;\n\n\t},\n\n\tapplyNormalMatrix: function ( m ) {\n\n\t\treturn this.applyMatrix3( m ).normalize();\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tconst w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );\n\n\t\tthis.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;\n\t\tthis.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;\n\t\tthis.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;\n\n\t\treturn this;\n\n\t},\n\n\tapplyQuaternion: function ( q ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst qx = q.x, qy = q.y, qz = q.z, qw = q.w;\n\n\t\t// calculate quat * vector\n\n\t\tconst ix = qw * x + qy * z - qz * y;\n\t\tconst iy = qw * y + qz * x - qx * z;\n\t\tconst iz = qw * z + qx * y - qy * x;\n\t\tconst iw = - qx * x - qy * y - qz * z;\n\n\t\t// calculate result * inverse quat\n\n\t\tthis.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;\n\t\tthis.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;\n\t\tthis.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;\n\n\t\treturn this;\n\n\t},\n\n\tproject: function ( camera ) {\n\n\t\treturn this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );\n\n\t},\n\n\tunproject: function ( camera ) {\n\n\t\treturn this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );\n\n\t},\n\n\ttransformDirection: function ( m ) {\n\n\t\t// input: THREE.Matrix4 affine matrix\n\t\t// vector interpreted as a direction\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;\n\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;\n\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;\n\n\t\treturn this.normalize();\n\n\t},\n\n\tdivide: function ( v ) {\n\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\t\tthis.z /= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\t\tthis.z = Math.min( this.z, v.z );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\t\tthis.z = Math.max( this.z, v.z );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\t\tthis.z = Math.max( minVal, Math.min( maxVal, this.z ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\t\tthis.z = Math.floor( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\t\tthis.z = Math.ceil( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\t\tthis.z = Math.round( this.z );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\t\tthis.z = - this.z;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\n\t},\n\n\t// TODO lengthSquared?\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\tthis.z += ( v.z - this.z ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tcross: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );\n\t\t\treturn this.crossVectors( v, w );\n\n\t\t}\n\n\t\treturn this.crossVectors( this, v );\n\n\t},\n\n\tcrossVectors: function ( a, b ) {\n\n\t\tconst ax = a.x, ay = a.y, az = a.z;\n\t\tconst bx = b.x, by = b.y, bz = b.z;\n\n\t\tthis.x = ay * bz - az * by;\n\t\tthis.y = az * bx - ax * bz;\n\t\tthis.z = ax * by - ay * bx;\n\n\t\treturn this;\n\n\t},\n\n\tprojectOnVector: function ( v ) {\n\n\t\tconst denominator = v.lengthSq();\n\n\t\tif ( denominator === 0 ) return this.set( 0, 0, 0 );\n\n\t\tconst scalar = v.dot( this ) / denominator;\n\n\t\treturn this.copy( v ).multiplyScalar( scalar );\n\n\t},\n\n\tprojectOnPlane: function ( planeNormal ) {\n\n\t\t_vector.copy( this ).projectOnVector( planeNormal );\n\n\t\treturn this.sub( _vector );\n\n\t},\n\n\treflect: function ( normal ) {\n\n\t\t// reflect incident vector off plane orthogonal to normal\n\t\t// normal is assumed to have unit length\n\n\t\treturn this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );\n\n\t},\n\n\tangleTo: function ( v ) {\n\n\t\tconst denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );\n\n\t\tif ( denominator === 0 ) return Math.PI / 2;\n\n\t\tconst theta = this.dot( v ) / denominator;\n\n\t\t// clamp, to handle numerical problems\n\n\t\treturn Math.acos( MathUtils.clamp( theta, - 1, 1 ) );\n\n\t},\n\n\tdistanceTo: function ( v ) {\n\n\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t},\n\n\tdistanceToSquared: function ( v ) {\n\n\t\tconst dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;\n\n\t\treturn dx * dx + dy * dy + dz * dz;\n\n\t},\n\n\tmanhattanDistanceTo: function ( v ) {\n\n\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );\n\n\t},\n\n\tsetFromSpherical: function ( s ) {\n\n\t\treturn this.setFromSphericalCoords( s.radius, s.phi, s.theta );\n\n\t},\n\n\tsetFromSphericalCoords: function ( radius, phi, theta ) {\n\n\t\tconst sinPhiRadius = Math.sin( phi ) * radius;\n\n\t\tthis.x = sinPhiRadius * Math.sin( theta );\n\t\tthis.y = Math.cos( phi ) * radius;\n\t\tthis.z = sinPhiRadius * Math.cos( theta );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCylindrical: function ( c ) {\n\n\t\treturn this.setFromCylindricalCoords( c.radius, c.theta, c.y );\n\n\t},\n\n\tsetFromCylindricalCoords: function ( radius, theta, y ) {\n\n\t\tthis.x = radius * Math.sin( theta );\n\t\tthis.y = y;\n\t\tthis.z = radius * Math.cos( theta );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixPosition: function ( m ) {\n\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 12 ];\n\t\tthis.y = e[ 13 ];\n\t\tthis.z = e[ 14 ];\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixScale: function ( m ) {\n\n\t\tconst sx = this.setFromMatrixColumn( m, 0 ).length();\n\t\tconst sy = this.setFromMatrixColumn( m, 1 ).length();\n\t\tconst sz = this.setFromMatrixColumn( m, 2 ).length();\n\n\t\tthis.x = sx;\n\t\tthis.y = sy;\n\t\tthis.z = sz;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixColumn: function ( m, index ) {\n\n\t\treturn this.fromArray( m.elements, index * 4 );\n\n\t},\n\n\tsetFromMatrix3Column: function ( m, index ) {\n\n\t\treturn this.fromArray( m.elements, index * 3 );\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\t\tthis.z = array[ offset + 2 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\t\tarray[ offset + 2 ] = this.z;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\t\tthis.z = attribute.getZ( index );\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector3 };\n","import { Vector3 } from './Vector3.js';\n\nconst _v1 = new Vector3();\nconst _m1 = new Matrix4();\nconst _zero = new Vector3( 0, 0, 0 );\nconst _one = new Vector3( 1, 1, 1 );\nconst _x = new Vector3();\nconst _y = new Vector3();\nconst _z = new Vector3();\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author jordi_ros / http://plattsoft.com\n * @author D1plo1d / http://github.com/D1plo1d\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author timknip / http://www.floorplanner.com/\n * @author bhouston / http://clara.io\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Matrix4() {\n\n\tthis.elements = [\n\n\t\t1, 0, 0, 0,\n\t\t0, 1, 0, 0,\n\t\t0, 0, 1, 0,\n\t\t0, 0, 0, 1\n\n\t];\n\n\tif ( arguments.length > 0 ) {\n\n\t\tconsole.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );\n\n\t}\n\n}\n\nObject.assign( Matrix4.prototype, {\n\n\tisMatrix4: true,\n\n\tset: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;\n\t\tte[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;\n\t\tte[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;\n\t\tte[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;\n\n\t\treturn this;\n\n\t},\n\n\tidentity: function () {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, 1, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new Matrix4().fromArray( this.elements );\n\n\t},\n\n\tcopy: function ( m ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];\n\t\tte[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];\n\t\tte[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];\n\t\tte[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];\n\n\t\treturn this;\n\n\t},\n\n\tcopyPosition: function ( m ) {\n\n\t\tconst te = this.elements, me = m.elements;\n\n\t\tte[ 12 ] = me[ 12 ];\n\t\tte[ 13 ] = me[ 13 ];\n\t\tte[ 14 ] = me[ 14 ];\n\n\t\treturn this;\n\n\t},\n\n\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\txAxis.setFromMatrixColumn( this, 0 );\n\t\tyAxis.setFromMatrixColumn( this, 1 );\n\t\tzAxis.setFromMatrixColumn( this, 2 );\n\n\t\treturn this;\n\n\t},\n\n\tmakeBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\tthis.set(\n\t\t\txAxis.x, yAxis.x, zAxis.x, 0,\n\t\t\txAxis.y, yAxis.y, zAxis.y, 0,\n\t\t\txAxis.z, yAxis.z, zAxis.z, 0,\n\t\t\t0, 0, 0, 1\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\textractRotation: function ( m ) {\n\n\t\t// this method does not support reflection matrices\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tconst scaleX = 1 / _v1.setFromMatrixColumn( m, 0 ).length();\n\t\tconst scaleY = 1 / _v1.setFromMatrixColumn( m, 1 ).length();\n\t\tconst scaleZ = 1 / _v1.setFromMatrixColumn( m, 2 ).length();\n\n\t\tte[ 0 ] = me[ 0 ] * scaleX;\n\t\tte[ 1 ] = me[ 1 ] * scaleX;\n\t\tte[ 2 ] = me[ 2 ] * scaleX;\n\t\tte[ 3 ] = 0;\n\n\t\tte[ 4 ] = me[ 4 ] * scaleY;\n\t\tte[ 5 ] = me[ 5 ] * scaleY;\n\t\tte[ 6 ] = me[ 6 ] * scaleY;\n\t\tte[ 7 ] = 0;\n\n\t\tte[ 8 ] = me[ 8 ] * scaleZ;\n\t\tte[ 9 ] = me[ 9 ] * scaleZ;\n\t\tte[ 10 ] = me[ 10 ] * scaleZ;\n\t\tte[ 11 ] = 0;\n\n\t\tte[ 12 ] = 0;\n\t\tte[ 13 ] = 0;\n\t\tte[ 14 ] = 0;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationFromEuler: function ( euler ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\tconst te = this.elements;\n\n\t\tconst x = euler.x, y = euler.y, z = euler.z;\n\t\tconst a = Math.cos( x ), b = Math.sin( x );\n\t\tconst c = Math.cos( y ), d = Math.sin( y );\n\t\tconst e = Math.cos( z ), f = Math.sin( z );\n\n\t\tif ( euler.order === 'XYZ' ) {\n\n\t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = - c * f;\n\t\t\tte[ 8 ] = d;\n\n\t\t\tte[ 1 ] = af + be * d;\n\t\t\tte[ 5 ] = ae - bf * d;\n\t\t\tte[ 9 ] = - b * c;\n\n\t\t\tte[ 2 ] = bf - ae * d;\n\t\t\tte[ 6 ] = be + af * d;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'YXZ' ) {\n\n\t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\tte[ 0 ] = ce + df * b;\n\t\t\tte[ 4 ] = de * b - cf;\n\t\t\tte[ 8 ] = a * d;\n\n\t\t\tte[ 1 ] = a * f;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = - b;\n\n\t\t\tte[ 2 ] = cf * b - de;\n\t\t\tte[ 6 ] = df + ce * b;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'ZXY' ) {\n\n\t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\tte[ 0 ] = ce - df * b;\n\t\t\tte[ 4 ] = - a * f;\n\t\t\tte[ 8 ] = de + cf * b;\n\n\t\t\tte[ 1 ] = cf + de * b;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = df - ce * b;\n\n\t\t\tte[ 2 ] = - a * d;\n\t\t\tte[ 6 ] = b;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'ZYX' ) {\n\n\t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = be * d - af;\n\t\t\tte[ 8 ] = ae * d + bf;\n\n\t\t\tte[ 1 ] = c * f;\n\t\t\tte[ 5 ] = bf * d + ae;\n\t\t\tte[ 9 ] = af * d - be;\n\n\t\t\tte[ 2 ] = - d;\n\t\t\tte[ 6 ] = b * c;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'YZX' ) {\n\n\t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = bd - ac * f;\n\t\t\tte[ 8 ] = bc * f + ad;\n\n\t\t\tte[ 1 ] = f;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = - b * e;\n\n\t\t\tte[ 2 ] = - d * e;\n\t\t\tte[ 6 ] = ad * f + bc;\n\t\t\tte[ 10 ] = ac - bd * f;\n\n\t\t} else if ( euler.order === 'XZY' ) {\n\n\t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = - f;\n\t\t\tte[ 8 ] = d * e;\n\n\t\t\tte[ 1 ] = ac * f + bd;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = ad * f - bc;\n\n\t\t\tte[ 2 ] = bc * f - ad;\n\t\t\tte[ 6 ] = b * e;\n\t\t\tte[ 10 ] = bd * f + ac;\n\n\t\t}\n\n\t\t// bottom row\n\t\tte[ 3 ] = 0;\n\t\tte[ 7 ] = 0;\n\t\tte[ 11 ] = 0;\n\n\t\t// last column\n\t\tte[ 12 ] = 0;\n\t\tte[ 13 ] = 0;\n\t\tte[ 14 ] = 0;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationFromQuaternion: function ( q ) {\n\n\t\treturn this.compose( _zero, q, _one );\n\n\t},\n\n\tlookAt: function ( eye, target, up ) {\n\n\t\tconst te = this.elements;\n\n\t\t_z.subVectors( eye, target );\n\n\t\tif ( _z.lengthSq() === 0 ) {\n\n\t\t\t// eye and target are in the same position\n\n\t\t\t_z.z = 1;\n\n\t\t}\n\n\t\t_z.normalize();\n\t\t_x.crossVectors( up, _z );\n\n\t\tif ( _x.lengthSq() === 0 ) {\n\n\t\t\t// up and z are parallel\n\n\t\t\tif ( Math.abs( up.z ) === 1 ) {\n\n\t\t\t\t_z.x += 0.0001;\n\n\t\t\t} else {\n\n\t\t\t\t_z.z += 0.0001;\n\n\t\t\t}\n\n\t\t\t_z.normalize();\n\t\t\t_x.crossVectors( up, _z );\n\n\t\t}\n\n\t\t_x.normalize();\n\t\t_y.crossVectors( _z, _x );\n\n\t\tte[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x;\n\t\tte[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y;\n\t\tte[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( m, n ) {\n\n\t\tif ( n !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );\n\t\t\treturn this.multiplyMatrices( m, n );\n\n\t\t}\n\n\t\treturn this.multiplyMatrices( this, m );\n\n\t},\n\n\tpremultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( m, this );\n\n\t},\n\n\tmultiplyMatrices: function ( a, b ) {\n\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\n\t\tconst a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];\n\t\tconst a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];\n\t\tconst a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];\n\t\tconst a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];\n\n\t\tconst b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];\n\t\tconst b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];\n\t\tconst b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];\n\t\tconst b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];\n\n\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n\t\tte[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n\t\tte[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n\t\tte[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n\t\tte[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n\t\tte[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n\t\tte[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n\t\tte[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n\t\tte[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n\t\tte[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n\t\tte[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n\t\tte[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n\t\tte[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n\t\tte[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;\n\t\tte[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;\n\t\tte[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;\n\t\tte[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;\n\n\t\treturn this;\n\n\t},\n\n\tdeterminant: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];\n\t\tconst n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];\n\t\tconst n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];\n\t\tconst n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];\n\n\t\t//TODO: make this more efficient\n\t\t//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )\n\n\t\treturn (\n\t\t\tn41 * (\n\t\t\t\t+ n14 * n23 * n32\n\t\t\t\t - n13 * n24 * n32\n\t\t\t\t - n14 * n22 * n33\n\t\t\t\t + n12 * n24 * n33\n\t\t\t\t + n13 * n22 * n34\n\t\t\t\t - n12 * n23 * n34\n\t\t\t) +\n\t\t\tn42 * (\n\t\t\t\t+ n11 * n23 * n34\n\t\t\t\t - n11 * n24 * n33\n\t\t\t\t + n14 * n21 * n33\n\t\t\t\t - n13 * n21 * n34\n\t\t\t\t + n13 * n24 * n31\n\t\t\t\t - n14 * n23 * n31\n\t\t\t) +\n\t\t\tn43 * (\n\t\t\t\t+ n11 * n24 * n32\n\t\t\t\t - n11 * n22 * n34\n\t\t\t\t - n14 * n21 * n32\n\t\t\t\t + n12 * n21 * n34\n\t\t\t\t + n14 * n22 * n31\n\t\t\t\t - n12 * n24 * n31\n\t\t\t) +\n\t\t\tn44 * (\n\t\t\t\t- n13 * n22 * n31\n\t\t\t\t - n11 * n23 * n32\n\t\t\t\t + n11 * n22 * n33\n\t\t\t\t + n13 * n21 * n32\n\t\t\t\t - n12 * n21 * n33\n\t\t\t\t + n12 * n23 * n31\n\t\t\t)\n\n\t\t);\n\n\t},\n\n\ttranspose: function () {\n\n\t\tconst te = this.elements;\n\t\tlet tmp;\n\n\t\ttmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;\n\t\ttmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;\n\t\ttmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;\n\n\t\ttmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;\n\t\ttmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;\n\t\ttmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;\n\n\t\treturn this;\n\n\t},\n\n\tsetPosition: function ( x, y, z ) {\n\n\t\tconst te = this.elements;\n\n\t\tif ( x.isVector3 ) {\n\n\t\t\tte[ 12 ] = x.x;\n\t\t\tte[ 13 ] = x.y;\n\t\t\tte[ 14 ] = x.z;\n\n\t\t} else {\n\n\t\t\tte[ 12 ] = x;\n\t\t\tte[ 13 ] = y;\n\t\t\tte[ 14 ] = z;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetInverse: function ( m, throwOnDegenerate ) {\n\n\t\tif ( throwOnDegenerate !== undefined ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.\" );\n\n\t\t}\n\n\t\t// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm\n\t\tconst te = this.elements,\n\t\t\tme = m.elements,\n\n\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],\n\t\t\tn12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],\n\t\t\tn13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],\n\t\t\tn14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],\n\n\t\t\tt11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,\n\t\t\tt12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,\n\t\t\tt13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,\n\t\t\tt14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;\n\n\t\tconst det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;\n\n\t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n\t\tconst detInv = 1 / det;\n\n\t\tte[ 0 ] = t11 * detInv;\n\t\tte[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;\n\t\tte[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;\n\t\tte[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;\n\n\t\tte[ 4 ] = t12 * detInv;\n\t\tte[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;\n\t\tte[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;\n\t\tte[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;\n\n\t\tte[ 8 ] = t13 * detInv;\n\t\tte[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;\n\t\tte[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;\n\t\tte[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;\n\n\t\tte[ 12 ] = t14 * detInv;\n\t\tte[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;\n\t\tte[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;\n\t\tte[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( v ) {\n\n\t\tconst te = this.elements;\n\t\tconst x = v.x, y = v.y, z = v.z;\n\n\t\tte[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;\n\t\tte[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;\n\t\tte[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;\n\t\tte[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;\n\n\t\treturn this;\n\n\t},\n\n\tgetMaxScaleOnAxis: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];\n\t\tconst scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];\n\t\tconst scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];\n\n\t\treturn Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );\n\n\t},\n\n\tmakeTranslation: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, x,\n\t\t\t0, 1, 0, y,\n\t\t\t0, 0, 1, z,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationX: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, c, - s, 0,\n\t\t\t0, s, c, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationY: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\t c, 0, s, 0,\n\t\t\t 0, 1, 0, 0,\n\t\t\t- s, 0, c, 0,\n\t\t\t 0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationZ: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\tc, - s, 0, 0,\n\t\t\ts, c, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationAxis: function ( axis, angle ) {\n\n\t\t// Based on http://www.gamedev.net/reference/articles/article1199.asp\n\n\t\tconst c = Math.cos( angle );\n\t\tconst s = Math.sin( angle );\n\t\tconst t = 1 - c;\n\t\tconst x = axis.x, y = axis.y, z = axis.z;\n\t\tconst tx = t * x, ty = t * y;\n\n\t\tthis.set(\n\n\t\t\ttx * x + c, tx * y - s * z, tx * z + s * y, 0,\n\t\t\ttx * y + s * z, ty * y + c, ty * z - s * x, 0,\n\t\t\ttx * z - s * y, ty * z + s * x, t * z * z + c, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\t return this;\n\n\t},\n\n\tmakeScale: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\tx, 0, 0, 0,\n\t\t\t0, y, 0, 0,\n\t\t\t0, 0, z, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeShear: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\t1, y, z, 0,\n\t\t\tx, 1, z, 0,\n\t\t\tx, y, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tcompose: function ( position, quaternion, scale ) {\n\n\t\tconst te = this.elements;\n\n\t\tconst x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;\n\t\tconst x2 = x + x,\ty2 = y + y, z2 = z + z;\n\t\tconst xx = x * x2, xy = x * y2, xz = x * z2;\n\t\tconst yy = y * y2, yz = y * z2, zz = z * z2;\n\t\tconst wx = w * x2, wy = w * y2, wz = w * z2;\n\n\t\tconst sx = scale.x, sy = scale.y, sz = scale.z;\n\n\t\tte[ 0 ] = ( 1 - ( yy + zz ) ) * sx;\n\t\tte[ 1 ] = ( xy + wz ) * sx;\n\t\tte[ 2 ] = ( xz - wy ) * sx;\n\t\tte[ 3 ] = 0;\n\n\t\tte[ 4 ] = ( xy - wz ) * sy;\n\t\tte[ 5 ] = ( 1 - ( xx + zz ) ) * sy;\n\t\tte[ 6 ] = ( yz + wx ) * sy;\n\t\tte[ 7 ] = 0;\n\n\t\tte[ 8 ] = ( xz + wy ) * sz;\n\t\tte[ 9 ] = ( yz - wx ) * sz;\n\t\tte[ 10 ] = ( 1 - ( xx + yy ) ) * sz;\n\t\tte[ 11 ] = 0;\n\n\t\tte[ 12 ] = position.x;\n\t\tte[ 13 ] = position.y;\n\t\tte[ 14 ] = position.z;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tdecompose: function ( position, quaternion, scale ) {\n\n\t\tconst te = this.elements;\n\n\t\tlet sx = _v1.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();\n\t\tlet sy = _v1.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();\n\t\tlet sz = _v1.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();\n\n\t\t// if determine is negative, we need to invert one scale\n\t\tconst det = this.determinant();\n\t\tif ( det < 0 ) sx = - sx;\n\n\t\tposition.x = te[ 12 ];\n\t\tposition.y = te[ 13 ];\n\t\tposition.z = te[ 14 ];\n\n\t\t// scale the rotation part\n\t\t_m1.copy( this );\n\n\t\tconst invSX = 1 / sx;\n\t\tconst invSY = 1 / sy;\n\t\tconst invSZ = 1 / sz;\n\n\t\t_m1.elements[ 0 ] *= invSX;\n\t\t_m1.elements[ 1 ] *= invSX;\n\t\t_m1.elements[ 2 ] *= invSX;\n\n\t\t_m1.elements[ 4 ] *= invSY;\n\t\t_m1.elements[ 5 ] *= invSY;\n\t\t_m1.elements[ 6 ] *= invSY;\n\n\t\t_m1.elements[ 8 ] *= invSZ;\n\t\t_m1.elements[ 9 ] *= invSZ;\n\t\t_m1.elements[ 10 ] *= invSZ;\n\n\t\tquaternion.setFromRotationMatrix( _m1 );\n\n\t\tscale.x = sx;\n\t\tscale.y = sy;\n\t\tscale.z = sz;\n\n\t\treturn this;\n\n\t},\n\n\tmakePerspective: function ( left, right, top, bottom, near, far ) {\n\n\t\tif ( far === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );\n\n\t\t}\n\n\t\tconst te = this.elements;\n\t\tconst x = 2 * near / ( right - left );\n\t\tconst y = 2 * near / ( top - bottom );\n\n\t\tconst a = ( right + left ) / ( right - left );\n\t\tconst b = ( top + bottom ) / ( top - bottom );\n\t\tconst c = - ( far + near ) / ( far - near );\n\t\tconst d = - 2 * far * near / ( far - near );\n\n\t\tte[ 0 ] = x;\tte[ 4 ] = 0;\tte[ 8 ] = a;\tte[ 12 ] = 0;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = y;\tte[ 9 ] = b;\tte[ 13 ] = 0;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = c;\tte[ 14 ] = d;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = - 1;\tte[ 15 ] = 0;\n\n\t\treturn this;\n\n\t},\n\n\tmakeOrthographic: function ( left, right, top, bottom, near, far ) {\n\n\t\tconst te = this.elements;\n\t\tconst w = 1.0 / ( right - left );\n\t\tconst h = 1.0 / ( top - bottom );\n\t\tconst p = 1.0 / ( far - near );\n\n\t\tconst x = ( right + left ) * w;\n\t\tconst y = ( top + bottom ) * h;\n\t\tconst z = ( far + near ) * p;\n\n\t\tte[ 0 ] = 2 * w;\tte[ 4 ] = 0;\tte[ 8 ] = 0;\tte[ 12 ] = - x;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = 2 * h;\tte[ 9 ] = 0;\tte[ 13 ] = - y;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = - 2 * p;\tte[ 14 ] = - z;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = 0;\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( matrix ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor ( let i = 0; i < 16; i ++ ) {\n\n\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tfor ( let i = 0; i < 16; i ++ ) {\n\n\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tconst te = this.elements;\n\n\t\tarray[ offset ] = te[ 0 ];\n\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\tarray[ offset + 2 ] = te[ 2 ];\n\t\tarray[ offset + 3 ] = te[ 3 ];\n\n\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\tarray[ offset + 5 ] = te[ 5 ];\n\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\tarray[ offset + 7 ] = te[ 7 ];\n\n\t\tarray[ offset + 8 ] = te[ 8 ];\n\t\tarray[ offset + 9 ] = te[ 9 ];\n\t\tarray[ offset + 10 ] = te[ 10 ];\n\t\tarray[ offset + 11 ] = te[ 11 ];\n\n\t\tarray[ offset + 12 ] = te[ 12 ];\n\t\tarray[ offset + 13 ] = te[ 13 ];\n\t\tarray[ offset + 14 ] = te[ 14 ];\n\t\tarray[ offset + 15 ] = te[ 15 ];\n\n\t\treturn array;\n\n\t}\n\n} );\n\n\nexport { Matrix4 };\n","import { Quaternion } from './Quaternion.js';\nimport { Vector3 } from './Vector3.js';\nimport { Matrix4 } from './Matrix4.js';\nimport { MathUtils } from './MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n */\n\nconst _matrix = new Matrix4();\nconst _quaternion = new Quaternion();\n\nfunction Euler( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {\n\n\tthis._x = x;\n\tthis._y = y;\n\tthis._z = z;\n\tthis._order = order;\n\n}\n\nEuler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];\n\nEuler.DefaultOrder = 'XYZ';\n\nObject.defineProperties( Euler.prototype, {\n\n\tx: {\n\n\t\tget: function () {\n\n\t\t\treturn this._x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._x = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\ty: {\n\n\t\tget: function () {\n\n\t\t\treturn this._y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._y = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tz: {\n\n\t\tget: function () {\n\n\t\t\treturn this._z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._z = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\torder: {\n\n\t\tget: function () {\n\n\t\t\treturn this._order;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._order = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Euler.prototype, {\n\n\tisEuler: true,\n\n\tset: function ( x, y, z, order ) {\n\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._order = order || this._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this._x, this._y, this._z, this._order );\n\n\t},\n\n\tcopy: function ( euler ) {\n\n\t\tthis._x = euler._x;\n\t\tthis._y = euler._y;\n\t\tthis._z = euler._z;\n\t\tthis._order = euler._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromRotationMatrix: function ( m, order, update ) {\n\n\t\tconst clamp = MathUtils.clamp;\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tconst te = m.elements;\n\t\tconst m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];\n\t\tconst m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];\n\t\tconst m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\torder = order || this._order;\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYZ':\n\n\t\t\t\tthis._y = Math.asin( clamp( m13, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m13 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\n\t\t\t\tthis._x = Math.asin( - clamp( m23, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m23 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\n\t\t\t\tthis._x = Math.asin( clamp( m32, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m32 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = 0;\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\n\t\t\t\tthis._y = Math.asin( - clamp( m31, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m31 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\n\t\t\t\tthis._z = Math.asin( clamp( m21, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m21 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m22 );\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\n\t\t\t\tthis._z = Math.asin( - clamp( m12, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m12 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._y = Math.atan2( m13, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._y = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\n\t\t\t\tconsole.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t\tthis._order = order;\n\n\t\tif ( update !== false ) this._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromQuaternion: function ( q, order, update ) {\n\n\t\t_matrix.makeRotationFromQuaternion( q );\n\n\t\treturn this.setFromRotationMatrix( _matrix, order, update );\n\n\t},\n\n\tsetFromVector3: function ( v, order ) {\n\n\t\treturn this.set( v.x, v.y, v.z, order || this._order );\n\n\t},\n\n\treorder: function ( newOrder ) {\n\n\t\t// WARNING: this discards revolution information -bhouston\n\n\t\t_quaternion.setFromEuler( this );\n\n\t\treturn this.setFromQuaternion( _quaternion, newOrder );\n\n\t},\n\n\tequals: function ( euler ) {\n\n\t\treturn ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );\n\n\t},\n\n\tfromArray: function ( array ) {\n\n\t\tthis._x = array[ 0 ];\n\t\tthis._y = array[ 1 ];\n\t\tthis._z = array[ 2 ];\n\t\tif ( array[ 3 ] !== undefined ) this._order = array[ 3 ];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this._x;\n\t\tarray[ offset + 1 ] = this._y;\n\t\tarray[ offset + 2 ] = this._z;\n\t\tarray[ offset + 3 ] = this._order;\n\n\t\treturn array;\n\n\t},\n\n\ttoVector3: function ( optionalResult ) {\n\n\t\tif ( optionalResult ) {\n\n\t\t\treturn optionalResult.set( this._x, this._y, this._z );\n\n\t\t} else {\n\n\t\t\treturn new Vector3( this._x, this._y, this._z );\n\n\t\t}\n\n\t},\n\n\t_onChange: function ( callback ) {\n\n\t\tthis._onChangeCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\t_onChangeCallback: function () {}\n\n} );\n\n\nexport { Euler };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Layers() {\n\n\tthis.mask = 1 | 0;\n\n}\n\nObject.assign( Layers.prototype, {\n\n\tset: function ( channel ) {\n\n\t\tthis.mask = 1 << channel | 0;\n\n\t},\n\n\tenable: function ( channel ) {\n\n\t\tthis.mask |= 1 << channel | 0;\n\n\t},\n\n\tenableAll: function () {\n\n\t\tthis.mask = 0xffffffff | 0;\n\n\t},\n\n\ttoggle: function ( channel ) {\n\n\t\tthis.mask ^= 1 << channel | 0;\n\n\t},\n\n\tdisable: function ( channel ) {\n\n\t\tthis.mask &= ~ ( 1 << channel | 0 );\n\n\t},\n\n\tdisableAll: function () {\n\n\t\tthis.mask = 0;\n\n\t},\n\n\ttest: function ( layers ) {\n\n\t\treturn ( this.mask & layers.mask ) !== 0;\n\n\t}\n\n} );\n\n\nexport { Layers };\n","import { Quaternion } from '../math/Quaternion.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { EventDispatcher } from './EventDispatcher.js';\nimport { Euler } from '../math/Euler.js';\nimport { Layers } from './Layers.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\nlet _object3DId = 0;\n\nconst _v1 = new Vector3();\nconst _q1 = new Quaternion();\nconst _m1 = new Matrix4();\nconst _target = new Vector3();\n\nconst _position = new Vector3();\nconst _scale = new Vector3();\nconst _quaternion = new Quaternion();\n\nconst _xAxis = new Vector3( 1, 0, 0 );\nconst _yAxis = new Vector3( 0, 1, 0 );\nconst _zAxis = new Vector3( 0, 0, 1 );\n\nconst _addedEvent = { type: 'added' };\nconst _removedEvent = { type: 'removed' };\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author elephantatwork / www.elephantatwork.ch\n */\n\nfunction Object3D() {\n\n\tObject.defineProperty( this, 'id', { value: _object3DId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Object3D';\n\n\tthis.parent = null;\n\tthis.children = [];\n\n\tthis.up = Object3D.DefaultUp.clone();\n\n\tconst position = new Vector3();\n\tconst rotation = new Euler();\n\tconst quaternion = new Quaternion();\n\tconst scale = new Vector3( 1, 1, 1 );\n\n\tfunction onRotationChange() {\n\n\t\tquaternion.setFromEuler( rotation, false );\n\n\t}\n\n\tfunction onQuaternionChange() {\n\n\t\trotation.setFromQuaternion( quaternion, undefined, false );\n\n\t}\n\n\trotation._onChange( onRotationChange );\n\tquaternion._onChange( onQuaternionChange );\n\n\tObject.defineProperties( this, {\n\t\tposition: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: position\n\t\t},\n\t\trotation: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: rotation\n\t\t},\n\t\tquaternion: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: quaternion\n\t\t},\n\t\tscale: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: scale\n\t\t},\n\t\tmodelViewMatrix: {\n\t\t\tvalue: new Matrix4()\n\t\t},\n\t\tnormalMatrix: {\n\t\t\tvalue: new Matrix3()\n\t\t}\n\t} );\n\n\tthis.matrix = new Matrix4();\n\tthis.matrixWorld = new Matrix4();\n\n\tthis.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;\n\tthis.matrixWorldNeedsUpdate = false;\n\n\tthis.layers = new Layers();\n\tthis.visible = true;\n\n\tthis.castShadow = false;\n\tthis.receiveShadow = false;\n\n\tthis.frustumCulled = true;\n\tthis.renderOrder = 0;\n\n\tthis.userData = {};\n\n}\n\nObject3D.DefaultUp = new Vector3( 0, 1, 0 );\nObject3D.DefaultMatrixAutoUpdate = true;\n\nObject3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Object3D,\n\n\tisObject3D: true,\n\n\tonBeforeRender: function () {},\n\tonAfterRender: function () {},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tthis.matrix.premultiply( matrix );\n\n\t\tthis.matrix.decompose( this.position, this.quaternion, this.scale );\n\n\t},\n\n\tapplyQuaternion: function ( q ) {\n\n\t\tthis.quaternion.premultiply( q );\n\n\t\treturn this;\n\n\t},\n\n\tsetRotationFromAxisAngle: function ( axis, angle ) {\n\n\t\t// assumes axis is normalized\n\n\t\tthis.quaternion.setFromAxisAngle( axis, angle );\n\n\t},\n\n\tsetRotationFromEuler: function ( euler ) {\n\n\t\tthis.quaternion.setFromEuler( euler, true );\n\n\t},\n\n\tsetRotationFromMatrix: function ( m ) {\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tthis.quaternion.setFromRotationMatrix( m );\n\n\t},\n\n\tsetRotationFromQuaternion: function ( q ) {\n\n\t\t// assumes q is normalized\n\n\t\tthis.quaternion.copy( q );\n\n\t},\n\n\trotateOnAxis: function ( axis, angle ) {\n\n\t\t// rotate object on axis in object space\n\t\t// axis is assumed to be normalized\n\n\t\t_q1.setFromAxisAngle( axis, angle );\n\n\t\tthis.quaternion.multiply( _q1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateOnWorldAxis: function ( axis, angle ) {\n\n\t\t// rotate object on axis in world space\n\t\t// axis is assumed to be normalized\n\t\t// method assumes no rotated parent\n\n\t\t_q1.setFromAxisAngle( axis, angle );\n\n\t\tthis.quaternion.premultiply( _q1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _xAxis, angle );\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _yAxis, angle );\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _zAxis, angle );\n\n\t},\n\n\ttranslateOnAxis: function ( axis, distance ) {\n\n\t\t// translate object by distance along axis in object space\n\t\t// axis is assumed to be normalized\n\n\t\t_v1.copy( axis ).applyQuaternion( this.quaternion );\n\n\t\tthis.position.add( _v1.multiplyScalar( distance ) );\n\n\t\treturn this;\n\n\t},\n\n\ttranslateX: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _xAxis, distance );\n\n\t},\n\n\ttranslateY: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _yAxis, distance );\n\n\t},\n\n\ttranslateZ: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _zAxis, distance );\n\n\t},\n\n\tlocalToWorld: function ( vector ) {\n\n\t\treturn vector.applyMatrix4( this.matrixWorld );\n\n\t},\n\n\tworldToLocal: function ( vector ) {\n\n\t\treturn vector.applyMatrix4( _m1.getInverse( this.matrixWorld ) );\n\n\t},\n\n\tlookAt: function ( x, y, z ) {\n\n\t\t// This method does not support objects having non-uniformly-scaled parent(s)\n\n\t\tif ( x.isVector3 ) {\n\n\t\t\t_target.copy( x );\n\n\t\t} else {\n\n\t\t\t_target.set( x, y, z );\n\n\t\t}\n\n\t\tconst parent = this.parent;\n\n\t\tthis.updateWorldMatrix( true, false );\n\n\t\t_position.setFromMatrixPosition( this.matrixWorld );\n\n\t\tif ( this.isCamera || this.isLight ) {\n\n\t\t\t_m1.lookAt( _position, _target, this.up );\n\n\t\t} else {\n\n\t\t\t_m1.lookAt( _target, _position, this.up );\n\n\t\t}\n\n\t\tthis.quaternion.setFromRotationMatrix( _m1 );\n\n\t\tif ( parent ) {\n\n\t\t\t_m1.extractRotation( parent.matrixWorld );\n\t\t\t_q1.setFromRotationMatrix( _m1 );\n\t\t\tthis.quaternion.premultiply( _q1.inverse() );\n\n\t\t}\n\n\t},\n\n\tadd: function ( object ) {\n\n\t\tif ( arguments.length > 1 ) {\n\n\t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\tthis.add( arguments[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tif ( object === this ) {\n\n\t\t\tconsole.error( \"THREE.Object3D.add: object can't be added as a child of itself.\", object );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tif ( ( object && object.isObject3D ) ) {\n\n\t\t\tif ( object.parent !== null ) {\n\n\t\t\t\tobject.parent.remove( object );\n\n\t\t\t}\n\n\t\t\tobject.parent = this;\n\t\t\tthis.children.push( object );\n\n\t\t\tobject.dispatchEvent( _addedEvent );\n\n\t\t} else {\n\n\t\t\tconsole.error( \"THREE.Object3D.add: object not an instance of THREE.Object3D.\", object );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tremove: function ( object ) {\n\n\t\tif ( arguments.length > 1 ) {\n\n\t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\tthis.remove( arguments[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst index = this.children.indexOf( object );\n\n\t\tif ( index !== - 1 ) {\n\n\t\t\tobject.parent = null;\n\t\t\tthis.children.splice( index, 1 );\n\n\t\t\tobject.dispatchEvent( _removedEvent );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tattach: function ( object ) {\n\n\t\t// adds object as a child of this, while maintaining the object's world transform\n\n\t\tthis.updateWorldMatrix( true, false );\n\n\t\t_m1.getInverse( this.matrixWorld );\n\n\t\tif ( object.parent !== null ) {\n\n\t\t\tobject.parent.updateWorldMatrix( true, false );\n\n\t\t\t_m1.multiply( object.parent.matrixWorld );\n\n\t\t}\n\n\t\tobject.applyMatrix4( _m1 );\n\n\t\tobject.updateWorldMatrix( false, false );\n\n\t\tthis.add( object );\n\n\t\treturn this;\n\n\t},\n\n\tgetObjectById: function ( id ) {\n\n\t\treturn this.getObjectByProperty( 'id', id );\n\n\t},\n\n\tgetObjectByName: function ( name ) {\n\n\t\treturn this.getObjectByProperty( 'name', name );\n\n\t},\n\n\tgetObjectByProperty: function ( name, value ) {\n\n\t\tif ( this[ name ] === value ) return this;\n\n\t\tfor ( let i = 0, l = this.children.length; i < l; i ++ ) {\n\n\t\t\tconst child = this.children[ i ];\n\t\t\tconst object = child.getObjectByProperty( name, value );\n\n\t\t\tif ( object !== undefined ) {\n\n\t\t\t\treturn object;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn undefined;\n\n\t},\n\n\tgetWorldPosition: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldPosition() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\treturn target.setFromMatrixPosition( this.matrixWorld );\n\n\t},\n\n\tgetWorldQuaternion: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );\n\t\t\ttarget = new Quaternion();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tthis.matrixWorld.decompose( _position, target, _scale );\n\n\t\treturn target;\n\n\t},\n\n\tgetWorldScale: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldScale() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tthis.matrixWorld.decompose( _position, _quaternion, target );\n\n\t\treturn target;\n\n\t},\n\n\tgetWorldDirection: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldDirection() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tconst e = this.matrixWorld.elements;\n\n\t\treturn target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize();\n\n\t},\n\n\traycast: function () {},\n\n\ttraverse: function ( callback ) {\n\n\t\tcallback( this );\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].traverse( callback );\n\n\t\t}\n\n\t},\n\n\ttraverseVisible: function ( callback ) {\n\n\t\tif ( this.visible === false ) return;\n\n\t\tcallback( this );\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].traverseVisible( callback );\n\n\t\t}\n\n\t},\n\n\ttraverseAncestors: function ( callback ) {\n\n\t\tconst parent = this.parent;\n\n\t\tif ( parent !== null ) {\n\n\t\t\tcallback( parent );\n\n\t\t\tparent.traverseAncestors( callback );\n\n\t\t}\n\n\t},\n\n\tupdateMatrix: function () {\n\n\t\tthis.matrix.compose( this.position, this.quaternion, this.scale );\n\n\t\tthis.matrixWorldNeedsUpdate = true;\n\n\t},\n\n\tupdateMatrixWorld: function ( force ) {\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tif ( this.matrixWorldNeedsUpdate || force ) {\n\n\t\t\tif ( this.parent === null ) {\n\n\t\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t\t} else {\n\n\t\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t\t}\n\n\t\t\tthis.matrixWorldNeedsUpdate = false;\n\n\t\t\tforce = true;\n\n\t\t}\n\n\t\t// update children\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].updateMatrixWorld( force );\n\n\t\t}\n\n\t},\n\n\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\tconst parent = this.parent;\n\n\t\tif ( updateParents === true && parent !== null ) {\n\n\t\t\tparent.updateWorldMatrix( true, false );\n\n\t\t}\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tif ( this.parent === null ) {\n\n\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t} else {\n\n\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t}\n\n\t\t// update children\n\n\t\tif ( updateChildren === true ) {\n\n\t\t\tconst children = this.children;\n\n\t\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tchildren[ i ].updateWorldMatrix( false, true );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\t// meta is a string when called from JSON.stringify\n\t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\tconst output = {};\n\n\t\t// meta is a hash used to collect geometries, materials.\n\t\t// not providing it implies that this is the root object\n\t\t// being serialized.\n\t\tif ( isRootObject ) {\n\n\t\t\t// initialize meta obj\n\t\t\tmeta = {\n\t\t\t\tgeometries: {},\n\t\t\t\tmaterials: {},\n\t\t\t\ttextures: {},\n\t\t\t\timages: {},\n\t\t\t\tshapes: {}\n\t\t\t};\n\n\t\t\toutput.metadata = {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Object',\n\t\t\t\tgenerator: 'Object3D.toJSON'\n\t\t\t};\n\n\t\t}\n\n\t\t// standard Object3D serialization\n\n\t\tconst object = {};\n\n\t\tobject.uuid = this.uuid;\n\t\tobject.type = this.type;\n\n\t\tif ( this.name !== '' ) object.name = this.name;\n\t\tif ( this.castShadow === true ) object.castShadow = true;\n\t\tif ( this.receiveShadow === true ) object.receiveShadow = true;\n\t\tif ( this.visible === false ) object.visible = false;\n\t\tif ( this.frustumCulled === false ) object.frustumCulled = false;\n\t\tif ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder;\n\t\tif ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData;\n\n\t\tobject.layers = this.layers.mask;\n\t\tobject.matrix = this.matrix.toArray();\n\n\t\tif ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;\n\n\t\t// object specific properties\n\n\t\tif ( this.isInstancedMesh ) {\n\n\t\t\tobject.type = 'InstancedMesh';\n\t\t\tobject.count = this.count;\n\t\t\tobject.instanceMatrix = this.instanceMatrix.toJSON();\n\n\t\t}\n\n\t\t//\n\n\t\tfunction serialize( library, element ) {\n\n\t\t\tif ( library[ element.uuid ] === undefined ) {\n\n\t\t\t\tlibrary[ element.uuid ] = element.toJSON( meta );\n\n\t\t\t}\n\n\t\t\treturn element.uuid;\n\n\t\t}\n\n\t\tif ( this.isMesh || this.isLine || this.isPoints ) {\n\n\t\t\tobject.geometry = serialize( meta.geometries, this.geometry );\n\n\t\t\tconst parameters = this.geometry.parameters;\n\n\t\t\tif ( parameters !== undefined && parameters.shapes !== undefined ) {\n\n\t\t\t\tconst shapes = parameters.shapes;\n\n\t\t\t\tif ( Array.isArray( shapes ) ) {\n\n\t\t\t\t\tfor ( let i = 0, l = shapes.length; i < l; i ++ ) {\n\n\t\t\t\t\t\tconst shape = shapes[ i ];\n\n\t\t\t\t\t\tserialize( meta.shapes, shape );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tserialize( meta.shapes, shapes );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.material !== undefined ) {\n\n\t\t\tif ( Array.isArray( this.material ) ) {\n\n\t\t\t\tconst uuids = [];\n\n\t\t\t\tfor ( let i = 0, l = this.material.length; i < l; i ++ ) {\n\n\t\t\t\t\tuuids.push( serialize( meta.materials, this.material[ i ] ) );\n\n\t\t\t\t}\n\n\t\t\t\tobject.material = uuids;\n\n\t\t\t} else {\n\n\t\t\t\tobject.material = serialize( meta.materials, this.material );\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tif ( this.children.length > 0 ) {\n\n\t\t\tobject.children = [];\n\n\t\t\tfor ( let i = 0; i < this.children.length; i ++ ) {\n\n\t\t\t\tobject.children.push( this.children[ i ].toJSON( meta ).object );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( isRootObject ) {\n\n\t\t\tconst geometries = extractFromCache( meta.geometries );\n\t\t\tconst materials = extractFromCache( meta.materials );\n\t\t\tconst textures = extractFromCache( meta.textures );\n\t\t\tconst images = extractFromCache( meta.images );\n\t\t\tconst shapes = extractFromCache( meta.shapes );\n\n\t\t\tif ( geometries.length > 0 ) output.geometries = geometries;\n\t\t\tif ( materials.length > 0 ) output.materials = materials;\n\t\t\tif ( textures.length > 0 ) output.textures = textures;\n\t\t\tif ( images.length > 0 ) output.images = images;\n\t\t\tif ( shapes.length > 0 ) output.shapes = shapes;\n\n\t\t}\n\n\t\toutput.object = object;\n\n\t\treturn output;\n\n\t\t// extract data from the cache hash\n\t\t// remove metadata on each item\n\t\t// and return as array\n\t\tfunction extractFromCache( cache ) {\n\n\t\t\tconst values = [];\n\t\t\tfor ( const key in cache ) {\n\n\t\t\t\tconst data = cache[ key ];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push( data );\n\n\t\t\t}\n\n\t\t\treturn values;\n\n\t\t}\n\n\t},\n\n\tclone: function ( recursive ) {\n\n\t\treturn new this.constructor().copy( this, recursive );\n\n\t},\n\n\tcopy: function ( source, recursive ) {\n\n\t\tif ( recursive === undefined ) recursive = true;\n\n\t\tthis.name = source.name;\n\n\t\tthis.up.copy( source.up );\n\n\t\tthis.position.copy( source.position );\n\t\tthis.quaternion.copy( source.quaternion );\n\t\tthis.scale.copy( source.scale );\n\n\t\tthis.matrix.copy( source.matrix );\n\t\tthis.matrixWorld.copy( source.matrixWorld );\n\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;\n\n\t\tthis.layers.mask = source.layers.mask;\n\t\tthis.visible = source.visible;\n\n\t\tthis.castShadow = source.castShadow;\n\t\tthis.receiveShadow = source.receiveShadow;\n\n\t\tthis.frustumCulled = source.frustumCulled;\n\t\tthis.renderOrder = source.renderOrder;\n\n\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\tif ( recursive === true ) {\n\n\t\t\tfor ( let i = 0; i < source.children.length; i ++ ) {\n\n\t\t\t\tconst child = source.children[ i ];\n\t\t\t\tthis.add( child.clone() );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Object3D };\n","import { Object3D } from '../core/Object3D.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Scene() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Scene';\n\n\tthis.background = null;\n\tthis.environment = null;\n\tthis.fog = null;\n\n\tthis.overrideMaterial = null;\n\n\tthis.autoUpdate = true; // checked by the renderer\n\n\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef\n\n\t}\n\n}\n\nScene.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Scene,\n\n\tisScene: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\tif ( source.background !== null ) this.background = source.background.clone();\n\t\tif ( source.environment !== null ) this.environment = source.environment.clone();\n\t\tif ( source.fog !== null ) this.fog = source.fog.clone();\n\n\t\tif ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();\n\n\t\tthis.autoUpdate = source.autoUpdate;\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tif ( this.background !== null ) data.object.background = this.background.toJSON( meta );\n\t\tif ( this.environment !== null ) data.object.environment = this.environment.toJSON( meta );\n\t\tif ( this.fog !== null ) data.object.fog = this.fog.toJSON();\n\n\t\treturn data;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\n\nexport { Scene };\n","import { Vector3 } from './Vector3.js';\n\nconst _points = [\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3()\n];\n\nconst _vector = new Vector3();\n\nconst _box = new Box3();\n\n// triangle centered vertices\n\nconst _v0 = new Vector3();\nconst _v1 = new Vector3();\nconst _v2 = new Vector3();\n\n// triangle edge vectors\n\nconst _f0 = new Vector3();\nconst _f1 = new Vector3();\nconst _f2 = new Vector3();\n\nconst _center = new Vector3();\nconst _extents = new Vector3();\nconst _triangleNormal = new Vector3();\nconst _testAxis = new Vector3();\n\n/**\n * @author bhouston / http://clara.io\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Box3( min, max ) {\n\n\tthis.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );\n\tthis.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );\n\n}\n\n\nObject.assign( Box3.prototype, {\n\n\tisBox3: true,\n\n\tset: function ( min, max ) {\n\n\t\tthis.min.copy( min );\n\t\tthis.max.copy( max );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromArray: function ( array ) {\n\n\t\tlet minX = + Infinity;\n\t\tlet minY = + Infinity;\n\t\tlet minZ = + Infinity;\n\n\t\tlet maxX = - Infinity;\n\t\tlet maxY = - Infinity;\n\t\tlet maxZ = - Infinity;\n\n\t\tfor ( let i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\tconst x = array[ i ];\n\t\t\tconst y = array[ i + 1 ];\n\t\t\tconst z = array[ i + 2 ];\n\n\t\t\tif ( x < minX ) minX = x;\n\t\t\tif ( y < minY ) minY = y;\n\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\tif ( x > maxX ) maxX = x;\n\t\t\tif ( y > maxY ) maxY = y;\n\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t}\n\n\t\tthis.min.set( minX, minY, minZ );\n\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromBufferAttribute: function ( attribute ) {\n\n\t\tlet minX = + Infinity;\n\t\tlet minY = + Infinity;\n\t\tlet minZ = + Infinity;\n\n\t\tlet maxX = - Infinity;\n\t\tlet maxY = - Infinity;\n\t\tlet maxZ = - Infinity;\n\n\t\tfor ( let i = 0, l = attribute.count; i < l; i ++ ) {\n\n\t\t\tconst x = attribute.getX( i );\n\t\t\tconst y = attribute.getY( i );\n\t\t\tconst z = attribute.getZ( i );\n\n\t\t\tif ( x < minX ) minX = x;\n\t\t\tif ( y < minY ) minY = y;\n\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\tif ( x > maxX ) maxX = x;\n\t\t\tif ( y > maxY ) maxY = y;\n\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t}\n\n\t\tthis.min.set( minX, minY, minZ );\n\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tthis.makeEmpty();\n\n\t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\tthis.expandByPoint( points[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCenterAndSize: function ( center, size ) {\n\n\t\tconst halfSize = _vector.copy( size ).multiplyScalar( 0.5 );\n\n\t\tthis.min.copy( center ).sub( halfSize );\n\t\tthis.max.copy( center ).add( halfSize );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromObject: function ( object ) {\n\n\t\tthis.makeEmpty();\n\n\t\treturn this.expandByObject( object );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( box ) {\n\n\t\tthis.min.copy( box.min );\n\t\tthis.max.copy( box.max );\n\n\t\treturn this;\n\n\t},\n\n\tmakeEmpty: function () {\n\n\t\tthis.min.x = this.min.y = this.min.z = + Infinity;\n\t\tthis.max.x = this.max.y = this.max.z = - Infinity;\n\n\t\treturn this;\n\n\t},\n\n\tisEmpty: function () {\n\n\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\n\t\treturn ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );\n\n\t},\n\n\tgetCenter: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getCenter() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );\n\n\t},\n\n\tgetSize: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getSize() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );\n\n\t},\n\n\texpandByPoint: function ( point ) {\n\n\t\tthis.min.min( point );\n\t\tthis.max.max( point );\n\n\t\treturn this;\n\n\t},\n\n\texpandByVector: function ( vector ) {\n\n\t\tthis.min.sub( vector );\n\t\tthis.max.add( vector );\n\n\t\treturn this;\n\n\t},\n\n\texpandByScalar: function ( scalar ) {\n\n\t\tthis.min.addScalar( - scalar );\n\t\tthis.max.addScalar( scalar );\n\n\t\treturn this;\n\n\t},\n\n\texpandByObject: function ( object ) {\n\n\t\t// Computes the world-axis-aligned bounding box of an object (including its children),\n\t\t// accounting for both the object's, and children's, world transforms\n\n\t\tobject.updateWorldMatrix( false, false );\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( geometry !== undefined ) {\n\n\t\t\tif ( geometry.boundingBox === null ) {\n\n\t\t\t\tgeometry.computeBoundingBox();\n\n\t\t\t}\n\n\t\t\t_box.copy( geometry.boundingBox );\n\t\t\t_box.applyMatrix4( object.matrixWorld );\n\n\t\t\tthis.union( _box );\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tthis.expandByObject( children[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn point.x < this.min.x || point.x > this.max.x ||\n\t\t\tpoint.y < this.min.y || point.y > this.max.y ||\n\t\t\tpoint.z < this.min.z || point.z > this.max.z ? false : true;\n\n\t},\n\n\tcontainsBox: function ( box ) {\n\n\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x &&\n\t\t\tthis.min.y <= box.min.y && box.max.y <= this.max.y &&\n\t\t\tthis.min.z <= box.min.z && box.max.z <= this.max.z;\n\n\t},\n\n\tgetParameter: function ( point, target ) {\n\n\t\t// This can potentially have a divide by zero if the box\n\t\t// has a size dimension of 0.\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getParameter() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.set(\n\t\t\t( point.x - this.min.x ) / ( this.max.x - this.min.x ),\n\t\t\t( point.y - this.min.y ) / ( this.max.y - this.min.y ),\n\t\t\t( point.z - this.min.z ) / ( this.max.z - this.min.z )\n\t\t);\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\t// using 6 splitting planes to rule out intersections.\n\t\treturn box.max.x < this.min.x || box.min.x > this.max.x ||\n\t\t\tbox.max.y < this.min.y || box.min.y > this.max.y ||\n\t\t\tbox.max.z < this.min.z || box.min.z > this.max.z ? false : true;\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\t// Find the point on the AABB closest to the sphere center.\n\t\tthis.clampPoint( sphere.center, _vector );\n\n\t\t// If that point is inside the sphere, the AABB and sphere intersect.\n\t\treturn _vector.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\t// We compute the minimum and maximum dot product values. If those values\n\t\t// are on the same side (back or front) of the plane, then there is no intersection.\n\n\t\tlet min, max;\n\n\t\tif ( plane.normal.x > 0 ) {\n\n\t\t\tmin = plane.normal.x * this.min.x;\n\t\t\tmax = plane.normal.x * this.max.x;\n\n\t\t} else {\n\n\t\t\tmin = plane.normal.x * this.max.x;\n\t\t\tmax = plane.normal.x * this.min.x;\n\n\t\t}\n\n\t\tif ( plane.normal.y > 0 ) {\n\n\t\t\tmin += plane.normal.y * this.min.y;\n\t\t\tmax += plane.normal.y * this.max.y;\n\n\t\t} else {\n\n\t\t\tmin += plane.normal.y * this.max.y;\n\t\t\tmax += plane.normal.y * this.min.y;\n\n\t\t}\n\n\t\tif ( plane.normal.z > 0 ) {\n\n\t\t\tmin += plane.normal.z * this.min.z;\n\t\t\tmax += plane.normal.z * this.max.z;\n\n\t\t} else {\n\n\t\t\tmin += plane.normal.z * this.max.z;\n\t\t\tmax += plane.normal.z * this.min.z;\n\n\t\t}\n\n\t\treturn ( min <= - plane.constant && max >= - plane.constant );\n\n\t},\n\n\tintersectsTriangle: function ( triangle ) {\n\n\t\tif ( this.isEmpty() ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// compute box center and extents\n\t\tthis.getCenter( _center );\n\t\t_extents.subVectors( this.max, _center );\n\n\t\t// translate triangle to aabb origin\n\t\t_v0.subVectors( triangle.a, _center );\n\t\t_v1.subVectors( triangle.b, _center );\n\t\t_v2.subVectors( triangle.c, _center );\n\n\t\t// compute edge vectors for triangle\n\t\t_f0.subVectors( _v1, _v0 );\n\t\t_f1.subVectors( _v2, _v1 );\n\t\t_f2.subVectors( _v0, _v2 );\n\n\t\t// test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb\n\t\t// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation\n\t\t// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)\n\t\tlet axes = [\n\t\t\t0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y,\n\t\t\t_f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,\n\t\t\t- _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0\n\t\t];\n\t\tif ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// test 3 face normals from the aabb\n\t\taxes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];\n\t\tif ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// finally testing the face normal of the triangle\n\t\t// use already existing triangle edge vectors here\n\t\t_triangleNormal.crossVectors( _f0, _f1 );\n\t\taxes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];\n\n\t\treturn satForAxes( axes, _v0, _v1, _v2, _extents );\n\n\t},\n\n\tclampPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .clampPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( point ).clamp( this.min, this.max );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\tconst clampedPoint = _vector.copy( point ).clamp( this.min, this.max );\n\n\t\treturn clampedPoint.sub( point ).length();\n\n\t},\n\n\tgetBoundingSphere: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.error( 'THREE.Box3: .getBoundingSphere() target is now required' );\n\t\t\t//target = new Sphere(); // removed to avoid cyclic dependency\n\n\t\t}\n\n\t\tthis.getCenter( target.center );\n\n\t\ttarget.radius = this.getSize( _vector ).length() * 0.5;\n\n\t\treturn target;\n\n\t},\n\n\tintersect: function ( box ) {\n\n\t\tthis.min.max( box.min );\n\t\tthis.max.min( box.max );\n\n\t\t// ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.\n\t\tif ( this.isEmpty() ) this.makeEmpty();\n\n\t\treturn this;\n\n\t},\n\n\tunion: function ( box ) {\n\n\t\tthis.min.min( box.min );\n\t\tthis.max.max( box.max );\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\t// transform of empty box is an empty box.\n\t\tif ( this.isEmpty() ) return this;\n\n\t\t// NOTE: I am using a binary pattern to specify all 2^3 combinations below\n\t\t_points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000\n\t\t_points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001\n\t\t_points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010\n\t\t_points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011\n\t\t_points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100\n\t\t_points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101\n\t\t_points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110\n\t\t_points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111\n\n\t\tthis.setFromPoints( _points );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.min.add( offset );\n\t\tthis.max.add( offset );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( box ) {\n\n\t\treturn box.min.equals( this.min ) && box.max.equals( this.max );\n\n\t}\n\n} );\n\nfunction satForAxes( axes, v0, v1, v2, extents ) {\n\n\tfor ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {\n\n\t\t_testAxis.fromArray( axes, i );\n\t\t// project the aabb onto the seperating axis\n\t\tconst r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );\n\t\t// project all 3 vertices of the triangle onto the seperating axis\n\t\tconst p0 = v0.dot( _testAxis );\n\t\tconst p1 = v1.dot( _testAxis );\n\t\tconst p2 = v2.dot( _testAxis );\n\t\t// actual test, basically see if either of the most extreme of the triangle points intersects r\n\t\tif ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {\n\n\t\t\t// points of the projected triangle are outside the projected half-length of the aabb\n\t\t\t// the axis is seperating and we can exit\n\t\t\treturn false;\n\n\t\t}\n\n\t}\n\n\treturn true;\n\n}\n\nexport { Box3 };\n","import { Box3 } from './Box3.js';\nimport { Vector3 } from './Vector3.js';\n\nconst _box = new Box3();\n\n/**\n * @author bhouston / http://clara.io\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Sphere( center, radius ) {\n\n\tthis.center = ( center !== undefined ) ? center : new Vector3();\n\tthis.radius = ( radius !== undefined ) ? radius : - 1;\n\n}\n\nObject.assign( Sphere.prototype, {\n\n\tset: function ( center, radius ) {\n\n\t\tthis.center.copy( center );\n\t\tthis.radius = radius;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points, optionalCenter ) {\n\n\t\tconst center = this.center;\n\n\t\tif ( optionalCenter !== undefined ) {\n\n\t\t\tcenter.copy( optionalCenter );\n\n\t\t} else {\n\n\t\t\t_box.setFromPoints( points ).getCenter( center );\n\n\t\t}\n\n\t\tlet maxRadiusSq = 0;\n\n\t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );\n\n\t\t}\n\n\t\tthis.radius = Math.sqrt( maxRadiusSq );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( sphere ) {\n\n\t\tthis.center.copy( sphere.center );\n\t\tthis.radius = sphere.radius;\n\n\t\treturn this;\n\n\t},\n\n\tisEmpty: function () {\n\n\t\treturn ( this.radius < 0 );\n\n\t},\n\n\tmakeEmpty: function () {\n\n\t\tthis.center.set( 0, 0, 0 );\n\t\tthis.radius = - 1;\n\n\t\treturn this;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn ( point.distanceTo( this.center ) - this.radius );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\tconst radiusSum = this.radius + sphere.radius;\n\n\t\treturn sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsSphere( this );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\treturn Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;\n\n\t},\n\n\tclampPoint: function ( point, target ) {\n\n\t\tconst deltaLengthSq = this.center.distanceToSquared( point );\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Sphere: .clampPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.copy( point );\n\n\t\tif ( deltaLengthSq > ( this.radius * this.radius ) ) {\n\n\t\t\ttarget.sub( this.center ).normalize();\n\t\t\ttarget.multiplyScalar( this.radius ).add( this.center );\n\n\t\t}\n\n\t\treturn target;\n\n\t},\n\n\tgetBoundingBox: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );\n\t\t\ttarget = new Box3();\n\n\t\t}\n\n\t\tif ( this.isEmpty() ) {\n\n\t\t\t// Empty sphere produces empty bounding box\n\t\t\ttarget.makeEmpty();\n\t\t\treturn target;\n\n\t\t}\n\n\t\ttarget.set( this.center, this.center );\n\t\ttarget.expandByScalar( this.radius );\n\n\t\treturn target;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tthis.center.applyMatrix4( matrix );\n\t\tthis.radius = this.radius * matrix.getMaxScaleOnAxis();\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.center.add( offset );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( sphere ) {\n\n\t\treturn sphere.center.equals( this.center ) && ( sphere.radius === this.radius );\n\n\t}\n\n} );\n\n\nexport { Sphere };\n","import { Vector3 } from './Vector3.js';\n\nconst _vector = new Vector3();\nconst _segCenter = new Vector3();\nconst _segDir = new Vector3();\nconst _diff = new Vector3();\n\nconst _edge1 = new Vector3();\nconst _edge2 = new Vector3();\nconst _normal = new Vector3();\n\n/**\n * @author bhouston / http://clara.io\n */\n\nfunction Ray( origin, direction ) {\n\n\tthis.origin = ( origin !== undefined ) ? origin : new Vector3();\n\tthis.direction = ( direction !== undefined ) ? direction : new Vector3( 0, 0, - 1 );\n\n}\n\nObject.assign( Ray.prototype, {\n\n\tset: function ( origin, direction ) {\n\n\t\tthis.origin.copy( origin );\n\t\tthis.direction.copy( direction );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( ray ) {\n\n\t\tthis.origin.copy( ray.origin );\n\t\tthis.direction.copy( ray.direction );\n\n\t\treturn this;\n\n\t},\n\n\tat: function ( t, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .at() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.direction ).multiplyScalar( t ).add( this.origin );\n\n\t},\n\n\tlookAt: function ( v ) {\n\n\t\tthis.direction.copy( v ).sub( this.origin ).normalize();\n\n\t\treturn this;\n\n\t},\n\n\trecast: function ( t ) {\n\n\t\tthis.origin.copy( this.at( t, _vector ) );\n\n\t\treturn this;\n\n\t},\n\n\tclosestPointToPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .closestPointToPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.subVectors( point, this.origin );\n\n\t\tconst directionDistance = target.dot( this.direction );\n\n\t\tif ( directionDistance < 0 ) {\n\n\t\t\treturn target.copy( this.origin );\n\n\t\t}\n\n\t\treturn target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn Math.sqrt( this.distanceSqToPoint( point ) );\n\n\t},\n\n\tdistanceSqToPoint: function ( point ) {\n\n\t\tconst directionDistance = _vector.subVectors( point, this.origin ).dot( this.direction );\n\n\t\t// point behind the ray\n\n\t\tif ( directionDistance < 0 ) {\n\n\t\t\treturn this.origin.distanceToSquared( point );\n\n\t\t}\n\n\t\t_vector.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t\treturn _vector.distanceToSquared( point );\n\n\t},\n\n\tdistanceSqToSegment: function ( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {\n\n\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h\n\t\t// It returns the min distance between the ray and the segment\n\t\t// defined by v0 and v1\n\t\t// It can also set two optional targets :\n\t\t// - The closest point on the ray\n\t\t// - The closest point on the segment\n\n\t\t_segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );\n\t\t_segDir.copy( v1 ).sub( v0 ).normalize();\n\t\t_diff.copy( this.origin ).sub( _segCenter );\n\n\t\tconst segExtent = v0.distanceTo( v1 ) * 0.5;\n\t\tconst a01 = - this.direction.dot( _segDir );\n\t\tconst b0 = _diff.dot( this.direction );\n\t\tconst b1 = - _diff.dot( _segDir );\n\t\tconst c = _diff.lengthSq();\n\t\tconst det = Math.abs( 1 - a01 * a01 );\n\t\tlet s0, s1, sqrDist, extDet;\n\n\t\tif ( det > 0 ) {\n\n\t\t\t// The ray and segment are not parallel.\n\n\t\t\ts0 = a01 * b1 - b0;\n\t\t\ts1 = a01 * b0 - b1;\n\t\t\textDet = segExtent * det;\n\n\t\t\tif ( s0 >= 0 ) {\n\n\t\t\t\tif ( s1 >= - extDet ) {\n\n\t\t\t\t\tif ( s1 <= extDet ) {\n\n\t\t\t\t\t\t// region 0\n\t\t\t\t\t\t// Minimum at interior points of ray and segment.\n\n\t\t\t\t\t\tconst invDet = 1 / det;\n\t\t\t\t\t\ts0 *= invDet;\n\t\t\t\t\t\ts1 *= invDet;\n\t\t\t\t\t\tsqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// region 1\n\n\t\t\t\t\t\ts1 = segExtent;\n\t\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// region 5\n\n\t\t\t\t\ts1 = - segExtent;\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( s1 <= - extDet ) {\n\n\t\t\t\t\t// region 4\n\n\t\t\t\t\ts0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );\n\t\t\t\t\ts1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t} else if ( s1 <= extDet ) {\n\n\t\t\t\t\t// region 3\n\n\t\t\t\t\ts0 = 0;\n\t\t\t\t\ts1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// region 2\n\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * segExtent + b0 ) );\n\t\t\t\t\ts1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// Ray and segment are parallel.\n\n\t\t\ts1 = ( a01 > 0 ) ? - segExtent : segExtent;\n\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t}\n\n\t\tif ( optionalPointOnRay ) {\n\n\t\t\toptionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin );\n\n\t\t}\n\n\t\tif ( optionalPointOnSegment ) {\n\n\t\t\toptionalPointOnSegment.copy( _segDir ).multiplyScalar( s1 ).add( _segCenter );\n\n\t\t}\n\n\t\treturn sqrDist;\n\n\t},\n\n\tintersectSphere: function ( sphere, target ) {\n\n\t\t_vector.subVectors( sphere.center, this.origin );\n\t\tconst tca = _vector.dot( this.direction );\n\t\tconst d2 = _vector.dot( _vector ) - tca * tca;\n\t\tconst radius2 = sphere.radius * sphere.radius;\n\n\t\tif ( d2 > radius2 ) return null;\n\n\t\tconst thc = Math.sqrt( radius2 - d2 );\n\n\t\t// t0 = first intersect point - entrance on front of sphere\n\t\tconst t0 = tca - thc;\n\n\t\t// t1 = second intersect point - exit point on back of sphere\n\t\tconst t1 = tca + thc;\n\n\t\t// test to see if both t0 and t1 are behind the ray - if so, return null\n\t\tif ( t0 < 0 && t1 < 0 ) return null;\n\n\t\t// test to see if t0 is behind the ray:\n\t\t// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,\n\t\t// in order to always return an intersect point that is in front of the ray.\n\t\tif ( t0 < 0 ) return this.at( t1, target );\n\n\t\t// else t0 is in front of the ray, so return the first collision point scaled by t0\n\t\treturn this.at( t0, target );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\treturn this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t},\n\n\tdistanceToPlane: function ( plane ) {\n\n\t\tconst denominator = plane.normal.dot( this.direction );\n\n\t\tif ( denominator === 0 ) {\n\n\t\t\t// line is coplanar, return origin\n\t\t\tif ( plane.distanceToPoint( this.origin ) === 0 ) {\n\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\t// Null is preferable to undefined since undefined means.... it is undefined\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\tconst t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;\n\n\t\t// Return if the ray never intersects the plane\n\n\t\treturn t >= 0 ? t : null;\n\n\t},\n\n\tintersectPlane: function ( plane, target ) {\n\n\t\tconst t = this.distanceToPlane( plane );\n\n\t\tif ( t === null ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\treturn this.at( t, target );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\t// check if the ray lies on the plane first\n\n\t\tconst distToPoint = plane.distanceToPoint( this.origin );\n\n\t\tif ( distToPoint === 0 ) {\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\tconst denominator = plane.normal.dot( this.direction );\n\n\t\tif ( denominator * distToPoint < 0 ) {\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\t// ray origin is behind the plane (and is pointing behind it)\n\n\t\treturn false;\n\n\t},\n\n\tintersectBox: function ( box, target ) {\n\n\t\tlet tmin, tmax, tymin, tymax, tzmin, tzmax;\n\n\t\tconst invdirx = 1 / this.direction.x,\n\t\t\tinvdiry = 1 / this.direction.y,\n\t\t\tinvdirz = 1 / this.direction.z;\n\n\t\tconst origin = this.origin;\n\n\t\tif ( invdirx >= 0 ) {\n\n\t\t\ttmin = ( box.min.x - origin.x ) * invdirx;\n\t\t\ttmax = ( box.max.x - origin.x ) * invdirx;\n\n\t\t} else {\n\n\t\t\ttmin = ( box.max.x - origin.x ) * invdirx;\n\t\t\ttmax = ( box.min.x - origin.x ) * invdirx;\n\n\t\t}\n\n\t\tif ( invdiry >= 0 ) {\n\n\t\t\ttymin = ( box.min.y - origin.y ) * invdiry;\n\t\t\ttymax = ( box.max.y - origin.y ) * invdiry;\n\n\t\t} else {\n\n\t\t\ttymin = ( box.max.y - origin.y ) * invdiry;\n\t\t\ttymax = ( box.min.y - origin.y ) * invdiry;\n\n\t\t}\n\n\t\tif ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;\n\n\t\t// These lines also handle the case where tmin or tmax is NaN\n\t\t// (result of 0 * Infinity). x !== x returns true if x is NaN\n\n\t\tif ( tymin > tmin || tmin !== tmin ) tmin = tymin;\n\n\t\tif ( tymax < tmax || tmax !== tmax ) tmax = tymax;\n\n\t\tif ( invdirz >= 0 ) {\n\n\t\t\ttzmin = ( box.min.z - origin.z ) * invdirz;\n\t\t\ttzmax = ( box.max.z - origin.z ) * invdirz;\n\n\t\t} else {\n\n\t\t\ttzmin = ( box.max.z - origin.z ) * invdirz;\n\t\t\ttzmax = ( box.min.z - origin.z ) * invdirz;\n\n\t\t}\n\n\t\tif ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null;\n\n\t\tif ( tzmin > tmin || tmin !== tmin ) tmin = tzmin;\n\n\t\tif ( tzmax < tmax || tmax !== tmax ) tmax = tzmax;\n\n\t\t//return point closest to the ray (positive side)\n\n\t\tif ( tmax < 0 ) return null;\n\n\t\treturn this.at( tmin >= 0 ? tmin : tmax, target );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn this.intersectBox( box, _vector ) !== null;\n\n\t},\n\n\tintersectTriangle: function ( a, b, c, backfaceCulling, target ) {\n\n\t\t// Compute the offset origin, edges, and normal.\n\n\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h\n\n\t\t_edge1.subVectors( b, a );\n\t\t_edge2.subVectors( c, a );\n\t\t_normal.crossVectors( _edge1, _edge2 );\n\n\t\t// Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,\n\t\t// E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by\n\t\t// |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))\n\t\t// |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))\n\t\t// |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)\n\t\tlet DdN = this.direction.dot( _normal );\n\t\tlet sign;\n\n\t\tif ( DdN > 0 ) {\n\n\t\t\tif ( backfaceCulling ) return null;\n\t\t\tsign = 1;\n\n\t\t} else if ( DdN < 0 ) {\n\n\t\t\tsign = - 1;\n\t\t\tDdN = - DdN;\n\n\t\t} else {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t_diff.subVectors( this.origin, a );\n\t\tconst DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) );\n\n\t\t// b1 < 0, no intersection\n\t\tif ( DdQxE2 < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\tconst DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) );\n\n\t\t// b2 < 0, no intersection\n\t\tif ( DdE1xQ < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// b1+b2 > 1, no intersection\n\t\tif ( DdQxE2 + DdE1xQ > DdN ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// Line intersects triangle, check if ray does.\n\t\tconst QdN = - sign * _diff.dot( _normal );\n\n\t\t// t < 0, no intersection\n\t\tif ( QdN < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// Ray intersects triangle.\n\t\treturn this.at( QdN / DdN, target );\n\n\t},\n\n\tapplyMatrix4: function ( matrix4 ) {\n\n\t\tthis.origin.applyMatrix4( matrix4 );\n\t\tthis.direction.transformDirection( matrix4 );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( ray ) {\n\n\t\treturn ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );\n\n\t}\n\n} );\n\n\nexport { Ray };\n","import { Matrix3 } from './Matrix3.js';\nimport { Vector3 } from './Vector3.js';\n\n/**\n * @author bhouston / http://clara.io\n */\n\nconst _vector1 = new Vector3();\nconst _vector2 = new Vector3();\nconst _normalMatrix = new Matrix3();\n\nfunction Plane( normal, constant ) {\n\n\t// normal is assumed to be normalized\n\n\tthis.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );\n\tthis.constant = ( constant !== undefined ) ? constant : 0;\n\n}\n\nObject.assign( Plane.prototype, {\n\n\tisPlane: true,\n\n\tset: function ( normal, constant ) {\n\n\t\tthis.normal.copy( normal );\n\t\tthis.constant = constant;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponents: function ( x, y, z, w ) {\n\n\t\tthis.normal.set( x, y, z );\n\t\tthis.constant = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromNormalAndCoplanarPoint: function ( normal, point ) {\n\n\t\tthis.normal.copy( normal );\n\t\tthis.constant = - point.dot( this.normal );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCoplanarPoints: function ( a, b, c ) {\n\n\t\tconst normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();\n\n\t\t// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?\n\n\t\tthis.setFromNormalAndCoplanarPoint( normal, a );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( plane ) {\n\n\t\tthis.normal.copy( plane.normal );\n\t\tthis.constant = plane.constant;\n\n\t\treturn this;\n\n\t},\n\n\tnormalize: function () {\n\n\t\t// Note: will lead to a divide by zero if the plane is invalid.\n\n\t\tconst inverseNormalLength = 1.0 / this.normal.length();\n\t\tthis.normal.multiplyScalar( inverseNormalLength );\n\t\tthis.constant *= inverseNormalLength;\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.constant *= - 1;\n\t\tthis.normal.negate();\n\n\t\treturn this;\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn this.normal.dot( point ) + this.constant;\n\n\t},\n\n\tdistanceToSphere: function ( sphere ) {\n\n\t\treturn this.distanceToPoint( sphere.center ) - sphere.radius;\n\n\t},\n\n\tprojectPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .projectPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );\n\n\t},\n\n\tintersectLine: function ( line, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .intersectLine() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tconst direction = line.delta( _vector1 );\n\n\t\tconst denominator = this.normal.dot( direction );\n\n\t\tif ( denominator === 0 ) {\n\n\t\t\t// line is coplanar, return origin\n\t\t\tif ( this.distanceToPoint( line.start ) === 0 ) {\n\n\t\t\t\treturn target.copy( line.start );\n\n\t\t\t}\n\n\t\t\t// Unsure if this is the correct method to handle this case.\n\t\t\treturn undefined;\n\n\t\t}\n\n\t\tconst t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;\n\n\t\tif ( t < 0 || t > 1 ) {\n\n\t\t\treturn undefined;\n\n\t\t}\n\n\t\treturn target.copy( direction ).multiplyScalar( t ).add( line.start );\n\n\t},\n\n\tintersectsLine: function ( line ) {\n\n\t\t// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.\n\n\t\tconst startSign = this.distanceToPoint( line.start );\n\t\tconst endSign = this.distanceToPoint( line.end );\n\n\t\treturn ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsPlane( this );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\treturn sphere.intersectsPlane( this );\n\n\t},\n\n\tcoplanarPoint: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .coplanarPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.normal ).multiplyScalar( - this.constant );\n\n\t},\n\n\tapplyMatrix4: function ( matrix, optionalNormalMatrix ) {\n\n\t\tconst normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );\n\n\t\tconst referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );\n\n\t\tconst normal = this.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\tthis.constant = - referencePoint.dot( normal );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.constant -= offset.dot( this.normal );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( plane ) {\n\n\t\treturn plane.normal.equals( this.normal ) && ( plane.constant === this.constant );\n\n\t}\n\n} );\n\n\nexport { Plane };\n","import { Vector3 } from './Vector3.js';\nimport { Plane } from './Plane.js';\n\n/**\n * @author bhouston / http://clara.io\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _v0 = new Vector3();\nconst _v1 = new Vector3();\nconst _v2 = new Vector3();\nconst _v3 = new Vector3();\n\nconst _vab = new Vector3();\nconst _vac = new Vector3();\nconst _vbc = new Vector3();\nconst _vap = new Vector3();\nconst _vbp = new Vector3();\nconst _vcp = new Vector3();\n\nfunction Triangle( a, b, c ) {\n\n\tthis.a = ( a !== undefined ) ? a : new Vector3();\n\tthis.b = ( b !== undefined ) ? b : new Vector3();\n\tthis.c = ( c !== undefined ) ? c : new Vector3();\n\n}\n\nObject.assign( Triangle, {\n\n\tgetNormal: function ( a, b, c, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getNormal() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.subVectors( c, b );\n\t\t_v0.subVectors( a, b );\n\t\ttarget.cross( _v0 );\n\n\t\tconst targetLengthSq = target.lengthSq();\n\t\tif ( targetLengthSq > 0 ) {\n\n\t\t\treturn target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );\n\n\t\t}\n\n\t\treturn target.set( 0, 0, 0 );\n\n\t},\n\n\t// static/instance method to calculate barycentric coordinates\n\t// based on: http://www.blackpawn.com/texts/pointinpoly/default.html\n\tgetBarycoord: function ( point, a, b, c, target ) {\n\n\t\t_v0.subVectors( c, a );\n\t\t_v1.subVectors( b, a );\n\t\t_v2.subVectors( point, a );\n\n\t\tconst dot00 = _v0.dot( _v0 );\n\t\tconst dot01 = _v0.dot( _v1 );\n\t\tconst dot02 = _v0.dot( _v2 );\n\t\tconst dot11 = _v1.dot( _v1 );\n\t\tconst dot12 = _v1.dot( _v2 );\n\n\t\tconst denom = ( dot00 * dot11 - dot01 * dot01 );\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getBarycoord() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\t// collinear or singular triangle\n\t\tif ( denom === 0 ) {\n\n\t\t\t// arbitrary location outside of triangle?\n\t\t\t// not sure if this is the best idea, maybe should be returning undefined\n\t\t\treturn target.set( - 2, - 1, - 1 );\n\n\t\t}\n\n\t\tconst invDenom = 1 / denom;\n\t\tconst u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;\n\t\tconst v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;\n\n\t\t// barycentric coordinates must always sum to 1\n\t\treturn target.set( 1 - u - v, v, u );\n\n\t},\n\n\tcontainsPoint: function ( point, a, b, c ) {\n\n\t\tTriangle.getBarycoord( point, a, b, c, _v3 );\n\n\t\treturn ( _v3.x >= 0 ) && ( _v3.y >= 0 ) && ( ( _v3.x + _v3.y ) <= 1 );\n\n\t},\n\n\tgetUV: function ( point, p1, p2, p3, uv1, uv2, uv3, target ) {\n\n\t\tthis.getBarycoord( point, p1, p2, p3, _v3 );\n\n\t\ttarget.set( 0, 0 );\n\t\ttarget.addScaledVector( uv1, _v3.x );\n\t\ttarget.addScaledVector( uv2, _v3.y );\n\t\ttarget.addScaledVector( uv3, _v3.z );\n\n\t\treturn target;\n\n\t},\n\n\tisFrontFacing: function ( a, b, c, direction ) {\n\n\t\t_v0.subVectors( c, b );\n\t\t_v1.subVectors( a, b );\n\n\t\t// strictly front facing\n\t\treturn ( _v0.cross( _v1 ).dot( direction ) < 0 ) ? true : false;\n\n\t}\n\n} );\n\nObject.assign( Triangle.prototype, {\n\n\tset: function ( a, b, c ) {\n\n\t\tthis.a.copy( a );\n\t\tthis.b.copy( b );\n\t\tthis.c.copy( c );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPointsAndIndices: function ( points, i0, i1, i2 ) {\n\n\t\tthis.a.copy( points[ i0 ] );\n\t\tthis.b.copy( points[ i1 ] );\n\t\tthis.c.copy( points[ i2 ] );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( triangle ) {\n\n\t\tthis.a.copy( triangle.a );\n\t\tthis.b.copy( triangle.b );\n\t\tthis.c.copy( triangle.c );\n\n\t\treturn this;\n\n\t},\n\n\tgetArea: function () {\n\n\t\t_v0.subVectors( this.c, this.b );\n\t\t_v1.subVectors( this.a, this.b );\n\n\t\treturn _v0.cross( _v1 ).length() * 0.5;\n\n\t},\n\n\tgetMidpoint: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getMidpoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 );\n\n\t},\n\n\tgetNormal: function ( target ) {\n\n\t\treturn Triangle.getNormal( this.a, this.b, this.c, target );\n\n\t},\n\n\tgetPlane: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getPlane() target is now required' );\n\t\t\ttarget = new Plane();\n\n\t\t}\n\n\t\treturn target.setFromCoplanarPoints( this.a, this.b, this.c );\n\n\t},\n\n\tgetBarycoord: function ( point, target ) {\n\n\t\treturn Triangle.getBarycoord( point, this.a, this.b, this.c, target );\n\n\t},\n\n\tgetUV: function ( point, uv1, uv2, uv3, target ) {\n\n\t\treturn Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, target );\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn Triangle.containsPoint( point, this.a, this.b, this.c );\n\n\t},\n\n\tisFrontFacing: function ( direction ) {\n\n\t\treturn Triangle.isFrontFacing( this.a, this.b, this.c, direction );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsTriangle( this );\n\n\t},\n\n\tclosestPointToPoint: function ( p, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tconst a = this.a, b = this.b, c = this.c;\n\t\tlet v, w;\n\n\t\t// algorithm thanks to Real-Time Collision Detection by Christer Ericson,\n\t\t// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,\n\t\t// under the accompanying license; see chapter 5.1.5 for detailed explanation.\n\t\t// basically, we're distinguishing which of the voronoi regions of the triangle\n\t\t// the point lies in with the minimum amount of redundant computation.\n\n\t\t_vab.subVectors( b, a );\n\t\t_vac.subVectors( c, a );\n\t\t_vap.subVectors( p, a );\n\t\tconst d1 = _vab.dot( _vap );\n\t\tconst d2 = _vac.dot( _vap );\n\t\tif ( d1 <= 0 && d2 <= 0 ) {\n\n\t\t\t// vertex region of A; barycentric coords (1, 0, 0)\n\t\t\treturn target.copy( a );\n\n\t\t}\n\n\t\t_vbp.subVectors( p, b );\n\t\tconst d3 = _vab.dot( _vbp );\n\t\tconst d4 = _vac.dot( _vbp );\n\t\tif ( d3 >= 0 && d4 <= d3 ) {\n\n\t\t\t// vertex region of B; barycentric coords (0, 1, 0)\n\t\t\treturn target.copy( b );\n\n\t\t}\n\n\t\tconst vc = d1 * d4 - d3 * d2;\n\t\tif ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {\n\n\t\t\tv = d1 / ( d1 - d3 );\n\t\t\t// edge region of AB; barycentric coords (1-v, v, 0)\n\t\t\treturn target.copy( a ).addScaledVector( _vab, v );\n\n\t\t}\n\n\t\t_vcp.subVectors( p, c );\n\t\tconst d5 = _vab.dot( _vcp );\n\t\tconst d6 = _vac.dot( _vcp );\n\t\tif ( d6 >= 0 && d5 <= d6 ) {\n\n\t\t\t// vertex region of C; barycentric coords (0, 0, 1)\n\t\t\treturn target.copy( c );\n\n\t\t}\n\n\t\tconst vb = d5 * d2 - d1 * d6;\n\t\tif ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {\n\n\t\t\tw = d2 / ( d2 - d6 );\n\t\t\t// edge region of AC; barycentric coords (1-w, 0, w)\n\t\t\treturn target.copy( a ).addScaledVector( _vac, w );\n\n\t\t}\n\n\t\tconst va = d3 * d6 - d5 * d4;\n\t\tif ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {\n\n\t\t\t_vbc.subVectors( c, b );\n\t\t\tw = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );\n\t\t\t// edge region of BC; barycentric coords (0, 1-w, w)\n\t\t\treturn target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC\n\n\t\t}\n\n\t\t// face region\n\t\tconst denom = 1 / ( va + vb + vc );\n\t\t// u = va * denom\n\t\tv = vb * denom;\n\t\tw = vc * denom;\n\n\t\treturn target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w );\n\n\t},\n\n\tequals: function ( triangle ) {\n\n\t\treturn triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c );\n\n\t}\n\n} );\n\n\nexport { Triangle };\n","import { MathUtils } from './MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,\n\t'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,\n\t'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,\n\t'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,\n\t'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B,\n\t'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F,\n\t'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3,\n\t'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222,\n\t'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700,\n\t'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4,\n\t'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00,\n\t'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3,\n\t'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA,\n\t'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32,\n\t'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3,\n\t'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC,\n\t'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD,\n\t'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6,\n\t'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9,\n\t'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F,\n\t'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE,\n\t'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA,\n\t'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,\n\t'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };\n\nconst _hslA = { h: 0, s: 0, l: 0 };\nconst _hslB = { h: 0, s: 0, l: 0 };\n\nfunction Color( r, g, b ) {\n\n\tif ( g === undefined && b === undefined ) {\n\n\t\t// r is THREE.Color, hex or string\n\t\treturn this.set( r );\n\n\t}\n\n\treturn this.setRGB( r, g, b );\n\n}\n\nfunction hue2rgb( p, q, t ) {\n\n\tif ( t < 0 ) t += 1;\n\tif ( t > 1 ) t -= 1;\n\tif ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;\n\tif ( t < 1 / 2 ) return q;\n\tif ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );\n\treturn p;\n\n}\n\nfunction SRGBToLinear( c ) {\n\n\treturn ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n}\n\nfunction LinearToSRGB( c ) {\n\n\treturn ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;\n\n}\n\nObject.assign( Color.prototype, {\n\n\tisColor: true,\n\n\tr: 1, g: 1, b: 1,\n\n\tset: function ( value ) {\n\n\t\tif ( value && value.isColor ) {\n\n\t\t\tthis.copy( value );\n\n\t\t} else if ( typeof value === 'number' ) {\n\n\t\t\tthis.setHex( value );\n\n\t\t} else if ( typeof value === 'string' ) {\n\n\t\t\tthis.setStyle( value );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.r = scalar;\n\t\tthis.g = scalar;\n\t\tthis.b = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetHex: function ( hex ) {\n\n\t\thex = Math.floor( hex );\n\n\t\tthis.r = ( hex >> 16 & 255 ) / 255;\n\t\tthis.g = ( hex >> 8 & 255 ) / 255;\n\t\tthis.b = ( hex & 255 ) / 255;\n\n\t\treturn this;\n\n\t},\n\n\tsetRGB: function ( r, g, b ) {\n\n\t\tthis.r = r;\n\t\tthis.g = g;\n\t\tthis.b = b;\n\n\t\treturn this;\n\n\t},\n\n\tsetHSL: function ( h, s, l ) {\n\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\th = MathUtils.euclideanModulo( h, 1 );\n\t\ts = MathUtils.clamp( s, 0, 1 );\n\t\tl = MathUtils.clamp( l, 0, 1 );\n\n\t\tif ( s === 0 ) {\n\n\t\t\tthis.r = this.g = this.b = l;\n\n\t\t} else {\n\n\t\t\tconst p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );\n\t\t\tconst q = ( 2 * l ) - p;\n\n\t\t\tthis.r = hue2rgb( q, p, h + 1 / 3 );\n\t\t\tthis.g = hue2rgb( q, p, h );\n\t\t\tthis.b = hue2rgb( q, p, h - 1 / 3 );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetStyle: function ( style ) {\n\n\t\tfunction handleAlpha( string ) {\n\n\t\t\tif ( string === undefined ) return;\n\n\t\t\tif ( parseFloat( string ) < 1 ) {\n\n\t\t\t\tconsole.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );\n\n\t\t\t}\n\n\t\t}\n\n\n\t\tlet m;\n\n\t\tif ( m = /^((?:rgb|hsl)a?)\\(\\s*([^\\)]*)\\)/.exec( style ) ) {\n\n\t\t\t// rgb / hsl\n\n\t\t\tlet color;\n\t\t\tconst name = m[ 1 ];\n\t\t\tconst components = m[ 2 ];\n\n\t\t\tswitch ( name ) {\n\n\t\t\t\tcase 'rgb':\n\t\t\t\tcase 'rgba':\n\n\t\t\t\t\tif ( color = /^(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// rgb(255,0,0) rgba(255,0,0,0.5)\n\t\t\t\t\t\tthis.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;\n\t\t\t\t\t\tthis.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;\n\t\t\t\t\t\tthis.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( color = /^(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)\n\t\t\t\t\t\tthis.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;\n\t\t\t\t\t\tthis.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;\n\t\t\t\t\t\tthis.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'hsl':\n\t\t\t\tcase 'hsla':\n\n\t\t\t\t\tif ( color = /^([0-9]*\\.?[0-9]+)\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// hsl(120,50%,50%) hsla(120,50%,50%,0.5)\n\t\t\t\t\t\tconst h = parseFloat( color[ 1 ] ) / 360;\n\t\t\t\t\t\tconst s = parseInt( color[ 2 ], 10 ) / 100;\n\t\t\t\t\t\tconst l = parseInt( color[ 3 ], 10 ) / 100;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this.setHSL( h, s, l );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t} else if ( m = /^\\#([A-Fa-f0-9]+)$/.exec( style ) ) {\n\n\t\t\t// hex color\n\n\t\t\tconst hex = m[ 1 ];\n\t\t\tconst size = hex.length;\n\n\t\t\tif ( size === 3 ) {\n\n\t\t\t\t// #ff0\n\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;\n\t\t\t\tthis.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\tthis.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;\n\n\t\t\t\treturn this;\n\n\t\t\t} else if ( size === 6 ) {\n\n\t\t\t\t// #ff0000\n\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\tthis.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;\n\t\t\t\tthis.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;\n\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( style && style.length > 0 ) {\n\n\t\t\treturn this.setColorName( style );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetColorName: function ( style ) {\n\n\t\t// color keywords\n\t\tconst hex = _colorKeywords[ style ];\n\n\t\tif ( hex !== undefined ) {\n\n\t\t\t// red\n\t\t\tthis.setHex( hex );\n\n\t\t} else {\n\n\t\t\t// unknown color\n\t\t\tconsole.warn( 'THREE.Color: Unknown color ' + style );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.r, this.g, this.b );\n\n\t},\n\n\tcopy: function ( color ) {\n\n\t\tthis.r = color.r;\n\t\tthis.g = color.g;\n\t\tthis.b = color.b;\n\n\t\treturn this;\n\n\t},\n\n\tcopyGammaToLinear: function ( color, gammaFactor ) {\n\n\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\tthis.r = Math.pow( color.r, gammaFactor );\n\t\tthis.g = Math.pow( color.g, gammaFactor );\n\t\tthis.b = Math.pow( color.b, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tcopyLinearToGamma: function ( color, gammaFactor ) {\n\n\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\tconst safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;\n\n\t\tthis.r = Math.pow( color.r, safeInverse );\n\t\tthis.g = Math.pow( color.g, safeInverse );\n\t\tthis.b = Math.pow( color.b, safeInverse );\n\n\t\treturn this;\n\n\t},\n\n\tconvertGammaToLinear: function ( gammaFactor ) {\n\n\t\tthis.copyGammaToLinear( this, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tconvertLinearToGamma: function ( gammaFactor ) {\n\n\t\tthis.copyLinearToGamma( this, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tcopySRGBToLinear: function ( color ) {\n\n\t\tthis.r = SRGBToLinear( color.r );\n\t\tthis.g = SRGBToLinear( color.g );\n\t\tthis.b = SRGBToLinear( color.b );\n\n\t\treturn this;\n\n\t},\n\n\tcopyLinearToSRGB: function ( color ) {\n\n\t\tthis.r = LinearToSRGB( color.r );\n\t\tthis.g = LinearToSRGB( color.g );\n\t\tthis.b = LinearToSRGB( color.b );\n\n\t\treturn this;\n\n\t},\n\n\tconvertSRGBToLinear: function () {\n\n\t\tthis.copySRGBToLinear( this );\n\n\t\treturn this;\n\n\t},\n\n\tconvertLinearToSRGB: function () {\n\n\t\tthis.copyLinearToSRGB( this );\n\n\t\treturn this;\n\n\t},\n\n\tgetHex: function () {\n\n\t\treturn ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;\n\n\t},\n\n\tgetHexString: function () {\n\n\t\treturn ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );\n\n\t},\n\n\tgetHSL: function ( target ) {\n\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Color: .getHSL() target is now required' );\n\t\t\ttarget = { h: 0, s: 0, l: 0 };\n\n\t\t}\n\n\t\tconst r = this.r, g = this.g, b = this.b;\n\n\t\tconst max = Math.max( r, g, b );\n\t\tconst min = Math.min( r, g, b );\n\n\t\tlet hue, saturation;\n\t\tconst lightness = ( min + max ) / 2.0;\n\n\t\tif ( min === max ) {\n\n\t\t\thue = 0;\n\t\t\tsaturation = 0;\n\n\t\t} else {\n\n\t\t\tconst delta = max - min;\n\n\t\t\tsaturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );\n\n\t\t\tswitch ( max ) {\n\n\t\t\t\tcase r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;\n\t\t\t\tcase g: hue = ( b - r ) / delta + 2; break;\n\t\t\t\tcase b: hue = ( r - g ) / delta + 4; break;\n\n\t\t\t}\n\n\t\t\thue /= 6;\n\n\t\t}\n\n\t\ttarget.h = hue;\n\t\ttarget.s = saturation;\n\t\ttarget.l = lightness;\n\n\t\treturn target;\n\n\t},\n\n\tgetStyle: function () {\n\n\t\treturn 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';\n\n\t},\n\n\toffsetHSL: function ( h, s, l ) {\n\n\t\tthis.getHSL( _hslA );\n\n\t\t_hslA.h += h; _hslA.s += s; _hslA.l += l;\n\n\t\tthis.setHSL( _hslA.h, _hslA.s, _hslA.l );\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( color ) {\n\n\t\tthis.r += color.r;\n\t\tthis.g += color.g;\n\t\tthis.b += color.b;\n\n\t\treturn this;\n\n\t},\n\n\taddColors: function ( color1, color2 ) {\n\n\t\tthis.r = color1.r + color2.r;\n\t\tthis.g = color1.g + color2.g;\n\t\tthis.b = color1.b + color2.b;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.r += s;\n\t\tthis.g += s;\n\t\tthis.b += s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( color ) {\n\n\t\tthis.r = Math.max( 0, this.r - color.r );\n\t\tthis.g = Math.max( 0, this.g - color.g );\n\t\tthis.b = Math.max( 0, this.b - color.b );\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( color ) {\n\n\t\tthis.r *= color.r;\n\t\tthis.g *= color.g;\n\t\tthis.b *= color.b;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tthis.r *= s;\n\t\tthis.g *= s;\n\t\tthis.b *= s;\n\n\t\treturn this;\n\n\t},\n\n\tlerp: function ( color, alpha ) {\n\n\t\tthis.r += ( color.r - this.r ) * alpha;\n\t\tthis.g += ( color.g - this.g ) * alpha;\n\t\tthis.b += ( color.b - this.b ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpHSL: function ( color, alpha ) {\n\n\t\tthis.getHSL( _hslA );\n\t\tcolor.getHSL( _hslB );\n\n\t\tconst h = MathUtils.lerp( _hslA.h, _hslB.h, alpha );\n\t\tconst s = MathUtils.lerp( _hslA.s, _hslB.s, alpha );\n\t\tconst l = MathUtils.lerp( _hslA.l, _hslB.l, alpha );\n\n\t\tthis.setHSL( h, s, l );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( c ) {\n\n\t\treturn ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.r = array[ offset ];\n\t\tthis.g = array[ offset + 1 ];\n\t\tthis.b = array[ offset + 2 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.r;\n\t\tarray[ offset + 1 ] = this.g;\n\t\tarray[ offset + 2 ] = this.b;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index ) {\n\n\t\tthis.r = attribute.getX( index );\n\t\tthis.g = attribute.getY( index );\n\t\tthis.b = attribute.getZ( index );\n\n\t\tif ( attribute.normalized === true ) {\n\n\t\t\t// assuming Uint8Array\n\n\t\t\tthis.r /= 255;\n\t\t\tthis.g /= 255;\n\t\t\tthis.b /= 255;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\treturn this.getHex();\n\n\t}\n\n} );\n\nColor.NAMES = _colorKeywords;\n\nexport { Color };\n","import { Color } from '../math/Color.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction Face3( a, b, c, normal, color, materialIndex ) {\n\n\tthis.a = a;\n\tthis.b = b;\n\tthis.c = c;\n\n\tthis.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();\n\tthis.vertexNormals = Array.isArray( normal ) ? normal : [];\n\n\tthis.color = ( color && color.isColor ) ? color : new Color();\n\tthis.vertexColors = Array.isArray( color ) ? color : [];\n\n\tthis.materialIndex = materialIndex !== undefined ? materialIndex : 0;\n\n}\n\nObject.assign( Face3.prototype, {\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.a = source.a;\n\t\tthis.b = source.b;\n\t\tthis.c = source.c;\n\n\t\tthis.normal.copy( source.normal );\n\t\tthis.color.copy( source.color );\n\n\t\tthis.materialIndex = source.materialIndex;\n\n\t\tfor ( let i = 0, il = source.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\tthis.vertexNormals[ i ] = source.vertexNormals[ i ].clone();\n\n\t\t}\n\n\t\tfor ( let i = 0, il = source.vertexColors.length; i < il; i ++ ) {\n\n\t\t\tthis.vertexColors[ i ] = source.vertexColors[ i ].clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Face3 };\n","import { EventDispatcher } from '../core/EventDispatcher.js';\nimport { FrontSide, FlatShading, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nlet materialId = 0;\n\nfunction Material() {\n\n\tObject.defineProperty( this, 'id', { value: materialId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Material';\n\n\tthis.fog = true;\n\n\tthis.blending = NormalBlending;\n\tthis.side = FrontSide;\n\tthis.flatShading = false;\n\tthis.vertexColors = false;\n\n\tthis.opacity = 1;\n\tthis.transparent = false;\n\n\tthis.blendSrc = SrcAlphaFactor;\n\tthis.blendDst = OneMinusSrcAlphaFactor;\n\tthis.blendEquation = AddEquation;\n\tthis.blendSrcAlpha = null;\n\tthis.blendDstAlpha = null;\n\tthis.blendEquationAlpha = null;\n\n\tthis.depthFunc = LessEqualDepth;\n\tthis.depthTest = true;\n\tthis.depthWrite = true;\n\n\tthis.stencilWriteMask = 0xff;\n\tthis.stencilFunc = AlwaysStencilFunc;\n\tthis.stencilRef = 0;\n\tthis.stencilFuncMask = 0xff;\n\tthis.stencilFail = KeepStencilOp;\n\tthis.stencilZFail = KeepStencilOp;\n\tthis.stencilZPass = KeepStencilOp;\n\tthis.stencilWrite = false;\n\n\tthis.clippingPlanes = null;\n\tthis.clipIntersection = false;\n\tthis.clipShadows = false;\n\n\tthis.shadowSide = null;\n\n\tthis.colorWrite = true;\n\n\tthis.precision = null; // override the renderer's default precision for this material\n\n\tthis.polygonOffset = false;\n\tthis.polygonOffsetFactor = 0;\n\tthis.polygonOffsetUnits = 0;\n\n\tthis.dithering = false;\n\n\tthis.alphaTest = 0;\n\tthis.premultipliedAlpha = false;\n\n\tthis.visible = true;\n\n\tthis.toneMapped = true;\n\n\tthis.userData = {};\n\n\tthis.version = 0;\n\n}\n\nMaterial.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Material,\n\n\tisMaterial: true,\n\n\tonBeforeCompile: function ( /* shaderobject, renderer */ ) {},\n\n\tcustomProgramCacheKey: function () {\n\n\t\treturn this.onBeforeCompile.toString();\n\n\t},\n\n\tsetValues: function ( values ) {\n\n\t\tif ( values === undefined ) return;\n\n\t\tfor ( const key in values ) {\n\n\t\t\tconst newValue = values[ key ];\n\n\t\t\tif ( newValue === undefined ) {\n\n\t\t\t\tconsole.warn( \"THREE.Material: '\" + key + \"' parameter is undefined.\" );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\t// for backward compatability if shading is set in the constructor\n\t\t\tif ( key === 'shading' ) {\n\n\t\t\t\tconsole.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );\n\t\t\t\tthis.flatShading = ( newValue === FlatShading ) ? true : false;\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tconst currentValue = this[ key ];\n\n\t\t\tif ( currentValue === undefined ) {\n\n\t\t\t\tconsole.warn( \"THREE.\" + this.type + \": '\" + key + \"' is not a property of this material.\" );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tif ( currentValue && currentValue.isColor ) {\n\n\t\t\t\tcurrentValue.set( newValue );\n\n\t\t\t} else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {\n\n\t\t\t\tcurrentValue.copy( newValue );\n\n\t\t\t} else {\n\n\t\t\t\tthis[ key ] = newValue;\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst isRoot = ( meta === undefined || typeof meta === 'string' );\n\n\t\tif ( isRoot ) {\n\n\t\t\tmeta = {\n\t\t\t\ttextures: {},\n\t\t\t\timages: {}\n\t\t\t};\n\n\t\t}\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Material',\n\t\t\t\tgenerator: 'Material.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard Material serialization\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\n\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\tif ( this.color && this.color.isColor ) data.color = this.color.getHex();\n\n\t\tif ( this.roughness !== undefined ) data.roughness = this.roughness;\n\t\tif ( this.metalness !== undefined ) data.metalness = this.metalness;\n\n\t\tif ( this.sheen && this.sheen.isColor ) data.sheen = this.sheen.getHex();\n\t\tif ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();\n\t\tif ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;\n\n\t\tif ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();\n\t\tif ( this.shininess !== undefined ) data.shininess = this.shininess;\n\t\tif ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;\n\t\tif ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;\n\n\t\tif ( this.clearcoatMap && this.clearcoatMap.isTexture ) {\n\n\t\t\tdata.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {\n\n\t\t\tdata.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {\n\n\t\t\tdata.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;\n\t\t\tdata.clearcoatNormalScale = this.clearcoatNormalScale.toArray();\n\n\t\t}\n\n\t\tif ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;\n\t\tif ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;\n\t\tif ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;\n\t\tif ( this.lightMap && this.lightMap.isTexture ) data.lightMap = this.lightMap.toJSON( meta ).uuid;\n\n\t\tif ( this.aoMap && this.aoMap.isTexture ) {\n\n\t\t\tdata.aoMap = this.aoMap.toJSON( meta ).uuid;\n\t\t\tdata.aoMapIntensity = this.aoMapIntensity;\n\n\t\t}\n\n\t\tif ( this.bumpMap && this.bumpMap.isTexture ) {\n\n\t\t\tdata.bumpMap = this.bumpMap.toJSON( meta ).uuid;\n\t\t\tdata.bumpScale = this.bumpScale;\n\n\t\t}\n\n\t\tif ( this.normalMap && this.normalMap.isTexture ) {\n\n\t\t\tdata.normalMap = this.normalMap.toJSON( meta ).uuid;\n\t\t\tdata.normalMapType = this.normalMapType;\n\t\t\tdata.normalScale = this.normalScale.toArray();\n\n\t\t}\n\n\t\tif ( this.displacementMap && this.displacementMap.isTexture ) {\n\n\t\t\tdata.displacementMap = this.displacementMap.toJSON( meta ).uuid;\n\t\t\tdata.displacementScale = this.displacementScale;\n\t\t\tdata.displacementBias = this.displacementBias;\n\n\t\t}\n\n\t\tif ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;\n\t\tif ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;\n\n\t\tif ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;\n\t\tif ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;\n\n\t\tif ( this.envMap && this.envMap.isTexture ) {\n\n\t\t\tdata.envMap = this.envMap.toJSON( meta ).uuid;\n\t\t\tdata.reflectivity = this.reflectivity; // Scale behind envMap\n\t\t\tdata.refractionRatio = this.refractionRatio;\n\n\t\t\tif ( this.combine !== undefined ) data.combine = this.combine;\n\t\t\tif ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;\n\n\t\t}\n\n\t\tif ( this.gradientMap && this.gradientMap.isTexture ) {\n\n\t\t\tdata.gradientMap = this.gradientMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.size !== undefined ) data.size = this.size;\n\t\tif ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;\n\n\t\tif ( this.blending !== NormalBlending ) data.blending = this.blending;\n\t\tif ( this.flatShading === true ) data.flatShading = this.flatShading;\n\t\tif ( this.side !== FrontSide ) data.side = this.side;\n\t\tif ( this.vertexColors ) data.vertexColors = true;\n\n\t\tif ( this.opacity < 1 ) data.opacity = this.opacity;\n\t\tif ( this.transparent === true ) data.transparent = this.transparent;\n\n\t\tdata.depthFunc = this.depthFunc;\n\t\tdata.depthTest = this.depthTest;\n\t\tdata.depthWrite = this.depthWrite;\n\n\t\tdata.stencilWrite = this.stencilWrite;\n\t\tdata.stencilWriteMask = this.stencilWriteMask;\n\t\tdata.stencilFunc = this.stencilFunc;\n\t\tdata.stencilRef = this.stencilRef;\n\t\tdata.stencilFuncMask = this.stencilFuncMask;\n\t\tdata.stencilFail = this.stencilFail;\n\t\tdata.stencilZFail = this.stencilZFail;\n\t\tdata.stencilZPass = this.stencilZPass;\n\n\t\t// rotation (SpriteMaterial)\n\t\tif ( this.rotation && this.rotation !== 0 ) data.rotation = this.rotation;\n\n\t\tif ( this.polygonOffset === true ) data.polygonOffset = true;\n\t\tif ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;\n\t\tif ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;\n\n\t\tif ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth;\n\t\tif ( this.dashSize !== undefined ) data.dashSize = this.dashSize;\n\t\tif ( this.gapSize !== undefined ) data.gapSize = this.gapSize;\n\t\tif ( this.scale !== undefined ) data.scale = this.scale;\n\n\t\tif ( this.dithering === true ) data.dithering = true;\n\n\t\tif ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;\n\t\tif ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;\n\n\t\tif ( this.wireframe === true ) data.wireframe = this.wireframe;\n\t\tif ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;\n\t\tif ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;\n\t\tif ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;\n\n\t\tif ( this.morphTargets === true ) data.morphTargets = true;\n\t\tif ( this.morphNormals === true ) data.morphNormals = true;\n\t\tif ( this.skinning === true ) data.skinning = true;\n\n\t\tif ( this.visible === false ) data.visible = false;\n\n\t\tif ( this.toneMapped === false ) data.toneMapped = false;\n\n\t\tif ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;\n\n\t\t// TODO: Copied from Object3D.toJSON\n\n\t\tfunction extractFromCache( cache ) {\n\n\t\t\tconst values = [];\n\n\t\t\tfor ( const key in cache ) {\n\n\t\t\t\tconst data = cache[ key ];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push( data );\n\n\t\t\t}\n\n\t\t\treturn values;\n\n\t\t}\n\n\t\tif ( isRoot ) {\n\n\t\t\tconst textures = extractFromCache( meta.textures );\n\t\t\tconst images = extractFromCache( meta.images );\n\n\t\t\tif ( textures.length > 0 ) data.textures = textures;\n\t\t\tif ( images.length > 0 ) data.images = images;\n\n\t\t}\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\n\t\tthis.fog = source.fog;\n\n\t\tthis.blending = source.blending;\n\t\tthis.side = source.side;\n\t\tthis.flatShading = source.flatShading;\n\t\tthis.vertexColors = source.vertexColors;\n\n\t\tthis.opacity = source.opacity;\n\t\tthis.transparent = source.transparent;\n\n\t\tthis.blendSrc = source.blendSrc;\n\t\tthis.blendDst = source.blendDst;\n\t\tthis.blendEquation = source.blendEquation;\n\t\tthis.blendSrcAlpha = source.blendSrcAlpha;\n\t\tthis.blendDstAlpha = source.blendDstAlpha;\n\t\tthis.blendEquationAlpha = source.blendEquationAlpha;\n\n\t\tthis.depthFunc = source.depthFunc;\n\t\tthis.depthTest = source.depthTest;\n\t\tthis.depthWrite = source.depthWrite;\n\n\t\tthis.stencilWriteMask = source.stencilWriteMask;\n\t\tthis.stencilFunc = source.stencilFunc;\n\t\tthis.stencilRef = source.stencilRef;\n\t\tthis.stencilFuncMask = source.stencilFuncMask;\n\t\tthis.stencilFail = source.stencilFail;\n\t\tthis.stencilZFail = source.stencilZFail;\n\t\tthis.stencilZPass = source.stencilZPass;\n\t\tthis.stencilWrite = source.stencilWrite;\n\n\t\tconst srcPlanes = source.clippingPlanes;\n\t\tlet dstPlanes = null;\n\n\t\tif ( srcPlanes !== null ) {\n\n\t\t\tconst n = srcPlanes.length;\n\t\t\tdstPlanes = new Array( n );\n\n\t\t\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\t\t\tdstPlanes[ i ] = srcPlanes[ i ].clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.clippingPlanes = dstPlanes;\n\t\tthis.clipIntersection = source.clipIntersection;\n\t\tthis.clipShadows = source.clipShadows;\n\n\t\tthis.shadowSide = source.shadowSide;\n\n\t\tthis.colorWrite = source.colorWrite;\n\n\t\tthis.precision = source.precision;\n\n\t\tthis.polygonOffset = source.polygonOffset;\n\t\tthis.polygonOffsetFactor = source.polygonOffsetFactor;\n\t\tthis.polygonOffsetUnits = source.polygonOffsetUnits;\n\n\t\tthis.dithering = source.dithering;\n\n\t\tthis.alphaTest = source.alphaTest;\n\t\tthis.premultipliedAlpha = source.premultipliedAlpha;\n\n\t\tthis.visible = source.visible;\n\n\t\tthis.toneMapped = source.toneMapped;\n\n\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\nObject.defineProperty( Material.prototype, 'needsUpdate', {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\nexport { Material };\n","import { Material } from './Material.js';\nimport { MultiplyOperation } from '../constants.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n * map: new THREE.Texture( ),\n *\n * lightMap: new THREE.Texture( ),\n * lightMapIntensity: \n *\n * aoMap: new THREE.Texture( ),\n * aoMapIntensity: \n *\n * specularMap: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n * combine: THREE.Multiply,\n * reflectivity: ,\n * refractionRatio: ,\n *\n * depthTest: ,\n * depthWrite: ,\n *\n * wireframe: ,\n * wireframeLinewidth: ,\n *\n * skinning: ,\n * morphTargets: \n * }\n */\n\nfunction MeshBasicMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshBasicMaterial';\n\n\tthis.color = new Color( 0xffffff ); // emissive\n\n\tthis.map = null;\n\n\tthis.lightMap = null;\n\tthis.lightMapIntensity = 1.0;\n\n\tthis.aoMap = null;\n\tthis.aoMapIntensity = 1.0;\n\n\tthis.specularMap = null;\n\n\tthis.alphaMap = null;\n\n\tthis.envMap = null;\n\tthis.combine = MultiplyOperation;\n\tthis.reflectivity = 1;\n\tthis.refractionRatio = 0.98;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\tthis.wireframeLinecap = 'round';\n\tthis.wireframeLinejoin = 'round';\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshBasicMaterial.prototype = Object.create( Material.prototype );\nMeshBasicMaterial.prototype.constructor = MeshBasicMaterial;\n\nMeshBasicMaterial.prototype.isMeshBasicMaterial = true;\n\nMeshBasicMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.map = source.map;\n\n\tthis.lightMap = source.lightMap;\n\tthis.lightMapIntensity = source.lightMapIntensity;\n\n\tthis.aoMap = source.aoMap;\n\tthis.aoMapIntensity = source.aoMapIntensity;\n\n\tthis.specularMap = source.specularMap;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.envMap = source.envMap;\n\tthis.combine = source.combine;\n\tthis.reflectivity = source.reflectivity;\n\tthis.refractionRatio = source.refractionRatio;\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\tthis.wireframeLinecap = source.wireframeLinecap;\n\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { MeshBasicMaterial };\n","import { Vector4 } from '../math/Vector4.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Color } from '../math/Color.js';\nimport { StaticDrawUsage } from '../constants.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _vector = new Vector3();\nconst _vector2 = new Vector2();\n\nfunction BufferAttribute( array, itemSize, normalized ) {\n\n\tif ( Array.isArray( array ) ) {\n\n\t\tthrow new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );\n\n\t}\n\n\tthis.name = '';\n\n\tthis.array = array;\n\tthis.itemSize = itemSize;\n\tthis.count = array !== undefined ? array.length / itemSize : 0;\n\tthis.normalized = normalized === true;\n\n\tthis.usage = StaticDrawUsage;\n\tthis.updateRange = { offset: 0, count: - 1 };\n\n\tthis.version = 0;\n\n}\n\nObject.defineProperty( BufferAttribute.prototype, 'needsUpdate', {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\nObject.assign( BufferAttribute.prototype, {\n\n\tisBufferAttribute: true,\n\n\tonUploadCallback: function () {},\n\n\tsetUsage: function ( value ) {\n\n\t\tthis.usage = value;\n\n\t\treturn this;\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\t\tthis.array = new source.array.constructor( source.array );\n\t\tthis.itemSize = source.itemSize;\n\t\tthis.count = source.count;\n\t\tthis.normalized = source.normalized;\n\n\t\tthis.usage = source.usage;\n\n\t\treturn this;\n\n\t},\n\n\tcopyAt: function ( index1, attribute, index2 ) {\n\n\t\tindex1 *= this.itemSize;\n\t\tindex2 *= attribute.itemSize;\n\n\t\tfor ( let i = 0, l = this.itemSize; i < l; i ++ ) {\n\n\t\t\tthis.array[ index1 + i ] = attribute.array[ index2 + i ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyArray: function ( array ) {\n\n\t\tthis.array.set( array );\n\n\t\treturn this;\n\n\t},\n\n\tcopyColorsArray: function ( colors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = colors.length; i < l; i ++ ) {\n\n\t\t\tlet color = colors[ i ];\n\n\t\t\tif ( color === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );\n\t\t\t\tcolor = new Color();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = color.r;\n\t\t\tarray[ offset ++ ] = color.g;\n\t\t\tarray[ offset ++ ] = color.b;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector2sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector2();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector3sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector3();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\tarray[ offset ++ ] = vector.z;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector4sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector4();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\tarray[ offset ++ ] = vector.z;\n\t\t\tarray[ offset ++ ] = vector.w;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tif ( this.itemSize === 2 ) {\n\n\t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t\t_vector2.fromBufferAttribute( this, i );\n\t\t\t\t_vector2.applyMatrix3( m );\n\n\t\t\t\tthis.setXY( i, _vector2.x, _vector2.y, );\n\n\t\t\t}\n\n\t\t} else if ( this.itemSize === 3 ) {\n\n\t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( this, i );\n\t\t\t\t_vector.applyMatrix3( m );\n\n\t\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.applyMatrix4( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyNormalMatrix: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.applyNormalMatrix( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttransformDirection: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.transformDirection( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tset: function ( value, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.array.set( value, offset );\n\n\t\treturn this;\n\n\t},\n\n\tgetX: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize ];\n\n\t},\n\n\tsetX: function ( index, x ) {\n\n\t\tthis.array[ index * this.itemSize ] = x;\n\n\t\treturn this;\n\n\t},\n\n\tgetY: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 1 ];\n\n\t},\n\n\tsetY: function ( index, y ) {\n\n\t\tthis.array[ index * this.itemSize + 1 ] = y;\n\n\t\treturn this;\n\n\t},\n\n\tgetZ: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 2 ];\n\n\t},\n\n\tsetZ: function ( index, z ) {\n\n\t\tthis.array[ index * this.itemSize + 2 ] = z;\n\n\t\treturn this;\n\n\t},\n\n\tgetW: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 3 ];\n\n\t},\n\n\tsetW: function ( index, w ) {\n\n\t\tthis.array[ index * this.itemSize + 3 ] = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetXY: function ( index, x, y ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetXYZ: function ( index, x, y, z ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\t\tthis.array[ index + 2 ] = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetXYZW: function ( index, x, y, z, w ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\t\tthis.array[ index + 2 ] = z;\n\t\tthis.array[ index + 3 ] = w;\n\n\t\treturn this;\n\n\t},\n\n\tonUpload: function ( callback ) {\n\n\t\tthis.onUploadCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.array, this.itemSize ).copy( this );\n\n\t},\n\n\ttoJSON: function () {\n\n\t\treturn {\n\t\t\titemSize: this.itemSize,\n\t\t\ttype: this.array.constructor.name,\n\t\t\tarray: Array.prototype.slice.call( this.array ),\n\t\t\tnormalized: this.normalized\n\t\t};\n\n\t}\n\n} );\n\n//\n\nfunction Int8BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int8Array( array ), itemSize, normalized );\n\n}\n\nInt8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt8BufferAttribute.prototype.constructor = Int8BufferAttribute;\n\n\nfunction Uint8BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint8Array( array ), itemSize, normalized );\n\n}\n\nUint8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;\n\n\nfunction Uint8ClampedBufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint8ClampedArray( array ), itemSize, normalized );\n\n}\n\nUint8ClampedBufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;\n\n\nfunction Int16BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int16Array( array ), itemSize, normalized );\n\n}\n\nInt16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt16BufferAttribute.prototype.constructor = Int16BufferAttribute;\n\n\nfunction Uint16BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint16Array( array ), itemSize, normalized );\n\n}\n\nUint16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;\n\n\nfunction Int32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int32Array( array ), itemSize, normalized );\n\n}\n\nInt32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt32BufferAttribute.prototype.constructor = Int32BufferAttribute;\n\n\nfunction Uint32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint32Array( array ), itemSize, normalized );\n\n}\n\nUint32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;\n\n\nfunction Float32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Float32Array( array ), itemSize, normalized );\n\n}\n\nFloat32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nFloat32BufferAttribute.prototype.constructor = Float32BufferAttribute;\n\n\nfunction Float64BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Float64Array( array ), itemSize, normalized );\n\n}\n\nFloat64BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nFloat64BufferAttribute.prototype.constructor = Float64BufferAttribute;\n\n//\n\nexport {\n\tFloat64BufferAttribute,\n\tFloat32BufferAttribute,\n\tUint32BufferAttribute,\n\tInt32BufferAttribute,\n\tUint16BufferAttribute,\n\tInt16BufferAttribute,\n\tUint8ClampedBufferAttribute,\n\tUint8BufferAttribute,\n\tInt8BufferAttribute,\n\tBufferAttribute\n};\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Vector2 } from '../math/Vector2.js';\n\nfunction DirectGeometry() {\n\n\tthis.vertices = [];\n\tthis.normals = [];\n\tthis.colors = [];\n\tthis.uvs = [];\n\tthis.uvs2 = [];\n\n\tthis.groups = [];\n\n\tthis.morphTargets = {};\n\n\tthis.skinWeights = [];\n\tthis.skinIndices = [];\n\n\t// this.lineDistances = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\t// update flags\n\n\tthis.verticesNeedUpdate = false;\n\tthis.normalsNeedUpdate = false;\n\tthis.colorsNeedUpdate = false;\n\tthis.uvsNeedUpdate = false;\n\tthis.groupsNeedUpdate = false;\n\n}\n\nObject.assign( DirectGeometry.prototype, {\n\n\tcomputeGroups: function ( geometry ) {\n\n\t\tconst groups = [];\n\n\t\tlet group, i;\n\t\tlet materialIndex = undefined;\n\n\t\tconst faces = geometry.faces;\n\n\t\tfor ( i = 0; i < faces.length; i ++ ) {\n\n\t\t\tconst face = faces[ i ];\n\n\t\t\t// materials\n\n\t\t\tif ( face.materialIndex !== materialIndex ) {\n\n\t\t\t\tmaterialIndex = face.materialIndex;\n\n\t\t\t\tif ( group !== undefined ) {\n\n\t\t\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\t\t\tgroups.push( group );\n\n\t\t\t\t}\n\n\t\t\t\tgroup = {\n\t\t\t\t\tstart: i * 3,\n\t\t\t\t\tmaterialIndex: materialIndex\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( group !== undefined ) {\n\n\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\tgroups.push( group );\n\n\t\t}\n\n\t\tthis.groups = groups;\n\n\t},\n\n\tfromGeometry: function ( geometry ) {\n\n\t\tconst faces = geometry.faces;\n\t\tconst vertices = geometry.vertices;\n\t\tconst faceVertexUvs = geometry.faceVertexUvs;\n\n\t\tconst hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;\n\t\tconst hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;\n\n\t\t// morphs\n\n\t\tconst morphTargets = geometry.morphTargets;\n\t\tconst morphTargetsLength = morphTargets.length;\n\n\t\tlet morphTargetsPosition;\n\n\t\tif ( morphTargetsLength > 0 ) {\n\n\t\t\tmorphTargetsPosition = [];\n\n\t\t\tfor ( let i = 0; i < morphTargetsLength; i ++ ) {\n\n\t\t\t\tmorphTargetsPosition[ i ] = {\n\t\t\t\t\tname: morphTargets[ i ].name,\n\t\t\t\t \tdata: []\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.position = morphTargetsPosition;\n\n\t\t}\n\n\t\tconst morphNormals = geometry.morphNormals;\n\t\tconst morphNormalsLength = morphNormals.length;\n\n\t\tlet morphTargetsNormal;\n\n\t\tif ( morphNormalsLength > 0 ) {\n\n\t\t\tmorphTargetsNormal = [];\n\n\t\t\tfor ( let i = 0; i < morphNormalsLength; i ++ ) {\n\n\t\t\t\tmorphTargetsNormal[ i ] = {\n\t\t\t\t\tname: morphNormals[ i ].name,\n\t\t\t\t \tdata: []\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.normal = morphTargetsNormal;\n\n\t\t}\n\n\t\t// skins\n\n\t\tconst skinIndices = geometry.skinIndices;\n\t\tconst skinWeights = geometry.skinWeights;\n\n\t\tconst hasSkinIndices = skinIndices.length === vertices.length;\n\t\tconst hasSkinWeights = skinWeights.length === vertices.length;\n\n\t\t//\n\n\t\tif ( vertices.length > 0 && faces.length === 0 ) {\n\n\t\t\tconsole.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' );\n\n\t\t}\n\n\t\tfor ( let i = 0; i < faces.length; i ++ ) {\n\n\t\t\tconst face = faces[ i ];\n\n\t\t\tthis.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tthis.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] );\n\n\t\t\t} else {\n\n\t\t\t\tconst normal = face.normal;\n\n\t\t\t\tthis.normals.push( normal, normal, normal );\n\n\t\t\t}\n\n\t\t\tconst vertexColors = face.vertexColors;\n\n\t\t\tif ( vertexColors.length === 3 ) {\n\n\t\t\t\tthis.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );\n\n\t\t\t} else {\n\n\t\t\t\tconst color = face.color;\n\n\t\t\t\tthis.colors.push( color, color, color );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexUv === true ) {\n\n\t\t\t\tconst vertexUvs = faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\tthis.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );\n\n\t\t\t\t\tthis.uvs.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexUv2 === true ) {\n\n\t\t\t\tconst vertexUvs = faceVertexUvs[ 1 ][ i ];\n\n\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\tthis.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );\n\n\t\t\t\t\tthis.uvs2.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// morphs\n\n\t\t\tfor ( let j = 0; j < morphTargetsLength; j ++ ) {\n\n\t\t\t\tconst morphTarget = morphTargets[ j ].vertices;\n\n\t\t\t\tmorphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0; j < morphNormalsLength; j ++ ) {\n\n\t\t\t\tconst morphNormal = morphNormals[ j ].vertexNormals[ i ];\n\n\t\t\t\tmorphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );\n\n\t\t\t}\n\n\t\t\t// skins\n\n\t\t\tif ( hasSkinIndices ) {\n\n\t\t\t\tthis.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] );\n\n\t\t\t}\n\n\t\t\tif ( hasSkinWeights ) {\n\n\t\t\t\tthis.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.computeGroups( geometry );\n\n\t\tthis.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\tthis.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\tthis.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\tthis.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\tthis.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { DirectGeometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction arrayMin( array ) {\n\n\tif ( array.length === 0 ) return Infinity;\n\n\tlet min = array[ 0 ];\n\n\tfor ( let i = 1, l = array.length; i < l; ++ i ) {\n\n\t\tif ( array[ i ] < min ) min = array[ i ];\n\n\t}\n\n\treturn min;\n\n}\n\nfunction arrayMax( array ) {\n\n\tif ( array.length === 0 ) return - Infinity;\n\n\tlet max = array[ 0 ];\n\n\tfor ( let i = 1, l = array.length; i < l; ++ i ) {\n\n\t\tif ( array[ i ] > max ) max = array[ i ];\n\n\t}\n\n\treturn max;\n\n}\n\nexport { arrayMin, arrayMax };\n","import { Vector3 } from '../math/Vector3.js';\nimport { Box3 } from '../math/Box3.js';\nimport { EventDispatcher } from './EventDispatcher.js';\nimport { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { DirectGeometry } from './DirectGeometry.js';\nimport { Object3D } from './Object3D.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { arrayMax } from '../utils.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n */\n\nlet _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id\n\nconst _m1 = new Matrix4();\nconst _obj = new Object3D();\nconst _offset = new Vector3();\nconst _box = new Box3();\nconst _boxMorphTargets = new Box3();\nconst _vector = new Vector3();\n\nfunction BufferGeometry() {\n\n\tObject.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'BufferGeometry';\n\n\tthis.index = null;\n\tthis.attributes = {};\n\n\tthis.morphAttributes = {};\n\tthis.morphTargetsRelative = false;\n\n\tthis.groups = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\tthis.drawRange = { start: 0, count: Infinity };\n\n\tthis.userData = {};\n\n}\n\nBufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: BufferGeometry,\n\n\tisBufferGeometry: true,\n\n\tgetIndex: function () {\n\n\t\treturn this.index;\n\n\t},\n\n\tsetIndex: function ( index ) {\n\n\t\tif ( Array.isArray( index ) ) {\n\n\t\t\tthis.index = new ( arrayMax( index ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );\n\n\t\t} else {\n\n\t\t\tthis.index = index;\n\n\t\t}\n\n\t},\n\n\tgetAttribute: function ( name ) {\n\n\t\treturn this.attributes[ name ];\n\n\t},\n\n\tsetAttribute: function ( name, attribute ) {\n\n\t\tthis.attributes[ name ] = attribute;\n\n\t\treturn this;\n\n\t},\n\n\tdeleteAttribute: function ( name ) {\n\n\t\tdelete this.attributes[ name ];\n\n\t\treturn this;\n\n\t},\n\n\taddGroup: function ( start, count, materialIndex ) {\n\n\t\tthis.groups.push( {\n\n\t\t\tstart: start,\n\t\t\tcount: count,\n\t\t\tmaterialIndex: materialIndex !== undefined ? materialIndex : 0\n\n\t\t} );\n\n\t},\n\n\tclearGroups: function () {\n\n\t\tthis.groups = [];\n\n\t},\n\n\tsetDrawRange: function ( start, count ) {\n\n\t\tthis.drawRange.start = start;\n\t\tthis.drawRange.count = count;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tconst position = this.attributes.position;\n\n\t\tif ( position !== undefined ) {\n\n\t\t\tposition.applyMatrix4( matrix );\n\n\t\t\tposition.needsUpdate = true;\n\n\t\t}\n\n\t\tconst normal = this.attributes.normal;\n\n\t\tif ( normal !== undefined ) {\n\n\t\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t\tnormal.applyNormalMatrix( normalMatrix );\n\n\t\t\tnormal.needsUpdate = true;\n\n\t\t}\n\n\t\tconst tangent = this.attributes.tangent;\n\n\t\tif ( tangent !== undefined ) {\n\n\t\t\ttangent.transformDirection( matrix );\n\n\t\t\ttangent.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\t// rotate geometry around world x-axis\n\n\t\t_m1.makeRotationX( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\t// rotate geometry around world y-axis\n\n\t\t_m1.makeRotationY( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\t// rotate geometry around world z-axis\n\n\t\t_m1.makeRotationZ( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( x, y, z ) {\n\n\t\t// translate geometry\n\n\t\t_m1.makeTranslation( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( x, y, z ) {\n\n\t\t// scale geometry\n\n\t\t_m1.makeScale( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tlookAt: function ( vector ) {\n\n\t\t_obj.lookAt( vector );\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4( _obj.matrix );\n\n\t\treturn this;\n\n\t},\n\n\tcenter: function () {\n\n\t\tthis.computeBoundingBox();\n\n\t\tthis.boundingBox.getCenter( _offset ).negate();\n\n\t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromObject: function ( object ) {\n\n\t\t// console.log( 'THREE.BufferGeometry.setFromObject(). Converting', object, this );\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( object.isPoints || object.isLine ) {\n\n\t\t\tconst positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );\n\t\t\tconst colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );\n\n\t\t\tthis.setAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );\n\t\t\tthis.setAttribute( 'color', colors.copyColorsArray( geometry.colors ) );\n\n\t\t\tif ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {\n\n\t\t\t\tconst lineDistances = new Float32BufferAttribute( geometry.lineDistances.length, 1 );\n\n\t\t\t\tthis.setAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t\t}\n\n\t\t} else if ( object.isMesh ) {\n\n\t\t\tif ( geometry && geometry.isGeometry ) {\n\n\t\t\t\tthis.fromGeometry( geometry );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tconst position = [];\n\n\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\tconst point = points[ i ];\n\t\t\tposition.push( point.x, point.y, point.z || 0 );\n\n\t\t}\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );\n\n\t\treturn this;\n\n\t},\n\n\tupdateFromObject: function ( object ) {\n\n\t\tlet geometry = object.geometry;\n\n\t\tif ( object.isMesh ) {\n\n\t\t\tlet direct = geometry.__directGeometry;\n\n\t\t\tif ( geometry.elementsNeedUpdate === true ) {\n\n\t\t\t\tdirect = undefined;\n\t\t\t\tgeometry.elementsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( direct === undefined ) {\n\n\t\t\t\treturn this.fromGeometry( geometry );\n\n\t\t\t}\n\n\t\t\tdirect.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\t\tdirect.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\t\tdirect.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\t\tdirect.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\t\tdirect.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\t\tgeometry.verticesNeedUpdate = false;\n\t\t\tgeometry.normalsNeedUpdate = false;\n\t\t\tgeometry.colorsNeedUpdate = false;\n\t\t\tgeometry.uvsNeedUpdate = false;\n\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t\tgeometry = direct;\n\n\t\t}\n\n\t\tif ( geometry.verticesNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.position;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector3sArray( geometry.vertices );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.verticesNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.normalsNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.normal;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector3sArray( geometry.normals );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.normalsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.colorsNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.color;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyColorsArray( geometry.colors );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.colorsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.uvsNeedUpdate ) {\n\n\t\t\tconst attribute = this.attributes.uv;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector2sArray( geometry.uvs );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.uvsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.lineDistancesNeedUpdate ) {\n\n\t\t\tconst attribute = this.attributes.lineDistance;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyArray( geometry.lineDistances );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.lineDistancesNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.groupsNeedUpdate ) {\n\n\t\t\tgeometry.computeGroups( object.geometry );\n\t\t\tthis.groups = geometry.groups;\n\n\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tfromGeometry: function ( geometry ) {\n\n\t\tgeometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );\n\n\t\treturn this.fromDirectGeometry( geometry.__directGeometry );\n\n\t},\n\n\tfromDirectGeometry: function ( geometry ) {\n\n\t\tconst positions = new Float32Array( geometry.vertices.length * 3 );\n\t\tthis.setAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );\n\n\t\tif ( geometry.normals.length > 0 ) {\n\n\t\t\tconst normals = new Float32Array( geometry.normals.length * 3 );\n\t\t\tthis.setAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );\n\n\t\t}\n\n\t\tif ( geometry.colors.length > 0 ) {\n\n\t\t\tconst colors = new Float32Array( geometry.colors.length * 3 );\n\t\t\tthis.setAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );\n\n\t\t}\n\n\t\tif ( geometry.uvs.length > 0 ) {\n\n\t\t\tconst uvs = new Float32Array( geometry.uvs.length * 2 );\n\t\t\tthis.setAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );\n\n\t\t}\n\n\t\tif ( geometry.uvs2.length > 0 ) {\n\n\t\t\tconst uvs2 = new Float32Array( geometry.uvs2.length * 2 );\n\t\t\tthis.setAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );\n\n\t\t}\n\n\t\t// groups\n\n\t\tthis.groups = geometry.groups;\n\n\t\t// morphs\n\n\t\tfor ( const name in geometry.morphTargets ) {\n\n\t\t\tconst array = [];\n\t\t\tconst morphTargets = geometry.morphTargets[ name ];\n\n\t\t\tfor ( let i = 0, l = morphTargets.length; i < l; i ++ ) {\n\n\t\t\t\tconst morphTarget = morphTargets[ i ];\n\n\t\t\t\tconst attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );\n\t\t\t\tattribute.name = morphTarget.name;\n\n\t\t\t\tarray.push( attribute.copyVector3sArray( morphTarget.data ) );\n\n\t\t\t}\n\n\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t}\n\n\t\t// skinning\n\n\t\tif ( geometry.skinIndices.length > 0 ) {\n\n\t\t\tconst skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );\n\t\t\tthis.setAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );\n\n\t\t}\n\n\t\tif ( geometry.skinWeights.length > 0 ) {\n\n\t\t\tconst skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );\n\t\t\tthis.setAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcomputeBoundingBox: function () {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif ( position !== undefined ) {\n\n\t\t\tthis.boundingBox.setFromBufferAttribute( position );\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\t_box.setFromBufferAttribute( morphAttribute );\n\n\t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n\t\t\t\t\t\t_vector.addVectors( this.boundingBox.min, _box.min );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector );\n\n\t\t\t\t\t\t_vector.addVectors( this.boundingBox.max, _box.max );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _box.min );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _box.max );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.boundingBox.makeEmpty();\n\n\t\t}\n\n\t\tif ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {\n\n\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t}\n\n\t},\n\n\tcomputeBoundingSphere: function () {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif ( position ) {\n\n\t\t\t// first, find the center of the bounding sphere\n\n\t\t\tconst center = this.boundingSphere.center;\n\n\t\t\t_box.setFromBufferAttribute( position );\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\t_boxMorphTargets.setFromBufferAttribute( morphAttribute );\n\n\t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n\t\t\t\t\t\t_vector.addVectors( _box.min, _boxMorphTargets.min );\n\t\t\t\t\t\t_box.expandByPoint( _vector );\n\n\t\t\t\t\t\t_vector.addVectors( _box.max, _boxMorphTargets.max );\n\t\t\t\t\t\t_box.expandByPoint( _vector );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t_box.expandByPoint( _boxMorphTargets.min );\n\t\t\t\t\t\t_box.expandByPoint( _boxMorphTargets.max );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t_box.getCenter( center );\n\n\t\t\t// second, try to find a boundingSphere with a radius smaller than the\n\t\t\t// boundingSphere of the boundingBox: sqrt(3) smaller in the best case\n\n\t\t\tlet maxRadiusSq = 0;\n\n\t\t\tfor ( let i = 0, il = position.count; i < il; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( position, i );\n\n\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t}\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\tconst morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t\t\t\tfor ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {\n\n\t\t\t\t\t\t_vector.fromBufferAttribute( morphAttribute, j );\n\n\t\t\t\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t\t\t\t_offset.fromBufferAttribute( position, j );\n\t\t\t\t\t\t\t_vector.add( _offset );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.boundingSphere.radius = Math.sqrt( maxRadiusSq );\n\n\t\t\tif ( isNaN( this.boundingSphere.radius ) ) {\n\n\t\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tcomputeFaceNormals: function () {\n\n\t\t// backwards compatibility\n\n\t},\n\n\tcomputeVertexNormals: function () {\n\n\t\tconst index = this.index;\n\t\tconst positionAttribute = this.getAttribute( 'position' );\n\n\t\tif ( positionAttribute !== undefined ) {\n\n\t\t\tlet normalAttribute = this.getAttribute( 'normal' );\n\n\t\t\tif ( normalAttribute === undefined ) {\n\n\t\t\t\tnormalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 );\n\t\t\t\tthis.setAttribute( 'normal', normalAttribute );\n\n\t\t\t} else {\n\n\t\t\t\t// reset existing normals to zero\n\n\t\t\t\tfor ( let i = 0, il = normalAttribute.count; i < il; i ++ ) {\n\n\t\t\t\t\tnormalAttribute.setXYZ( i, 0, 0, 0 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst pA = new Vector3(), pB = new Vector3(), pC = new Vector3();\n\t\t\tconst nA = new Vector3(), nB = new Vector3(), nC = new Vector3();\n\t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\t\t// indexed elements\n\n\t\t\tif ( index ) {\n\n\t\t\t\tfor ( let i = 0, il = index.count; i < il; i += 3 ) {\n\n\t\t\t\t\tconst vA = index.getX( i + 0 );\n\t\t\t\t\tconst vB = index.getX( i + 1 );\n\t\t\t\t\tconst vC = index.getX( i + 2 );\n\n\t\t\t\t\tpA.fromBufferAttribute( positionAttribute, vA );\n\t\t\t\t\tpB.fromBufferAttribute( positionAttribute, vB );\n\t\t\t\t\tpC.fromBufferAttribute( positionAttribute, vC );\n\n\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tnA.fromBufferAttribute( normalAttribute, vA );\n\t\t\t\t\tnB.fromBufferAttribute( normalAttribute, vB );\n\t\t\t\t\tnC.fromBufferAttribute( normalAttribute, vC );\n\n\t\t\t\t\tnA.add( cb );\n\t\t\t\t\tnB.add( cb );\n\t\t\t\t\tnC.add( cb );\n\n\t\t\t\t\tnormalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );\n\t\t\t\t\tnormalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );\n\t\t\t\t\tnormalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// non-indexed elements (unconnected triangle soup)\n\n\t\t\t\tfor ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) {\n\n\t\t\t\t\tpA.fromBufferAttribute( positionAttribute, i + 0 );\n\t\t\t\t\tpB.fromBufferAttribute( positionAttribute, i + 1 );\n\t\t\t\t\tpC.fromBufferAttribute( positionAttribute, i + 2 );\n\n\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tnormalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z );\n\t\t\t\t\tnormalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z );\n\t\t\t\t\tnormalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.normalizeNormals();\n\n\t\t\tnormalAttribute.needsUpdate = true;\n\n\t\t}\n\n\t},\n\n\tmerge: function ( geometry, offset ) {\n\n\t\tif ( ! ( geometry && geometry.isBufferGeometry ) ) {\n\n\t\t\tconsole.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( offset === undefined ) {\n\n\t\t\toffset = 0;\n\n\t\t\tconsole.warn(\n\t\t\t\t'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. '\n\t\t\t\t+ 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.'\n\t\t\t);\n\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tif ( geometry.attributes[ key ] === undefined ) continue;\n\n\t\t\tconst attribute1 = attributes[ key ];\n\t\t\tconst attributeArray1 = attribute1.array;\n\n\t\t\tconst attribute2 = geometry.attributes[ key ];\n\t\t\tconst attributeArray2 = attribute2.array;\n\n\t\t\tconst attributeOffset = attribute2.itemSize * offset;\n\t\t\tconst length = Math.min( attributeArray2.length, attributeArray1.length - attributeOffset );\n\n\t\t\tfor ( let i = 0, j = attributeOffset; i < length; i ++, j ++ ) {\n\n\t\t\t\tattributeArray1[ j ] = attributeArray2[ i ];\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tnormalizeNormals: function () {\n\n\t\tconst normals = this.attributes.normal;\n\n\t\tfor ( let i = 0, il = normals.count; i < il; i ++ ) {\n\n\t\t\t_vector.fromBufferAttribute( normals, i );\n\n\t\t\t_vector.normalize();\n\n\t\t\tnormals.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t},\n\n\ttoNonIndexed: function () {\n\n\t\tfunction convertBufferAttribute( attribute, indices ) {\n\n\t\t\tconst array = attribute.array;\n\t\t\tconst itemSize = attribute.itemSize;\n\t\t\tconst normalized = attribute.normalized;\n\n\t\t\tconst array2 = new array.constructor( indices.length * itemSize );\n\n\t\t\tlet index = 0, index2 = 0;\n\n\t\t\tfor ( let i = 0, l = indices.length; i < l; i ++ ) {\n\n\t\t\t\tindex = indices[ i ] * itemSize;\n\n\t\t\t\tfor ( let j = 0; j < itemSize; j ++ ) {\n\n\t\t\t\t\tarray2[ index2 ++ ] = array[ index ++ ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn new BufferAttribute( array2, itemSize, normalized );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( this.index === null ) {\n\n\t\t\tconsole.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst geometry2 = new BufferGeometry();\n\n\t\tconst indices = this.index.array;\n\t\tconst attributes = this.attributes;\n\n\t\t// attributes\n\n\t\tfor ( const name in attributes ) {\n\n\t\t\tconst attribute = attributes[ name ];\n\n\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n\t\t\tgeometry2.setAttribute( name, newAttribute );\n\n\t\t}\n\n\t\t// morph attributes\n\n\t\tconst morphAttributes = this.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst morphArray = [];\n\t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor ( let i = 0, il = morphAttribute.length; i < il; i ++ ) {\n\n\t\t\t\tconst attribute = morphAttribute[ i ];\n\n\t\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n\t\t\t\tmorphArray.push( newAttribute );\n\n\t\t\t}\n\n\t\t\tgeometry2.morphAttributes[ name ] = morphArray;\n\n\t\t}\n\n\t\tgeometry2.morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t// groups\n\n\t\tconst groups = this.groups;\n\n\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\tconst group = groups[ i ];\n\t\t\tgeometry2.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t}\n\n\t\treturn geometry2;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'BufferGeometry',\n\t\t\t\tgenerator: 'BufferGeometry.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard BufferGeometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif ( this.name !== '' ) data.name = this.name;\n\t\tif ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;\n\n\t\tif ( this.parameters !== undefined ) {\n\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor ( const key in parameters ) {\n\n\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t\tdata.data = { attributes: {} };\n\n\t\tconst index = this.index;\n\n\t\tif ( index !== null ) {\n\n\t\t\tdata.data.index = {\n\t\t\t\ttype: index.array.constructor.name,\n\t\t\t\tarray: Array.prototype.slice.call( index.array )\n\t\t\t};\n\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tconst attribute = attributes[ key ];\n\n\t\t\tconst attributeData = attribute.toJSON( data.data );\n\n\t\t\tif ( attribute.name !== '' ) attributeData.name = attribute.name;\n\n\t\t\tdata.data.attributes[ key ] = attributeData;\n\n\t\t}\n\n\t\tconst morphAttributes = {};\n\t\tlet hasMorphAttributes = false;\n\n\t\tfor ( const key in this.morphAttributes ) {\n\n\t\t\tconst attributeArray = this.morphAttributes[ key ];\n\n\t\t\tconst array = [];\n\n\t\t\tfor ( let i = 0, il = attributeArray.length; i < il; i ++ ) {\n\n\t\t\t\tconst attribute = attributeArray[ i ];\n\n\t\t\t\tconst attributeData = attribute.toJSON( data.data );\n\n\t\t\t\tif ( attribute.name !== '' ) attributeData.name = attribute.name;\n\n\t\t\t\tarray.push( attributeData );\n\n\t\t\t}\n\n\t\t\tif ( array.length > 0 ) {\n\n\t\t\t\tmorphAttributes[ key ] = array;\n\n\t\t\t\thasMorphAttributes = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( hasMorphAttributes ) {\n\n\t\t\tdata.data.morphAttributes = morphAttributes;\n\t\t\tdata.data.morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t}\n\n\t\tconst groups = this.groups;\n\n\t\tif ( groups.length > 0 ) {\n\n\t\t\tdata.data.groups = JSON.parse( JSON.stringify( groups ) );\n\n\t\t}\n\n\t\tconst boundingSphere = this.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tdata.data.boundingSphere = {\n\t\t\t\tcenter: boundingSphere.center.toArray(),\n\t\t\t\tradius: boundingSphere.radius\n\t\t\t};\n\n\t\t}\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\t/*\n\t\t // Handle primitives\n\n\t\t const parameters = this.parameters;\n\n\t\t if ( parameters !== undefined ) {\n\n\t\t const values = [];\n\n\t\t for ( const key in parameters ) {\n\n\t\t values.push( parameters[ key ] );\n\n\t\t }\n\n\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t this.constructor.apply( geometry, values );\n\t\t return geometry;\n\n\t\t }\n\n\t\t return new this.constructor().copy( this );\n\t\t */\n\n\t\treturn new BufferGeometry().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\t// reset\n\n\t\tthis.index = null;\n\t\tthis.attributes = {};\n\t\tthis.morphAttributes = {};\n\t\tthis.groups = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// used for storing cloned, shared data\n\n\t\tconst data = {};\n\n\t\t// name\n\n\t\tthis.name = source.name;\n\n\t\t// index\n\n\t\tconst index = source.index;\n\n\t\tif ( index !== null ) {\n\n\t\t\tthis.setIndex( index.clone( data ) );\n\n\t\t}\n\n\t\t// attributes\n\n\t\tconst attributes = source.attributes;\n\n\t\tfor ( const name in attributes ) {\n\n\t\t\tconst attribute = attributes[ name ];\n\t\t\tthis.setAttribute( name, attribute.clone( data ) );\n\n\t\t}\n\n\t\t// morph attributes\n\n\t\tconst morphAttributes = source.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst array = [];\n\t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor ( let i = 0, l = morphAttribute.length; i < l; i ++ ) {\n\n\t\t\t\tarray.push( morphAttribute[ i ].clone( data ) );\n\n\t\t\t}\n\n\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t}\n\n\t\tthis.morphTargetsRelative = source.morphTargetsRelative;\n\n\t\t// groups\n\n\t\tconst groups = source.groups;\n\n\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\tconst group = groups[ i ];\n\t\t\tthis.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t}\n\n\t\t// bounding box\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif ( boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t}\n\n\t\t// bounding sphere\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t}\n\n\t\t// draw range\n\n\t\tthis.drawRange.start = source.drawRange.start;\n\t\tthis.drawRange.count = source.drawRange.count;\n\n\t\t// user data\n\n\t\tthis.userData = source.userData;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { BufferGeometry };\n","import { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Triangle } from '../math/Triangle.js';\nimport { Face3 } from '../core/Face3.js';\nimport { DoubleSide, BackSide } from '../constants.js';\nimport { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author jonobr1 / http://jonobr1.com/\n */\n\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\n\nconst _vA = new Vector3();\nconst _vB = new Vector3();\nconst _vC = new Vector3();\n\nconst _tempA = new Vector3();\nconst _tempB = new Vector3();\nconst _tempC = new Vector3();\n\nconst _morphA = new Vector3();\nconst _morphB = new Vector3();\nconst _morphC = new Vector3();\n\nconst _uvA = new Vector2();\nconst _uvB = new Vector2();\nconst _uvC = new Vector2();\n\nconst _intersectionPoint = new Vector3();\nconst _intersectionPointWorld = new Vector3();\n\nfunction Mesh( geometry, material ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Mesh';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new MeshBasicMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nMesh.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Mesh,\n\n\tisMesh: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tif ( source.morphTargetInfluences !== undefined ) {\n\n\t\t\tthis.morphTargetInfluences = source.morphTargetInfluences.slice();\n\n\t\t}\n\n\t\tif ( source.morphTargetDictionary !== undefined ) {\n\n\t\t\tthis.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );\n\n\t\t}\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst material = this.material;\n\t\tconst matrixWorld = this.matrixWorld;\n\n\t\tif ( material === undefined ) return;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\t// Check boundingBox before continuing\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tif ( _ray.intersectsBox( geometry.boundingBox ) === false ) return;\n\n\t\t}\n\n\t\tlet intersection;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst position = geometry.attributes.position;\n\t\t\tconst morphPosition = geometry.morphAttributes.position;\n\t\t\tconst morphTargetsRelative = geometry.morphTargetsRelative;\n\t\t\tconst uv = geometry.attributes.uv;\n\t\t\tconst uv2 = geometry.attributes.uv2;\n\t\t\tconst groups = geometry.groups;\n\t\t\tconst drawRange = geometry.drawRange;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\t// indexed buffer geometry\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\tconst end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\tconst a = index.getX( j );\n\t\t\t\t\t\t\tconst b = index.getX( j + 1 );\n\t\t\t\t\t\t\tconst c = index.getX( j + 2 );\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst start = Math.max( 0, drawRange.start );\n\t\t\t\t\tconst end = Math.min( index.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\tconst a = index.getX( i );\n\t\t\t\t\t\tconst b = index.getX( i + 1 );\n\t\t\t\t\t\tconst c = index.getX( i + 2 );\n\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( position !== undefined ) {\n\n\t\t\t\t// non-indexed buffer geometry\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\tconst end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\tconst a = j;\n\t\t\t\t\t\t\tconst b = j + 1;\n\t\t\t\t\t\t\tconst c = j + 2;\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst start = Math.max( 0, drawRange.start );\n\t\t\t\t\tconst end = Math.min( position.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\tconst a = i;\n\t\t\t\t\t\tconst b = i + 1;\n\t\t\t\t\t\tconst c = i + 2;\n\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst isMultiMaterial = Array.isArray( material );\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst faces = geometry.faces;\n\t\t\tlet uvs;\n\n\t\t\tconst faceVertexUvs = geometry.faceVertexUvs[ 0 ];\n\t\t\tif ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;\n\n\t\t\tfor ( let f = 0, fl = faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = faces[ f ];\n\t\t\t\tconst faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;\n\n\t\t\t\tif ( faceMaterial === undefined ) continue;\n\n\t\t\t\tconst fvA = vertices[ face.a ];\n\t\t\t\tconst fvB = vertices[ face.b ];\n\t\t\t\tconst fvC = vertices[ face.c ];\n\n\t\t\t\tintersection = checkIntersection( this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint );\n\n\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\tif ( uvs && uvs[ f ] ) {\n\n\t\t\t\t\t\tconst uvs_f = uvs[ f ];\n\t\t\t\t\t\t_uvA.copy( uvs_f[ 0 ] );\n\t\t\t\t\t\t_uvB.copy( uvs_f[ 1 ] );\n\t\t\t\t\t\t_uvC.copy( uvs_f[ 2 ] );\n\n\t\t\t\t\t\tintersection.uv = Triangle.getUV( _intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tintersection.face = face;\n\t\t\t\t\tintersection.faceIndex = f;\n\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\nfunction checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {\n\n\tlet intersect;\n\n\tif ( material.side === BackSide ) {\n\n\t\tintersect = ray.intersectTriangle( pC, pB, pA, true, point );\n\n\t} else {\n\n\t\tintersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );\n\n\t}\n\n\tif ( intersect === null ) return null;\n\n\t_intersectionPointWorld.copy( point );\n\t_intersectionPointWorld.applyMatrix4( object.matrixWorld );\n\n\tconst distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );\n\n\tif ( distance < raycaster.near || distance > raycaster.far ) return null;\n\n\treturn {\n\t\tdistance: distance,\n\t\tpoint: _intersectionPointWorld.clone(),\n\t\tobject: object\n\t};\n\n}\n\nfunction checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) {\n\n\t_vA.fromBufferAttribute( position, a );\n\t_vB.fromBufferAttribute( position, b );\n\t_vC.fromBufferAttribute( position, c );\n\n\tconst morphInfluences = object.morphTargetInfluences;\n\n\tif ( material.morphTargets && morphPosition && morphInfluences ) {\n\n\t\t_morphA.set( 0, 0, 0 );\n\t\t_morphB.set( 0, 0, 0 );\n\t\t_morphC.set( 0, 0, 0 );\n\n\t\tfor ( let i = 0, il = morphPosition.length; i < il; i ++ ) {\n\n\t\t\tconst influence = morphInfluences[ i ];\n\t\t\tconst morphAttribute = morphPosition[ i ];\n\n\t\t\tif ( influence === 0 ) continue;\n\n\t\t\t_tempA.fromBufferAttribute( morphAttribute, a );\n\t\t\t_tempB.fromBufferAttribute( morphAttribute, b );\n\t\t\t_tempC.fromBufferAttribute( morphAttribute, c );\n\n\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t_morphA.addScaledVector( _tempA, influence );\n\t\t\t\t_morphB.addScaledVector( _tempB, influence );\n\t\t\t\t_morphC.addScaledVector( _tempC, influence );\n\n\t\t\t} else {\n\n\t\t\t\t_morphA.addScaledVector( _tempA.sub( _vA ), influence );\n\t\t\t\t_morphB.addScaledVector( _tempB.sub( _vB ), influence );\n\t\t\t\t_morphC.addScaledVector( _tempC.sub( _vC ), influence );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_vA.add( _morphA );\n\t\t_vB.add( _morphB );\n\t\t_vC.add( _morphC );\n\n\t}\n\n\tif ( object.isSkinnedMesh ) {\n\n\t\tobject.boneTransform( a, _vA );\n\t\tobject.boneTransform( b, _vB );\n\t\tobject.boneTransform( c, _vC );\n\n\t}\n\n\tconst intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );\n\n\tif ( intersection ) {\n\n\t\tif ( uv ) {\n\n\t\t\t_uvA.fromBufferAttribute( uv, a );\n\t\t\t_uvB.fromBufferAttribute( uv, b );\n\t\t\t_uvC.fromBufferAttribute( uv, c );\n\n\t\t\tintersection.uv = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t}\n\n\t\tif ( uv2 ) {\n\n\t\t\t_uvA.fromBufferAttribute( uv2, a );\n\t\t\t_uvB.fromBufferAttribute( uv2, b );\n\t\t\t_uvC.fromBufferAttribute( uv2, c );\n\n\t\t\tintersection.uv2 = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t}\n\n\t\tconst face = new Face3( a, b, c );\n\t\tTriangle.getNormal( _vA, _vB, _vC, face.normal );\n\n\t\tintersection.face = face;\n\n\t}\n\n\treturn intersection;\n\n}\n\nexport { Mesh };\n","import { EventDispatcher } from './EventDispatcher.js';\nimport { Face3 } from './Face3.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { Box3 } from '../math/Box3.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Color } from '../math/Color.js';\nimport { Object3D } from './Object3D.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author kile / http://kile.stravaganza.org/\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n * @author bhouston / http://clara.io\n */\n\nlet _geometryId = 0; // Geometry uses even numbers as Id\nconst _m1 = new Matrix4();\nconst _obj = new Object3D();\nconst _offset = new Vector3();\n\nfunction Geometry() {\n\n\tObject.defineProperty( this, 'id', { value: _geometryId += 2 } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Geometry';\n\n\tthis.vertices = [];\n\tthis.colors = [];\n\tthis.faces = [];\n\tthis.faceVertexUvs = [[]];\n\n\tthis.morphTargets = [];\n\tthis.morphNormals = [];\n\n\tthis.skinWeights = [];\n\tthis.skinIndices = [];\n\n\tthis.lineDistances = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\t// update flags\n\n\tthis.elementsNeedUpdate = false;\n\tthis.verticesNeedUpdate = false;\n\tthis.uvsNeedUpdate = false;\n\tthis.normalsNeedUpdate = false;\n\tthis.colorsNeedUpdate = false;\n\tthis.lineDistancesNeedUpdate = false;\n\tthis.groupsNeedUpdate = false;\n\n}\n\nGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Geometry,\n\n\tisGeometry: true,\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\tfor ( let i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\tconst vertex = this.vertices[ i ];\n\t\t\tvertex.applyMatrix4( matrix );\n\n\t\t}\n\n\t\tfor ( let i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\t\t\tface.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\tfor ( let j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\tface.vertexNormals[ j ].applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\tthis.verticesNeedUpdate = true;\n\t\tthis.normalsNeedUpdate = true;\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\t// rotate geometry around world x-axis\n\n\t\t_m1.makeRotationX( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\t// rotate geometry around world y-axis\n\n\t\t_m1.makeRotationY( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\t// rotate geometry around world z-axis\n\n\t\t_m1.makeRotationZ( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( x, y, z ) {\n\n\t\t// translate geometry\n\n\t\t_m1.makeTranslation( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( x, y, z ) {\n\n\t\t// scale geometry\n\n\t\t_m1.makeScale( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tlookAt: function ( vector ) {\n\n\t\t_obj.lookAt( vector );\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4( _obj.matrix );\n\n\t\treturn this;\n\n\t},\n\n\tfromBufferGeometry: function ( geometry ) {\n\n\t\tconst scope = this;\n\n\t\tconst index = geometry.index !== null ? geometry.index : undefined;\n\t\tconst attributes = geometry.attributes;\n\n\t\tif ( attributes.position === undefined ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.' );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst position = attributes.position;\n\t\tconst normal = attributes.normal;\n\t\tconst color = attributes.color;\n\t\tconst uv = attributes.uv;\n\t\tconst uv2 = attributes.uv2;\n\n\t\tif ( uv2 !== undefined ) this.faceVertexUvs[ 1 ] = [];\n\n\t\tfor ( let i = 0; i < position.count; i ++ ) {\n\n\t\t\tscope.vertices.push( new Vector3().fromBufferAttribute( position, i ) );\n\n\t\t\tif ( color !== undefined ) {\n\n\t\t\t\tscope.colors.push( new Color().fromBufferAttribute( color, i ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction addFace( a, b, c, materialIndex ) {\n\n\t\t\tconst vertexColors = ( color === undefined ) ? [] : [\n\t\t\t\tscope.colors[ a ].clone(),\n\t\t\t\tscope.colors[ b ].clone(),\n\t\t\t\tscope.colors[ c ].clone()\n\t\t\t];\n\n\t\t\tconst vertexNormals = ( normal === undefined ) ? [] : [\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, a ),\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, b ),\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, c )\n\t\t\t];\n\n\t\t\tconst face = new Face3( a, b, c, vertexNormals, vertexColors, materialIndex );\n\n\t\t\tscope.faces.push( face );\n\n\t\t\tif ( uv !== undefined ) {\n\n\t\t\t\tscope.faceVertexUvs[ 0 ].push( [\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, a ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, b ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, c )\n\t\t\t\t] );\n\n\t\t\t}\n\n\t\t\tif ( uv2 !== undefined ) {\n\n\t\t\t\tscope.faceVertexUvs[ 1 ].push( [\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, a ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, b ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, c )\n\t\t\t\t] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst groups = geometry.groups;\n\n\t\tif ( groups.length > 0 ) {\n\n\t\t\tfor ( let i = 0; i < groups.length; i ++ ) {\n\n\t\t\t\tconst group = groups[ i ];\n\n\t\t\t\tconst start = group.start;\n\t\t\t\tconst count = group.count;\n\n\t\t\t\tfor ( let j = start, jl = start + count; j < jl; j += 3 ) {\n\n\t\t\t\t\tif ( index !== undefined ) {\n\n\t\t\t\t\t\taddFace( index.getX( j ), index.getX( j + 1 ), index.getX( j + 2 ), group.materialIndex );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\taddFace( j, j + 1, j + 2, group.materialIndex );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( index !== undefined ) {\n\n\t\t\t\tfor ( let i = 0; i < index.count; i += 3 ) {\n\n\t\t\t\t\taddFace( index.getX( i ), index.getX( i + 1 ), index.getX( i + 2 ) );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0; i < position.count; i += 3 ) {\n\n\t\t\t\t\taddFace( i, i + 1, i + 2 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.computeFaceNormals();\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcenter: function () {\n\n\t\tthis.computeBoundingBox();\n\n\t\tthis.boundingBox.getCenter( _offset ).negate();\n\n\t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n\t\treturn this;\n\n\t},\n\n\tnormalize: function () {\n\n\t\tthis.computeBoundingSphere();\n\n\t\tconst center = this.boundingSphere.center;\n\t\tconst radius = this.boundingSphere.radius;\n\n\t\tconst s = radius === 0 ? 1 : 1.0 / radius;\n\n\t\tconst matrix = new Matrix4();\n\t\tmatrix.set(\n\t\t\ts, 0, 0, - s * center.x,\n\t\t\t0, s, 0, - s * center.y,\n\t\t\t0, 0, s, - s * center.z,\n\t\t\t0, 0, 0, 1\n\t\t);\n\n\t\tthis.applyMatrix4( matrix );\n\n\t\treturn this;\n\n\t},\n\n\tcomputeFaceNormals: function () {\n\n\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vA = this.vertices[ face.a ];\n\t\t\tconst vB = this.vertices[ face.b ];\n\t\t\tconst vC = this.vertices[ face.c ];\n\n\t\t\tcb.subVectors( vC, vB );\n\t\t\tab.subVectors( vA, vB );\n\t\t\tcb.cross( ab );\n\n\t\t\tcb.normalize();\n\n\t\t\tface.normal.copy( cb );\n\n\t\t}\n\n\t},\n\n\tcomputeVertexNormals: function ( areaWeighted ) {\n\n\t\tif ( areaWeighted === undefined ) areaWeighted = true;\n\n\t\tconst vertices = new Array( this.vertices.length );\n\n\t\tfor ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\tvertices[ v ] = new Vector3();\n\n\t\t}\n\n\t\tif ( areaWeighted ) {\n\n\t\t\t// vertex normals weighted by triangle areas\n\t\t\t// http://www.iquilezles.org/www/articles/normals/normals.htm\n\n\t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tconst vA = this.vertices[ face.a ];\n\t\t\t\tconst vB = this.vertices[ face.b ];\n\t\t\t\tconst vC = this.vertices[ face.c ];\n\n\t\t\t\tcb.subVectors( vC, vB );\n\t\t\t\tab.subVectors( vA, vB );\n\t\t\t\tcb.cross( ab );\n\n\t\t\t\tvertices[ face.a ].add( cb );\n\t\t\t\tvertices[ face.b ].add( cb );\n\t\t\t\tvertices[ face.c ].add( cb );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.computeFaceNormals();\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tvertices[ face.a ].add( face.normal );\n\t\t\t\tvertices[ face.b ].add( face.normal );\n\t\t\t\tvertices[ face.c ].add( face.normal );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\tvertices[ v ].normalize();\n\n\t\t}\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tvertexNormals[ 0 ].copy( vertices[ face.a ] );\n\t\t\t\tvertexNormals[ 1 ].copy( vertices[ face.b ] );\n\t\t\t\tvertexNormals[ 2 ].copy( vertices[ face.c ] );\n\n\t\t\t} else {\n\n\t\t\t\tvertexNormals[ 0 ] = vertices[ face.a ].clone();\n\t\t\t\tvertexNormals[ 1 ] = vertices[ face.b ].clone();\n\t\t\t\tvertexNormals[ 2 ] = vertices[ face.c ].clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.faces.length > 0 ) {\n\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t}\n\n\t},\n\n\tcomputeFlatVertexNormals: function () {\n\n\t\tthis.computeFaceNormals();\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tvertexNormals[ 0 ].copy( face.normal );\n\t\t\t\tvertexNormals[ 1 ].copy( face.normal );\n\t\t\t\tvertexNormals[ 2 ].copy( face.normal );\n\n\t\t\t} else {\n\n\t\t\t\tvertexNormals[ 0 ] = face.normal.clone();\n\t\t\t\tvertexNormals[ 1 ] = face.normal.clone();\n\t\t\t\tvertexNormals[ 2 ] = face.normal.clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.faces.length > 0 ) {\n\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t}\n\n\t},\n\n\tcomputeMorphNormals: function () {\n\n\t\t// save original normals\n\t\t// - create temp variables on first access\n\t\t// otherwise just copy (for faster repeated calls)\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tif ( ! face.__originalFaceNormal ) {\n\n\t\t\t\tface.__originalFaceNormal = face.normal.clone();\n\n\t\t\t} else {\n\n\t\t\t\tface.__originalFaceNormal.copy( face.normal );\n\n\t\t\t}\n\n\t\t\tif ( ! face.__originalVertexNormals ) face.__originalVertexNormals = [];\n\n\t\t\tfor ( let i = 0, il = face.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\t\tif ( ! face.__originalVertexNormals[ i ] ) {\n\n\t\t\t\t\tface.__originalVertexNormals[ i ] = face.vertexNormals[ i ].clone();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tface.__originalVertexNormals[ i ].copy( face.vertexNormals[ i ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// use temp geometry to compute face and vertex normals for each morph\n\n\t\tconst tmpGeo = new Geometry();\n\t\ttmpGeo.faces = this.faces;\n\n\t\tfor ( let i = 0, il = this.morphTargets.length; i < il; i ++ ) {\n\n\t\t\t// create on first access\n\n\t\t\tif ( ! this.morphNormals[ i ] ) {\n\n\t\t\t\tthis.morphNormals[ i ] = {};\n\t\t\t\tthis.morphNormals[ i ].faceNormals = [];\n\t\t\t\tthis.morphNormals[ i ].vertexNormals = [];\n\n\t\t\t\tconst dstNormalsFace = this.morphNormals[ i ].faceNormals;\n\t\t\t\tconst dstNormalsVertex = this.morphNormals[ i ].vertexNormals;\n\n\t\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\tconst faceNormal = new Vector3();\n\t\t\t\t\tconst vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };\n\n\t\t\t\t\tdstNormalsFace.push( faceNormal );\n\t\t\t\t\tdstNormalsVertex.push( vertexNormals );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst morphNormals = this.morphNormals[ i ];\n\n\t\t\t// set vertices to morph target\n\n\t\t\ttmpGeo.vertices = this.morphTargets[ i ].vertices;\n\n\t\t\t// compute morph normals\n\n\t\t\ttmpGeo.computeFaceNormals();\n\t\t\ttmpGeo.computeVertexNormals();\n\n\t\t\t// store morph normals\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tconst faceNormal = morphNormals.faceNormals[ f ];\n\t\t\t\tconst vertexNormals = morphNormals.vertexNormals[ f ];\n\n\t\t\t\tfaceNormal.copy( face.normal );\n\n\t\t\t\tvertexNormals.a.copy( face.vertexNormals[ 0 ] );\n\t\t\t\tvertexNormals.b.copy( face.vertexNormals[ 1 ] );\n\t\t\t\tvertexNormals.c.copy( face.vertexNormals[ 2 ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// restore original normals\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tface.normal = face.__originalFaceNormal;\n\t\t\tface.vertexNormals = face.__originalVertexNormals;\n\n\t\t}\n\n\t},\n\n\tcomputeBoundingBox: function () {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tthis.boundingBox.setFromPoints( this.vertices );\n\n\t},\n\n\tcomputeBoundingSphere: function () {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tthis.boundingSphere.setFromPoints( this.vertices );\n\n\t},\n\n\tmerge: function ( geometry, matrix, materialIndexOffset ) {\n\n\t\tif ( ! ( geometry && geometry.isGeometry ) ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet normalMatrix,\n\t\t\tvertexOffset = this.vertices.length,\n\t\t\tvertices1 = this.vertices,\n\t\t\tvertices2 = geometry.vertices,\n\t\t\tfaces1 = this.faces,\n\t\t\tfaces2 = geometry.faces,\n\t\t\tcolors1 = this.colors,\n\t\t\tcolors2 = geometry.colors;\n\n\t\tif ( materialIndexOffset === undefined ) materialIndexOffset = 0;\n\n\t\tif ( matrix !== undefined ) {\n\n\t\t\tnormalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t}\n\n\t\t// vertices\n\n\t\tfor ( let i = 0, il = vertices2.length; i < il; i ++ ) {\n\n\t\t\tconst vertex = vertices2[ i ];\n\n\t\t\tconst vertexCopy = vertex.clone();\n\n\t\t\tif ( matrix !== undefined ) vertexCopy.applyMatrix4( matrix );\n\n\t\t\tvertices1.push( vertexCopy );\n\n\t\t}\n\n\t\t// colors\n\n\t\tfor ( let i = 0, il = colors2.length; i < il; i ++ ) {\n\n\t\t\tcolors1.push( colors2[ i ].clone() );\n\n\t\t}\n\n\t\t// faces\n\n\t\tfor ( let i = 0, il = faces2.length; i < il; i ++ ) {\n\n\t\t\tlet face = faces2[ i ], faceCopy, normal, color,\n\t\t\t\tfaceVertexNormals = face.vertexNormals,\n\t\t\t\tfaceVertexColors = face.vertexColors;\n\n\t\t\tfaceCopy = new Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );\n\t\t\tfaceCopy.normal.copy( face.normal );\n\n\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\tfaceCopy.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0, jl = faceVertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\tnormal = faceVertexNormals[ j ].clone();\n\n\t\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\t\tnormal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t}\n\n\t\t\t\tfaceCopy.vertexNormals.push( normal );\n\n\t\t\t}\n\n\t\t\tfaceCopy.color.copy( face.color );\n\n\t\t\tfor ( let j = 0, jl = faceVertexColors.length; j < jl; j ++ ) {\n\n\t\t\t\tcolor = faceVertexColors[ j ];\n\t\t\t\tfaceCopy.vertexColors.push( color.clone() );\n\n\t\t\t}\n\n\t\t\tfaceCopy.materialIndex = face.materialIndex + materialIndexOffset;\n\n\t\t\tfaces1.push( faceCopy );\n\n\t\t}\n\n\t\t// uvs\n\n\t\tfor ( let i = 0, il = geometry.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\tconst faceVertexUvs2 = geometry.faceVertexUvs[ i ];\n\n\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) this.faceVertexUvs[ i ] = [];\n\n\t\t\tfor ( let j = 0, jl = faceVertexUvs2.length; j < jl; j ++ ) {\n\n\t\t\t\tconst uvs2 = faceVertexUvs2[ j ], uvsCopy = [];\n\n\t\t\t\tfor ( let k = 0, kl = uvs2.length; k < kl; k ++ ) {\n\n\t\t\t\t\tuvsCopy.push( uvs2[ k ].clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tmergeMesh: function ( mesh ) {\n\n\t\tif ( ! ( mesh && mesh.isMesh ) ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( mesh.matrixAutoUpdate ) mesh.updateMatrix();\n\n\t\tthis.merge( mesh.geometry, mesh.matrix );\n\n\t},\n\n\t/*\n\t * Checks for duplicate vertices with hashmap.\n\t * Duplicated vertices are removed\n\t * and faces' vertices are updated.\n\t */\n\n\tmergeVertices: function () {\n\n\t\tconst verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)\n\t\tconst unique = [], changes = [];\n\n\t\tconst precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001\n\t\tconst precision = Math.pow( 10, precisionPoints );\n\n\t\tfor ( let i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\tconst v = this.vertices[ i ];\n\t\t\tconst key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision );\n\n\t\t\tif ( verticesMap[ key ] === undefined ) {\n\n\t\t\t\tverticesMap[ key ] = i;\n\t\t\t\tunique.push( this.vertices[ i ] );\n\t\t\t\tchanges[ i ] = unique.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\t//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);\n\t\t\t\tchanges[ i ] = changes[ verticesMap[ key ] ];\n\n\t\t\t}\n\n\t\t}\n\n\n\t\t// if faces are completely degenerate after merging vertices, we\n\t\t// have to remove them from the geometry.\n\t\tconst faceIndicesToRemove = [];\n\n\t\tfor ( let i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\n\t\t\tface.a = changes[ face.a ];\n\t\t\tface.b = changes[ face.b ];\n\t\t\tface.c = changes[ face.c ];\n\n\t\t\tconst indices = [ face.a, face.b, face.c ];\n\n\t\t\t// if any duplicate vertices are found in a Face3\n\t\t\t// we have to remove the face as nothing can be saved\n\t\t\tfor ( let n = 0; n < 3; n ++ ) {\n\n\t\t\t\tif ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) {\n\n\t\t\t\t\tfaceIndicesToRemove.push( i );\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let i = faceIndicesToRemove.length - 1; i >= 0; i -- ) {\n\n\t\t\tconst idx = faceIndicesToRemove[ i ];\n\n\t\t\tthis.faces.splice( idx, 1 );\n\n\t\t\tfor ( let j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\tthis.faceVertexUvs[ j ].splice( idx, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Use unique set of vertices\n\n\t\tconst diff = this.vertices.length - unique.length;\n\t\tthis.vertices = unique;\n\t\treturn diff;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tthis.vertices = [];\n\n\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\tconst point = points[ i ];\n\t\t\tthis.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsortFacesByMaterialIndex: function () {\n\n\t\tconst faces = this.faces;\n\t\tconst length = faces.length;\n\n\t\t// tag faces\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tfaces[ i ]._id = i;\n\n\t\t}\n\n\t\t// sort faces\n\n\t\tfunction materialIndexSort( a, b ) {\n\n\t\t\treturn a.materialIndex - b.materialIndex;\n\n\t\t}\n\n\t\tfaces.sort( materialIndexSort );\n\n\t\t// sort uvs\n\n\t\tconst uvs1 = this.faceVertexUvs[ 0 ];\n\t\tconst uvs2 = this.faceVertexUvs[ 1 ];\n\n\t\tlet newUvs1, newUvs2;\n\n\t\tif ( uvs1 && uvs1.length === length ) newUvs1 = [];\n\t\tif ( uvs2 && uvs2.length === length ) newUvs2 = [];\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tconst id = faces[ i ]._id;\n\n\t\t\tif ( newUvs1 ) newUvs1.push( uvs1[ id ] );\n\t\t\tif ( newUvs2 ) newUvs2.push( uvs2[ id ] );\n\n\t\t}\n\n\t\tif ( newUvs1 ) this.faceVertexUvs[ 0 ] = newUvs1;\n\t\tif ( newUvs2 ) this.faceVertexUvs[ 1 ] = newUvs2;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Geometry',\n\t\t\t\tgenerator: 'Geometry.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard Geometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\tif ( this.parameters !== undefined ) {\n\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor ( const key in parameters ) {\n\n\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t\tconst vertices = [];\n\n\t\tfor ( let i = 0; i < this.vertices.length; i ++ ) {\n\n\t\t\tconst vertex = this.vertices[ i ];\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t}\n\n\t\tconst faces = [];\n\t\tconst normals = [];\n\t\tconst normalsHash = {};\n\t\tconst colors = [];\n\t\tconst colorsHash = {};\n\t\tconst uvs = [];\n\t\tconst uvsHash = {};\n\n\t\tfor ( let i = 0; i < this.faces.length; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\n\t\t\tconst hasMaterial = true;\n\t\t\tconst hasFaceUv = false; // deprecated\n\t\t\tconst hasFaceVertexUv = this.faceVertexUvs[ 0 ][ i ] !== undefined;\n\t\t\tconst hasFaceNormal = face.normal.length() > 0;\n\t\t\tconst hasFaceVertexNormal = face.vertexNormals.length > 0;\n\t\t\tconst hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;\n\t\t\tconst hasFaceVertexColor = face.vertexColors.length > 0;\n\n\t\t\tlet faceType = 0;\n\n\t\t\tfaceType = setBit( faceType, 0, 0 ); // isQuad\n\t\t\tfaceType = setBit( faceType, 1, hasMaterial );\n\t\t\tfaceType = setBit( faceType, 2, hasFaceUv );\n\t\t\tfaceType = setBit( faceType, 3, hasFaceVertexUv );\n\t\t\tfaceType = setBit( faceType, 4, hasFaceNormal );\n\t\t\tfaceType = setBit( faceType, 5, hasFaceVertexNormal );\n\t\t\tfaceType = setBit( faceType, 6, hasFaceColor );\n\t\t\tfaceType = setBit( faceType, 7, hasFaceVertexColor );\n\n\t\t\tfaces.push( faceType );\n\t\t\tfaces.push( face.a, face.b, face.c );\n\t\t\tfaces.push( face.materialIndex );\n\n\t\t\tif ( hasFaceVertexUv ) {\n\n\t\t\t\tconst faceVertexUvs = this.faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 0 ] ),\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 1 ] ),\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tif ( hasFaceNormal ) {\n\n\t\t\t\tfaces.push( getNormalIndex( face.normal ) );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexNormal ) {\n\n\t\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 0 ] ),\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 1 ] ),\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tif ( hasFaceColor ) {\n\n\t\t\t\tfaces.push( getColorIndex( face.color ) );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexColor ) {\n\n\t\t\t\tconst vertexColors = face.vertexColors;\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetColorIndex( vertexColors[ 0 ] ),\n\t\t\t\t\tgetColorIndex( vertexColors[ 1 ] ),\n\t\t\t\t\tgetColorIndex( vertexColors[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setBit( value, position, enabled ) {\n\n\t\t\treturn enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position ) );\n\n\t\t}\n\n\t\tfunction getNormalIndex( normal ) {\n\n\t\t\tconst hash = normal.x.toString() + normal.y.toString() + normal.z.toString();\n\n\t\t\tif ( normalsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn normalsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tnormalsHash[ hash ] = normals.length / 3;\n\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\treturn normalsHash[ hash ];\n\n\t\t}\n\n\t\tfunction getColorIndex( color ) {\n\n\t\t\tconst hash = color.r.toString() + color.g.toString() + color.b.toString();\n\n\t\t\tif ( colorsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn colorsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tcolorsHash[ hash ] = colors.length;\n\t\t\tcolors.push( color.getHex() );\n\n\t\t\treturn colorsHash[ hash ];\n\n\t\t}\n\n\t\tfunction getUvIndex( uv ) {\n\n\t\t\tconst hash = uv.x.toString() + uv.y.toString();\n\n\t\t\tif ( uvsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn uvsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tuvsHash[ hash ] = uvs.length / 2;\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\treturn uvsHash[ hash ];\n\n\t\t}\n\n\t\tdata.data = {};\n\n\t\tdata.data.vertices = vertices;\n\t\tdata.data.normals = normals;\n\t\tif ( colors.length > 0 ) data.data.colors = colors;\n\t\tif ( uvs.length > 0 ) data.data.uvs = [ uvs ]; // temporal backward compatibility\n\t\tdata.data.faces = faces;\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\t/*\n\t\t // Handle primitives\n\n\t\t const parameters = this.parameters;\n\n\t\t if ( parameters !== undefined ) {\n\n\t\t const values = [];\n\n\t\t for ( const key in parameters ) {\n\n\t\t values.push( parameters[ key ] );\n\n\t\t }\n\n\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t this.constructor.apply( geometry, values );\n\t\t return geometry;\n\n\t\t }\n\n\t\t return new this.constructor().copy( this );\n\t\t */\n\n\t\treturn new Geometry().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\t// reset\n\n\t\tthis.vertices = [];\n\t\tthis.colors = [];\n\t\tthis.faces = [];\n\t\tthis.faceVertexUvs = [[]];\n\t\tthis.morphTargets = [];\n\t\tthis.morphNormals = [];\n\t\tthis.skinWeights = [];\n\t\tthis.skinIndices = [];\n\t\tthis.lineDistances = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// name\n\n\t\tthis.name = source.name;\n\n\t\t// vertices\n\n\t\tconst vertices = source.vertices;\n\n\t\tfor ( let i = 0, il = vertices.length; i < il; i ++ ) {\n\n\t\t\tthis.vertices.push( vertices[ i ].clone() );\n\n\t\t}\n\n\t\t// colors\n\n\t\tconst colors = source.colors;\n\n\t\tfor ( let i = 0, il = colors.length; i < il; i ++ ) {\n\n\t\t\tthis.colors.push( colors[ i ].clone() );\n\n\t\t}\n\n\t\t// faces\n\n\t\tconst faces = source.faces;\n\n\t\tfor ( let i = 0, il = faces.length; i < il; i ++ ) {\n\n\t\t\tthis.faces.push( faces[ i ].clone() );\n\n\t\t}\n\n\t\t// face vertex uvs\n\n\t\tfor ( let i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\tconst faceVertexUvs = source.faceVertexUvs[ i ];\n\n\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) {\n\n\t\t\t\tthis.faceVertexUvs[ i ] = [];\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0, jl = faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\tconst uvs = faceVertexUvs[ j ], uvsCopy = [];\n\n\t\t\t\tfor ( let k = 0, kl = uvs.length; k < kl; k ++ ) {\n\n\t\t\t\t\tconst uv = uvs[ k ];\n\n\t\t\t\t\tuvsCopy.push( uv.clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// morph targets\n\n\t\tconst morphTargets = source.morphTargets;\n\n\t\tfor ( let i = 0, il = morphTargets.length; i < il; i ++ ) {\n\n\t\t\tconst morphTarget = {};\n\t\t\tmorphTarget.name = morphTargets[ i ].name;\n\n\t\t\t// vertices\n\n\t\t\tif ( morphTargets[ i ].vertices !== undefined ) {\n\n\t\t\t\tmorphTarget.vertices = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphTargets[ i ].vertices.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphTarget.vertices.push( morphTargets[ i ].vertices[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// normals\n\n\t\t\tif ( morphTargets[ i ].normals !== undefined ) {\n\n\t\t\t\tmorphTarget.normals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphTargets[ i ].normals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphTarget.normals.push( morphTargets[ i ].normals[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.push( morphTarget );\n\n\t\t}\n\n\t\t// morph normals\n\n\t\tconst morphNormals = source.morphNormals;\n\n\t\tfor ( let i = 0, il = morphNormals.length; i < il; i ++ ) {\n\n\t\t\tconst morphNormal = {};\n\n\t\t\t// vertex normals\n\n\t\t\tif ( morphNormals[ i ].vertexNormals !== undefined ) {\n\n\t\t\t\tmorphNormal.vertexNormals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphNormals[ i ].vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tconst srcVertexNormal = morphNormals[ i ].vertexNormals[ j ];\n\t\t\t\t\tconst destVertexNormal = {};\n\n\t\t\t\t\tdestVertexNormal.a = srcVertexNormal.a.clone();\n\t\t\t\t\tdestVertexNormal.b = srcVertexNormal.b.clone();\n\t\t\t\t\tdestVertexNormal.c = srcVertexNormal.c.clone();\n\n\t\t\t\t\tmorphNormal.vertexNormals.push( destVertexNormal );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// face normals\n\n\t\t\tif ( morphNormals[ i ].faceNormals !== undefined ) {\n\n\t\t\t\tmorphNormal.faceNormals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphNormals[ i ].faceNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphNormal.faceNormals.push( morphNormals[ i ].faceNormals[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.morphNormals.push( morphNormal );\n\n\t\t}\n\n\t\t// skin weights\n\n\t\tconst skinWeights = source.skinWeights;\n\n\t\tfor ( let i = 0, il = skinWeights.length; i < il; i ++ ) {\n\n\t\t\tthis.skinWeights.push( skinWeights[ i ].clone() );\n\n\t\t}\n\n\t\t// skin indices\n\n\t\tconst skinIndices = source.skinIndices;\n\n\t\tfor ( let i = 0, il = skinIndices.length; i < il; i ++ ) {\n\n\t\t\tthis.skinIndices.push( skinIndices[ i ].clone() );\n\n\t\t}\n\n\t\t// line distances\n\n\t\tconst lineDistances = source.lineDistances;\n\n\t\tfor ( let i = 0, il = lineDistances.length; i < il; i ++ ) {\n\n\t\t\tthis.lineDistances.push( lineDistances[ i ] );\n\n\t\t}\n\n\t\t// bounding box\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif ( boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t}\n\n\t\t// bounding sphere\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t}\n\n\t\t// update flags\n\n\t\tthis.elementsNeedUpdate = source.elementsNeedUpdate;\n\t\tthis.verticesNeedUpdate = source.verticesNeedUpdate;\n\t\tthis.uvsNeedUpdate = source.uvsNeedUpdate;\n\t\tthis.normalsNeedUpdate = source.normalsNeedUpdate;\n\t\tthis.colorsNeedUpdate = source.colorsNeedUpdate;\n\t\tthis.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;\n\t\tthis.groupsNeedUpdate = source.groupsNeedUpdate;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { Geometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n// BoxGeometry\n\nclass BoxGeometry extends Geometry {\n\n\tconstructor( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tsuper();\n\n\t\tthis.type = 'BoxGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tthis.fromBufferGeometry( new BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n}\n\n// BoxBufferGeometry\n\nclass BoxBufferGeometry extends BufferGeometry {\n\n\tconstructor( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tsuper();\n\n\t\tthis.type = 'BoxBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tconst scope = this;\n\n\t\twidth = width || 1;\n\t\theight = height || 1;\n\t\tdepth = depth || 1;\n\n\t\t// segments\n\n\t\twidthSegments = Math.floor( widthSegments ) || 1;\n\t\theightSegments = Math.floor( heightSegments ) || 1;\n\t\tdepthSegments = Math.floor( depthSegments ) || 1;\n\n\t\t// buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = [];\n\n\t\t// helper variables\n\n\t\tlet numberOfVertices = 0;\n\t\tlet groupStart = 0;\n\n\t\t// build each side of the box geometry\n\n\t\tbuildPlane( 'z', 'y', 'x', - 1, - 1, depth, height, width, depthSegments, heightSegments, 0 ); // px\n\t\tbuildPlane( 'z', 'y', 'x', 1, - 1, depth, height, - width, depthSegments, heightSegments, 1 ); // nx\n\t\tbuildPlane( 'x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2 ); // py\n\t\tbuildPlane( 'x', 'z', 'y', 1, - 1, width, depth, - height, widthSegments, depthSegments, 3 ); // ny\n\t\tbuildPlane( 'x', 'y', 'z', 1, - 1, width, height, depth, widthSegments, heightSegments, 4 ); // pz\n\t\tbuildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth, widthSegments, heightSegments, 5 ); // nz\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\tfunction buildPlane( u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex ) {\n\n\t\t\tconst segmentWidth = width / gridX;\n\t\t\tconst segmentHeight = height / gridY;\n\n\t\t\tconst widthHalf = width / 2;\n\t\t\tconst heightHalf = height / 2;\n\t\t\tconst depthHalf = depth / 2;\n\n\t\t\tconst gridX1 = gridX + 1;\n\t\t\tconst gridY1 = gridY + 1;\n\n\t\t\tlet vertexCounter = 0;\n\t\t\tlet groupCount = 0;\n\n\t\t\tconst vector = new Vector3();\n\n\t\t\t// generate vertices, normals and uvs\n\n\t\t\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n\t\t\t\tconst y = iy * segmentHeight - heightHalf;\n\n\t\t\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\t\t\tconst x = ix * segmentWidth - widthHalf;\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = x * udir;\n\t\t\t\t\tvector[ v ] = y * vdir;\n\t\t\t\t\tvector[ w ] = depthHalf;\n\n\t\t\t\t\t// now apply vector to vertex buffer\n\n\t\t\t\t\tvertices.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = 0;\n\t\t\t\t\tvector[ v ] = 0;\n\t\t\t\t\tvector[ w ] = depth > 0 ? 1 : - 1;\n\n\t\t\t\t\t// now apply vector to normal buffer\n\n\t\t\t\t\tnormals.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// uvs\n\n\t\t\t\t\tuvs.push( ix / gridX );\n\t\t\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t\t\t\t// counters\n\n\t\t\t\t\tvertexCounter += 1;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// indices\n\n\t\t\t// 1. you need three indices to draw a single face\n\t\t\t// 2. a single segment consists of two faces\n\t\t\t// 3. so we need to generate six (2*3) indices per segment\n\n\t\t\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n\t\t\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\t\t\tconst a = numberOfVertices + ix + gridX1 * iy;\n\t\t\t\t\tconst b = numberOfVertices + ix + gridX1 * ( iy + 1 );\n\t\t\t\t\tconst c = numberOfVertices + ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\t\t\tconst d = numberOfVertices + ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t\t\t// faces\n\n\t\t\t\t\tindices.push( a, b, d );\n\t\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t\t// increase counter\n\n\t\t\t\t\tgroupCount += 6;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\t\tscope.addGroup( groupStart, groupCount, materialIndex );\n\n\t\t\t// calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\n\t\t\t// update total number of vertices\n\n\t\t\tnumberOfVertices += vertexCounter;\n\n\t\t}\n\n\t}\n\n}\n\nexport { BoxGeometry, BoxBufferGeometry };\n","/**\n * Uniform Utilities\n */\n\nexport function cloneUniforms( src ) {\n\n\tconst dst = {};\n\n\tfor ( const u in src ) {\n\n\t\tdst[ u ] = {};\n\n\t\tfor ( const p in src[ u ] ) {\n\n\t\t\tconst property = src[ u ][ p ];\n\n\t\t\tif ( property && ( property.isColor ||\n\t\t\t\tproperty.isMatrix3 || property.isMatrix4 ||\n\t\t\t\tproperty.isVector2 || property.isVector3 || property.isVector4 ||\n\t\t\t\tproperty.isTexture ) ) {\n\n\t\t\t\tdst[ u ][ p ] = property.clone();\n\n\t\t\t} else if ( Array.isArray( property ) ) {\n\n\t\t\t\tdst[ u ][ p ] = property.slice();\n\n\t\t\t} else {\n\n\t\t\t\tdst[ u ][ p ] = property;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn dst;\n\n}\n\nexport function mergeUniforms( uniforms ) {\n\n\tconst merged = {};\n\n\tfor ( let u = 0; u < uniforms.length; u ++ ) {\n\n\t\tconst tmp = cloneUniforms( uniforms[ u ] );\n\n\t\tfor ( const p in tmp ) {\n\n\t\t\tmerged[ p ] = tmp[ p ];\n\n\t\t}\n\n\t}\n\n\treturn merged;\n\n}\n\n// Legacy\n\nconst UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };\n\nexport { UniformsUtils };\n","/**\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * defines: { \"label\" : \"value\" },\n * uniforms: { \"parameter1\": { value: 1.0 }, \"parameter2\": { value2: 2 } },\n *\n * fragmentShader: ,\n * vertexShader: ,\n *\n * wireframe: ,\n * wireframeLinewidth: ,\n *\n * lights: ,\n *\n * skinning: ,\n * morphTargets: ,\n * morphNormals: \n * }\n */\n\nimport { Material } from './Material.js';\nimport { cloneUniforms } from '../renderers/shaders/UniformsUtils.js';\n\nimport default_vertex from '../renderers/shaders/ShaderChunk/default_vertex.glsl.js';\nimport default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.glsl.js';\n\nfunction ShaderMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'ShaderMaterial';\n\n\tthis.defines = {};\n\tthis.uniforms = {};\n\n\tthis.vertexShader = default_vertex;\n\tthis.fragmentShader = default_fragment;\n\n\tthis.linewidth = 1;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\n\tthis.fog = false; // set to use scene fog\n\tthis.lights = false; // set to use scene lights\n\tthis.clipping = false; // set to use user-defined clipping planes\n\n\tthis.skinning = false; // set to use skinning attribute streams\n\tthis.morphTargets = false; // set to use morph targets\n\tthis.morphNormals = false; // set to use morph normals\n\n\tthis.extensions = {\n\t\tderivatives: false, // set to use derivatives\n\t\tfragDepth: false, // set to use fragment depth values\n\t\tdrawBuffers: false, // set to use draw buffers\n\t\tshaderTextureLOD: false // set to use shader texture LOD\n\t};\n\n\t// When rendered geometry doesn't include these attributes but the material does,\n\t// use these default values in WebGL. This avoids errors when buffer data is missing.\n\tthis.defaultAttributeValues = {\n\t\t'color': [ 1, 1, 1 ],\n\t\t'uv': [ 0, 0 ],\n\t\t'uv2': [ 0, 0 ]\n\t};\n\n\tthis.index0AttributeName = undefined;\n\tthis.uniformsNeedUpdate = false;\n\n\tif ( parameters !== undefined ) {\n\n\t\tif ( parameters.attributes !== undefined ) {\n\n\t\t\tconsole.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' );\n\n\t\t}\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n}\n\nShaderMaterial.prototype = Object.create( Material.prototype );\nShaderMaterial.prototype.constructor = ShaderMaterial;\n\nShaderMaterial.prototype.isShaderMaterial = true;\n\nShaderMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.fragmentShader = source.fragmentShader;\n\tthis.vertexShader = source.vertexShader;\n\n\tthis.uniforms = cloneUniforms( source.uniforms );\n\n\tthis.defines = Object.assign( {}, source.defines );\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\tthis.lights = source.lights;\n\tthis.clipping = source.clipping;\n\n\tthis.skinning = source.skinning;\n\n\tthis.morphTargets = source.morphTargets;\n\tthis.morphNormals = source.morphNormals;\n\n\tthis.extensions = Object.assign( {}, source.extensions );\n\n\treturn this;\n\n};\n\nShaderMaterial.prototype.toJSON = function ( meta ) {\n\n\tconst data = Material.prototype.toJSON.call( this, meta );\n\n\tdata.uniforms = {};\n\n\tfor ( const name in this.uniforms ) {\n\n\t\tconst uniform = this.uniforms[ name ];\n\t\tconst value = uniform.value;\n\n\t\tif ( value && value.isTexture ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 't',\n\t\t\t\tvalue: value.toJSON( meta ).uuid\n\t\t\t};\n\n\t\t} else if ( value && value.isColor ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'c',\n\t\t\t\tvalue: value.getHex()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector2 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v2',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector3 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v3',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector4 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v4',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isMatrix3 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'm3',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isMatrix4 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'm4',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\tvalue: value\n\t\t\t};\n\n\t\t\t// note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far\n\n\t\t}\n\n\t}\n\n\tif ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;\n\n\tdata.vertexShader = this.vertexShader;\n\tdata.fragmentShader = this.fragmentShader;\n\n\tconst extensions = {};\n\n\tfor ( const key in this.extensions ) {\n\n\t\tif ( this.extensions[ key ] === true ) extensions[ key ] = true;\n\n\t}\n\n\tif ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;\n\n\treturn data;\n\n};\n\n\nexport { ShaderMaterial };\n","export default /* glsl */`\nvoid main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n`;\n","export default /* glsl */`\nvoid main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}\n`;\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n * @author WestLangley / http://github.com/WestLangley\n*/\n\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\n\nfunction Camera() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Camera';\n\n\tthis.matrixWorldInverse = new Matrix4();\n\n\tthis.projectionMatrix = new Matrix4();\n\tthis.projectionMatrixInverse = new Matrix4();\n\n}\n\nCamera.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Camera,\n\n\tisCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\tthis.matrixWorldInverse.copy( source.matrixWorldInverse );\n\n\t\tthis.projectionMatrix.copy( source.projectionMatrix );\n\t\tthis.projectionMatrixInverse.copy( source.projectionMatrixInverse );\n\n\t\treturn this;\n\n\t},\n\n\tgetWorldDirection: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Camera: .getWorldDirection() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tconst e = this.matrixWorld.elements;\n\n\t\treturn target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();\n\n\t},\n\n\tupdateMatrixWorld: function ( force ) {\n\n\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t},\n\n\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\tObject3D.prototype.updateWorldMatrix.call( this, updateParents, updateChildren );\n\n\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t}\n\n} );\n\nexport { Camera };\n","import { Camera } from './Camera.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author greggman / http://games.greggman.com/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n * @author tschw\n */\n\nfunction PerspectiveCamera( fov, aspect, near, far ) {\n\n\tCamera.call( this );\n\n\tthis.type = 'PerspectiveCamera';\n\n\tthis.fov = fov !== undefined ? fov : 50;\n\tthis.zoom = 1;\n\n\tthis.near = near !== undefined ? near : 0.1;\n\tthis.far = far !== undefined ? far : 2000;\n\tthis.focus = 10;\n\n\tthis.aspect = aspect !== undefined ? aspect : 1;\n\tthis.view = null;\n\n\tthis.filmGauge = 35;\t// width of the film (default in millimeters)\n\tthis.filmOffset = 0;\t// horizontal film offset (same unit as gauge)\n\n\tthis.updateProjectionMatrix();\n\n}\n\nPerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\tconstructor: PerspectiveCamera,\n\n\tisPerspectiveCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\tthis.fov = source.fov;\n\t\tthis.zoom = source.zoom;\n\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\t\tthis.focus = source.focus;\n\n\t\tthis.aspect = source.aspect;\n\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\tthis.filmGauge = source.filmGauge;\n\t\tthis.filmOffset = source.filmOffset;\n\n\t\treturn this;\n\n\t},\n\n\t/**\n\t * Sets the FOV by focal length in respect to the current .filmGauge.\n\t *\n\t * The default film gauge is 35, so that the focal length can be specified for\n\t * a 35mm (full frame) camera.\n\t *\n\t * Values for focal length and film gauge must have the same unit.\n\t */\n\tsetFocalLength: function ( focalLength ) {\n\n\t\t// see http://www.bobatkins.com/photography/technical/field_of_view.html\n\t\tconst vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;\n\n\t\tthis.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope );\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\t/**\n\t * Calculates the focal length from the current .fov and .filmGauge.\n\t */\n\tgetFocalLength: function () {\n\n\t\tconst vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov );\n\n\t\treturn 0.5 * this.getFilmHeight() / vExtentSlope;\n\n\t},\n\n\tgetEffectiveFOV: function () {\n\n\t\treturn MathUtils.RAD2DEG * 2 * Math.atan(\n\t\t\tMath.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom );\n\n\t},\n\n\tgetFilmWidth: function () {\n\n\t\t// film not completely covered in portrait format (aspect < 1)\n\t\treturn this.filmGauge * Math.min( this.aspect, 1 );\n\n\t},\n\n\tgetFilmHeight: function () {\n\n\t\t// film not completely covered in landscape format (aspect > 1)\n\t\treturn this.filmGauge / Math.max( this.aspect, 1 );\n\n\t},\n\n\t/**\n\t * Sets an offset in a larger frustum. This is useful for multi-window or\n\t * multi-monitor/multi-machine setups.\n\t *\n\t * For example, if you have 3x2 monitors and each monitor is 1920x1080 and\n\t * the monitors are in grid like this\n\t *\n\t * +---+---+---+\n\t * | A | B | C |\n\t * +---+---+---+\n\t * | D | E | F |\n\t * +---+---+---+\n\t *\n\t * then for each monitor you would call it like this\n\t *\n\t * const w = 1920;\n\t * const h = 1080;\n\t * const fullWidth = w * 3;\n\t * const fullHeight = h * 2;\n\t *\n\t * --A--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );\n\t * --B--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );\n\t * --C--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );\n\t * --D--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );\n\t * --E--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );\n\t * --F--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );\n\t *\n\t * Note there is no reason monitors have to be the same size or in a grid.\n\t */\n\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\tthis.aspect = fullWidth / fullHeight;\n\n\t\tif ( this.view === null ) {\n\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tclearViewOffset: function () {\n\n\t\tif ( this.view !== null ) {\n\n\t\t\tthis.view.enabled = false;\n\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tupdateProjectionMatrix: function () {\n\n\t\tlet near = this.near,\n\t\t\ttop = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom,\n\t\t\theight = 2 * top,\n\t\t\twidth = this.aspect * height,\n\t\t\tleft = - 0.5 * width,\n\t\t\tview = this.view;\n\n\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\tconst fullWidth = view.fullWidth,\n\t\t\t\tfullHeight = view.fullHeight;\n\n\t\t\tleft += view.offsetX * width / fullWidth;\n\t\t\ttop -= view.offsetY * height / fullHeight;\n\t\t\twidth *= view.width / fullWidth;\n\t\t\theight *= view.height / fullHeight;\n\n\t\t}\n\n\t\tconst skew = this.filmOffset;\n\t\tif ( skew !== 0 ) left += near * skew / this.getFilmWidth();\n\n\t\tthis.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );\n\n\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.fov = this.fov;\n\t\tdata.object.zoom = this.zoom;\n\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\t\tdata.object.focus = this.focus;\n\n\t\tdata.object.aspect = this.aspect;\n\n\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\tdata.object.filmGauge = this.filmGauge;\n\t\tdata.object.filmOffset = this.filmOffset;\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { PerspectiveCamera };\n","/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nimport { Texture } from './Texture.js';\nimport { NearestFilter } from '../constants.js';\n\nfunction DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {\n\n\tTexture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1 };\n\n\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\tthis.unpackAlignment = 1;\n\n\tthis.needsUpdate = true;\n\n}\n\nDataTexture.prototype = Object.create( Texture.prototype );\nDataTexture.prototype.constructor = DataTexture;\n\nDataTexture.prototype.isDataTexture = true;\n\n\nexport { DataTexture };\n","import { Vector3 } from './Vector3.js';\nimport { Sphere } from './Sphere.js';\nimport { Plane } from './Plane.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author bhouston / http://clara.io\n */\n\nconst _sphere = new Sphere();\nconst _vector = new Vector3();\n\nfunction Frustum( p0, p1, p2, p3, p4, p5 ) {\n\n\tthis.planes = [\n\n\t\t( p0 !== undefined ) ? p0 : new Plane(),\n\t\t( p1 !== undefined ) ? p1 : new Plane(),\n\t\t( p2 !== undefined ) ? p2 : new Plane(),\n\t\t( p3 !== undefined ) ? p3 : new Plane(),\n\t\t( p4 !== undefined ) ? p4 : new Plane(),\n\t\t( p5 !== undefined ) ? p5 : new Plane()\n\n\t];\n\n}\n\nObject.assign( Frustum.prototype, {\n\n\tset: function ( p0, p1, p2, p3, p4, p5 ) {\n\n\t\tconst planes = this.planes;\n\n\t\tplanes[ 0 ].copy( p0 );\n\t\tplanes[ 1 ].copy( p1 );\n\t\tplanes[ 2 ].copy( p2 );\n\t\tplanes[ 3 ].copy( p3 );\n\t\tplanes[ 4 ].copy( p4 );\n\t\tplanes[ 5 ].copy( p5 );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( frustum ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tplanes[ i ].copy( frustum.planes[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromProjectionMatrix: function ( m ) {\n\n\t\tconst planes = this.planes;\n\t\tconst me = m.elements;\n\t\tconst me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];\n\t\tconst me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];\n\t\tconst me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];\n\t\tconst me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];\n\n\t\tplanes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();\n\t\tplanes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();\n\t\tplanes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();\n\t\tplanes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();\n\t\tplanes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();\n\t\tplanes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();\n\n\t\treturn this;\n\n\t},\n\n\tintersectsObject: function ( object ) {\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );\n\n\t\treturn this.intersectsSphere( _sphere );\n\n\t},\n\n\tintersectsSprite: function ( sprite ) {\n\n\t\t_sphere.center.set( 0, 0, 0 );\n\t\t_sphere.radius = 0.7071067811865476;\n\t\t_sphere.applyMatrix4( sprite.matrixWorld );\n\n\t\treturn this.intersectsSphere( _sphere );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\tconst planes = this.planes;\n\t\tconst center = sphere.center;\n\t\tconst negRadius = - sphere.radius;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tconst distance = planes[ i ].distanceToPoint( center );\n\n\t\t\tif ( distance < negRadius ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tconst plane = planes[ i ];\n\n\t\t\t// corner at max distance\n\n\t\t\t_vector.x = plane.normal.x > 0 ? box.max.x : box.min.x;\n\t\t\t_vector.y = plane.normal.y > 0 ? box.max.y : box.min.y;\n\t\t\t_vector.z = plane.normal.z > 0 ? box.max.z : box.min.z;\n\n\t\t\tif ( plane.distanceToPoint( _vector ) < 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tif ( planes[ i ].distanceToPoint( point ) < 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n} );\n\n\nexport { Frustum };\n","import { Color } from '../../math/Color.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Matrix3 } from '../../math/Matrix3.js';\n\n/**\n * Uniforms library for shared webgl shaders\n */\n\nconst UniformsLib = {\n\n\tcommon: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\n\t\tmap: { value: null },\n\t\tuvTransform: { value: new Matrix3() },\n\t\tuv2Transform: { value: new Matrix3() },\n\n\t\talphaMap: { value: null },\n\n\t},\n\n\tspecularmap: {\n\n\t\tspecularMap: { value: null },\n\n\t},\n\n\tenvmap: {\n\n\t\tenvMap: { value: null },\n\t\tflipEnvMap: { value: - 1 },\n\t\treflectivity: { value: 1.0 },\n\t\trefractionRatio: { value: 0.98 },\n\t\tmaxMipLevel: { value: 0 }\n\n\t},\n\n\taomap: {\n\n\t\taoMap: { value: null },\n\t\taoMapIntensity: { value: 1 }\n\n\t},\n\n\tlightmap: {\n\n\t\tlightMap: { value: null },\n\t\tlightMapIntensity: { value: 1 }\n\n\t},\n\n\temissivemap: {\n\n\t\temissiveMap: { value: null }\n\n\t},\n\n\tbumpmap: {\n\n\t\tbumpMap: { value: null },\n\t\tbumpScale: { value: 1 }\n\n\t},\n\n\tnormalmap: {\n\n\t\tnormalMap: { value: null },\n\t\tnormalScale: { value: new Vector2( 1, 1 ) }\n\n\t},\n\n\tdisplacementmap: {\n\n\t\tdisplacementMap: { value: null },\n\t\tdisplacementScale: { value: 1 },\n\t\tdisplacementBias: { value: 0 }\n\n\t},\n\n\troughnessmap: {\n\n\t\troughnessMap: { value: null }\n\n\t},\n\n\tmetalnessmap: {\n\n\t\tmetalnessMap: { value: null }\n\n\t},\n\n\tgradientmap: {\n\n\t\tgradientMap: { value: null }\n\n\t},\n\n\tfog: {\n\n\t\tfogDensity: { value: 0.00025 },\n\t\tfogNear: { value: 1 },\n\t\tfogFar: { value: 2000 },\n\t\tfogColor: { value: new Color( 0xffffff ) }\n\n\t},\n\n\tlights: {\n\n\t\tambientLightColor: { value: [] },\n\n\t\tlightProbe: { value: [] },\n\n\t\tdirectionalLights: { value: [], properties: {\n\t\t\tdirection: {},\n\t\t\tcolor: {}\n\t\t} },\n\n\t\tdirectionalLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {}\n\t\t} },\n\n\t\tdirectionalShadowMap: { value: [] },\n\t\tdirectionalShadowMatrix: { value: [] },\n\n\t\tspotLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\tdirection: {},\n\t\t\tdistance: {},\n\t\t\tconeCos: {},\n\t\t\tpenumbraCos: {},\n\t\t\tdecay: {}\n\t\t} },\n\n\t\tspotLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {}\n\t\t} },\n\n\t\tspotShadowMap: { value: [] },\n\t\tspotShadowMatrix: { value: [] },\n\n\t\tpointLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\tdecay: {},\n\t\t\tdistance: {}\n\t\t} },\n\n\t\tpointLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {},\n\t\t\tshadowCameraNear: {},\n\t\t\tshadowCameraFar: {}\n\t\t} },\n\n\t\tpointShadowMap: { value: [] },\n\t\tpointShadowMatrix: { value: [] },\n\n\t\themisphereLights: { value: [], properties: {\n\t\t\tdirection: {},\n\t\t\tskyColor: {},\n\t\t\tgroundColor: {}\n\t\t} },\n\n\t\t// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src\n\t\trectAreaLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\twidth: {},\n\t\t\theight: {}\n\t\t} }\n\n\t},\n\n\tpoints: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\t\tsize: { value: 1.0 },\n\t\tscale: { value: 1.0 },\n\t\tmap: { value: null },\n\t\talphaMap: { value: null },\n\t\tuvTransform: { value: new Matrix3() }\n\n\t},\n\n\tsprite: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\t\tcenter: { value: new Vector2( 0.5, 0.5 ) },\n\t\trotation: { value: 0.0 },\n\t\tmap: { value: null },\n\t\talphaMap: { value: null },\n\t\tuvTransform: { value: new Matrix3() }\n\n\t}\n\n};\n\nexport { UniformsLib };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLAnimation() {\n\n\tlet context = null;\n\tlet isAnimating = false;\n\tlet animationLoop = null;\n\tlet requestId = null;\n\n\tfunction onAnimationFrame( time, frame ) {\n\n\t\tanimationLoop( time, frame );\n\n\t\trequestId = context.requestAnimationFrame( onAnimationFrame );\n\n\t}\n\n\treturn {\n\n\t\tstart: function () {\n\n\t\t\tif ( isAnimating === true ) return;\n\t\t\tif ( animationLoop === null ) return;\n\n\t\t\trequestId = context.requestAnimationFrame( onAnimationFrame );\n\n\t\t\tisAnimating = true;\n\n\t\t},\n\n\t\tstop: function () {\n\n\t\t\tcontext.cancelAnimationFrame( requestId );\n\n\t\t\tisAnimating = false;\n\n\t\t},\n\n\t\tsetAnimationLoop: function ( callback ) {\n\n\t\t\tanimationLoop = callback;\n\n\t\t},\n\n\t\tsetContext: function ( value ) {\n\n\t\t\tcontext = value;\n\n\t\t}\n\n\t};\n\n}\n\nexport { WebGLAnimation };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLAttributes( gl, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tconst buffers = new WeakMap();\n\n\tfunction createBuffer( attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst usage = attribute.usage;\n\n\t\tconst buffer = gl.createBuffer();\n\n\t\tgl.bindBuffer( bufferType, buffer );\n\t\tgl.bufferData( bufferType, array, usage );\n\n\t\tattribute.onUploadCallback();\n\n\t\tlet type = gl.FLOAT;\n\n\t\tif ( array instanceof Float32Array ) {\n\n\t\t\ttype = gl.FLOAT;\n\n\t\t} else if ( array instanceof Float64Array ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' );\n\n\t\t} else if ( array instanceof Uint16Array ) {\n\n\t\t\ttype = gl.UNSIGNED_SHORT;\n\n\t\t} else if ( array instanceof Int16Array ) {\n\n\t\t\ttype = gl.SHORT;\n\n\t\t} else if ( array instanceof Uint32Array ) {\n\n\t\t\ttype = gl.UNSIGNED_INT;\n\n\t\t} else if ( array instanceof Int32Array ) {\n\n\t\t\ttype = gl.INT;\n\n\t\t} else if ( array instanceof Int8Array ) {\n\n\t\t\ttype = gl.BYTE;\n\n\t\t} else if ( array instanceof Uint8Array ) {\n\n\t\t\ttype = gl.UNSIGNED_BYTE;\n\n\t\t}\n\n\t\treturn {\n\t\t\tbuffer: buffer,\n\t\t\ttype: type,\n\t\t\tbytesPerElement: array.BYTES_PER_ELEMENT,\n\t\t\tversion: attribute.version\n\t\t};\n\n\t}\n\n\tfunction updateBuffer( buffer, attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst updateRange = attribute.updateRange;\n\n\t\tgl.bindBuffer( bufferType, buffer );\n\n\t\tif ( updateRange.count === - 1 ) {\n\n\t\t\t// Not using update ranges\n\n\t\t\tgl.bufferSubData( bufferType, 0, array );\n\n\t\t} else {\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray, updateRange.offset, updateRange.count );\n\n\t\t\t} else {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );\n\n\t\t\t}\n\n\t\t\tupdateRange.count = - 1; // reset range\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction get( attribute ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\treturn buffers.get( attribute );\n\n\t}\n\n\tfunction remove( attribute ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\tconst data = buffers.get( attribute );\n\n\t\tif ( data ) {\n\n\t\t\tgl.deleteBuffer( data.buffer );\n\n\t\t\tbuffers.delete( attribute );\n\n\t\t}\n\n\t}\n\n\tfunction update( attribute, bufferType ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\tconst data = buffers.get( attribute );\n\n\t\tif ( data === undefined ) {\n\n\t\t\tbuffers.set( attribute, createBuffer( attribute, bufferType ) );\n\n\t\t} else if ( data.version < attribute.version ) {\n\n\t\t\tupdateBuffer( data.buffer, attribute, bufferType );\n\n\t\t\tdata.version = attribute.version;\n\n\t\t}\n\n\t}\n\n\treturn {\n\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update\n\n\t};\n\n}\n\n\nexport { WebGLAttributes };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n// PlaneGeometry\n\nfunction PlaneGeometry( width, height, widthSegments, heightSegments ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'PlaneGeometry';\n\n\tthis.parameters = {\n\t\twidth: width,\n\t\theight: height,\n\t\twidthSegments: widthSegments,\n\t\theightSegments: heightSegments\n\t};\n\n\tthis.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );\n\tthis.mergeVertices();\n\n}\n\nPlaneGeometry.prototype = Object.create( Geometry.prototype );\nPlaneGeometry.prototype.constructor = PlaneGeometry;\n\n// PlaneBufferGeometry\n\nfunction PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'PlaneBufferGeometry';\n\n\tthis.parameters = {\n\t\twidth: width,\n\t\theight: height,\n\t\twidthSegments: widthSegments,\n\t\theightSegments: heightSegments\n\t};\n\n\twidth = width || 1;\n\theight = height || 1;\n\n\tconst width_half = width / 2;\n\tconst height_half = height / 2;\n\n\tconst gridX = Math.floor( widthSegments ) || 1;\n\tconst gridY = Math.floor( heightSegments ) || 1;\n\n\tconst gridX1 = gridX + 1;\n\tconst gridY1 = gridY + 1;\n\n\tconst segment_width = width / gridX;\n\tconst segment_height = height / gridY;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// generate vertices, normals and uvs\n\n\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n\t\tconst y = iy * segment_height - height_half;\n\n\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\tconst x = ix * segment_width - width_half;\n\n\t\t\tvertices.push( x, - y, 0 );\n\n\t\t\tnormals.push( 0, 0, 1 );\n\n\t\t\tuvs.push( ix / gridX );\n\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t}\n\n\t}\n\n\t// indices\n\n\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\tconst a = ix + gridX1 * iy;\n\t\t\tconst b = ix + gridX1 * ( iy + 1 );\n\t\t\tconst c = ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\tconst d = ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t// faces\n\n\t\t\tindices.push( a, b, d );\n\t\t\tindices.push( b, c, d );\n\n\t\t}\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n}\n\nPlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nPlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;\n\n\nexport { PlaneGeometry, PlaneBufferGeometry };\n","export default /* glsl */`\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n`;\n","import alphamap_fragment from './ShaderChunk/alphamap_fragment.glsl.js';\nimport alphamap_pars_fragment from './ShaderChunk/alphamap_pars_fragment.glsl.js';\nimport alphatest_fragment from './ShaderChunk/alphatest_fragment.glsl.js';\nimport aomap_fragment from './ShaderChunk/aomap_fragment.glsl.js';\nimport aomap_pars_fragment from './ShaderChunk/aomap_pars_fragment.glsl.js';\nimport begin_vertex from './ShaderChunk/begin_vertex.glsl.js';\nimport beginnormal_vertex from './ShaderChunk/beginnormal_vertex.glsl.js';\nimport bsdfs from './ShaderChunk/bsdfs.glsl.js';\nimport bumpmap_pars_fragment from './ShaderChunk/bumpmap_pars_fragment.glsl.js';\nimport clipping_planes_fragment from './ShaderChunk/clipping_planes_fragment.glsl.js';\nimport clipping_planes_pars_fragment from './ShaderChunk/clipping_planes_pars_fragment.glsl.js';\nimport clipping_planes_pars_vertex from './ShaderChunk/clipping_planes_pars_vertex.glsl.js';\nimport clipping_planes_vertex from './ShaderChunk/clipping_planes_vertex.glsl.js';\nimport color_fragment from './ShaderChunk/color_fragment.glsl.js';\nimport color_pars_fragment from './ShaderChunk/color_pars_fragment.glsl.js';\nimport color_pars_vertex from './ShaderChunk/color_pars_vertex.glsl.js';\nimport color_vertex from './ShaderChunk/color_vertex.glsl.js';\nimport common from './ShaderChunk/common.glsl.js';\nimport cube_uv_reflection_fragment from './ShaderChunk/cube_uv_reflection_fragment.glsl.js';\nimport defaultnormal_vertex from './ShaderChunk/defaultnormal_vertex.glsl.js';\nimport displacementmap_pars_vertex from './ShaderChunk/displacementmap_pars_vertex.glsl.js';\nimport displacementmap_vertex from './ShaderChunk/displacementmap_vertex.glsl.js';\nimport emissivemap_fragment from './ShaderChunk/emissivemap_fragment.glsl.js';\nimport emissivemap_pars_fragment from './ShaderChunk/emissivemap_pars_fragment.glsl.js';\nimport encodings_fragment from './ShaderChunk/encodings_fragment.glsl.js';\nimport encodings_pars_fragment from './ShaderChunk/encodings_pars_fragment.glsl.js';\nimport envmap_fragment from './ShaderChunk/envmap_fragment.glsl.js';\nimport envmap_common_pars_fragment from './ShaderChunk/envmap_common_pars_fragment.glsl.js';\nimport envmap_pars_fragment from './ShaderChunk/envmap_pars_fragment.glsl.js';\nimport envmap_pars_vertex from './ShaderChunk/envmap_pars_vertex.glsl.js';\nimport envmap_vertex from './ShaderChunk/envmap_vertex.glsl.js';\nimport fog_vertex from './ShaderChunk/fog_vertex.glsl.js';\nimport fog_pars_vertex from './ShaderChunk/fog_pars_vertex.glsl.js';\nimport fog_fragment from './ShaderChunk/fog_fragment.glsl.js';\nimport fog_pars_fragment from './ShaderChunk/fog_pars_fragment.glsl.js';\nimport gradientmap_pars_fragment from './ShaderChunk/gradientmap_pars_fragment.glsl.js';\nimport lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl.js';\nimport lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl.js';\nimport lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl.js';\nimport lights_pars_begin from './ShaderChunk/lights_pars_begin.glsl.js';\nimport envmap_physical_pars_fragment from './ShaderChunk/envmap_physical_pars_fragment.glsl.js';\nimport lights_toon_fragment from './ShaderChunk/lights_toon_fragment.glsl.js';\nimport lights_toon_pars_fragment from './ShaderChunk/lights_toon_pars_fragment.glsl.js';\nimport lights_phong_fragment from './ShaderChunk/lights_phong_fragment.glsl.js';\nimport lights_phong_pars_fragment from './ShaderChunk/lights_phong_pars_fragment.glsl.js';\nimport lights_physical_fragment from './ShaderChunk/lights_physical_fragment.glsl.js';\nimport lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fragment.glsl.js';\nimport lights_fragment_begin from './ShaderChunk/lights_fragment_begin.glsl.js';\nimport lights_fragment_maps from './ShaderChunk/lights_fragment_maps.glsl.js';\nimport lights_fragment_end from './ShaderChunk/lights_fragment_end.glsl.js';\nimport logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl.js';\nimport logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl.js';\nimport logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl.js';\nimport logdepthbuf_vertex from './ShaderChunk/logdepthbuf_vertex.glsl.js';\nimport map_fragment from './ShaderChunk/map_fragment.glsl.js';\nimport map_pars_fragment from './ShaderChunk/map_pars_fragment.glsl.js';\nimport map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js';\nimport map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js';\nimport metalnessmap_fragment from './ShaderChunk/metalnessmap_fragment.glsl.js';\nimport metalnessmap_pars_fragment from './ShaderChunk/metalnessmap_pars_fragment.glsl.js';\nimport morphnormal_vertex from './ShaderChunk/morphnormal_vertex.glsl.js';\nimport morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.js';\nimport morphtarget_vertex from './ShaderChunk/morphtarget_vertex.glsl.js';\nimport normal_fragment_begin from './ShaderChunk/normal_fragment_begin.glsl.js';\nimport normal_fragment_maps from './ShaderChunk/normal_fragment_maps.glsl.js';\nimport normalmap_pars_fragment from './ShaderChunk/normalmap_pars_fragment.glsl.js';\nimport clearcoat_normal_fragment_begin from './ShaderChunk/clearcoat_normal_fragment_begin.glsl.js';\nimport clearcoat_normal_fragment_maps from './ShaderChunk/clearcoat_normal_fragment_maps.glsl.js';\nimport clearcoat_pars_fragment from './ShaderChunk/clearcoat_pars_fragment.glsl.js';\nimport packing from './ShaderChunk/packing.glsl.js';\nimport premultiplied_alpha_fragment from './ShaderChunk/premultiplied_alpha_fragment.glsl.js';\nimport project_vertex from './ShaderChunk/project_vertex.glsl.js';\nimport dithering_fragment from './ShaderChunk/dithering_fragment.glsl.js';\nimport dithering_pars_fragment from './ShaderChunk/dithering_pars_fragment.glsl.js';\nimport roughnessmap_fragment from './ShaderChunk/roughnessmap_fragment.glsl.js';\nimport roughnessmap_pars_fragment from './ShaderChunk/roughnessmap_pars_fragment.glsl.js';\nimport shadowmap_pars_fragment from './ShaderChunk/shadowmap_pars_fragment.glsl.js';\nimport shadowmap_pars_vertex from './ShaderChunk/shadowmap_pars_vertex.glsl.js';\nimport shadowmap_vertex from './ShaderChunk/shadowmap_vertex.glsl.js';\nimport shadowmask_pars_fragment from './ShaderChunk/shadowmask_pars_fragment.glsl.js';\nimport skinbase_vertex from './ShaderChunk/skinbase_vertex.glsl.js';\nimport skinning_pars_vertex from './ShaderChunk/skinning_pars_vertex.glsl.js';\nimport skinning_vertex from './ShaderChunk/skinning_vertex.glsl.js';\nimport skinnormal_vertex from './ShaderChunk/skinnormal_vertex.glsl.js';\nimport specularmap_fragment from './ShaderChunk/specularmap_fragment.glsl.js';\nimport specularmap_pars_fragment from './ShaderChunk/specularmap_pars_fragment.glsl.js';\nimport tonemapping_fragment from './ShaderChunk/tonemapping_fragment.glsl.js';\nimport tonemapping_pars_fragment from './ShaderChunk/tonemapping_pars_fragment.glsl.js';\nimport uv_pars_fragment from './ShaderChunk/uv_pars_fragment.glsl.js';\nimport uv_pars_vertex from './ShaderChunk/uv_pars_vertex.glsl.js';\nimport uv_vertex from './ShaderChunk/uv_vertex.glsl.js';\nimport uv2_pars_fragment from './ShaderChunk/uv2_pars_fragment.glsl.js';\nimport uv2_pars_vertex from './ShaderChunk/uv2_pars_vertex.glsl.js';\nimport uv2_vertex from './ShaderChunk/uv2_vertex.glsl.js';\nimport worldpos_vertex from './ShaderChunk/worldpos_vertex.glsl.js';\n\nimport background_frag from './ShaderLib/background_frag.glsl.js';\nimport background_vert from './ShaderLib/background_vert.glsl.js';\nimport cube_frag from './ShaderLib/cube_frag.glsl.js';\nimport cube_vert from './ShaderLib/cube_vert.glsl.js';\nimport depth_frag from './ShaderLib/depth_frag.glsl.js';\nimport depth_vert from './ShaderLib/depth_vert.glsl.js';\nimport distanceRGBA_frag from './ShaderLib/distanceRGBA_frag.glsl.js';\nimport distanceRGBA_vert from './ShaderLib/distanceRGBA_vert.glsl.js';\nimport equirect_frag from './ShaderLib/equirect_frag.glsl.js';\nimport equirect_vert from './ShaderLib/equirect_vert.glsl.js';\nimport linedashed_frag from './ShaderLib/linedashed_frag.glsl.js';\nimport linedashed_vert from './ShaderLib/linedashed_vert.glsl.js';\nimport meshbasic_frag from './ShaderLib/meshbasic_frag.glsl.js';\nimport meshbasic_vert from './ShaderLib/meshbasic_vert.glsl.js';\nimport meshlambert_frag from './ShaderLib/meshlambert_frag.glsl.js';\nimport meshlambert_vert from './ShaderLib/meshlambert_vert.glsl.js';\nimport meshmatcap_frag from './ShaderLib/meshmatcap_frag.glsl.js';\nimport meshmatcap_vert from './ShaderLib/meshmatcap_vert.glsl.js';\nimport meshtoon_frag from './ShaderLib/meshtoon_frag.glsl.js';\nimport meshtoon_vert from './ShaderLib/meshtoon_vert.glsl.js';\nimport meshphong_frag from './ShaderLib/meshphong_frag.glsl.js';\nimport meshphong_vert from './ShaderLib/meshphong_vert.glsl.js';\nimport meshphysical_frag from './ShaderLib/meshphysical_frag.glsl.js';\nimport meshphysical_vert from './ShaderLib/meshphysical_vert.glsl.js';\nimport normal_frag from './ShaderLib/normal_frag.glsl.js';\nimport normal_vert from './ShaderLib/normal_vert.glsl.js';\nimport points_frag from './ShaderLib/points_frag.glsl.js';\nimport points_vert from './ShaderLib/points_vert.glsl.js';\nimport shadow_frag from './ShaderLib/shadow_frag.glsl.js';\nimport shadow_vert from './ShaderLib/shadow_vert.glsl.js';\nimport sprite_frag from './ShaderLib/sprite_frag.glsl.js';\nimport sprite_vert from './ShaderLib/sprite_vert.glsl.js';\n\nexport const ShaderChunk = {\n\talphamap_fragment: alphamap_fragment,\n\talphamap_pars_fragment: alphamap_pars_fragment,\n\talphatest_fragment: alphatest_fragment,\n\taomap_fragment: aomap_fragment,\n\taomap_pars_fragment: aomap_pars_fragment,\n\tbegin_vertex: begin_vertex,\n\tbeginnormal_vertex: beginnormal_vertex,\n\tbsdfs: bsdfs,\n\tbumpmap_pars_fragment: bumpmap_pars_fragment,\n\tclipping_planes_fragment: clipping_planes_fragment,\n\tclipping_planes_pars_fragment: clipping_planes_pars_fragment,\n\tclipping_planes_pars_vertex: clipping_planes_pars_vertex,\n\tclipping_planes_vertex: clipping_planes_vertex,\n\tcolor_fragment: color_fragment,\n\tcolor_pars_fragment: color_pars_fragment,\n\tcolor_pars_vertex: color_pars_vertex,\n\tcolor_vertex: color_vertex,\n\tcommon: common,\n\tcube_uv_reflection_fragment: cube_uv_reflection_fragment,\n\tdefaultnormal_vertex: defaultnormal_vertex,\n\tdisplacementmap_pars_vertex: displacementmap_pars_vertex,\n\tdisplacementmap_vertex: displacementmap_vertex,\n\temissivemap_fragment: emissivemap_fragment,\n\temissivemap_pars_fragment: emissivemap_pars_fragment,\n\tencodings_fragment: encodings_fragment,\n\tencodings_pars_fragment: encodings_pars_fragment,\n\tenvmap_fragment: envmap_fragment,\n\tenvmap_common_pars_fragment: envmap_common_pars_fragment,\n\tenvmap_pars_fragment: envmap_pars_fragment,\n\tenvmap_pars_vertex: envmap_pars_vertex,\n\tenvmap_physical_pars_fragment: envmap_physical_pars_fragment,\n\tenvmap_vertex: envmap_vertex,\n\tfog_vertex: fog_vertex,\n\tfog_pars_vertex: fog_pars_vertex,\n\tfog_fragment: fog_fragment,\n\tfog_pars_fragment: fog_pars_fragment,\n\tgradientmap_pars_fragment: gradientmap_pars_fragment,\n\tlightmap_fragment: lightmap_fragment,\n\tlightmap_pars_fragment: lightmap_pars_fragment,\n\tlights_lambert_vertex: lights_lambert_vertex,\n\tlights_pars_begin: lights_pars_begin,\n\tlights_toon_fragment: lights_toon_fragment,\n\tlights_toon_pars_fragment: lights_toon_pars_fragment,\n\tlights_phong_fragment: lights_phong_fragment,\n\tlights_phong_pars_fragment: lights_phong_pars_fragment,\n\tlights_physical_fragment: lights_physical_fragment,\n\tlights_physical_pars_fragment: lights_physical_pars_fragment,\n\tlights_fragment_begin: lights_fragment_begin,\n\tlights_fragment_maps: lights_fragment_maps,\n\tlights_fragment_end: lights_fragment_end,\n\tlogdepthbuf_fragment: logdepthbuf_fragment,\n\tlogdepthbuf_pars_fragment: logdepthbuf_pars_fragment,\n\tlogdepthbuf_pars_vertex: logdepthbuf_pars_vertex,\n\tlogdepthbuf_vertex: logdepthbuf_vertex,\n\tmap_fragment: map_fragment,\n\tmap_pars_fragment: map_pars_fragment,\n\tmap_particle_fragment: map_particle_fragment,\n\tmap_particle_pars_fragment: map_particle_pars_fragment,\n\tmetalnessmap_fragment: metalnessmap_fragment,\n\tmetalnessmap_pars_fragment: metalnessmap_pars_fragment,\n\tmorphnormal_vertex: morphnormal_vertex,\n\tmorphtarget_pars_vertex: morphtarget_pars_vertex,\n\tmorphtarget_vertex: morphtarget_vertex,\n\tnormal_fragment_begin: normal_fragment_begin,\n\tnormal_fragment_maps: normal_fragment_maps,\n\tnormalmap_pars_fragment: normalmap_pars_fragment,\n\tclearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin,\n\tclearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps,\n\tclearcoat_pars_fragment: clearcoat_pars_fragment,\n\tpacking: packing,\n\tpremultiplied_alpha_fragment: premultiplied_alpha_fragment,\n\tproject_vertex: project_vertex,\n\tdithering_fragment: dithering_fragment,\n\tdithering_pars_fragment: dithering_pars_fragment,\n\troughnessmap_fragment: roughnessmap_fragment,\n\troughnessmap_pars_fragment: roughnessmap_pars_fragment,\n\tshadowmap_pars_fragment: shadowmap_pars_fragment,\n\tshadowmap_pars_vertex: shadowmap_pars_vertex,\n\tshadowmap_vertex: shadowmap_vertex,\n\tshadowmask_pars_fragment: shadowmask_pars_fragment,\n\tskinbase_vertex: skinbase_vertex,\n\tskinning_pars_vertex: skinning_pars_vertex,\n\tskinning_vertex: skinning_vertex,\n\tskinnormal_vertex: skinnormal_vertex,\n\tspecularmap_fragment: specularmap_fragment,\n\tspecularmap_pars_fragment: specularmap_pars_fragment,\n\ttonemapping_fragment: tonemapping_fragment,\n\ttonemapping_pars_fragment: tonemapping_pars_fragment,\n\tuv_pars_fragment: uv_pars_fragment,\n\tuv_pars_vertex: uv_pars_vertex,\n\tuv_vertex: uv_vertex,\n\tuv2_pars_fragment: uv2_pars_fragment,\n\tuv2_pars_vertex: uv2_pars_vertex,\n\tuv2_vertex: uv2_vertex,\n\tworldpos_vertex: worldpos_vertex,\n\n\tbackground_frag: background_frag,\n\tbackground_vert: background_vert,\n\tcube_frag: cube_frag,\n\tcube_vert: cube_vert,\n\tdepth_frag: depth_frag,\n\tdepth_vert: depth_vert,\n\tdistanceRGBA_frag: distanceRGBA_frag,\n\tdistanceRGBA_vert: distanceRGBA_vert,\n\tequirect_frag: equirect_frag,\n\tequirect_vert: equirect_vert,\n\tlinedashed_frag: linedashed_frag,\n\tlinedashed_vert: linedashed_vert,\n\tmeshbasic_frag: meshbasic_frag,\n\tmeshbasic_vert: meshbasic_vert,\n\tmeshlambert_frag: meshlambert_frag,\n\tmeshlambert_vert: meshlambert_vert,\n\tmeshmatcap_frag: meshmatcap_frag,\n\tmeshmatcap_vert: meshmatcap_vert,\n\tmeshtoon_frag: meshtoon_frag,\n\tmeshtoon_vert: meshtoon_vert,\n\tmeshphong_frag: meshphong_frag,\n\tmeshphong_vert: meshphong_vert,\n\tmeshphysical_frag: meshphysical_frag,\n\tmeshphysical_vert: meshphysical_vert,\n\tnormal_frag: normal_frag,\n\tnormal_vert: normal_vert,\n\tpoints_frag: points_frag,\n\tpoints_vert: points_vert,\n\tshadow_frag: shadow_frag,\n\tshadow_vert: shadow_vert,\n\tsprite_frag: sprite_frag,\n\tsprite_vert: sprite_vert\n};\n","export default /* glsl */`\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef ALPHATEST\n\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 transformed = vec3( position );\n`;\n","export default /* glsl */`\nvec3 objectNormal = vec3( normal );\n\n#ifdef USE_TANGENT\n\n\tvec3 objectTangent = vec3( tangent.xyz );\n\n#endif\n`;\n","export default /* glsl */`\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via 'environmentBRDF' from \"Physically Based Shading on Mobile\"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n\tvec4 r = roughness * c0 + c1;\n\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n}\n\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\n\tif( cutoffDistance > 0.0 ) {\n\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\n\t}\n\n\treturn distanceFalloff;\n\n#else\n\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n#endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\n\treturn RECIPROCAL_PI * diffuseColor;\n\n} // validated\n\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\n\t// Original approximation by Christophe Schlick '94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH '13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n} // validated\n\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\n\treturn Fr * fresnel + F0;\n\n}\n\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\t// geometry term (normalized) = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\n\t// also see #12151\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\n\treturn 1.0 / ( gl * gv );\n\n} // validated\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4's roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\tfloat D = D_GGX( alpha, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// Rect Area Light\n\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\n\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\tfloat dotNV = saturate( dot( N, V ) );\n\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\treturn uv;\n\n}\n\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\n\tfloat l = length( f );\n\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n\n}\n\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\n\tfloat x = dot( v1, v2 );\n\n\tfloat y = abs( x );\n\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\n\treturn cross( v1, v2 ) * theta_sintheta;\n\n}\n\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\n\t// transform rect\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\n\t// project rect onto sphere\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\n\t// calculate vector form factor\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\n\tfloat result = len * scale;\n*/\n\n\treturn vec3( result );\n\n}\n\n// End Rect Area Light\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Agüera's \"Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting\"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n\n}\n\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n\n}\n\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n\n}\n\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\n\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n\n#if defined( USE_SHEEN )\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, \"Production Friendly Microfacet Sheen BRDF\"\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, \"Crafting a Next-gen Material Pipeline for The Order: 1886\"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\n\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n\n}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen\n\t// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf\n\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvec4 plane;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\n\t\tbool clipped = true;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t\tif ( clipped ) discard;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvClipPosition = - mvPosition.xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tdiffuseColor.rgb *= vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvColor.xyz = color.xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\n\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\n\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\n\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n}\n\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t// dir can be either a direction vector or a normal vector\n\t// upper-left 3x3 of matrix is assumed to be orthogonal\n\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n\n}\n\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\n\treturn - distance * planeNormal + point;\n\n}\n\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n\n}\n\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n\n}\n\nmat3 transposeMat3( const in mat3 m ) {\n\n\tmat3 tmp;\n\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\n\treturn tmp;\n\n}\n\n// https://en.wikipedia.org/wiki/Relative_luminance\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\n\treturn dot( weights, color.rgb );\n\n}\n\nbool isPerspectiveMatrix( mat4 m ) {\n\n return m[ 2 ][ 3 ] == - 1.0;\n\n}\n\nvec2 equirectUv( in vec3 dir ) {\n\n\t// dir is assumed to be unit length\n\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\treturn vec2( u, v );\n\n}\n`;\n","export default /* glsl */`\n#ifdef ENVMAP_TYPE_CUBE_UV\n\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\n\n// These shader functions convert between the UV coordinates of a single face of\n// a cubemap, the 0-5 integer index of a cube face, and the direction vector for\n// sampling a textureCube (not generally normalized).\n\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\n\n// RH coordinate system; PMREM face-indexing convention\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x\n } else if (face == 1.0) {\n uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y\n } else if (face == 2.0) {\n uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z\n } else if (face == 3.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x\n } else if (face == 4.0) {\n uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y\n } else {\n uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z\n }\n return 0.5 * (uv + 1.0);\n}\n\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n\n// These defines must match with PMREMGenerator\n\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\n\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n }\n return mip;\n}\n\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif\n`;\n","export default /* glsl */`\nvec3 transformedNormal = objectNormal;\n\n#ifdef USE_INSTANCING\n\n\t// this is in lieu of a per-instance normal-matrix\n\t// shear transforms in the instance matrix are not supported\n\n\tmat3 m = mat3( instanceMatrix );\n\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\n\ttransformedNormal = m * transformedNormal;\n\n#endif\n\ntransformedNormal = normalMatrix * transformedNormal;\n\n#ifdef FLIP_SIDED\n\n\ttransformedNormal = - transformedNormal;\n\n#endif\n\n#ifdef USE_TANGENT\n\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#ifdef FLIP_SIDED\n\n\t\ttransformedTangent = - transformedTangent;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_DISPLACEMENTMAP\n\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_EMISSIVEMAP\n\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_EMISSIVEMAP\n\n\tuniform sampler2D emissiveMap;\n\n#endif\n`;\n","export default /* glsl */`\ngl_FragColor = linearToOutputTexel( gl_FragColor );\n`;\n","export default /* glsl */`\n// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\n\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\n\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\n\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\n\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\n\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\n\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\n\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\t// NOTE: The implementation with min causes the shader to not compile on\n\t// a common Alcatel A502DL in Chrome 78/Android 8.1. Some research suggests \n\t// that the chipset is Mediatek MT6739 w/ IMG PowerVR GE8100 GPU.\n\t// D = min( floor( D ) / 255.0, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\n\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\n\n// M matrix, for encoding\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\n\n// Inverse M matrix, for decoding\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\n\t\t}\n\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#else\n\n\t\tvec3 reflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tvec2 sampleUV = equirectUv( reflectVec );\n\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\n\t#else\n\n\t\tvec4 envColor = vec4( 0.0 );\n\n\t#endif\n\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\n\t\tenvColor = envMapTexelToLinear( envColor );\n\n\t#endif\n\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_ENVMAP )\n\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\n\tvec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {\n\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#else\n\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\n\t\t#else\n\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\n\t\t#endif\n\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\n\t}\n\n\t// Trowbridge-Reitz distribution to Mip level, following the logic of http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\n\t\t// clamp to allowable LOD ranges.\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\n\t}\n\n\tvec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\n\t\t // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\n\t\t#else\n\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\n\t\t#endif\n\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\t\tvec2 sampleUV = equirectUv( reflectVec );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#endif\n\n\t\treturn envMapColor.rgb * envMapIntensity;\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvWorldPosition = worldPosition.xyz;\n\n\t#else\n\n\t\tvec3 cameraToVertex;\n\n\t\tif ( isOrthographic ) { \n\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\t\t}\n\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t\t#else\n\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tfogDepth = -mvPosition.z;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tvarying float fogDepth;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\t#ifdef FOG_EXP2\n\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\n\t#endif\n\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n\n#ifdef USE_GRADIENTMAP\n\n\tuniform sampler2D gradientMap;\n\n#endif\n\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\n\t// dotNL will be from -1.0 to 1.0\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\n\t#ifdef USE_GRADIENTMAP\n\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\n\t#else\n\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\n\t#endif\n\n}\n\n`;\n","export default /* glsl */`\n#ifdef USE_LIGHTMAP\n\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LIGHTMAP\n\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 diffuse = vec3( 1.0 );\n\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\n\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\n\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\n\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n\n#ifdef DOUBLE_SIDED\n\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n\n#endif\n\n#if NUM_POINT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n/*\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\t// TODO (abelnation): implement\n\n\t}\n\n#endif\n*/\n\n#if NUM_DIR_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_HEMI_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n`;\n","export default /* glsl */`\nuniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\n\n// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\n\t// normal is assumed to have unit length\n\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\n\t// band 0\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\n\t// band 1\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\n\t// band 2\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\n\treturn result;\n\n}\n\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\n\treturn irradiance;\n\n}\n\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\n\tvec3 irradiance = ambientLightColor;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI;\n\n\t#endif\n\n\treturn irradiance;\n\n}\n\n#if NUM_DIR_LIGHTS > 0\n\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\n\t}\n\n#endif\n\n\n#if NUM_POINT_LIGHTS > 0\n\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\n\t}\n\n#endif\n\n\n#if NUM_SPOT_LIGHTS > 0\n\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\n\t\tif ( angleCos > spotLight.coneCos ) {\n\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\n\t\t} else {\n\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\n\t\t}\n\t}\n\n#endif\n\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\n\t// Pre-computed values of LinearTransformedCosine approximation of BRDF\n\t// BRDF approximation Texture is 64x64\n\tuniform sampler2D ltc_1; // RGBA Float\n\tuniform sampler2D ltc_2; // RGBA Float\n\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n\n#endif\n\n\n#if NUM_HEMI_LIGHTS > 0\n\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tirradiance *= PI;\n\n\t\t#endif\n\n\t\treturn irradiance;\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\nToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\n`;\n","export default /* glsl */`\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct ToonMaterial {\n\n\tvec3\tdiffuseColor;\n\n};\n\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\n#define Material_LightProbeLOD( material )\t(0)\n`;\n","export default /* glsl */`\nBlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n`;\n","export default /* glsl */`\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct BlinnPhongMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n\n#define Material_LightProbeLOD( material )\t(0)\n`;\n","export default /* glsl */`\nPhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\n\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\n\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n\n#ifdef REFLECTIVITY\n\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\n#else\n\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n\n#endif\n\n#ifdef CLEARCOAT\n\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\n\t#ifdef USE_CLEARCOATMAP\n\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\n\t#endif\n\n\tmaterial.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model\n\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n\n#endif\n\n#ifdef USE_SHEEN\n\n\tmaterial.sheenColor = sheen;\n\n#endif\n`;\n","export default /* glsl */`\nstruct PhysicalMaterial {\n\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n\n};\n\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n\n// Clear coat directional hemishperical reflectance (this approximation should be improved)\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n\n}\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction\n\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\n\t\t// LTC Fresnel Approximation by Stephen Hill\n\t\t// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\n\t}\n\n#endif\n\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tccIrradiance *= PI; // punctual light\n\n\t\t#endif\n\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\n\t// Both indirect specular and indirect diffuse light accumulate here\n\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n\n// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n\n}\n`;\n","export default /* glsl */`\n/**\n * This is a template that can be used to light a material, it uses pluggable\n * RenderEquations (RE)for specific lighting scenarios.\n *\n * Instructions for use:\n * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined\n * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???\n * - Create a material parameter that is to be passed as the third parameter to your lighting functions.\n *\n * TODO:\n * - Add area light support.\n * - Add sphere light support.\n * - Add diffuse light probe (irradiance cubemap) support.\n */\n\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( RE_IndirectDiffuse )\n\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\t// Doing a strict comparison with == 1.0 can cause noise artifacts\n\t// on some platforms. See issue #17623.\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\n\t#else\n\n\t\tuniform float logDepthBufFC;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\n\t#else\n\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\n\t\t\tgl_Position.z *= gl_Position.w;\n\n\t\t}\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_MAP\n\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tuniform mat3 uvTransform;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n`;\n","export default /* glsl */`\nfloat metalnessFactor = metalness;\n\n#ifdef USE_METALNESSMAP\n\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\n\t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tmetalnessFactor *= texelMetalness.b;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_METALNESSMAP\n\n\tuniform sampler2D metalnessMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHNORMALS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHTARGETS\n\n\tuniform float morphTargetBaseInfluence;\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHTARGETS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef FLAT_SHADED\n\n\t// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...\n\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n\n#else\n\n\tvec3 normal = normalize( vNormal );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\t#ifdef USE_TANGENT\n\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n\n// non perturbed normal for clearcoat among others\n\nvec3 geometryNormal = normal;\n\n`;\n","export default /* glsl */`\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n\t#ifdef FLIP_SIDED\n\n\t\tnormal = - normal;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\tnormal = normalize( normalMatrix * normal );\n\n#elif defined( TANGENTSPACE_NORMALMAP )\n\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tnormal = normalize( vTBN * mapN );\n\n\t#else\n\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\n\t#endif\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n#endif\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tuniform mat3 normalMatrix;\n\n#endif\n\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\n\t// Per-Pixel Tangent Space Normal Mapping\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tmat3 tsn = mat3( S, T, N );\n\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef CLEARCOAT\n\n\tvec3 clearcoatNormal = geometryNormal;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\n\t#else\n\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n\n#ifdef USE_CLEARCOATMAP\n\n\tuniform sampler2D clearcoatMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform sampler2D clearcoatRoughnessMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\n\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\n\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\n\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\nconst float ShiftRight8 = 1. / 256.;\n\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\n\treturn r * PackUpscale;\n}\n\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\n\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\n\n// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions\n\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\n\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n`;\n","export default /* glsl */`\n#ifdef PREMULTIPLIED_ALPHA\n\n\t// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.\n\tgl_FragColor.rgb *= gl_FragColor.a;\n\n#endif\n`;\n","export default /* glsl */`\nvec4 mvPosition = vec4( transformed, 1.0 );\n\n#ifdef USE_INSTANCING\n\n\tmvPosition = instanceMatrix * mvPosition;\n\n#endif\n\nmvPosition = modelViewMatrix * mvPosition;\n\ngl_Position = projectionMatrix * mvPosition;\n`;\n","export default /* glsl */`\n#ifdef DITHERING\n\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef DITHERING\n\n\t// based on https://www.shadertoy.com/view/MslGR8\n\tvec3 dithering( vec3 color ) {\n\t\t//Calculate grid position\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\n\t\t//modify shift acording to grid position.\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\n\t\t//shift the color by dither_shift\n\t\treturn color + dither_shift_RGB;\n\t}\n\n#endif\n`;\n","export default /* glsl */`\nfloat roughnessFactor = roughness;\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\n\t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\troughnessFactor *= texelRoughness.g;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform sampler2D roughnessMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): create uniforms for area light shadows\n\n\t#endif\n\t*/\n\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\n\t}\n\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n\t}\n\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n\t\tfloat occlusion = 1.0;\n\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\n\t\tfloat hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n\t\tif (hard_shadow != 1.0 ) {\n\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n\t\t}\n\t\treturn occlusion;\n\n\t}\n\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n\t\tfloat shadow = 1.0;\n\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\n\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t// if ( all( something, something ) ) using this instead\n\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#else // no percentage-closer filtering:\n\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#endif\n\n\t\t}\n\n\t\treturn shadow;\n\n\t}\n\n\t// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D\n\t// vector suitable for 2D texture mapping. This code uses the following layout for the\n\t// 2D texture:\n\t//\n\t// xzXZ\n\t// y Y\n\t//\n\t// Y - Positive y direction\n\t// y - Negative y direction\n\t// X - Positive x direction\n\t// x - Negative x direction\n\t// Z - Positive z direction\n\t// z - Negative z direction\n\t//\n\t// Source and test bed:\n\t// https://gist.github.com/tschw/da10c43c467ce8afd0c4\n\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\n\t\t// Number of texels to avoid at the edge of each square\n\n\t\tvec3 absV = abs( v );\n\n\t\t// Intersect unit cube\n\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\n\t\t// Apply scale to avoid seams\n\n\t\t// two texels less per square (one texel will do for NEAREST)\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\n\t\t// Unwrap\n\n\t\t// space: -1 ... 1 range for each square\n\t\t//\n\t\t// #X##\t\tdim := ( 4 , 2 )\n\t\t// # #\t\tcenter := ( 1 , 1 )\n\n\t\tvec2 planar = v.xy;\n\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\n\t\tif ( absV.z >= almostOne ) {\n\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\n\t\t} else if ( absV.x >= almostOne ) {\n\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\n\t\t} else if ( absV.y >= almostOne ) {\n\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\n\t\t}\n\n\t\t// Transform to UV space\n\n\t\t// scale := 0.5 / dim\n\t\t// translate := ( center + 0.5 ) / dim\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\n\t}\n\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n\t\t// for point lights, the uniform @vShadowCoord is re-purposed to hold\n\t\t// the vector from the light to the world-space position of the fragment.\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\n\t\t// dp = normalized distance from light to fragment position\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?\n\t\tdp += shadowBias;\n\n\t\t// bd3D = base direction 3D\n\t\tvec3 bd3D = normalize( lightToPosition );\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#else // no percentage-closer filtering\n\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\n\t\t#endif\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): uniforms for area light shadows\n\n\t#endif\n\t*/\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\t// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\n\t#endif\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update vAreaShadowCoord with area light info\n\n\t#endif\n\t*/\n\n#endif\n`;\n","export default /* glsl */`\nfloat getShadowMask() {\n\n\tfloat shadow = 1.0;\n\n\t#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\tDirectionalLightShadow directionalLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\tSpotLightShadow spotLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\tPointLightShadow pointLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update shadow for Area light\n\n\t#endif\n\t*/\n\n\t#endif\n\n\treturn shadow;\n\n}\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\n\t\t\ty = dy * ( y + 0.5 );\n\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\n\t#ifdef USE_TANGENT\n\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\nfloat specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( TONE_MAPPING )\n\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\n#endif\n`;\n","export default /* glsl */`\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n\nuniform float toneMappingExposure;\n\n// exposure only\nvec3 LinearToneMapping( vec3 color ) {\n\n\treturn toneMappingExposure * color;\n\n}\n\n// source: https://www.cs.utah.edu/~reinhard/cdrom/\nvec3 ReinhardToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n\n}\n\n// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\n\t// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n\n}\n\n// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs\nvec3 RRTAndODTFit( vec3 v ) {\n\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n\n}\n\n// this implementation of ACES is modified to accommodate a brighter viewing environment.\n// the scale factor of 1/0.6 is subjective. see discussion in #19621.\n\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\n\t// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ), // transposed from source\n\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\n\t// ODT_SAT => XYZ => D60_2_D65 => sRGB\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ), // transposed from source\n\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\n\tcolor *= toneMappingExposure / 0.6;\n\n\tcolor = ACESInputMat * color;\n\n\t// Apply RRT and ODT\n\tcolor = RRTAndODTFit( color );\n\n\tcolor = ACESOutputMat * color;\n\n\t// Clamp to [0, 1]\n\treturn saturate( color );\n\n}\n\nvec3 CustomToneMapping( vec3 color ) { return color; }\n`;\n","export default /* glsl */`\n#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\n\tvarying vec2 vUv;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_UV\n\n\t#ifdef UVS_VERTEX_ONLY\n\n\t\tvec2 vUv;\n\n\t#else\n\n\t\tvarying vec2 vUv;\n\n\t#endif\n\n\tuniform mat3 uvTransform;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_UV\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvarying vec2 vUv2;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\n\tuniform mat3 uv2Transform;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t#ifdef USE_INSTANCING\n\n\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t#endif\n\n\tworldPosition = modelMatrix * worldPosition;\n\n#endif\n`;\n","export default /* glsl */`\nuniform sampler2D t2D;\n\nvarying vec2 vUv;\n\nvoid main() {\n\n\tvec4 texColor = texture2D( t2D, vUv );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec2 vUv;\nuniform mat3 uvTransform;\n\nvoid main() {\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n\n}\n`;\n","export default /* glsl */`\n#include \nuniform float opacity;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n}\n`;\n","export default /* glsl */`\n#if DEPTH_PACKING == 3200\n\n\tuniform float opacity;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tdiffuseColor.a = opacity;\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\n\t// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\n\t#elif DEPTH_PACKING == 3201\n\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\n\t#endif\n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvHighPrecisionZW = gl_Position.zw;\n\n}\n`;\n","export default /* glsl */`\n#define DISTANCE\n\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main () {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#include \n\t#include \n\t#include \n\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist ); // clamp to [ 0, 1 ]\n\n\tgl_FragColor = packDepthToRGBA( dist );\n\n}\n`;\n","export default /* glsl */`\n#define DISTANCE\n\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvWorldPosition = worldPosition.xyz;\n\n}\n`;\n","export default /* glsl */`\nuniform sampler2D tEquirect;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 direction = normalize( vWorldDirection );\n\n\tvec2 sampleUV = equirectUv( direction );\n\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform float dashSize;\nuniform float totalSize;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\n\t\tdiscard;\n\n\t}\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb; // simple shader\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float scale;\nattribute float lineDistance;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tvLineDistance = scale * lineDistance;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\n\t#endif\n\n\t// modulation\n\t#include \n\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifdef USE_ENVMAP\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\n\t#endif\n\n\t#include \n\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\n\t#else\n\n\t\treflectedLight.directDiffuse = vLightFront;\n\n\t#endif\n\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\n\t// modulation\n\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n`;\n","export default /* glsl */`\n#define LAMBERT\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n`;\n","export default /* glsl */`\n#define MATCAP\n\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks\n\n\t#ifdef USE_MATCAP\n\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\n\t#else\n\n\t\tvec4 matcapColor = vec4( 1.0 );\n\n\t#endif\n\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define MATCAP\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\t\tvNormal = normalize( transformedNormal );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n}\n`;\n","export default /* glsl */`\n#define TOON\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define TOON\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define PHONG\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t// this is a stub for the transparency model\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define NORMAL\n\nuniform float opacity;\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\n}\n`;\n","export default /* glsl */`\n#define NORMAL\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvViewPosition = - mvPosition.xyz;\n\n#endif\n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float size;\nuniform float scale;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_PointSize = size;\n\n\t#ifdef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 color;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float rotation;\nuniform vec2 center;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n\t#ifndef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\n\t#endif\n\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\n\tmvPosition.xy += rotatedPosition;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","import { ShaderChunk } from './ShaderChunk.js';\nimport { mergeUniforms } from './UniformsUtils.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Vector3 } from '../../math/Vector3.js';\nimport { UniformsLib } from './UniformsLib.js';\nimport { Color } from '../../math/Color.js';\nimport { Matrix3 } from '../../math/Matrix3.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n */\n\nconst ShaderLib = {\n\n\tbasic: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshbasic_vert,\n\t\tfragmentShader: ShaderChunk.meshbasic_frag\n\n\t},\n\n\tlambert: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshlambert_vert,\n\t\tfragmentShader: ShaderChunk.meshlambert_frag\n\n\t},\n\n\tphong: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\tspecular: { value: new Color( 0x111111 ) },\n\t\t\t\tshininess: { value: 30 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphong_vert,\n\t\tfragmentShader: ShaderChunk.meshphong_frag\n\n\t},\n\n\tstandard: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.roughnessmap,\n\t\t\tUniformsLib.metalnessmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\troughness: { value: 1.0 },\n\t\t\t\tmetalness: { value: 0.0 },\n\t\t\t\tenvMapIntensity: { value: 1 } // temporary\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\n\t},\n\n\ttoon: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.gradientmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshtoon_vert,\n\t\tfragmentShader: ShaderChunk.meshtoon_frag\n\n\t},\n\n\tmatcap: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tmatcap: { value: null }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshmatcap_vert,\n\t\tfragmentShader: ShaderChunk.meshmatcap_frag\n\n\t},\n\n\tpoints: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.points,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.points_vert,\n\t\tfragmentShader: ShaderChunk.points_frag\n\n\t},\n\n\tdashed: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tscale: { value: 1 },\n\t\t\t\tdashSize: { value: 1 },\n\t\t\t\ttotalSize: { value: 2 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.linedashed_vert,\n\t\tfragmentShader: ShaderChunk.linedashed_frag\n\n\t},\n\n\tdepth: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.displacementmap\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.depth_vert,\n\t\tfragmentShader: ShaderChunk.depth_frag\n\n\t},\n\n\tnormal: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\t{\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.normal_vert,\n\t\tfragmentShader: ShaderChunk.normal_frag\n\n\t},\n\n\tsprite: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.sprite,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.sprite_vert,\n\t\tfragmentShader: ShaderChunk.sprite_frag\n\n\t},\n\n\tbackground: {\n\n\t\tuniforms: {\n\t\t\tuvTransform: { value: new Matrix3() },\n\t\t\tt2D: { value: null },\n\t\t},\n\n\t\tvertexShader: ShaderChunk.background_vert,\n\t\tfragmentShader: ShaderChunk.background_frag\n\n\t},\n\t/* -------------------------------------------------------------------------\n\t//\tCube map shader\n\t ------------------------------------------------------------------------- */\n\n\tcube: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.envmap,\n\t\t\t{\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.cube_vert,\n\t\tfragmentShader: ShaderChunk.cube_frag\n\n\t},\n\n\tequirect: {\n\n\t\tuniforms: {\n\t\t\ttEquirect: { value: null },\n\t\t},\n\n\t\tvertexShader: ShaderChunk.equirect_vert,\n\t\tfragmentShader: ShaderChunk.equirect_frag\n\n\t},\n\n\tdistanceRGBA: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.displacementmap,\n\t\t\t{\n\t\t\t\treferencePosition: { value: new Vector3() },\n\t\t\t\tnearDistance: { value: 1 },\n\t\t\t\tfarDistance: { value: 1000 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.distanceRGBA_vert,\n\t\tfragmentShader: ShaderChunk.distanceRGBA_frag\n\n\t},\n\n\tshadow: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.lights,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tcolor: { value: new Color( 0x00000 ) },\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t},\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.shadow_vert,\n\t\tfragmentShader: ShaderChunk.shadow_frag\n\n\t}\n\n};\n\nShaderLib.physical = {\n\n\tuniforms: mergeUniforms( [\n\t\tShaderLib.standard.uniforms,\n\t\t{\n\t\t\tclearcoat: { value: 0 },\n\t\t\tclearcoatMap: { value: null },\n\t\t\tclearcoatRoughness: { value: 0 },\n\t\t\tclearcoatRoughnessMap: { value: null },\n\t\t\tclearcoatNormalScale: { value: new Vector2( 1, 1 ) },\n\t\t\tclearcoatNormalMap: { value: null },\n\t\t\tsheen: { value: new Color( 0x000000 ) },\n\t\t\ttransparency: { value: 0 },\n\t\t}\n\t] ),\n\n\tvertexShader: ShaderChunk.meshphysical_vert,\n\tfragmentShader: ShaderChunk.meshphysical_frag\n\n};\n\n\nexport { ShaderLib };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide, FrontSide, CubeUVReflectionMapping } from '../../constants.js';\nimport { BoxBufferGeometry } from '../../geometries/BoxGeometry.js';\nimport { PlaneBufferGeometry } from '../../geometries/PlaneGeometry.js';\nimport { ShaderMaterial } from '../../materials/ShaderMaterial.js';\nimport { Color } from '../../math/Color.js';\nimport { Mesh } from '../../objects/Mesh.js';\nimport { ShaderLib } from '../shaders/ShaderLib.js';\nimport { cloneUniforms } from '../shaders/UniformsUtils.js';\n\nfunction WebGLBackground( renderer, state, objects, premultipliedAlpha ) {\n\n\tconst clearColor = new Color( 0x000000 );\n\tlet clearAlpha = 0;\n\n\tlet planeMesh;\n\tlet boxMesh;\n\n\tlet currentBackground = null;\n\tlet currentBackgroundVersion = 0;\n\tlet currentTonemapping = null;\n\n\tfunction render( renderList, scene, camera, forceClear ) {\n\n\t\tlet background = scene.isScene === true ? scene.background : null;\n\n\t\t// Ignore background in AR\n\t\t// TODO: Reconsider this.\n\n\t\tconst xr = renderer.xr;\n\t\tconst session = xr.getSession && xr.getSession();\n\n\t\tif ( session && session.environmentBlendMode === 'additive' ) {\n\n\t\t\tbackground = null;\n\n\t\t}\n\n\t\tif ( background === null ) {\n\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t} else if ( background && background.isColor ) {\n\n\t\t\tsetClear( background, 1 );\n\t\t\tforceClear = true;\n\n\t\t}\n\n\t\tif ( renderer.autoClear || forceClear ) {\n\n\t\t\trenderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );\n\n\t\t}\n\n\t\tif ( background && ( background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping ) ) {\n\n\t\t\tif ( boxMesh === undefined ) {\n\n\t\t\t\tboxMesh = new Mesh(\n\t\t\t\t\tnew BoxBufferGeometry( 1, 1, 1 ),\n\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\tname: 'BackgroundCubeMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.cube.uniforms ),\n\t\t\t\t\t\tvertexShader: ShaderLib.cube.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.cube.fragmentShader,\n\t\t\t\t\t\tside: BackSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\t\tboxMesh.geometry.deleteAttribute( 'normal' );\n\t\t\t\tboxMesh.geometry.deleteAttribute( 'uv' );\n\n\t\t\t\tboxMesh.onBeforeRender = function ( renderer, scene, camera ) {\n\n\t\t\t\t\tthis.matrixWorld.copyPosition( camera.matrixWorld );\n\n\t\t\t\t};\n\n\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\tObject.defineProperty( boxMesh.material, 'envMap', {\n\n\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\treturn this.uniforms.envMap.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\tobjects.update( boxMesh );\n\n\t\t\t}\n\n\t\t\tconst texture = background.isWebGLCubeRenderTarget ? background.texture : background;\n\n\t\t\tboxMesh.material.uniforms.envMap.value = texture;\n\t\t\tboxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1;\n\n\t\t\tif ( currentBackground !== background ||\n\t\t\t\tcurrentBackgroundVersion !== texture.version ||\n\t\t\t\tcurrentTonemapping !== renderer.toneMapping ) {\n\n\t\t\t\tboxMesh.material.needsUpdate = true;\n\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = texture.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\n\t\t\t}\n\n\t\t\t// push to the pre-sorted opaque render list\n\t\t\trenderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null );\n\n\t\t} else if ( background && background.isTexture ) {\n\n\t\t\tif ( planeMesh === undefined ) {\n\n\t\t\t\tplaneMesh = new Mesh(\n\t\t\t\t\tnew PlaneBufferGeometry( 2, 2 ),\n\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\tname: 'BackgroundMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.background.uniforms ),\n\t\t\t\t\t\tvertexShader: ShaderLib.background.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.background.fragmentShader,\n\t\t\t\t\t\tside: FrontSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\t\tplaneMesh.geometry.deleteAttribute( 'normal' );\n\n\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\tObject.defineProperty( planeMesh.material, 'map', {\n\n\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\treturn this.uniforms.t2D.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\tobjects.update( planeMesh );\n\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.t2D.value = background;\n\n\t\t\tif ( background.matrixAutoUpdate === true ) {\n\n\t\t\t\tbackground.updateMatrix();\n\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.uvTransform.value.copy( background.matrix );\n\n\t\t\tif ( currentBackground !== background ||\n\t\t\t\tcurrentBackgroundVersion !== background.version ||\n\t\t\t\tcurrentTonemapping !== renderer.toneMapping ) {\n\n\t\t\t\tplaneMesh.material.needsUpdate = true;\n\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = background.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\n\t\t\t}\n\n\n\t\t\t// push to the pre-sorted opaque render list\n\t\t\trenderList.unshift( planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null );\n\n\t\t}\n\n\t}\n\n\tfunction setClear( color, alpha ) {\n\n\t\tstate.buffers.color.setClear( color.r, color.g, color.b, alpha, premultipliedAlpha );\n\n\t}\n\n\treturn {\n\n\t\tgetClearColor: function () {\n\n\t\t\treturn clearColor;\n\n\t\t},\n\t\tsetClearColor: function ( color, alpha ) {\n\n\t\t\tclearColor.set( color );\n\t\t\tclearAlpha = alpha !== undefined ? alpha : 1;\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t},\n\t\tgetClearAlpha: function () {\n\n\t\t\treturn clearAlpha;\n\n\t\t},\n\t\tsetClearAlpha: function ( alpha ) {\n\n\t\t\tclearAlpha = alpha;\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t},\n\t\trender: render\n\n\t};\n\n}\n\n\nexport { WebGLBackground };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n * @author Takahiro / https://github.com/takahirox\n */\n\nfunction WebGLBindingStates( gl, extensions, attributes, capabilities ) {\n\n\tconst maxVertexAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );\n\n\tconst extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' );\n\tconst vaoAvailable = capabilities.isWebGL2 || extension !== null;\n\n\tconst bindingStates = {};\n\n\tconst defaultState = createBindingState( null );\n\tlet currentState = defaultState;\n\n\tfunction setup( object, material, program, geometry, index ) {\n\n\t\tlet updateBuffers = false;\n\n\t\tif ( vaoAvailable ) {\n\n\t\t\tconst state = getBindingState( geometry, program, material );\n\n\t\t\tif ( currentState !== state ) {\n\n\t\t\t\tcurrentState = state;\n\t\t\t\tbindVertexArrayObject( currentState.object );\n\n\t\t\t}\n\n\t\t\tupdateBuffers = needsUpdate( geometry );\n\n\t\t\tif ( updateBuffers ) saveCache( geometry );\n\n\t\t} else {\n\n\t\t\tconst wireframe = ( material.wireframe === true );\n\n\t\t\tif ( currentState.geometry !== geometry.id ||\n\t\t\t\tcurrentState.program !== program.id ||\n\t\t\t\tcurrentState.wireframe !== wireframe ) {\n\n\t\t\t\tcurrentState.geometry = geometry.id;\n\t\t\t\tcurrentState.program = program.id;\n\t\t\t\tcurrentState.wireframe = wireframe;\n\n\t\t\t\tupdateBuffers = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh === true ) {\n\n\t\t\tupdateBuffers = true;\n\n\t\t}\n\n\t\tif ( index !== null ) {\n\n\t\t\tattributes.update( index, gl.ELEMENT_ARRAY_BUFFER );\n\n\t\t}\n\n\t\tif ( updateBuffers ) {\n\n\t\t\tsetupVertexAttributes( object, material, program, geometry );\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tgl.bindBuffer( gl.ELEMENT_ARRAY_BUFFER, attributes.get( index ).buffer );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction createVertexArrayObject() {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.createVertexArray();\n\n\t\treturn extension.createVertexArrayOES();\n\n\t}\n\n\tfunction bindVertexArrayObject( vao ) {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.bindVertexArray( vao );\n\n\t\treturn extension.bindVertexArrayOES( vao );\n\n\t}\n\n\tfunction deleteVertexArrayObject( vao ) {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.deleteVertexArray( vao );\n\n\t\treturn extension.deleteVertexArrayOES( vao );\n\n\t}\n\n\tfunction getBindingState( geometry, program, material ) {\n\n\t\tconst wireframe = ( material.wireframe === true );\n\n\t\tlet programMap = bindingStates[ geometry.id ];\n\n\t\tif ( programMap === undefined ) {\n\n\t\t\tprogramMap = {};\n\t\t\tbindingStates[ geometry.id ] = programMap;\n\n\t\t}\n\n\t\tlet stateMap = programMap[ program.id ];\n\n\t\tif ( stateMap === undefined ) {\n\n\t\t\tstateMap = {};\n\t\t\tprogramMap[ program.id ] = stateMap;\n\n\t\t}\n\n\t\tlet state = stateMap[ wireframe ];\n\n\t\tif ( state === undefined ) {\n\n\t\t\tstate = createBindingState( createVertexArrayObject() );\n\t\t\tstateMap[ wireframe ] = state;\n\n\t\t}\n\n\t\treturn state;\n\n\t}\n\n\tfunction createBindingState( vao ) {\n\n\t\tconst newAttributes = [];\n\t\tconst enabledAttributes = [];\n\t\tconst attributeDivisors = [];\n\n\t\tfor ( let i = 0; i < maxVertexAttributes; i ++ ) {\n\n\t\t\tnewAttributes[ i ] = 0;\n\t\t\tenabledAttributes[ i ] = 0;\n\t\t\tattributeDivisors[ i ] = 0;\n\n\t\t}\n\n\t\treturn {\n\n\t\t\t// for backward compatibility on non-VAO support browser\n\t\t\tgeometry: null,\n\t\t\tprogram: null,\n\t\t\twireframe: false,\n\n\t\t\tnewAttributes: newAttributes,\n\t\t\tenabledAttributes: enabledAttributes,\n\t\t\tattributeDivisors: attributeDivisors,\n\t\t\tobject: vao,\n\t\t\tattributes: {}\n\n\t\t};\n\n\t}\n\n\tfunction needsUpdate( geometry ) {\n\n\t\tconst cachedAttributes = currentState.attributes;\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\tif ( Object.keys( cachedAttributes ).length !== Object.keys( geometryAttributes ).length ) return true;\n\n\t\tfor ( const key in geometryAttributes ) {\n\n\t\t\tconst cachedAttribute = cachedAttributes[ key ];\n\t\t\tconst geometryAttribute = geometryAttributes[ key ];\n\n\t\t\tif ( cachedAttribute.attribute !== geometryAttribute ) return true;\n\n\t\t\tif ( cachedAttribute.data !== geometryAttribute.data ) return true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tfunction saveCache( geometry ) {\n\n\t\tconst cache = {};\n\t\tconst attributes = geometry.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tconst attribute = attributes[ key ];\n\n\t\t\tconst data = {};\n\t\t\tdata.attribute = attribute;\n\n\t\t\tif ( attribute.data ) {\n\n\t\t\t\tdata.data = attribute.data;\n\n\t\t\t}\n\n\t\t\tcache[ key ] = data;\n\n\t\t}\n\n\t\tcurrentState.attributes = cache;\n\n\t}\n\n\tfunction initAttributes() {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\n\t\tfor ( let i = 0, il = newAttributes.length; i < il; i ++ ) {\n\n\t\t\tnewAttributes[ i ] = 0;\n\n\t\t}\n\n\t}\n\n\tfunction enableAttribute( attribute ) {\n\n\t\tenableAttributeAndDivisor( attribute, 0 );\n\n\t}\n\n\tfunction enableAttributeAndDivisor( attribute, meshPerAttribute ) {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\t\tconst attributeDivisors = currentState.attributeDivisors;\n\n\t\tnewAttributes[ attribute ] = 1;\n\n\t\tif ( enabledAttributes[ attribute ] === 0 ) {\n\n\t\t\tgl.enableVertexAttribArray( attribute );\n\t\t\tenabledAttributes[ attribute ] = 1;\n\n\t\t}\n\n\t\tif ( attributeDivisors[ attribute ] !== meshPerAttribute ) {\n\n\t\t\tconst extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t\textension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );\n\t\t\tattributeDivisors[ attribute ] = meshPerAttribute;\n\n\t\t}\n\n\t}\n\n\tfunction disableUnusedAttributes() {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\n\t\tfor ( let i = 0, il = enabledAttributes.length; i < il; i ++ ) {\n\n\t\t\tif ( enabledAttributes[ i ] !== newAttributes[ i ] ) {\n\n\t\t\t\tgl.disableVertexAttribArray( i );\n\t\t\t\tenabledAttributes[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction vertexAttribPointer( index, size, type, normalized, stride, offset ) {\n\n\t\tif ( capabilities.isWebGL2 === true && ( type === gl.INT || type === gl.UNSIGNED_INT ) ) {\n\n\t\t\tgl.vertexAttribIPointer( index, size, type, normalized, stride, offset );\n\n\t\t} else {\n\n\t\t\tgl.vertexAttribPointer( index, size, type, normalized, stride, offset );\n\n\t\t}\n\n\t}\n\n\tfunction setupVertexAttributes( object, material, program, geometry ) {\n\n\t\tif ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) {\n\n\t\t\tif ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return;\n\n\t\t}\n\n\t\tinitAttributes();\n\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tconst materialDefaultAttributeValues = material.defaultAttributeValues;\n\n\t\tfor ( const name in programAttributes ) {\n\n\t\t\tconst programAttribute = programAttributes[ name ];\n\n\t\t\tif ( programAttribute >= 0 ) {\n\n\t\t\t\tconst geometryAttribute = geometryAttributes[ name ];\n\n\t\t\t\tif ( geometryAttribute !== undefined ) {\n\n\t\t\t\t\tconst normalized = geometryAttribute.normalized;\n\t\t\t\t\tconst size = geometryAttribute.itemSize;\n\n\t\t\t\t\tconst attribute = attributes.get( geometryAttribute );\n\n\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\t\t\t\t\tconst bytesPerElement = attribute.bytesPerElement;\n\n\t\t\t\t\tif ( geometryAttribute.isInterleavedBufferAttribute ) {\n\n\t\t\t\t\t\tconst data = geometryAttribute.data;\n\t\t\t\t\t\tconst stride = data.stride;\n\t\t\t\t\t\tconst offset = geometryAttribute.offset;\n\n\t\t\t\t\t\tif ( data && data.isInstancedInterleavedBuffer ) {\n\n\t\t\t\t\t\t\tenableAttributeAndDivisor( programAttribute, data.meshPerAttribute );\n\n\t\t\t\t\t\t\tif ( geometry._maxInstanceCount === undefined ) {\n\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = data.meshPerAttribute * data.count;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tenableAttribute( programAttribute );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\t\t\t\t\t\tvertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( geometryAttribute.isInstancedBufferAttribute ) {\n\n\t\t\t\t\t\t\tenableAttributeAndDivisor( programAttribute, geometryAttribute.meshPerAttribute );\n\n\t\t\t\t\t\t\tif ( geometry._maxInstanceCount === undefined ) {\n\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tenableAttribute( programAttribute );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\t\t\t\t\t\tvertexAttribPointer( programAttribute, size, type, normalized, 0, 0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( name === 'instanceMatrix' ) {\n\n\t\t\t\t\tconst attribute = attributes.get( object.instanceMatrix );\n\n\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 0, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 1, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 2, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 3, 1 );\n\n\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 0, 4, type, false, 64, 0 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 1, 4, type, false, 64, 16 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 2, 4, type, false, 64, 32 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 3, 4, type, false, 64, 48 );\n\n\t\t\t\t} else if ( materialDefaultAttributeValues !== undefined ) {\n\n\t\t\t\t\tconst value = materialDefaultAttributeValues[ name ];\n\n\t\t\t\t\tif ( value !== undefined ) {\n\n\t\t\t\t\t\tswitch ( value.length ) {\n\n\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\tgl.vertexAttrib2fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\tgl.vertexAttrib3fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\tgl.vertexAttrib4fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tgl.vertexAttrib1fv( programAttribute, value );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tdisableUnusedAttributes();\n\n\t}\n\n\tfunction dispose() {\n\n\t\treset();\n\n\t\tfor ( const geometryId in bindingStates ) {\n\n\t\t\tconst programMap = bindingStates[ geometryId ];\n\n\t\t\tfor ( const programId in programMap ) {\n\n\t\t\t\tconst stateMap = programMap[ programId ];\n\n\t\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t\t}\n\n\t\t\t\tdelete programMap[ programId ];\n\n\t\t\t}\n\n\t\t\tdelete bindingStates[ geometryId ];\n\n\t\t}\n\n\t}\n\n\tfunction releaseStatesOfGeometry( geometry ) {\n\n\t\tif ( bindingStates[ geometry.id ] === undefined ) return;\n\n\t\tconst programMap = bindingStates[ geometry.id ];\n\n\t\tfor ( const programId in programMap ) {\n\n\t\t\tconst stateMap = programMap[ programId ];\n\n\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t}\n\n\t\t\tdelete programMap[ programId ];\n\n\t\t}\n\n\t\tdelete bindingStates[ geometry.id ];\n\n\t}\n\n\tfunction releaseStatesOfProgram( program ) {\n\n\t\tfor ( const geometryId in bindingStates ) {\n\n\t\t\tconst programMap = bindingStates[ geometryId ];\n\n\t\t\tif ( programMap[ program.id ] === undefined ) continue;\n\n\t\t\tconst stateMap = programMap[ program.id ];\n\n\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t}\n\n\t\t\tdelete programMap[ program.id ];\n\n\t\t}\n\n\t}\n\n\tfunction reset() {\n\n\t\tresetDefaultState();\n\n\t\tif ( currentState === defaultState ) return;\n\n\t\tcurrentState = defaultState;\n\t\tbindVertexArrayObject( currentState.object );\n\n\t}\n\n\t// for backward-compatilibity\n\n\tfunction resetDefaultState() {\n\n\t\tdefaultState.geometry = null;\n\t\tdefaultState.program = null;\n\t\tdefaultState.wireframe = false;\n\n\t}\n\n\treturn {\n\n\t\tsetup: setup,\n\t\treset: reset,\n\t\tresetDefaultState: resetDefaultState,\n\t\tdispose: dispose,\n\t\treleaseStatesOfGeometry: releaseStatesOfGeometry,\n\t\treleaseStatesOfProgram: releaseStatesOfProgram,\n\n\t\tinitAttributes: initAttributes,\n\t\tenableAttribute: enableAttribute,\n\t\tdisableUnusedAttributes: disableUnusedAttributes\n\n\t};\n\n}\n\n\nexport { WebGLBindingStates };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLBufferRenderer( gl, extensions, info, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tlet mode;\n\n\tfunction setMode( value ) {\n\n\t\tmode = value;\n\n\t}\n\n\tfunction render( start, count ) {\n\n\t\tgl.drawArrays( mode, start, count );\n\n\t\tinfo.update( count, mode );\n\n\t}\n\n\tfunction renderInstances( geometry, start, count, primcount ) {\n\n\t\tif ( primcount === 0 ) return;\n\n\t\tlet extension, methodName;\n\n\t\tif ( isWebGL2 ) {\n\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawArraysInstanced';\n\n\t\t} else {\n\n\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\t\t\tmethodName = 'drawArraysInstancedANGLE';\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\textension[ methodName ]( mode, start, count, primcount );\n\n\t\tinfo.update( count, mode, primcount );\n\n\t}\n\n\t//\n\n\tthis.setMode = setMode;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n\n}\n\n\nexport { WebGLBufferRenderer };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLCapabilities( gl, extensions, parameters ) {\n\n\tlet maxAnisotropy;\n\n\tfunction getMaxAnisotropy() {\n\n\t\tif ( maxAnisotropy !== undefined ) return maxAnisotropy;\n\n\t\tconst extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\tif ( extension !== null ) {\n\n\t\t\tmaxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT );\n\n\t\t} else {\n\n\t\t\tmaxAnisotropy = 0;\n\n\t\t}\n\n\t\treturn maxAnisotropy;\n\n\t}\n\n\tfunction getMaxPrecision( precision ) {\n\n\t\tif ( precision === 'highp' ) {\n\n\t\t\tif ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&\n\t\t\t\tgl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0 ) {\n\n\t\t\t\treturn 'highp';\n\n\t\t\t}\n\n\t\t\tprecision = 'mediump';\n\n\t\t}\n\n\t\tif ( precision === 'mediump' ) {\n\n\t\t\tif ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&\n\t\t\t\tgl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0 ) {\n\n\t\t\t\treturn 'mediump';\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn 'lowp';\n\n\t}\n\n\t/* eslint-disable no-undef */\n\tconst isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) ||\n\t\t( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext );\n\t/* eslint-enable no-undef */\n\n\tlet precision = parameters.precision !== undefined ? parameters.precision : 'highp';\n\tconst maxPrecision = getMaxPrecision( precision );\n\n\tif ( maxPrecision !== precision ) {\n\n\t\tconsole.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );\n\t\tprecision = maxPrecision;\n\n\t}\n\n\tconst logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;\n\n\tconst maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );\n\tconst maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );\n\tconst maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );\n\tconst maxCubemapSize = gl.getParameter( gl.MAX_CUBE_MAP_TEXTURE_SIZE );\n\n\tconst maxAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );\n\tconst maxVertexUniforms = gl.getParameter( gl.MAX_VERTEX_UNIFORM_VECTORS );\n\tconst maxVaryings = gl.getParameter( gl.MAX_VARYING_VECTORS );\n\tconst maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );\n\n\tconst vertexTextures = maxVertexTextures > 0;\n\tconst floatFragmentTextures = isWebGL2 || !! extensions.get( 'OES_texture_float' );\n\tconst floatVertexTextures = vertexTextures && floatFragmentTextures;\n\n\tconst maxSamples = isWebGL2 ? gl.getParameter( gl.MAX_SAMPLES ) : 0;\n\n\treturn {\n\n\t\tisWebGL2: isWebGL2,\n\n\t\tgetMaxAnisotropy: getMaxAnisotropy,\n\t\tgetMaxPrecision: getMaxPrecision,\n\n\t\tprecision: precision,\n\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\tmaxTextures: maxTextures,\n\t\tmaxVertexTextures: maxVertexTextures,\n\t\tmaxTextureSize: maxTextureSize,\n\t\tmaxCubemapSize: maxCubemapSize,\n\n\t\tmaxAttributes: maxAttributes,\n\t\tmaxVertexUniforms: maxVertexUniforms,\n\t\tmaxVaryings: maxVaryings,\n\t\tmaxFragmentUniforms: maxFragmentUniforms,\n\n\t\tvertexTextures: vertexTextures,\n\t\tfloatFragmentTextures: floatFragmentTextures,\n\t\tfloatVertexTextures: floatVertexTextures,\n\n\t\tmaxSamples: maxSamples\n\n\t};\n\n}\n\n\nexport { WebGLCapabilities };\n","/**\n * @author tschw\n */\n\nimport { Matrix3 } from '../../math/Matrix3.js';\nimport { Plane } from '../../math/Plane.js';\n\nfunction WebGLClipping() {\n\n\tconst scope = this;\n\n\tlet globalState = null,\n\t\tnumGlobalPlanes = 0,\n\t\tlocalClippingEnabled = false,\n\t\trenderingShadows = false;\n\n\tconst plane = new Plane(),\n\t\tviewNormalMatrix = new Matrix3(),\n\n\t\tuniform = { value: null, needsUpdate: false };\n\n\tthis.uniform = uniform;\n\tthis.numPlanes = 0;\n\tthis.numIntersection = 0;\n\n\tthis.init = function ( planes, enableLocalClipping, camera ) {\n\n\t\tconst enabled =\n\t\t\tplanes.length !== 0 ||\n\t\t\tenableLocalClipping ||\n\t\t\t// enable state of previous frame - the clipping code has to\n\t\t\t// run another frame in order to reset the state:\n\t\t\tnumGlobalPlanes !== 0 ||\n\t\t\tlocalClippingEnabled;\n\n\t\tlocalClippingEnabled = enableLocalClipping;\n\n\t\tglobalState = projectPlanes( planes, camera, 0 );\n\t\tnumGlobalPlanes = planes.length;\n\n\t\treturn enabled;\n\n\t};\n\n\tthis.beginShadows = function () {\n\n\t\trenderingShadows = true;\n\t\tprojectPlanes( null );\n\n\t};\n\n\tthis.endShadows = function () {\n\n\t\trenderingShadows = false;\n\t\tresetGlobalState();\n\n\t};\n\n\tthis.setState = function ( planes, clipIntersection, clipShadows, camera, cache, fromCache ) {\n\n\t\tif ( ! localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && ! clipShadows ) {\n\n\t\t\t// there's no local clipping\n\n\t\t\tif ( renderingShadows ) {\n\n\t\t\t\t// there's no global clipping\n\n\t\t\t\tprojectPlanes( null );\n\n\t\t\t} else {\n\n\t\t\t\tresetGlobalState();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst nGlobal = renderingShadows ? 0 : numGlobalPlanes,\n\t\t\t\tlGlobal = nGlobal * 4;\n\n\t\t\tlet dstArray = cache.clippingState || null;\n\n\t\t\tuniform.value = dstArray; // ensure unique state\n\n\t\t\tdstArray = projectPlanes( planes, camera, lGlobal, fromCache );\n\n\t\t\tfor ( let i = 0; i !== lGlobal; ++ i ) {\n\n\t\t\t\tdstArray[ i ] = globalState[ i ];\n\n\t\t\t}\n\n\t\t\tcache.clippingState = dstArray;\n\t\t\tthis.numIntersection = clipIntersection ? this.numPlanes : 0;\n\t\t\tthis.numPlanes += nGlobal;\n\n\t\t}\n\n\n\t};\n\n\tfunction resetGlobalState() {\n\n\t\tif ( uniform.value !== globalState ) {\n\n\t\t\tuniform.value = globalState;\n\t\t\tuniform.needsUpdate = numGlobalPlanes > 0;\n\n\t\t}\n\n\t\tscope.numPlanes = numGlobalPlanes;\n\t\tscope.numIntersection = 0;\n\n\t}\n\n\tfunction projectPlanes( planes, camera, dstOffset, skipTransform ) {\n\n\t\tlet nPlanes = planes !== null ? planes.length : 0,\n\t\t\tdstArray = null;\n\n\t\tif ( nPlanes !== 0 ) {\n\n\t\t\tdstArray = uniform.value;\n\n\t\t\tif ( skipTransform !== true || dstArray === null ) {\n\n\t\t\t\tconst flatSize = dstOffset + nPlanes * 4,\n\t\t\t\t\tviewMatrix = camera.matrixWorldInverse;\n\n\t\t\t\tviewNormalMatrix.getNormalMatrix( viewMatrix );\n\n\t\t\t\tif ( dstArray === null || dstArray.length < flatSize ) {\n\n\t\t\t\t\tdstArray = new Float32Array( flatSize );\n\n\t\t\t\t}\n\n\t\t\t\tfor ( let i = 0, i4 = dstOffset; i !== nPlanes; ++ i, i4 += 4 ) {\n\n\t\t\t\t\tplane.copy( planes[ i ] ).applyMatrix4( viewMatrix, viewNormalMatrix );\n\n\t\t\t\t\tplane.normal.toArray( dstArray, i4 );\n\t\t\t\t\tdstArray[ i4 + 3 ] = plane.constant;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tuniform.value = dstArray;\n\t\t\tuniform.needsUpdate = true;\n\n\t\t}\n\n\t\tscope.numPlanes = nPlanes;\n\t\tscope.numIntersection = 0;\n\n\t\treturn dstArray;\n\n\t}\n\n}\n\n\nexport { WebGLClipping };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLExtensions( gl ) {\n\n\tconst extensions = {};\n\n\treturn {\n\n\t\tget: function ( name ) {\n\n\t\t\tif ( extensions[ name ] !== undefined ) {\n\n\t\t\t\treturn extensions[ name ];\n\n\t\t\t}\n\n\t\t\tlet extension;\n\n\t\t\tswitch ( name ) {\n\n\t\t\t\tcase 'WEBGL_depth_texture':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'EXT_texture_filter_anisotropic':\n\t\t\t\t\textension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'WEBGL_compressed_texture_s3tc':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'WEBGL_compressed_texture_pvrtc':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\textension = gl.getExtension( name );\n\n\t\t\t}\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );\n\n\t\t\t}\n\n\t\t\textensions[ name ] = extension;\n\n\t\t\treturn extension;\n\n\t\t}\n\n\t};\n\n}\n\n\nexport { WebGLExtensions };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js';\nimport { BufferGeometry } from '../../core/BufferGeometry.js';\nimport { arrayMax } from '../../utils.js';\n\nfunction WebGLGeometries( gl, attributes, info, bindingStates ) {\n\n\tconst geometries = new WeakMap();\n\tconst wireframeAttributes = new WeakMap();\n\n\tfunction onGeometryDispose( event ) {\n\n\t\tconst geometry = event.target;\n\t\tconst buffergeometry = geometries.get( geometry );\n\n\t\tif ( buffergeometry.index !== null ) {\n\n\t\t\tattributes.remove( buffergeometry.index );\n\n\t\t}\n\n\t\tfor ( const name in buffergeometry.attributes ) {\n\n\t\t\tattributes.remove( buffergeometry.attributes[ name ] );\n\n\t\t}\n\n\t\tgeometry.removeEventListener( 'dispose', onGeometryDispose );\n\n\t\tgeometries.delete( geometry );\n\n\t\tconst attribute = wireframeAttributes.get( buffergeometry );\n\n\t\tif ( attribute ) {\n\n\t\t\tattributes.remove( attribute );\n\t\t\twireframeAttributes.delete( buffergeometry );\n\n\t\t}\n\n\t\tbindingStates.releaseStatesOfGeometry( geometry );\n\n\t\tif ( geometry.isInstancedBufferGeometry === true ) {\n\n\t\t\tdelete geometry._maxInstanceCount;\n\n\t\t}\n\n\t\t//\n\n\t\tinfo.memory.geometries --;\n\n\t}\n\n\tfunction get( object, geometry ) {\n\n\t\tlet buffergeometry = geometries.get( geometry );\n\n\t\tif ( buffergeometry ) return buffergeometry;\n\n\t\tgeometry.addEventListener( 'dispose', onGeometryDispose );\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tbuffergeometry = geometry;\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tif ( geometry._bufferGeometry === undefined ) {\n\n\t\t\t\tgeometry._bufferGeometry = new BufferGeometry().setFromObject( object );\n\n\t\t\t}\n\n\t\t\tbuffergeometry = geometry._bufferGeometry;\n\n\t\t}\n\n\t\tgeometries.set( geometry, buffergeometry );\n\n\t\tinfo.memory.geometries ++;\n\n\t\treturn buffergeometry;\n\n\t}\n\n\tfunction update( geometry ) {\n\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\t// Updating index buffer in VAO now. See WebGLBindingStates.\n\n\t\tfor ( const name in geometryAttributes ) {\n\n\t\t\tattributes.update( geometryAttributes[ name ], gl.ARRAY_BUFFER );\n\n\t\t}\n\n\t\t// morph targets\n\n\t\tconst morphAttributes = geometry.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst array = morphAttributes[ name ];\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\tattributes.update( array[ i ], gl.ARRAY_BUFFER );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction updateWireframeAttribute( geometry ) {\n\n\t\tconst indices = [];\n\n\t\tconst geometryIndex = geometry.index;\n\t\tconst geometryPosition = geometry.attributes.position;\n\t\tlet version = 0;\n\n\t\tif ( geometryIndex !== null ) {\n\n\t\t\tconst array = geometryIndex.array;\n\t\t\tversion = geometryIndex.version;\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\t\tconst a = array[ i + 0 ];\n\t\t\t\tconst b = array[ i + 1 ];\n\t\t\t\tconst c = array[ i + 2 ];\n\n\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst array = geometryPosition.array;\n\t\t\tversion = geometryPosition.version;\n\n\t\t\tfor ( let i = 0, l = ( array.length / 3 ) - 1; i < l; i += 3 ) {\n\n\t\t\t\tconst a = i + 0;\n\t\t\t\tconst b = i + 1;\n\t\t\t\tconst c = i + 2;\n\n\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst attribute = new ( arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );\n\t\tattribute.version = version;\n\n\t\t// Updating index buffer in VAO now. See WebGLBindingStates\n\n\t\t//\n\n\t\tconst previousAttribute = wireframeAttributes.get( geometry );\n\n\t\tif ( previousAttribute ) attributes.remove( previousAttribute );\n\n\t\t//\n\n\t\twireframeAttributes.set( geometry, attribute );\n\n\t}\n\n\tfunction getWireframeAttribute( geometry ) {\n\n\t\tconst currentAttribute = wireframeAttributes.get( geometry );\n\n\t\tif ( currentAttribute ) {\n\n\t\t\tconst geometryIndex = geometry.index;\n\n\t\t\tif ( geometryIndex !== null ) {\n\n\t\t\t\t// if the attribute is obsolete, create a new one\n\n\t\t\t\tif ( currentAttribute.version < geometryIndex.version ) {\n\n\t\t\t\t\tupdateWireframeAttribute( geometry );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tupdateWireframeAttribute( geometry );\n\n\t\t}\n\n\t\treturn wireframeAttributes.get( geometry );\n\n\t}\n\n\treturn {\n\n\t\tget: get,\n\t\tupdate: update,\n\n\t\tgetWireframeAttribute: getWireframeAttribute\n\n\t};\n\n}\n\n\nexport { WebGLGeometries };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tlet mode;\n\n\tfunction setMode( value ) {\n\n\t\tmode = value;\n\n\t}\n\n\tlet type, bytesPerElement;\n\n\tfunction setIndex( value ) {\n\n\t\ttype = value.type;\n\t\tbytesPerElement = value.bytesPerElement;\n\n\t}\n\n\tfunction render( start, count ) {\n\n\t\tgl.drawElements( mode, count, type, start * bytesPerElement );\n\n\t\tinfo.update( count, mode );\n\n\t}\n\n\tfunction renderInstances( geometry, start, count, primcount ) {\n\n\t\tif ( primcount === 0 ) return;\n\n\t\tlet extension, methodName;\n\n\t\tif ( isWebGL2 ) {\n\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawElementsInstanced';\n\n\t\t} else {\n\n\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\t\t\tmethodName = 'drawElementsInstancedANGLE';\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\textension[ methodName ]( mode, count, type, start * bytesPerElement, primcount );\n\n\t\tinfo.update( count, mode, primcount );\n\n\t}\n\n\t//\n\n\tthis.setMode = setMode;\n\tthis.setIndex = setIndex;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n\n}\n\n\nexport { WebGLIndexedBufferRenderer };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nfunction WebGLInfo( gl ) {\n\n\tconst memory = {\n\t\tgeometries: 0,\n\t\ttextures: 0\n\t};\n\n\tconst render = {\n\t\tframe: 0,\n\t\tcalls: 0,\n\t\ttriangles: 0,\n\t\tpoints: 0,\n\t\tlines: 0\n\t};\n\n\tfunction update( count, mode, instanceCount ) {\n\n\t\tinstanceCount = instanceCount || 1;\n\n\t\trender.calls ++;\n\n\t\tswitch ( mode ) {\n\n\t\t\tcase gl.TRIANGLES:\n\t\t\t\trender.triangles += instanceCount * ( count / 3 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINES:\n\t\t\t\trender.lines += instanceCount * ( count / 2 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_STRIP:\n\t\t\t\trender.lines += instanceCount * ( count - 1 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_LOOP:\n\t\t\t\trender.lines += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tcase gl.POINTS:\n\t\t\t\trender.points += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.error( 'THREE.WebGLInfo: Unknown draw mode:', mode );\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tfunction reset() {\n\n\t\trender.frame ++;\n\t\trender.calls = 0;\n\t\trender.triangles = 0;\n\t\trender.points = 0;\n\t\trender.lines = 0;\n\n\t}\n\n\treturn {\n\t\tmemory: memory,\n\t\trender: render,\n\t\tprograms: null,\n\t\tautoReset: true,\n\t\treset: reset,\n\t\tupdate: update\n\t};\n\n}\n\n\nexport { WebGLInfo };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction numericalSort( a, b ) {\n\n\treturn a[ 0 ] - b[ 0 ];\n\n}\n\nfunction absNumericalSort( a, b ) {\n\n\treturn Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );\n\n}\n\nfunction WebGLMorphtargets( gl ) {\n\n\tconst influencesList = {};\n\tconst morphInfluences = new Float32Array( 8 );\n\n\tconst workInfluences = [];\n\n\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\tworkInfluences[ i ] = [ i, 0 ];\n\n\t}\n\n\tfunction update( object, geometry, material, program ) {\n\n\t\tconst objectInfluences = object.morphTargetInfluences;\n\n\t\t// When object doesn't have morph target influences defined, we treat it as a 0-length array\n\t\t// This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences\n\n\t\tconst length = objectInfluences === undefined ? 0 : objectInfluences.length;\n\n\t\tlet influences = influencesList[ geometry.id ];\n\n\t\tif ( influences === undefined ) {\n\n\t\t\t// initialise list\n\n\t\t\tinfluences = [];\n\n\t\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\t\tinfluences[ i ] = [ i, 0 ];\n\n\t\t\t}\n\n\t\t\tinfluencesList[ geometry.id ] = influences;\n\n\t\t}\n\n\t\t// Collect influences\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tconst influence = influences[ i ];\n\n\t\t\tinfluence[ 0 ] = i;\n\t\t\tinfluence[ 1 ] = objectInfluences[ i ];\n\n\t\t}\n\n\t\tinfluences.sort( absNumericalSort );\n\n\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\tif ( i < length && influences[ i ][ 1 ] ) {\n\n\t\t\t\tworkInfluences[ i ][ 0 ] = influences[ i ][ 0 ];\n\t\t\t\tworkInfluences[ i ][ 1 ] = influences[ i ][ 1 ];\n\n\t\t\t} else {\n\n\t\t\t\tworkInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER;\n\t\t\t\tworkInfluences[ i ][ 1 ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tworkInfluences.sort( numericalSort );\n\n\t\tconst morphTargets = material.morphTargets && geometry.morphAttributes.position;\n\t\tconst morphNormals = material.morphNormals && geometry.morphAttributes.normal;\n\n\t\tlet morphInfluencesSum = 0;\n\n\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\tconst influence = workInfluences[ i ];\n\t\t\tconst index = influence[ 0 ];\n\t\t\tconst value = influence[ 1 ];\n\n\t\t\tif ( index !== Number.MAX_SAFE_INTEGER && value ) {\n\n\t\t\t\tif ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) {\n\n\t\t\t\t\tgeometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] );\n\n\t\t\t\t}\n\n\t\t\t\tif ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) {\n\n\t\t\t\t\tgeometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] );\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = value;\n\t\t\t\tmorphInfluencesSum += value;\n\n\t\t\t} else {\n\n\t\t\t\tif ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== undefined ) {\n\n\t\t\t\t\tgeometry.deleteAttribute( 'morphTarget' + i );\n\n\t\t\t\t}\n\n\t\t\t\tif ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== undefined ) {\n\n\t\t\t\t\tgeometry.deleteAttribute( 'morphNormal' + i );\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// GLSL shader uses formula baseinfluence * base + sum(target * influence)\n\t\t// This allows us to switch between absolute morphs and relative morphs without changing shader code\n\t\t// When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)\n\t\tconst morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;\n\n\t\tprogram.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );\n\t\tprogram.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences );\n\n\t}\n\n\treturn {\n\n\t\tupdate: update\n\n\t};\n\n}\n\n\nexport { WebGLMorphtargets };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLObjects( gl, geometries, attributes, info ) {\n\n\tlet updateMap = new WeakMap();\n\n\tfunction update( object ) {\n\n\t\tconst frame = info.render.frame;\n\n\t\tconst geometry = object.geometry;\n\t\tconst buffergeometry = geometries.get( object, geometry );\n\n\t\t// Update once per frame\n\n\t\tif ( updateMap.get( buffergeometry ) !== frame ) {\n\n\t\t\tif ( geometry.isGeometry ) {\n\n\t\t\t\tbuffergeometry.updateFromObject( object );\n\n\t\t\t}\n\n\t\t\tgeometries.update( buffergeometry );\n\n\t\t\tupdateMap.set( buffergeometry, frame );\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh ) {\n\n\t\t\tattributes.update( object.instanceMatrix, gl.ARRAY_BUFFER );\n\n\t\t}\n\n\t\treturn buffergeometry;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tupdateMap = new WeakMap();\n\n\t}\n\n\treturn {\n\n\t\tupdate: update,\n\t\tdispose: dispose\n\n\t};\n\n}\n\n\nexport { WebGLObjects };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Texture } from './Texture.js';\nimport { CubeReflectionMapping, RGBFormat } from '../constants.js';\n\nfunction CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\timages = images !== undefined ? images : [];\n\tmapping = mapping !== undefined ? mapping : CubeReflectionMapping;\n\tformat = format !== undefined ? format : RGBFormat;\n\n\tTexture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\tthis.flipY = false;\n\n}\n\nCubeTexture.prototype = Object.create( Texture.prototype );\nCubeTexture.prototype.constructor = CubeTexture;\n\nCubeTexture.prototype.isCubeTexture = true;\n\nObject.defineProperty( CubeTexture.prototype, 'images', {\n\n\tget: function () {\n\n\t\treturn this.image;\n\n\t},\n\n\tset: function ( value ) {\n\n\t\tthis.image = value;\n\n\t}\n\n} );\n\n\nexport { CubeTexture };\n","/**\n * @author Takahiro https://github.com/takahirox\n */\n\nimport { Texture } from './Texture.js';\nimport { ClampToEdgeWrapping, NearestFilter } from '../constants.js';\n\nfunction DataTexture2DArray( data, width, height, depth ) {\n\n\tTexture.call( this, null );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };\n\n\tthis.magFilter = NearestFilter;\n\tthis.minFilter = NearestFilter;\n\n\tthis.wrapR = ClampToEdgeWrapping;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\n\tthis.needsUpdate = true;\n\n}\n\nDataTexture2DArray.prototype = Object.create( Texture.prototype );\nDataTexture2DArray.prototype.constructor = DataTexture2DArray;\nDataTexture2DArray.prototype.isDataTexture2DArray = true;\n\nexport { DataTexture2DArray };\n","/**\n * @author Artur Trzesiok\n */\n\nimport { Texture } from './Texture.js';\nimport { ClampToEdgeWrapping, NearestFilter } from '../constants.js';\n\nfunction DataTexture3D( data, width, height, depth ) {\n\n\t// We're going to add .setXXX() methods for setting properties later.\n\t// Users can still set in DataTexture3D directly.\n\t//\n\t//\tconst texture = new THREE.DataTexture3D( data, width, height, depth );\n\t// \ttexture.anisotropy = 16;\n\t//\n\t// See #14839\n\n\tTexture.call( this, null );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };\n\n\tthis.magFilter = NearestFilter;\n\tthis.minFilter = NearestFilter;\n\n\tthis.wrapR = ClampToEdgeWrapping;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\n\tthis.needsUpdate = true;\n\n\n}\n\nDataTexture3D.prototype = Object.create( Texture.prototype );\nDataTexture3D.prototype.constructor = DataTexture3D;\nDataTexture3D.prototype.isDataTexture3D = true;\n\nexport { DataTexture3D };\n","/**\n * @author tschw\n * @author Mugen87 / https://github.com/Mugen87\n * @author mrdoob / http://mrdoob.com/\n *\n * Uniforms of a program.\n * Those form a tree structure with a special top-level container for the root,\n * which you get by calling 'new WebGLUniforms( gl, program )'.\n *\n *\n * Properties of inner nodes including the top-level container:\n *\n * .seq - array of nested uniforms\n * .map - nested uniforms by name\n *\n *\n * Methods of all nodes except the top-level container:\n *\n * .setValue( gl, value, [textures] )\n *\n * \t\tuploads a uniform value(s)\n * \tthe 'textures' parameter is needed for sampler uniforms\n *\n *\n * Static methods of the top-level container (textures factorizations):\n *\n * .upload( gl, seq, values, textures )\n *\n * \t\tsets uniforms in 'seq' to 'values[id].value'\n *\n * .seqWithValue( seq, values ) : filteredSeq\n *\n * \t\tfilters 'seq' entries with corresponding entry in values\n *\n *\n * Methods of the top-level container (textures factorizations):\n *\n * .setValue( gl, name, value, textures )\n *\n * \t\tsets uniform with name 'name' to 'value'\n *\n * .setOptional( gl, obj, prop )\n *\n * \t\tlike .set for an optional property of the object\n *\n */\n\nimport { CubeTexture } from '../../textures/CubeTexture.js';\nimport { Texture } from '../../textures/Texture.js';\nimport { DataTexture2DArray } from '../../textures/DataTexture2DArray.js';\nimport { DataTexture3D } from '../../textures/DataTexture3D.js';\n\nconst emptyTexture = new Texture();\nconst emptyTexture2dArray = new DataTexture2DArray();\nconst emptyTexture3d = new DataTexture3D();\nconst emptyCubeTexture = new CubeTexture();\n\n// --- Utilities ---\n\n// Array Caches (provide typed arrays for temporary by size)\n\nconst arrayCacheF32 = [];\nconst arrayCacheI32 = [];\n\n// Float32Array caches used for uploading Matrix uniforms\n\nconst mat4array = new Float32Array( 16 );\nconst mat3array = new Float32Array( 9 );\nconst mat2array = new Float32Array( 4 );\n\n// Flattening for arrays of vectors and matrices\n\nfunction flatten( array, nBlocks, blockSize ) {\n\n\tconst firstElem = array[ 0 ];\n\n\tif ( firstElem <= 0 || firstElem > 0 ) return array;\n\t// unoptimized: ! isNaN( firstElem )\n\t// see http://jacksondunstan.com/articles/983\n\n\tlet n = nBlocks * blockSize,\n\t\tr = arrayCacheF32[ n ];\n\n\tif ( r === undefined ) {\n\n\t\tr = new Float32Array( n );\n\t\tarrayCacheF32[ n ] = r;\n\n\t}\n\n\tif ( nBlocks !== 0 ) {\n\n\t\tfirstElem.toArray( r, 0 );\n\n\t\tfor ( let i = 1, offset = 0; i !== nBlocks; ++ i ) {\n\n\t\t\toffset += blockSize;\n\t\t\tarray[ i ].toArray( r, offset );\n\n\t\t}\n\n\t}\n\n\treturn r;\n\n}\n\nfunction arraysEqual( a, b ) {\n\n\tif ( a.length !== b.length ) return false;\n\n\tfor ( let i = 0, l = a.length; i < l; i ++ ) {\n\n\t\tif ( a[ i ] !== b[ i ] ) return false;\n\n\t}\n\n\treturn true;\n\n}\n\nfunction copyArray( a, b ) {\n\n\tfor ( let i = 0, l = b.length; i < l; i ++ ) {\n\n\t\ta[ i ] = b[ i ];\n\n\t}\n\n}\n\n// Texture unit allocation\n\nfunction allocTexUnits( textures, n ) {\n\n\tlet r = arrayCacheI32[ n ];\n\n\tif ( r === undefined ) {\n\n\t\tr = new Int32Array( n );\n\t\tarrayCacheI32[ n ] = r;\n\n\t}\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\tr[ i ] = textures.allocateTextureUnit();\n\n\t}\n\n\treturn r;\n\n}\n\n// --- Setters ---\n\n// Note: Defining these methods externally, because they come in a bunch\n// and this way their names minify.\n\n// Single scalar\n\nfunction setValueV1f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1f( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\n// Single float vector (from flat array or THREE.VectorN)\n\nfunction setValueV2f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {\n\n\t\t\tgl.uniform2f( this.addr, v.x, v.y );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform2fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\nfunction setValueV3f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {\n\n\t\t\tgl.uniform3f( this.addr, v.x, v.y, v.z );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\t\t\tcache[ 2 ] = v.z;\n\n\t\t}\n\n\t} else if ( v.r !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) {\n\n\t\t\tgl.uniform3f( this.addr, v.r, v.g, v.b );\n\n\t\t\tcache[ 0 ] = v.r;\n\t\t\tcache[ 1 ] = v.g;\n\t\t\tcache[ 2 ] = v.b;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform3fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\nfunction setValueV4f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {\n\n\t\t\tgl.uniform4f( this.addr, v.x, v.y, v.z, v.w );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\t\t\tcache[ 2 ] = v.z;\n\t\t\tcache[ 3 ] = v.w;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform4fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\n// Single matrix (from flat array or MatrixN)\n\nfunction setValueM2( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix2fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat2array.set( elements );\n\n\t\tgl.uniformMatrix2fv( this.addr, false, mat2array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\nfunction setValueM3( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix3fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat3array.set( elements );\n\n\t\tgl.uniformMatrix3fv( this.addr, false, mat3array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\nfunction setValueM4( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix4fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat4array.set( elements );\n\n\t\tgl.uniformMatrix4fv( this.addr, false, mat4array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\n// Single texture (2D / Cube)\n\nfunction setValueT1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.safeSetTexture2D( v || emptyTexture, unit );\n\n}\n\nfunction setValueT2DArray1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.setTexture2DArray( v || emptyTexture2dArray, unit );\n\n}\n\nfunction setValueT3D1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.setTexture3D( v || emptyTexture3d, unit );\n\n}\n\nfunction setValueT6( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.safeSetTextureCube( v || emptyCubeTexture, unit );\n\n}\n\n// Integer / Boolean vectors or arrays thereof (always flat arrays)\n\nfunction setValueV1i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1i( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\nfunction setValueV2i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform2iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\nfunction setValueV3i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform3iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\nfunction setValueV4i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform4iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\n// uint\n\nfunction setValueV1ui( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1ui( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\n// Helper to pick the right setter for the singular case\n\nfunction getSingularSetter( type ) {\n\n\tswitch ( type ) {\n\n\t\tcase 0x1406: return setValueV1f; // FLOAT\n\t\tcase 0x8b50: return setValueV2f; // _VEC2\n\t\tcase 0x8b51: return setValueV3f; // _VEC3\n\t\tcase 0x8b52: return setValueV4f; // _VEC4\n\n\t\tcase 0x8b5a: return setValueM2; // _MAT2\n\t\tcase 0x8b5b: return setValueM3; // _MAT3\n\t\tcase 0x8b5c: return setValueM4; // _MAT4\n\n\t\tcase 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL\n\t\tcase 0x8b53: case 0x8b57: return setValueV2i; // _VEC2\n\t\tcase 0x8b54: case 0x8b58: return setValueV3i; // _VEC3\n\t\tcase 0x8b55: case 0x8b59: return setValueV4i; // _VEC4\n\n\t\tcase 0x1405: return setValueV1ui; // UINT\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\t\tcase 0x8b62: // SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1;\n\n\t\tcase 0x8b5f: // SAMPLER_3D\n\t\tcase 0x8dcb: // INT_SAMPLER_3D\n\t\tcase 0x8dd3: // UNSIGNED_INT_SAMPLER_3D\n\t\t\treturn setValueT3D1;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\t\tcase 0x8dc5: // SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6;\n\n\t\tcase 0x8dc1: // SAMPLER_2D_ARRAY\n\t\tcase 0x8dcf: // INT_SAMPLER_2D_ARRAY\n\t\tcase 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY\n\t\tcase 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW\n\t\t\treturn setValueT2DArray1;\n\n\t}\n\n}\n\n// Array of scalars\nfunction setValueV1fArray( gl, v ) {\n\n\tgl.uniform1fv( this.addr, v );\n\n}\n\n// Integer / Boolean vectors or arrays thereof (always flat arrays)\nfunction setValueV1iArray( gl, v ) {\n\n\tgl.uniform1iv( this.addr, v );\n\n}\n\nfunction setValueV2iArray( gl, v ) {\n\n\tgl.uniform2iv( this.addr, v );\n\n}\n\nfunction setValueV3iArray( gl, v ) {\n\n\tgl.uniform3iv( this.addr, v );\n\n}\n\nfunction setValueV4iArray( gl, v ) {\n\n\tgl.uniform4iv( this.addr, v );\n\n}\n\n\n// Array of vectors (flat or from THREE classes)\n\nfunction setValueV2fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 2 );\n\n\tgl.uniform2fv( this.addr, data );\n\n}\n\nfunction setValueV3fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 3 );\n\n\tgl.uniform3fv( this.addr, data );\n\n}\n\nfunction setValueV4fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 4 );\n\n\tgl.uniform4fv( this.addr, data );\n\n}\n\n// Array of matrices (flat or from THREE clases)\n\nfunction setValueM2Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 4 );\n\n\tgl.uniformMatrix2fv( this.addr, false, data );\n\n}\n\nfunction setValueM3Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 9 );\n\n\tgl.uniformMatrix3fv( this.addr, false, data );\n\n}\n\nfunction setValueM4Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 16 );\n\n\tgl.uniformMatrix4fv( this.addr, false, data );\n\n}\n\n// Array of textures (2D / Cube)\n\nfunction setValueT1Array( gl, v, textures ) {\n\n\tconst n = v.length;\n\n\tconst units = allocTexUnits( textures, n );\n\n\tgl.uniform1iv( this.addr, units );\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\ttextures.safeSetTexture2D( v[ i ] || emptyTexture, units[ i ] );\n\n\t}\n\n}\n\nfunction setValueT6Array( gl, v, textures ) {\n\n\tconst n = v.length;\n\n\tconst units = allocTexUnits( textures, n );\n\n\tgl.uniform1iv( this.addr, units );\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\ttextures.safeSetTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );\n\n\t}\n\n}\n\n// Helper to pick the right setter for a pure (bottom-level) array\n\nfunction getPureArraySetter( type ) {\n\n\tswitch ( type ) {\n\n\t\tcase 0x1406: return setValueV1fArray; // FLOAT\n\t\tcase 0x8b50: return setValueV2fArray; // _VEC2\n\t\tcase 0x8b51: return setValueV3fArray; // _VEC3\n\t\tcase 0x8b52: return setValueV4fArray; // _VEC4\n\n\t\tcase 0x8b5a: return setValueM2Array; // _MAT2\n\t\tcase 0x8b5b: return setValueM3Array; // _MAT3\n\t\tcase 0x8b5c: return setValueM4Array; // _MAT4\n\n\t\tcase 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL\n\t\tcase 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2\n\t\tcase 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3\n\t\tcase 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\t\tcase 0x8b62: // SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1Array;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\t\tcase 0x8dc5: // SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6Array;\n\n\t}\n\n}\n\n// --- Uniform Classes ---\n\nfunction SingleUniform( id, activeInfo, addr ) {\n\n\tthis.id = id;\n\tthis.addr = addr;\n\tthis.cache = [];\n\tthis.setValue = getSingularSetter( activeInfo.type );\n\n\t// this.path = activeInfo.name; // DEBUG\n\n}\n\nfunction PureArrayUniform( id, activeInfo, addr ) {\n\n\tthis.id = id;\n\tthis.addr = addr;\n\tthis.cache = [];\n\tthis.size = activeInfo.size;\n\tthis.setValue = getPureArraySetter( activeInfo.type );\n\n\t// this.path = activeInfo.name; // DEBUG\n\n}\n\nPureArrayUniform.prototype.updateCache = function ( data ) {\n\n\tlet cache = this.cache;\n\n\tif ( data instanceof Float32Array && cache.length !== data.length ) {\n\n\t\tthis.cache = new Float32Array( data.length );\n\n\t}\n\n\tcopyArray( cache, data );\n\n};\n\nfunction StructuredUniform( id ) {\n\n\tthis.id = id;\n\n\tthis.seq = [];\n\tthis.map = {};\n\n}\n\nStructuredUniform.prototype.setValue = function ( gl, value, textures ) {\n\n\tconst seq = this.seq;\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ];\n\t\tu.setValue( gl, value[ u.id ], textures );\n\n\t}\n\n};\n\n// --- Top-level ---\n\n// Parser - builds up the property tree from the path strings\n\nconst RePathPart = /([\\w\\d_]+)(\\])?(\\[|\\.)?/g;\n\n// extracts\n// \t- the identifier (member name or array index)\n// - followed by an optional right bracket (found when array index)\n// - followed by an optional left bracket or dot (type of subscript)\n//\n// Note: These portions can be read in a non-overlapping fashion and\n// allow straightforward parsing of the hierarchy that WebGL encodes\n// in the uniform names.\n\nfunction addUniform( container, uniformObject ) {\n\n\tcontainer.seq.push( uniformObject );\n\tcontainer.map[ uniformObject.id ] = uniformObject;\n\n}\n\nfunction parseUniform( activeInfo, addr, container ) {\n\n\tconst path = activeInfo.name,\n\t\tpathLength = path.length;\n\n\t// reset RegExp object, because of the early exit of a previous run\n\tRePathPart.lastIndex = 0;\n\n\twhile ( true ) {\n\n\t\tconst match = RePathPart.exec( path ),\n\t\t\tmatchEnd = RePathPart.lastIndex;\n\n\t\tlet id = match[ 1 ],\n\t\t\tidIsIndex = match[ 2 ] === ']',\n\t\t\tsubscript = match[ 3 ];\n\n\t\tif ( idIsIndex ) id = id | 0; // convert to integer\n\n\t\tif ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) {\n\n\t\t\t// bare name or \"pure\" bottom-level array \"[0]\" suffix\n\n\t\t\taddUniform( container, subscript === undefined ?\n\t\t\t\tnew SingleUniform( id, activeInfo, addr ) :\n\t\t\t\tnew PureArrayUniform( id, activeInfo, addr ) );\n\n\t\t\tbreak;\n\n\t\t} else {\n\n\t\t\t// step into inner node / create it in case it doesn't exist\n\n\t\t\tconst map = container.map;\n\t\t\tlet next = map[ id ];\n\n\t\t\tif ( next === undefined ) {\n\n\t\t\t\tnext = new StructuredUniform( id );\n\t\t\t\taddUniform( container, next );\n\n\t\t\t}\n\n\t\t\tcontainer = next;\n\n\t\t}\n\n\t}\n\n}\n\n// Root Container\n\nfunction WebGLUniforms( gl, program ) {\n\n\tthis.seq = [];\n\tthis.map = {};\n\n\tconst n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );\n\n\tfor ( let i = 0; i < n; ++ i ) {\n\n\t\tconst info = gl.getActiveUniform( program, i ),\n\t\t\taddr = gl.getUniformLocation( program, info.name );\n\n\t\tparseUniform( info, addr, this );\n\n\t}\n\n}\n\nWebGLUniforms.prototype.setValue = function ( gl, name, value, textures ) {\n\n\tconst u = this.map[ name ];\n\n\tif ( u !== undefined ) u.setValue( gl, value, textures );\n\n};\n\nWebGLUniforms.prototype.setOptional = function ( gl, object, name ) {\n\n\tconst v = object[ name ];\n\n\tif ( v !== undefined ) this.setValue( gl, name, v );\n\n};\n\n\n// Static interface\n\nWebGLUniforms.upload = function ( gl, seq, values, textures ) {\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ],\n\t\t\tv = values[ u.id ];\n\n\t\tif ( v.needsUpdate !== false ) {\n\n\t\t\t// note: always updating when .needsUpdate is undefined\n\t\t\tu.setValue( gl, v.value, textures );\n\n\t\t}\n\n\t}\n\n};\n\nWebGLUniforms.seqWithValue = function ( seq, values ) {\n\n\tconst r = [];\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ];\n\t\tif ( u.id in values ) r.push( u );\n\n\t}\n\n\treturn r;\n\n};\n\nexport { WebGLUniforms };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLShader( gl, type, string ) {\n\n\tconst shader = gl.createShader( type );\n\n\tgl.shaderSource( shader, string );\n\tgl.compileShader( shader );\n\n\treturn shader;\n\n}\n\nexport { WebGLShader };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { WebGLUniforms } from './WebGLUniforms.js';\nimport { WebGLShader } from './WebGLShader.js';\nimport { ShaderChunk } from '../shaders/ShaderChunk.js';\nimport { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, EquirectangularRefractionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, CubeUVRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GammaEncoding, RGBDEncoding, RGBM16Encoding, RGBM7Encoding, RGBEEncoding, sRGBEncoding, LinearEncoding, LogLuvEncoding } from '../../constants.js';\n\nlet programIdCount = 0;\n\nfunction addLineNumbers( string ) {\n\n\tconst lines = string.split( '\\n' );\n\n\tfor ( let i = 0; i < lines.length; i ++ ) {\n\n\t\tlines[ i ] = ( i + 1 ) + ': ' + lines[ i ];\n\n\t}\n\n\treturn lines.join( '\\n' );\n\n}\n\nfunction getEncodingComponents( encoding ) {\n\n\tswitch ( encoding ) {\n\n\t\tcase LinearEncoding:\n\t\t\treturn [ 'Linear', '( value )' ];\n\t\tcase sRGBEncoding:\n\t\t\treturn [ 'sRGB', '( value )' ];\n\t\tcase RGBEEncoding:\n\t\t\treturn [ 'RGBE', '( value )' ];\n\t\tcase RGBM7Encoding:\n\t\t\treturn [ 'RGBM', '( value, 7.0 )' ];\n\t\tcase RGBM16Encoding:\n\t\t\treturn [ 'RGBM', '( value, 16.0 )' ];\n\t\tcase RGBDEncoding:\n\t\t\treturn [ 'RGBD', '( value, 256.0 )' ];\n\t\tcase GammaEncoding:\n\t\t\treturn [ 'Gamma', '( value, float( GAMMA_FACTOR ) )' ];\n\t\tcase LogLuvEncoding:\n\t\t\treturn [ 'LogLuv', '( value )' ];\n\t\tdefault:\n\t\t\tconsole.warn( 'THREE.WebGLProgram: Unsupported encoding:', encoding );\n\t\t\treturn [ 'Linear', '( value )' ];\n\n\t}\n\n}\n\nfunction getShaderErrors( gl, shader, type ) {\n\n\tconst status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );\n\tconst log = gl.getShaderInfoLog( shader ).trim();\n\n\tif ( status && log === '' ) return '';\n\n\t// --enable-privileged-webgl-extension\n\t// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );\n\n\tconst source = gl.getShaderSource( shader );\n\n\treturn 'THREE.WebGLShader: gl.getShaderInfoLog() ' + type + '\\n' + log + addLineNumbers( source );\n\n}\n\nfunction getTexelDecodingFunction( functionName, encoding ) {\n\n\tconst components = getEncodingComponents( encoding );\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return ' + components[ 0 ] + 'ToLinear' + components[ 1 ] + '; }';\n\n}\n\nfunction getTexelEncodingFunction( functionName, encoding ) {\n\n\tconst components = getEncodingComponents( encoding );\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }';\n\n}\n\nfunction getToneMappingFunction( functionName, toneMapping ) {\n\n\tlet toneMappingName;\n\n\tswitch ( toneMapping ) {\n\n\t\tcase LinearToneMapping:\n\t\t\ttoneMappingName = 'Linear';\n\t\t\tbreak;\n\n\t\tcase ReinhardToneMapping:\n\t\t\ttoneMappingName = 'Reinhard';\n\t\t\tbreak;\n\n\t\tcase CineonToneMapping:\n\t\t\ttoneMappingName = 'OptimizedCineon';\n\t\t\tbreak;\n\n\t\tcase ACESFilmicToneMapping:\n\t\t\ttoneMappingName = 'ACESFilmic';\n\t\t\tbreak;\n\n\t\tcase CustomToneMapping:\n\t\t\ttoneMappingName = 'Custom';\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tconsole.warn( 'THREE.WebGLProgram: Unsupported toneMapping:', toneMapping );\n\t\t\ttoneMappingName = 'Linear';\n\n\t}\n\n\treturn 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';\n\n}\n\nfunction generateExtensions( parameters ) {\n\n\tconst chunks = [\n\t\t( parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',\n\t\t( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',\n\t\t( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',\n\t\t( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''\n\t];\n\n\treturn chunks.filter( filterEmptyLine ).join( '\\n' );\n\n}\n\nfunction generateDefines( defines ) {\n\n\tconst chunks = [];\n\n\tfor ( const name in defines ) {\n\n\t\tconst value = defines[ name ];\n\n\t\tif ( value === false ) continue;\n\n\t\tchunks.push( '#define ' + name + ' ' + value );\n\n\t}\n\n\treturn chunks.join( '\\n' );\n\n}\n\nfunction fetchAttributeLocations( gl, program ) {\n\n\tconst attributes = {};\n\n\tconst n = gl.getProgramParameter( program, gl.ACTIVE_ATTRIBUTES );\n\n\tfor ( let i = 0; i < n; i ++ ) {\n\n\t\tconst info = gl.getActiveAttrib( program, i );\n\t\tconst name = info.name;\n\n\t\t// console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i );\n\n\t\tattributes[ name ] = gl.getAttribLocation( program, name );\n\n\t}\n\n\treturn attributes;\n\n}\n\nfunction filterEmptyLine( string ) {\n\n\treturn string !== '';\n\n}\n\nfunction replaceLightNums( string, parameters ) {\n\n\treturn string\n\t\t.replace( /NUM_DIR_LIGHTS/g, parameters.numDirLights )\n\t\t.replace( /NUM_SPOT_LIGHTS/g, parameters.numSpotLights )\n\t\t.replace( /NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights )\n\t\t.replace( /NUM_POINT_LIGHTS/g, parameters.numPointLights )\n\t\t.replace( /NUM_HEMI_LIGHTS/g, parameters.numHemiLights )\n\t\t.replace( /NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows )\n\t\t.replace( /NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows )\n\t\t.replace( /NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows );\n\n}\n\nfunction replaceClippingPlaneNums( string, parameters ) {\n\n\treturn string\n\t\t.replace( /NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes )\n\t\t.replace( /UNION_CLIPPING_PLANES/g, ( parameters.numClippingPlanes - parameters.numClipIntersection ) );\n\n}\n\n// Resolve Includes\n\nconst includePattern = /^[ \\t]*#include +<([\\w\\d./]+)>/gm;\n\nfunction resolveIncludes( string ) {\n\n\treturn string.replace( includePattern, includeReplacer );\n\n}\n\nfunction includeReplacer( match, include ) {\n\n\tconst string = ShaderChunk[ include ];\n\n\tif ( string === undefined ) {\n\n\t\tthrow new Error( 'Can not resolve #include <' + include + '>' );\n\n\t}\n\n\treturn resolveIncludes( string );\n\n}\n\n// Unroll Loops\n\nconst deprecatedUnrollLoopPattern = /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g;\nconst unrollLoopPattern = /#pragma unroll_loop_start[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}[\\s]+?#pragma unroll_loop_end/g;\n\nfunction unrollLoops( string ) {\n\n\treturn string\n\t\t.replace( unrollLoopPattern, loopReplacer )\n\t\t.replace( deprecatedUnrollLoopPattern, deprecatedLoopReplacer );\n\n}\n\nfunction deprecatedLoopReplacer( match, start, end, snippet ) {\n\n\tconsole.warn( 'WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.' );\n\treturn loopReplacer( match, start, end, snippet );\n\n}\n\nfunction loopReplacer( match, start, end, snippet ) {\n\n\tlet string = '';\n\n\tfor ( let i = parseInt( start ); i < parseInt( end ); i ++ ) {\n\n\t\tstring += snippet\n\t\t\t.replace( /\\[ i \\]/g, '[ ' + i + ' ]' )\n\t\t\t.replace( /UNROLLED_LOOP_INDEX/g, i );\n\n\t}\n\n\treturn string;\n\n}\n\n//\n\nfunction generatePrecision( parameters ) {\n\n\tlet precisionstring = \"precision \" + parameters.precision + \" float;\\nprecision \" + parameters.precision + \" int;\";\n\n\tif ( parameters.precision === \"highp\" ) {\n\n\t\tprecisionstring += \"\\n#define HIGH_PRECISION\";\n\n\t} else if ( parameters.precision === \"mediump\" ) {\n\n\t\tprecisionstring += \"\\n#define MEDIUM_PRECISION\";\n\n\t} else if ( parameters.precision === \"lowp\" ) {\n\n\t\tprecisionstring += \"\\n#define LOW_PRECISION\";\n\n\t}\n\n\treturn precisionstring;\n\n}\n\nfunction generateShadowMapTypeDefine( parameters ) {\n\n\tlet shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC';\n\n\tif ( parameters.shadowMapType === PCFShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF';\n\n\t} else if ( parameters.shadowMapType === PCFSoftShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT';\n\n\t} else if ( parameters.shadowMapType === VSMShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM';\n\n\t}\n\n\treturn shadowMapTypeDefine;\n\n}\n\nfunction generateEnvMapTypeDefine( parameters ) {\n\n\tlet envMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.envMapMode ) {\n\n\t\t\tcase CubeReflectionMapping:\n\t\t\tcase CubeRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\t\t\t\tbreak;\n\n\t\t\tcase CubeUVReflectionMapping:\n\t\t\tcase CubeUVRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV';\n\t\t\t\tbreak;\n\n\t\t\tcase EquirectangularReflectionMapping:\n\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_EQUIREC';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapTypeDefine;\n\n}\n\nfunction generateEnvMapModeDefine( parameters ) {\n\n\tlet envMapModeDefine = 'ENVMAP_MODE_REFLECTION';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.envMapMode ) {\n\n\t\t\tcase CubeRefractionMapping:\n\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\tenvMapModeDefine = 'ENVMAP_MODE_REFRACTION';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapModeDefine;\n\n}\n\nfunction generateEnvMapBlendingDefine( parameters ) {\n\n\tlet envMapBlendingDefine = 'ENVMAP_BLENDING_NONE';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.combine ) {\n\n\t\t\tcase MultiplyOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';\n\t\t\t\tbreak;\n\n\t\t\tcase MixOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MIX';\n\t\t\t\tbreak;\n\n\t\t\tcase AddOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_ADD';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapBlendingDefine;\n\n}\n\nfunction WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {\n\n\tconst gl = renderer.getContext();\n\n\tconst defines = parameters.defines;\n\n\tlet vertexShader = parameters.vertexShader;\n\tlet fragmentShader = parameters.fragmentShader;\n\n\tconst shadowMapTypeDefine = generateShadowMapTypeDefine( parameters );\n\tconst envMapTypeDefine = generateEnvMapTypeDefine( parameters );\n\tconst envMapModeDefine = generateEnvMapModeDefine( parameters );\n\tconst envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );\n\n\n\tconst gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0;\n\n\tconst customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );\n\n\tconst customDefines = generateDefines( defines );\n\n\tconst program = gl.createProgram();\n\n\tlet prefixVertex, prefixFragment;\n\n\tif ( parameters.isRawShaderMaterial ) {\n\n\t\tprefixVertex = [\n\n\t\t\tcustomDefines\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tif ( prefixVertex.length > 0 ) {\n\n\t\t\tprefixVertex += '\\n';\n\n\t\t}\n\n\t\tprefixFragment = [\n\n\t\t\tcustomExtensions,\n\t\t\tcustomDefines\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tif ( prefixFragment.length > 0 ) {\n\n\t\t\tprefixFragment += '\\n';\n\n\t\t}\n\n\t} else {\n\n\t\tprefixVertex = [\n\n\t\t\tgeneratePrecision( parameters ),\n\n\t\t\t'#define SHADER_NAME ' + parameters.shaderName,\n\n\t\t\tcustomDefines,\n\n\t\t\tparameters.instancing ? '#define USE_INSTANCING' : '',\n\t\t\tparameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',\n\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t'#define MAX_BONES ' + parameters.maxBones,\n\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',\n\n\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '',\n\n\t\t\tparameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',\n\t\t\tparameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',\n\t\t\tparameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',\n\t\t\tparameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '',\n\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\n\t\t\tparameters.vertexTangents ? '#define USE_TANGENT' : '',\n\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\t\t\tparameters.vertexUvs ? '#define USE_UV' : '',\n\t\t\tparameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',\n\n\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\tparameters.skinning ? '#define USE_SKINNING' : '',\n\t\t\tparameters.useVertexTexture ? '#define BONE_TEXTURE' : '',\n\n\t\t\tparameters.morphTargets ? '#define USE_MORPHTARGETS' : '',\n\t\t\tparameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',\n\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\tparameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',\n\n\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t'uniform mat4 modelMatrix;',\n\t\t\t'uniform mat4 modelViewMatrix;',\n\t\t\t'uniform mat4 projectionMatrix;',\n\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t'uniform mat3 normalMatrix;',\n\t\t\t'uniform vec3 cameraPosition;',\n\t\t\t'uniform bool isOrthographic;',\n\n\t\t\t'#ifdef USE_INSTANCING',\n\n\t\t\t' attribute mat4 instanceMatrix;',\n\n\t\t\t'#endif',\n\n\t\t\t'attribute vec3 position;',\n\t\t\t'attribute vec3 normal;',\n\t\t\t'attribute vec2 uv;',\n\n\t\t\t'#ifdef USE_TANGENT',\n\n\t\t\t'\tattribute vec4 tangent;',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_COLOR',\n\n\t\t\t'\tattribute vec3 color;',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_MORPHTARGETS',\n\n\t\t\t'\tattribute vec3 morphTarget0;',\n\t\t\t'\tattribute vec3 morphTarget1;',\n\t\t\t'\tattribute vec3 morphTarget2;',\n\t\t\t'\tattribute vec3 morphTarget3;',\n\n\t\t\t'\t#ifdef USE_MORPHNORMALS',\n\n\t\t\t'\t\tattribute vec3 morphNormal0;',\n\t\t\t'\t\tattribute vec3 morphNormal1;',\n\t\t\t'\t\tattribute vec3 morphNormal2;',\n\t\t\t'\t\tattribute vec3 morphNormal3;',\n\n\t\t\t'\t#else',\n\n\t\t\t'\t\tattribute vec3 morphTarget4;',\n\t\t\t'\t\tattribute vec3 morphTarget5;',\n\t\t\t'\t\tattribute vec3 morphTarget6;',\n\t\t\t'\t\tattribute vec3 morphTarget7;',\n\n\t\t\t'\t#endif',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_SKINNING',\n\n\t\t\t'\tattribute vec4 skinIndex;',\n\t\t\t'\tattribute vec4 skinWeight;',\n\n\t\t\t'#endif',\n\n\t\t\t'\\n'\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tprefixFragment = [\n\n\t\t\tcustomExtensions,\n\n\t\t\tgeneratePrecision( parameters ),\n\n\t\t\t'#define SHADER_NAME ' + parameters.shaderName,\n\n\t\t\tcustomDefines,\n\n\t\t\tparameters.alphaTest ? '#define ALPHATEST ' + parameters.alphaTest + ( parameters.alphaTest % 1 ? '' : '.0' ) : '', // add '.0' if integer\n\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',\n\n\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\tparameters.matcap ? '#define USE_MATCAP' : '',\n\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\tparameters.envMap ? '#define ' + envMapTypeDefine : '',\n\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\tparameters.envMap ? '#define ' + envMapBlendingDefine : '',\n\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '',\n\t\t\tparameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',\n\t\t\tparameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',\n\t\t\tparameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',\n\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\n\t\t\tparameters.sheen ? '#define USE_SHEEN' : '',\n\n\t\t\tparameters.vertexTangents ? '#define USE_TANGENT' : '',\n\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\t\t\tparameters.vertexUvs ? '#define USE_UV' : '',\n\t\t\tparameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',\n\n\t\t\tparameters.gradientMap ? '#define USE_GRADIENTMAP' : '',\n\n\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\tparameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',\n\n\t\t\tparameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',\n\n\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '',\n\n\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t'uniform vec3 cameraPosition;',\n\t\t\t'uniform bool isOrthographic;',\n\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '',\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '',\n\n\t\t\tparameters.dithering ? '#define DITHERING' : '',\n\n\t\t\tShaderChunk[ 'encodings_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below\n\t\t\tparameters.map ? getTexelDecodingFunction( 'mapTexelToLinear', parameters.mapEncoding ) : '',\n\t\t\tparameters.matcap ? getTexelDecodingFunction( 'matcapTexelToLinear', parameters.matcapEncoding ) : '',\n\t\t\tparameters.envMap ? getTexelDecodingFunction( 'envMapTexelToLinear', parameters.envMapEncoding ) : '',\n\t\t\tparameters.emissiveMap ? getTexelDecodingFunction( 'emissiveMapTexelToLinear', parameters.emissiveMapEncoding ) : '',\n\t\t\tparameters.lightMap ? getTexelDecodingFunction( 'lightMapTexelToLinear', parameters.lightMapEncoding ) : '',\n\t\t\tgetTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ),\n\n\t\t\tparameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',\n\n\t\t\t'\\n'\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t}\n\n\tvertexShader = resolveIncludes( vertexShader );\n\tvertexShader = replaceLightNums( vertexShader, parameters );\n\tvertexShader = replaceClippingPlaneNums( vertexShader, parameters );\n\n\tfragmentShader = resolveIncludes( fragmentShader );\n\tfragmentShader = replaceLightNums( fragmentShader, parameters );\n\tfragmentShader = replaceClippingPlaneNums( fragmentShader, parameters );\n\n\tvertexShader = unrollLoops( vertexShader );\n\tfragmentShader = unrollLoops( fragmentShader );\n\n\tif ( parameters.isWebGL2 && ! parameters.isRawShaderMaterial ) {\n\n\t\tlet isGLSL3ShaderMaterial = false;\n\n\t\tconst versionRegex = /^\\s*#version\\s+300\\s+es\\s*\\n/;\n\n\t\tif ( parameters.isShaderMaterial &&\n\t\t\tvertexShader.match( versionRegex ) !== null &&\n\t\t\tfragmentShader.match( versionRegex ) !== null ) {\n\n\t\t\tisGLSL3ShaderMaterial = true;\n\n\t\t\tvertexShader = vertexShader.replace( versionRegex, '' );\n\t\t\tfragmentShader = fragmentShader.replace( versionRegex, '' );\n\n\t\t}\n\n\t\t// GLSL 3.0 conversion\n\n\t\tprefixVertex = [\n\t\t\t'#version 300 es\\n',\n\t\t\t'#define attribute in',\n\t\t\t'#define varying out',\n\t\t\t'#define texture2D texture'\n\t\t].join( '\\n' ) + '\\n' + prefixVertex;\n\n\t\tprefixFragment = [\n\t\t\t'#version 300 es\\n',\n\t\t\t'#define varying in',\n\t\t\tisGLSL3ShaderMaterial ? '' : 'out highp vec4 pc_fragColor;',\n\t\t\tisGLSL3ShaderMaterial ? '' : '#define gl_FragColor pc_fragColor',\n\t\t\t'#define gl_FragDepthEXT gl_FragDepth',\n\t\t\t'#define texture2D texture',\n\t\t\t'#define textureCube texture',\n\t\t\t'#define texture2DProj textureProj',\n\t\t\t'#define texture2DLodEXT textureLod',\n\t\t\t'#define texture2DProjLodEXT textureProjLod',\n\t\t\t'#define textureCubeLodEXT textureLod',\n\t\t\t'#define texture2DGradEXT textureGrad',\n\t\t\t'#define texture2DProjGradEXT textureProjGrad',\n\t\t\t'#define textureCubeGradEXT textureGrad'\n\t\t].join( '\\n' ) + '\\n' + prefixFragment;\n\n\t}\n\n\tconst vertexGlsl = prefixVertex + vertexShader;\n\tconst fragmentGlsl = prefixFragment + fragmentShader;\n\n\t// console.log( '*VERTEX*', vertexGlsl );\n\t// console.log( '*FRAGMENT*', fragmentGlsl );\n\n\tconst glVertexShader = WebGLShader( gl, gl.VERTEX_SHADER, vertexGlsl );\n\tconst glFragmentShader = WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentGlsl );\n\n\tgl.attachShader( program, glVertexShader );\n\tgl.attachShader( program, glFragmentShader );\n\n\t// Force a particular attribute to index 0.\n\n\tif ( parameters.index0AttributeName !== undefined ) {\n\n\t\tgl.bindAttribLocation( program, 0, parameters.index0AttributeName );\n\n\t} else if ( parameters.morphTargets === true ) {\n\n\t\t// programs with morphTargets displace position out of attribute 0\n\t\tgl.bindAttribLocation( program, 0, 'position' );\n\n\t}\n\n\tgl.linkProgram( program );\n\n\t// check for link errors\n\tif ( renderer.debug.checkShaderErrors ) {\n\n\t\tconst programLog = gl.getProgramInfoLog( program ).trim();\n\t\tconst vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();\n\t\tconst fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();\n\n\t\tlet runnable = true;\n\t\tlet haveDiagnostics = true;\n\n\t\tif ( gl.getProgramParameter( program, gl.LINK_STATUS ) === false ) {\n\n\t\t\trunnable = false;\n\n\t\t\tconst vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );\n\t\t\tconst fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );\n\n\t\t\tconsole.error( 'THREE.WebGLProgram: shader error: ', gl.getError(), 'gl.VALIDATE_STATUS', gl.getProgramParameter( program, gl.VALIDATE_STATUS ), 'gl.getProgramInfoLog', programLog, vertexErrors, fragmentErrors );\n\n\t\t} else if ( programLog !== '' ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLProgram: gl.getProgramInfoLog()', programLog );\n\n\t\t} else if ( vertexLog === '' || fragmentLog === '' ) {\n\n\t\t\thaveDiagnostics = false;\n\n\t\t}\n\n\t\tif ( haveDiagnostics ) {\n\n\t\t\tthis.diagnostics = {\n\n\t\t\t\trunnable: runnable,\n\n\t\t\t\tprogramLog: programLog,\n\n\t\t\t\tvertexShader: {\n\n\t\t\t\t\tlog: vertexLog,\n\t\t\t\t\tprefix: prefixVertex\n\n\t\t\t\t},\n\n\t\t\t\tfragmentShader: {\n\n\t\t\t\t\tlog: fragmentLog,\n\t\t\t\t\tprefix: prefixFragment\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}\n\n\t}\n\n\t// Clean up\n\n\t// Crashes in iOS9 and iOS10. #18402\n\t// gl.detachShader( program, glVertexShader );\n\t// gl.detachShader( program, glFragmentShader );\n\n\tgl.deleteShader( glVertexShader );\n\tgl.deleteShader( glFragmentShader );\n\n\t// set up caching for uniform locations\n\n\tlet cachedUniforms;\n\n\tthis.getUniforms = function () {\n\n\t\tif ( cachedUniforms === undefined ) {\n\n\t\t\tcachedUniforms = new WebGLUniforms( gl, program );\n\n\t\t}\n\n\t\treturn cachedUniforms;\n\n\t};\n\n\t// set up caching for attribute locations\n\n\tlet cachedAttributes;\n\n\tthis.getAttributes = function () {\n\n\t\tif ( cachedAttributes === undefined ) {\n\n\t\t\tcachedAttributes = fetchAttributeLocations( gl, program );\n\n\t\t}\n\n\t\treturn cachedAttributes;\n\n\t};\n\n\t// free resource\n\n\tthis.destroy = function () {\n\n\t\tbindingStates.releaseStatesOfProgram( this );\n\n\t\tgl.deleteProgram( program );\n\t\tthis.program = undefined;\n\n\t};\n\n\t//\n\n\tthis.name = parameters.shaderName;\n\tthis.id = programIdCount ++;\n\tthis.cacheKey = cacheKey;\n\tthis.usedTimes = 1;\n\tthis.program = program;\n\tthis.vertexShader = glVertexShader;\n\tthis.fragmentShader = glFragmentShader;\n\n\treturn this;\n\n}\n\nexport { WebGLProgram };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide, DoubleSide, CubeUVRefractionMapping, CubeUVReflectionMapping, LinearEncoding, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping } from '../../constants.js';\nimport { WebGLProgram } from './WebGLProgram.js';\nimport { ShaderLib } from '../shaders/ShaderLib.js';\nimport { UniformsUtils } from '../shaders/UniformsUtils.js';\n\nfunction WebGLPrograms( renderer, extensions, capabilities, bindingStates ) {\n\n\tconst programs = [];\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;\n\tconst floatVertexTextures = capabilities.floatVertexTextures;\n\tconst maxVertexUniforms = capabilities.maxVertexUniforms;\n\tconst vertexTextures = capabilities.vertexTextures;\n\n\tlet precision = capabilities.precision;\n\n\tconst shaderIDs = {\n\t\tMeshDepthMaterial: 'depth',\n\t\tMeshDistanceMaterial: 'distanceRGBA',\n\t\tMeshNormalMaterial: 'normal',\n\t\tMeshBasicMaterial: 'basic',\n\t\tMeshLambertMaterial: 'lambert',\n\t\tMeshPhongMaterial: 'phong',\n\t\tMeshToonMaterial: 'toon',\n\t\tMeshStandardMaterial: 'physical',\n\t\tMeshPhysicalMaterial: 'physical',\n\t\tMeshMatcapMaterial: 'matcap',\n\t\tLineBasicMaterial: 'basic',\n\t\tLineDashedMaterial: 'dashed',\n\t\tPointsMaterial: 'points',\n\t\tShadowMaterial: 'shadow',\n\t\tSpriteMaterial: 'sprite'\n\t};\n\n\tconst parameterNames = [\n\t\t\"precision\", \"isWebGL2\", \"supportsVertexTextures\", \"outputEncoding\", \"instancing\",\n\t\t\"map\", \"mapEncoding\", \"matcap\", \"matcapEncoding\", \"envMap\", \"envMapMode\", \"envMapEncoding\", \"envMapCubeUV\",\n\t\t\"lightMap\", \"lightMapEncoding\", \"aoMap\", \"emissiveMap\", \"emissiveMapEncoding\", \"bumpMap\", \"normalMap\", \"objectSpaceNormalMap\", \"tangentSpaceNormalMap\", \"clearcoatMap\", \"clearcoatRoughnessMap\", \"clearcoatNormalMap\", \"displacementMap\", \"specularMap\",\n\t\t\"roughnessMap\", \"metalnessMap\", \"gradientMap\",\n\t\t\"alphaMap\", \"combine\", \"vertexColors\", \"vertexTangents\", \"vertexUvs\", \"uvsVertexOnly\", \"fog\", \"useFog\", \"fogExp2\",\n\t\t\"flatShading\", \"sizeAttenuation\", \"logarithmicDepthBuffer\", \"skinning\",\n\t\t\"maxBones\", \"useVertexTexture\", \"morphTargets\", \"morphNormals\",\n\t\t\"maxMorphTargets\", \"maxMorphNormals\", \"premultipliedAlpha\",\n\t\t\"numDirLights\", \"numPointLights\", \"numSpotLights\", \"numHemiLights\", \"numRectAreaLights\",\n\t\t\"numDirLightShadows\", \"numPointLightShadows\", \"numSpotLightShadows\",\n\t\t\"shadowMapEnabled\", \"shadowMapType\", \"toneMapping\", 'physicallyCorrectLights',\n\t\t\"alphaTest\", \"doubleSided\", \"flipSided\", \"numClippingPlanes\", \"numClipIntersection\", \"depthPacking\", \"dithering\",\n\t\t\"sheen\"\n\t];\n\n\tfunction getShaderObject( material, shaderID ) {\n\n\t\tlet shaderobject;\n\n\t\tif ( shaderID ) {\n\n\t\t\tconst shader = ShaderLib[ shaderID ];\n\n\t\t\tshaderobject = {\n\t\t\t\tname: material.name || material.type,\n\t\t\t\tuniforms: UniformsUtils.clone( shader.uniforms ),\n\t\t\t\tvertexShader: shader.vertexShader,\n\t\t\t\tfragmentShader: shader.fragmentShader\n\t\t\t};\n\n\t\t} else {\n\n\t\t\tshaderobject = {\n\t\t\t\tname: material.name || material.type,\n\t\t\t\tuniforms: material.uniforms,\n\t\t\t\tvertexShader: material.vertexShader,\n\t\t\t\tfragmentShader: material.fragmentShader\n\t\t\t};\n\n\t\t}\n\n\t\treturn shaderobject;\n\n\t}\n\n\tfunction allocateBones( object ) {\n\n\t\tconst skeleton = object.skeleton;\n\t\tconst bones = skeleton.bones;\n\n\t\tif ( floatVertexTextures ) {\n\n\t\t\treturn 1024;\n\n\t\t} else {\n\n\t\t\t// default for when object is not specified\n\t\t\t// ( for example when prebuilding shader to be used with multiple objects )\n\t\t\t//\n\t\t\t// - leave some extra space for other uniforms\n\t\t\t// - limit here is ANGLE's 254 max uniform vectors\n\t\t\t// (up to 54 should be safe)\n\n\t\t\tconst nVertexUniforms = maxVertexUniforms;\n\t\t\tconst nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );\n\n\t\t\tconst maxBones = Math.min( nVertexMatrices, bones.length );\n\n\t\t\tif ( maxBones < bones.length ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' );\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\treturn maxBones;\n\n\t\t}\n\n\t}\n\n\tfunction getTextureEncodingFromMap( map ) {\n\n\t\tlet encoding;\n\n\t\tif ( ! map ) {\n\n\t\t\tencoding = LinearEncoding;\n\n\t\t} else if ( map.isTexture ) {\n\n\t\t\tencoding = map.encoding;\n\n\t\t} else if ( map.isWebGLRenderTarget ) {\n\n\t\t\tconsole.warn( \"THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\tencoding = map.texture.encoding;\n\n\t\t}\n\n\t\treturn encoding;\n\n\t}\n\n\tfunction getParameters( material, lights, shadows, scene, nClipPlanes, nClipIntersection, object ) {\n\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\n\t\tconst envMap = material.envMap || environment;\n\n\t\tconst shaderID = shaderIDs[ material.type ];\n\n\t\t// heuristics to create shader parameters according to lights in the scene\n\t\t// (not to blow over maxLights budget)\n\n\t\tconst maxBones = object.isSkinnedMesh ? allocateBones( object ) : 0;\n\n\t\tif ( material.precision !== null ) {\n\n\t\t\tprecision = capabilities.getMaxPrecision( material.precision );\n\n\t\t\tif ( precision !== material.precision ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst shaderobject = getShaderObject( material, shaderID );\n\t\tmaterial.onBeforeCompile( shaderobject, renderer );\n\n\t\tconst currentRenderTarget = renderer.getRenderTarget();\n\n\t\tconst parameters = {\n\n\t\t\tisWebGL2: isWebGL2,\n\n\t\t\tshaderID: shaderID,\n\t\t\tshaderName: shaderobject.name,\n\n\t\t\tuniforms: shaderobject.uniforms,\n\t\t\tvertexShader: shaderobject.vertexShader,\n\t\t\tfragmentShader: shaderobject.fragmentShader,\n\t\t\tdefines: material.defines,\n\n\t\t\tisRawShaderMaterial: material.isRawShaderMaterial,\n\t\t\tisShaderMaterial: material.isShaderMaterial,\n\n\t\t\tprecision: precision,\n\n\t\t\tinstancing: object.isInstancedMesh === true,\n\n\t\t\tsupportsVertexTextures: vertexTextures,\n\t\t\toutputEncoding: ( currentRenderTarget !== null ) ? getTextureEncodingFromMap( currentRenderTarget.texture ) : renderer.outputEncoding,\n\t\t\tmap: !! material.map,\n\t\t\tmapEncoding: getTextureEncodingFromMap( material.map ),\n\t\t\tmatcap: !! material.matcap,\n\t\t\tmatcapEncoding: getTextureEncodingFromMap( material.matcap ),\n\t\t\tenvMap: !! envMap,\n\t\t\tenvMapMode: envMap && envMap.mapping,\n\t\t\tenvMapEncoding: getTextureEncodingFromMap( envMap ),\n\t\t\tenvMapCubeUV: ( !! envMap ) && ( ( envMap.mapping === CubeUVReflectionMapping ) || ( envMap.mapping === CubeUVRefractionMapping ) ),\n\t\t\tlightMap: !! material.lightMap,\n\t\t\tlightMapEncoding: getTextureEncodingFromMap( material.lightMap ),\n\t\t\taoMap: !! material.aoMap,\n\t\t\temissiveMap: !! material.emissiveMap,\n\t\t\temissiveMapEncoding: getTextureEncodingFromMap( material.emissiveMap ),\n\t\t\tbumpMap: !! material.bumpMap,\n\t\t\tnormalMap: !! material.normalMap,\n\t\t\tobjectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,\n\t\t\ttangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap,\n\t\t\tclearcoatMap: !! material.clearcoatMap,\n\t\t\tclearcoatRoughnessMap: !! material.clearcoatRoughnessMap,\n\t\t\tclearcoatNormalMap: !! material.clearcoatNormalMap,\n\t\t\tdisplacementMap: !! material.displacementMap,\n\t\t\troughnessMap: !! material.roughnessMap,\n\t\t\tmetalnessMap: !! material.metalnessMap,\n\t\t\tspecularMap: !! material.specularMap,\n\t\t\talphaMap: !! material.alphaMap,\n\n\t\t\tgradientMap: !! material.gradientMap,\n\n\t\t\tsheen: !! material.sheen,\n\n\t\t\tcombine: material.combine,\n\n\t\t\tvertexTangents: ( material.normalMap && material.vertexTangents ),\n\t\t\tvertexColors: material.vertexColors,\n\t\t\tvertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap,\n\t\t\tuvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap ) && !! material.displacementMap,\n\n\t\t\tfog: !! fog,\n\t\t\tuseFog: material.fog,\n\t\t\tfogExp2: ( fog && fog.isFogExp2 ),\n\n\t\t\tflatShading: material.flatShading,\n\n\t\t\tsizeAttenuation: material.sizeAttenuation,\n\t\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\t\tskinning: material.skinning && maxBones > 0,\n\t\t\tmaxBones: maxBones,\n\t\t\tuseVertexTexture: floatVertexTextures,\n\n\t\t\tmorphTargets: material.morphTargets,\n\t\t\tmorphNormals: material.morphNormals,\n\t\t\tmaxMorphTargets: renderer.maxMorphTargets,\n\t\t\tmaxMorphNormals: renderer.maxMorphNormals,\n\n\t\t\tnumDirLights: lights.directional.length,\n\t\t\tnumPointLights: lights.point.length,\n\t\t\tnumSpotLights: lights.spot.length,\n\t\t\tnumRectAreaLights: lights.rectArea.length,\n\t\t\tnumHemiLights: lights.hemi.length,\n\n\t\t\tnumDirLightShadows: lights.directionalShadowMap.length,\n\t\t\tnumPointLightShadows: lights.pointShadowMap.length,\n\t\t\tnumSpotLightShadows: lights.spotShadowMap.length,\n\n\t\t\tnumClippingPlanes: nClipPlanes,\n\t\t\tnumClipIntersection: nClipIntersection,\n\n\t\t\tdithering: material.dithering,\n\n\t\t\tshadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,\n\t\t\tshadowMapType: renderer.shadowMap.type,\n\n\t\t\ttoneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,\n\t\t\tphysicallyCorrectLights: renderer.physicallyCorrectLights,\n\n\t\t\tpremultipliedAlpha: material.premultipliedAlpha,\n\n\t\t\talphaTest: material.alphaTest,\n\t\t\tdoubleSided: material.side === DoubleSide,\n\t\t\tflipSided: material.side === BackSide,\n\n\t\t\tdepthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false,\n\n\t\t\tindex0AttributeName: material.index0AttributeName,\n\n\t\t\textensionDerivatives: material.extensions && material.extensions.derivatives,\n\t\t\textensionFragDepth: material.extensions && material.extensions.fragDepth,\n\t\t\textensionDrawBuffers: material.extensions && material.extensions.drawBuffers,\n\t\t\textensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD,\n\n\t\t\trendererExtensionFragDepth: isWebGL2 || extensions.get( 'EXT_frag_depth' ) !== null,\n\t\t\trendererExtensionDrawBuffers: isWebGL2 || extensions.get( 'WEBGL_draw_buffers' ) !== null,\n\t\t\trendererExtensionShaderTextureLod: isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) !== null,\n\n\t\t\tcustomProgramCacheKey: material.customProgramCacheKey()\n\n\t\t};\n\n\t\treturn parameters;\n\n\t}\n\n\tfunction getProgramCacheKey( parameters ) {\n\n\t\tconst array = [];\n\n\t\tif ( parameters.shaderID ) {\n\n\t\t\tarray.push( parameters.shaderID );\n\n\t\t} else {\n\n\t\t\tarray.push( parameters.fragmentShader );\n\t\t\tarray.push( parameters.vertexShader );\n\n\t\t}\n\n\t\tif ( parameters.defines !== undefined ) {\n\n\t\t\tfor ( const name in parameters.defines ) {\n\n\t\t\t\tarray.push( name );\n\t\t\t\tarray.push( parameters.defines[ name ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( parameters.isRawShaderMaterial === undefined ) {\n\n\t\t\tfor ( let i = 0; i < parameterNames.length; i ++ ) {\n\n\t\t\t\tarray.push( parameters[ parameterNames[ i ] ] );\n\n\t\t\t}\n\n\t\t\tarray.push( renderer.outputEncoding );\n\t\t\tarray.push( renderer.gammaFactor );\n\n\t\t}\n\n\t\tarray.push( parameters.customProgramCacheKey );\n\n\t\treturn array.join();\n\n\t}\n\n\tfunction acquireProgram( parameters, cacheKey ) {\n\n\t\tlet program;\n\n\t\t// Check if code has been already compiled\n\t\tfor ( let p = 0, pl = programs.length; p < pl; p ++ ) {\n\n\t\t\tconst preexistingProgram = programs[ p ];\n\n\t\t\tif ( preexistingProgram.cacheKey === cacheKey ) {\n\n\t\t\t\tprogram = preexistingProgram;\n\t\t\t\t++ program.usedTimes;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( program === undefined ) {\n\n\t\t\tprogram = new WebGLProgram( renderer, cacheKey, parameters, bindingStates );\n\t\t\tprograms.push( program );\n\n\t\t}\n\n\t\treturn program;\n\n\t}\n\n\tfunction releaseProgram( program ) {\n\n\t\tif ( -- program.usedTimes === 0 ) {\n\n\t\t\t// Remove from unordered set\n\t\t\tconst i = programs.indexOf( program );\n\t\t\tprograms[ i ] = programs[ programs.length - 1 ];\n\t\t\tprograms.pop();\n\n\t\t\t// Free WebGL resources\n\t\t\tprogram.destroy();\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\tgetParameters: getParameters,\n\t\tgetProgramCacheKey: getProgramCacheKey,\n\t\tacquireProgram: acquireProgram,\n\t\treleaseProgram: releaseProgram,\n\t\t// Exposed for resource monitoring & error feedback via renderer.info:\n\t\tprograms: programs\n\t};\n\n}\n\n\nexport { WebGLPrograms };\n","/**\n * @author fordacious / fordacious.github.io\n */\n\nfunction WebGLProperties() {\n\n\tlet properties = new WeakMap();\n\n\tfunction get( object ) {\n\n\t\tlet map = properties.get( object );\n\n\t\tif ( map === undefined ) {\n\n\t\t\tmap = {};\n\t\t\tproperties.set( object, map );\n\n\t\t}\n\n\t\treturn map;\n\n\t}\n\n\tfunction remove( object ) {\n\n\t\tproperties.delete( object );\n\n\t}\n\n\tfunction update( object, key, value ) {\n\n\t\tproperties.get( object )[ key ] = value;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tproperties = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLProperties };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction painterSortStable( a, b ) {\n\n\tif ( a.groupOrder !== b.groupOrder ) {\n\n\t\treturn a.groupOrder - b.groupOrder;\n\n\t} else if ( a.renderOrder !== b.renderOrder ) {\n\n\t\treturn a.renderOrder - b.renderOrder;\n\n\t} else if ( a.program !== b.program ) {\n\n\t\treturn a.program.id - b.program.id;\n\n\t} else if ( a.material.id !== b.material.id ) {\n\n\t\treturn a.material.id - b.material.id;\n\n\t} else if ( a.z !== b.z ) {\n\n\t\treturn a.z - b.z;\n\n\t} else {\n\n\t\treturn a.id - b.id;\n\n\t}\n\n}\n\nfunction reversePainterSortStable( a, b ) {\n\n\tif ( a.groupOrder !== b.groupOrder ) {\n\n\t\treturn a.groupOrder - b.groupOrder;\n\n\t} else if ( a.renderOrder !== b.renderOrder ) {\n\n\t\treturn a.renderOrder - b.renderOrder;\n\n\t} else if ( a.z !== b.z ) {\n\n\t\treturn b.z - a.z;\n\n\t} else {\n\n\t\treturn a.id - b.id;\n\n\t}\n\n}\n\n\nfunction WebGLRenderList() {\n\n\tconst renderItems = [];\n\tlet renderItemsIndex = 0;\n\n\tconst opaque = [];\n\tconst transparent = [];\n\n\tconst defaultProgram = { id: - 1 };\n\n\tfunction init() {\n\n\t\trenderItemsIndex = 0;\n\n\t\topaque.length = 0;\n\t\ttransparent.length = 0;\n\n\t}\n\n\tfunction getNextRenderItem( object, geometry, material, groupOrder, z, group ) {\n\n\t\tlet renderItem = renderItems[ renderItemsIndex ];\n\n\t\tif ( renderItem === undefined ) {\n\n\t\t\trenderItem = {\n\t\t\t\tid: object.id,\n\t\t\t\tobject: object,\n\t\t\t\tgeometry: geometry,\n\t\t\t\tmaterial: material,\n\t\t\t\tprogram: material.program || defaultProgram,\n\t\t\t\tgroupOrder: groupOrder,\n\t\t\t\trenderOrder: object.renderOrder,\n\t\t\t\tz: z,\n\t\t\t\tgroup: group\n\t\t\t};\n\n\t\t\trenderItems[ renderItemsIndex ] = renderItem;\n\n\t\t} else {\n\n\t\t\trenderItem.id = object.id;\n\t\t\trenderItem.object = object;\n\t\t\trenderItem.geometry = geometry;\n\t\t\trenderItem.material = material;\n\t\t\trenderItem.program = material.program || defaultProgram;\n\t\t\trenderItem.groupOrder = groupOrder;\n\t\t\trenderItem.renderOrder = object.renderOrder;\n\t\t\trenderItem.z = z;\n\t\t\trenderItem.group = group;\n\n\t\t}\n\n\t\trenderItemsIndex ++;\n\n\t\treturn renderItem;\n\n\t}\n\n\tfunction push( object, geometry, material, groupOrder, z, group ) {\n\n\t\tconst renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );\n\n\t\t( material.transparent === true ? transparent : opaque ).push( renderItem );\n\n\t}\n\n\tfunction unshift( object, geometry, material, groupOrder, z, group ) {\n\n\t\tconst renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );\n\n\t\t( material.transparent === true ? transparent : opaque ).unshift( renderItem );\n\n\t}\n\n\tfunction sort( customOpaqueSort, customTransparentSort ) {\n\n\t\tif ( opaque.length > 1 ) opaque.sort( customOpaqueSort || painterSortStable );\n\t\tif ( transparent.length > 1 ) transparent.sort( customTransparentSort || reversePainterSortStable );\n\n\t}\n\n\tfunction finish() {\n\n\t\t// Clear references from inactive renderItems in the list\n\n\t\tfor ( let i = renderItemsIndex, il = renderItems.length; i < il; i ++ ) {\n\n\t\t\tconst renderItem = renderItems[ i ];\n\n\t\t\tif ( renderItem.id === null ) break;\n\n\t\t\trenderItem.id = null;\n\t\t\trenderItem.object = null;\n\t\t\trenderItem.geometry = null;\n\t\t\trenderItem.material = null;\n\t\t\trenderItem.program = null;\n\t\t\trenderItem.group = null;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\topaque: opaque,\n\t\ttransparent: transparent,\n\n\t\tinit: init,\n\t\tpush: push,\n\t\tunshift: unshift,\n\t\tfinish: finish,\n\n\t\tsort: sort\n\t};\n\n}\n\nfunction WebGLRenderLists() {\n\n\tlet lists = new WeakMap();\n\n\tfunction onSceneDispose( event ) {\n\n\t\tconst scene = event.target;\n\n\t\tscene.removeEventListener( 'dispose', onSceneDispose );\n\n\t\tlists.delete( scene );\n\n\t}\n\n\tfunction get( scene, camera ) {\n\n\t\tconst cameras = lists.get( scene );\n\t\tlet list;\n\n\t\tif ( cameras === undefined ) {\n\n\t\t\tlist = new WebGLRenderList();\n\t\t\tlists.set( scene, new WeakMap() );\n\t\t\tlists.get( scene ).set( camera, list );\n\n\t\t\tscene.addEventListener( 'dispose', onSceneDispose );\n\n\t\t} else {\n\n\t\t\tlist = cameras.get( camera );\n\t\t\tif ( list === undefined ) {\n\n\t\t\t\tlist = new WebGLRenderList();\n\t\t\t\tcameras.set( camera, list );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn list;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tlists = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLRenderLists };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Color } from '../../math/Color.js';\nimport { Matrix4 } from '../../math/Matrix4.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Vector3 } from '../../math/Vector3.js';\n\nfunction UniformsCache() {\n\n\tconst lights = {};\n\n\treturn {\n\n\t\tget: function ( light ) {\n\n\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\treturn lights[ light.id ];\n\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch ( light.type ) {\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tconeCos: 0,\n\t\t\t\t\t\tpenumbraCos: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'HemisphereLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tskyColor: new Color(),\n\t\t\t\t\t\tgroundColor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RectAreaLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\thalfWidth: new Vector3(),\n\t\t\t\t\t\thalfHeight: new Vector3()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\treturn uniforms;\n\n\t\t}\n\n\t};\n\n}\n\nfunction ShadowUniformsCache() {\n\n\tconst lights = {};\n\n\treturn {\n\n\t\tget: function ( light ) {\n\n\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\treturn lights[ light.id ];\n\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch ( light.type ) {\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2(),\n\t\t\t\t\t\tshadowCameraNear: 1,\n\t\t\t\t\t\tshadowCameraFar: 1000\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\t// TODO (abelnation): set RectAreaLight shadow uniforms\n\n\t\t\t}\n\n\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\treturn uniforms;\n\n\t\t}\n\n\t};\n\n}\n\n\n\nlet nextVersion = 0;\n\nfunction shadowCastingLightsFirst( lightA, lightB ) {\n\n\treturn ( lightB.castShadow ? 1 : 0 ) - ( lightA.castShadow ? 1 : 0 );\n\n}\n\nfunction WebGLLights() {\n\n\tconst cache = new UniformsCache();\n\n\tconst shadowCache = ShadowUniformsCache();\n\n\tconst state = {\n\n\t\tversion: 0,\n\n\t\thash: {\n\t\t\tdirectionalLength: - 1,\n\t\t\tpointLength: - 1,\n\t\t\tspotLength: - 1,\n\t\t\trectAreaLength: - 1,\n\t\t\themiLength: - 1,\n\n\t\t\tnumDirectionalShadows: - 1,\n\t\t\tnumPointShadows: - 1,\n\t\t\tnumSpotShadows: - 1\n\t\t},\n\n\t\tambient: [ 0, 0, 0 ],\n\t\tprobe: [],\n\t\tdirectional: [],\n\t\tdirectionalShadow: [],\n\t\tdirectionalShadowMap: [],\n\t\tdirectionalShadowMatrix: [],\n\t\tspot: [],\n\t\tspotShadow: [],\n\t\tspotShadowMap: [],\n\t\tspotShadowMatrix: [],\n\t\trectArea: [],\n\t\tpoint: [],\n\t\tpointShadow: [],\n\t\tpointShadowMap: [],\n\t\tpointShadowMatrix: [],\n\t\themi: []\n\n\t};\n\n\tfor ( let i = 0; i < 9; i ++ ) state.probe.push( new Vector3() );\n\n\tconst vector3 = new Vector3();\n\tconst matrix4 = new Matrix4();\n\tconst matrix42 = new Matrix4();\n\n\tfunction setup( lights, shadows, camera ) {\n\n\t\tlet r = 0, g = 0, b = 0;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) state.probe[ i ].set( 0, 0, 0 );\n\n\t\tlet directionalLength = 0;\n\t\tlet pointLength = 0;\n\t\tlet spotLength = 0;\n\t\tlet rectAreaLength = 0;\n\t\tlet hemiLength = 0;\n\n\t\tlet numDirectionalShadows = 0;\n\t\tlet numPointShadows = 0;\n\t\tlet numSpotShadows = 0;\n\n\t\tconst viewMatrix = camera.matrixWorldInverse;\n\n\t\tlights.sort( shadowCastingLightsFirst );\n\n\t\tfor ( let i = 0, l = lights.length; i < l; i ++ ) {\n\n\t\t\tconst light = lights[ i ];\n\n\t\t\tconst color = light.color;\n\t\t\tconst intensity = light.intensity;\n\t\t\tconst distance = light.distance;\n\n\t\t\tconst shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null;\n\n\t\t\tif ( light.isAmbientLight ) {\n\n\t\t\t\tr += color.r * intensity;\n\t\t\t\tg += color.g * intensity;\n\t\t\t\tb += color.b * intensity;\n\n\t\t\t} else if ( light.isLightProbe ) {\n\n\t\t\t\tfor ( let j = 0; j < 9; j ++ ) {\n\n\t\t\t\t\tstate.probe[ j ].addScaledVector( light.sh.coefficients[ j ], intensity );\n\n\t\t\t\t}\n\n\t\t\t} else if ( light.isDirectionalLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\tstate.directionalShadow[ directionalLength ] = shadowUniforms;\n\t\t\t\t\tstate.directionalShadowMap[ directionalLength ] = shadowMap;\n\t\t\t\t\tstate.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumDirectionalShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.directional[ directionalLength ] = uniforms;\n\n\t\t\t\tdirectionalLength ++;\n\n\t\t\t} else if ( light.isSpotLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\t\t\t\tuniforms.distance = distance;\n\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\tuniforms.coneCos = Math.cos( light.angle );\n\t\t\t\tuniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) );\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\tstate.spotShadow[ spotLength ] = shadowUniforms;\n\t\t\t\t\tstate.spotShadowMap[ spotLength ] = shadowMap;\n\t\t\t\t\tstate.spotShadowMatrix[ spotLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumSpotShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.spot[ spotLength ] = uniforms;\n\n\t\t\t\tspotLength ++;\n\n\t\t\t} else if ( light.isRectAreaLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\t// (a) intensity is the total visible light emitted\n\t\t\t\t//uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );\n\n\t\t\t\t// (b) intensity is the brightness of the light\n\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\t// extract local rotation of light to derive width/height half vectors\n\t\t\t\tmatrix42.identity();\n\t\t\t\tmatrix4.copy( light.matrixWorld );\n\t\t\t\tmatrix4.premultiply( viewMatrix );\n\t\t\t\tmatrix42.extractRotation( matrix4 );\n\n\t\t\t\tuniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 );\n\t\t\t\tuniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 );\n\n\t\t\t\tuniforms.halfWidth.applyMatrix4( matrix42 );\n\t\t\t\tuniforms.halfHeight.applyMatrix4( matrix42 );\n\n\t\t\t\t// TODO (abelnation): RectAreaLight distance?\n\t\t\t\t// uniforms.distance = distance;\n\n\t\t\t\tstate.rectArea[ rectAreaLength ] = uniforms;\n\n\t\t\t\trectAreaLength ++;\n\n\t\t\t} else if ( light.isPointLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\tuniforms.distance = light.distance;\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\tshadowUniforms.shadowCameraNear = shadow.camera.near;\n\t\t\t\t\tshadowUniforms.shadowCameraFar = shadow.camera.far;\n\n\t\t\t\t\tstate.pointShadow[ pointLength ] = shadowUniforms;\n\t\t\t\t\tstate.pointShadowMap[ pointLength ] = shadowMap;\n\t\t\t\t\tstate.pointShadowMatrix[ pointLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumPointShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.point[ pointLength ] = uniforms;\n\n\t\t\t\tpointLength ++;\n\n\t\t\t} else if ( light.isHemisphereLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\t\t\t\tuniforms.direction.normalize();\n\n\t\t\t\tuniforms.skyColor.copy( light.color ).multiplyScalar( intensity );\n\t\t\t\tuniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );\n\n\t\t\t\tstate.hemi[ hemiLength ] = uniforms;\n\n\t\t\t\themiLength ++;\n\n\t\t\t}\n\n\t\t}\n\n\t\tstate.ambient[ 0 ] = r;\n\t\tstate.ambient[ 1 ] = g;\n\t\tstate.ambient[ 2 ] = b;\n\n\t\tconst hash = state.hash;\n\n\t\tif ( hash.directionalLength !== directionalLength ||\n\t\t\thash.pointLength !== pointLength ||\n\t\t\thash.spotLength !== spotLength ||\n\t\t\thash.rectAreaLength !== rectAreaLength ||\n\t\t\thash.hemiLength !== hemiLength ||\n\t\t\thash.numDirectionalShadows !== numDirectionalShadows ||\n\t\t\thash.numPointShadows !== numPointShadows ||\n\t\t\thash.numSpotShadows !== numSpotShadows ) {\n\n\t\t\tstate.directional.length = directionalLength;\n\t\t\tstate.spot.length = spotLength;\n\t\t\tstate.rectArea.length = rectAreaLength;\n\t\t\tstate.point.length = pointLength;\n\t\t\tstate.hemi.length = hemiLength;\n\n\t\t\tstate.directionalShadow.length = numDirectionalShadows;\n\t\t\tstate.directionalShadowMap.length = numDirectionalShadows;\n\t\t\tstate.pointShadow.length = numPointShadows;\n\t\t\tstate.pointShadowMap.length = numPointShadows;\n\t\t\tstate.spotShadow.length = numSpotShadows;\n\t\t\tstate.spotShadowMap.length = numSpotShadows;\n\t\t\tstate.directionalShadowMatrix.length = numDirectionalShadows;\n\t\t\tstate.pointShadowMatrix.length = numPointShadows;\n\t\t\tstate.spotShadowMatrix.length = numSpotShadows;\n\n\t\t\thash.directionalLength = directionalLength;\n\t\t\thash.pointLength = pointLength;\n\t\t\thash.spotLength = spotLength;\n\t\t\thash.rectAreaLength = rectAreaLength;\n\t\t\thash.hemiLength = hemiLength;\n\n\t\t\thash.numDirectionalShadows = numDirectionalShadows;\n\t\t\thash.numPointShadows = numPointShadows;\n\t\t\thash.numSpotShadows = numSpotShadows;\n\n\t\t\tstate.version = nextVersion ++;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\tsetup: setup,\n\t\tstate: state\n\t};\n\n}\n\n\nexport { WebGLLights };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { WebGLLights } from './WebGLLights.js';\n\nfunction WebGLRenderState() {\n\n\tconst lights = new WebGLLights();\n\n\tconst lightsArray = [];\n\tconst shadowsArray = [];\n\n\tfunction init() {\n\n\t\tlightsArray.length = 0;\n\t\tshadowsArray.length = 0;\n\n\t}\n\n\tfunction pushLight( light ) {\n\n\t\tlightsArray.push( light );\n\n\t}\n\n\tfunction pushShadow( shadowLight ) {\n\n\t\tshadowsArray.push( shadowLight );\n\n\t}\n\n\tfunction setupLights( camera ) {\n\n\t\tlights.setup( lightsArray, shadowsArray, camera );\n\n\t}\n\n\tconst state = {\n\t\tlightsArray: lightsArray,\n\t\tshadowsArray: shadowsArray,\n\n\t\tlights: lights\n\t};\n\n\treturn {\n\t\tinit: init,\n\t\tstate: state,\n\t\tsetupLights: setupLights,\n\n\t\tpushLight: pushLight,\n\t\tpushShadow: pushShadow\n\t};\n\n}\n\nfunction WebGLRenderStates() {\n\n\tlet renderStates = new WeakMap();\n\n\tfunction onSceneDispose( event ) {\n\n\t\tconst scene = event.target;\n\n\t\tscene.removeEventListener( 'dispose', onSceneDispose );\n\n\t\trenderStates.delete( scene );\n\n\t}\n\n\tfunction get( scene, camera ) {\n\n\t\tlet renderState;\n\n\t\tif ( renderStates.has( scene ) === false ) {\n\n\t\t\trenderState = new WebGLRenderState();\n\t\t\trenderStates.set( scene, new WeakMap() );\n\t\t\trenderStates.get( scene ).set( camera, renderState );\n\n\t\t\tscene.addEventListener( 'dispose', onSceneDispose );\n\n\t\t} else {\n\n\t\t\tif ( renderStates.get( scene ).has( camera ) === false ) {\n\n\t\t\t\trenderState = new WebGLRenderState();\n\t\t\t\trenderStates.get( scene ).set( camera, renderState );\n\n\t\t\t} else {\n\n\t\t\t\trenderState = renderStates.get( scene ).get( camera );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn renderState;\n\n\t}\n\n\tfunction dispose() {\n\n\t\trenderStates = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLRenderStates };\n","import { Material } from './Material.js';\nimport { BasicDepthPacking } from '../constants.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author bhouston / https://clara.io\n * @author WestLangley / http://github.com/WestLangley\n *\n * parameters = {\n *\n * opacity: ,\n *\n * map: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * displacementMap: new THREE.Texture( ),\n * displacementScale: ,\n * displacementBias: ,\n *\n * wireframe: ,\n * wireframeLinewidth: \n * }\n */\n\nfunction MeshDepthMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshDepthMaterial';\n\n\tthis.depthPacking = BasicDepthPacking;\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.displacementMap = null;\n\tthis.displacementScale = 1;\n\tthis.displacementBias = 0;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\n\tthis.fog = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshDepthMaterial.prototype = Object.create( Material.prototype );\nMeshDepthMaterial.prototype.constructor = MeshDepthMaterial;\n\nMeshDepthMaterial.prototype.isMeshDepthMaterial = true;\n\nMeshDepthMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.depthPacking = source.depthPacking;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.displacementMap = source.displacementMap;\n\tthis.displacementScale = source.displacementScale;\n\tthis.displacementBias = source.displacementBias;\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\treturn this;\n\n};\n\n\nexport { MeshDepthMaterial };\n","import { Material } from './Material.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n/**\n * @author WestLangley / http://github.com/WestLangley\n *\n * parameters = {\n *\n * referencePosition: ,\n * nearDistance: ,\n * farDistance: ,\n *\n * skinning: ,\n * morphTargets: ,\n *\n * map: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * displacementMap: new THREE.Texture( ),\n * displacementScale: ,\n * displacementBias: \n *\n * }\n */\n\nfunction MeshDistanceMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshDistanceMaterial';\n\n\tthis.referencePosition = new Vector3();\n\tthis.nearDistance = 1;\n\tthis.farDistance = 1000;\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.displacementMap = null;\n\tthis.displacementScale = 1;\n\tthis.displacementBias = 0;\n\n\tthis.fog = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshDistanceMaterial.prototype = Object.create( Material.prototype );\nMeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;\n\nMeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;\n\nMeshDistanceMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.referencePosition.copy( source.referencePosition );\n\tthis.nearDistance = source.nearDistance;\n\tthis.farDistance = source.farDistance;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.displacementMap = source.displacementMap;\n\tthis.displacementScale = source.displacementScale;\n\tthis.displacementBias = source.displacementBias;\n\n\treturn this;\n\n};\n\n\nexport { MeshDistanceMaterial };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { FrontSide, BackSide, DoubleSide, RGBAFormat, NearestFilter, LinearFilter, PCFShadowMap, VSMShadowMap, RGBADepthPacking, NoBlending } from '../../constants.js';\nimport { WebGLRenderTarget } from '../WebGLRenderTarget.js';\nimport { MeshDepthMaterial } from '../../materials/MeshDepthMaterial.js';\nimport { MeshDistanceMaterial } from '../../materials/MeshDistanceMaterial.js';\nimport { ShaderMaterial } from '../../materials/ShaderMaterial.js';\nimport { BufferAttribute } from '../../core/BufferAttribute.js';\nimport { BufferGeometry } from '../../core/BufferGeometry.js';\nimport { Mesh } from '../../objects/Mesh.js';\nimport { Vector4 } from '../../math/Vector4.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Frustum } from '../../math/Frustum.js';\n\nimport vsm_frag from '../shaders/ShaderLib/vsm_frag.glsl.js';\nimport vsm_vert from '../shaders/ShaderLib/vsm_vert.glsl.js';\n\nfunction WebGLShadowMap( _renderer, _objects, maxTextureSize ) {\n\n\tlet _frustum = new Frustum();\n\n\tconst _shadowMapSize = new Vector2(),\n\t\t_viewportSize = new Vector2(),\n\n\t\t_viewport = new Vector4(),\n\n\t\t_depthMaterials = [],\n\t\t_distanceMaterials = [],\n\n\t\t_materialCache = {};\n\n\tconst shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };\n\n\tconst shadowMaterialVertical = new ShaderMaterial( {\n\n\t\tdefines: {\n\t\t\tSAMPLE_RATE: 2.0 / 8.0,\n\t\t\tHALF_SAMPLE_RATE: 1.0 / 8.0\n\t\t},\n\n\t\tuniforms: {\n\t\t\tshadow_pass: { value: null },\n\t\t\tresolution: { value: new Vector2() },\n\t\t\tradius: { value: 4.0 }\n\t\t},\n\n\t\tvertexShader: vsm_vert,\n\n\t\tfragmentShader: vsm_frag\n\n\t} );\n\n\tconst shadowMaterialHorizonal = shadowMaterialVertical.clone();\n\tshadowMaterialHorizonal.defines.HORIZONAL_PASS = 1;\n\n\tconst fullScreenTri = new BufferGeometry();\n\tfullScreenTri.setAttribute(\n\t\t\"position\",\n\t\tnew BufferAttribute(\n\t\t\tnew Float32Array( [ - 1, - 1, 0.5, 3, - 1, 0.5, - 1, 3, 0.5 ] ),\n\t\t\t3\n\t\t)\n\t);\n\n\tconst fullScreenMesh = new Mesh( fullScreenTri, shadowMaterialVertical );\n\n\tconst scope = this;\n\n\tthis.enabled = false;\n\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\n\tthis.type = PCFShadowMap;\n\n\tthis.render = function ( lights, scene, camera ) {\n\n\t\tif ( scope.enabled === false ) return;\n\t\tif ( scope.autoUpdate === false && scope.needsUpdate === false ) return;\n\n\t\tif ( lights.length === 0 ) return;\n\n\t\tconst currentRenderTarget = _renderer.getRenderTarget();\n\t\tconst activeCubeFace = _renderer.getActiveCubeFace();\n\t\tconst activeMipmapLevel = _renderer.getActiveMipmapLevel();\n\n\t\tconst _state = _renderer.state;\n\n\t\t// Set GL state for depth map.\n\t\t_state.setBlending( NoBlending );\n\t\t_state.buffers.color.setClear( 1, 1, 1, 1 );\n\t\t_state.buffers.depth.setTest( true );\n\t\t_state.setScissorTest( false );\n\n\t\t// render depth map\n\n\t\tfor ( let i = 0, il = lights.length; i < il; i ++ ) {\n\n\t\t\tconst light = lights[ i ];\n\t\t\tconst shadow = light.shadow;\n\n\t\t\tif ( shadow.autoUpdate === false && shadow.needsUpdate === false ) continue;\n\n\t\t\tif ( shadow === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\t_shadowMapSize.copy( shadow.mapSize );\n\n\t\t\tconst shadowFrameExtents = shadow.getFrameExtents();\n\n\t\t\t_shadowMapSize.multiply( shadowFrameExtents );\n\n\t\t\t_viewportSize.copy( shadow.mapSize );\n\n\t\t\tif ( _shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize ) {\n\n\t\t\t\tif ( _shadowMapSize.x > maxTextureSize ) {\n\n\t\t\t\t\t_viewportSize.x = Math.floor( maxTextureSize / shadowFrameExtents.x );\n\t\t\t\t\t_shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x;\n\t\t\t\t\tshadow.mapSize.x = _viewportSize.x;\n\n\t\t\t\t}\n\n\t\t\t\tif ( _shadowMapSize.y > maxTextureSize ) {\n\n\t\t\t\t\t_viewportSize.y = Math.floor( maxTextureSize / shadowFrameExtents.y );\n\t\t\t\t\t_shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y;\n\t\t\t\t\tshadow.mapSize.y = _viewportSize.y;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( shadow.map === null && ! shadow.isPointLightShadow && this.type === VSMShadowMap ) {\n\n\t\t\t\tconst pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };\n\n\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\tshadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t\tif ( shadow.map === null ) {\n\n\t\t\t\tconst pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat };\n\n\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t\t_renderer.setRenderTarget( shadow.map );\n\t\t\t_renderer.clear();\n\n\t\t\tconst viewportCount = shadow.getViewportCount();\n\n\t\t\tfor ( let vp = 0; vp < viewportCount; vp ++ ) {\n\n\t\t\t\tconst viewport = shadow.getViewport( vp );\n\n\t\t\t\t_viewport.set(\n\t\t\t\t\t_viewportSize.x * viewport.x,\n\t\t\t\t\t_viewportSize.y * viewport.y,\n\t\t\t\t\t_viewportSize.x * viewport.z,\n\t\t\t\t\t_viewportSize.y * viewport.w\n\t\t\t\t);\n\n\t\t\t\t_state.viewport( _viewport );\n\n\t\t\t\tshadow.updateMatrices( light, vp );\n\n\t\t\t\t_frustum = shadow.getFrustum();\n\n\t\t\t\trenderObject( scene, camera, shadow.camera, light, this.type );\n\n\t\t\t}\n\n\t\t\t// do blur pass for VSM\n\n\t\t\tif ( ! shadow.isPointLightShadow && this.type === VSMShadowMap ) {\n\n\t\t\t\tVSMPass( shadow, camera );\n\n\t\t\t}\n\n\t\t\tshadow.needsUpdate = false;\n\n\t\t}\n\n\t\tscope.needsUpdate = false;\n\n\t\t_renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );\n\n\t};\n\n\tfunction VSMPass( shadow, camera ) {\n\n\t\tconst geometry = _objects.update( fullScreenMesh );\n\n\t\t// vertical pass\n\n\t\tshadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;\n\t\tshadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialVertical.uniforms.radius.value = shadow.radius;\n\t\t_renderer.setRenderTarget( shadow.mapPass );\n\t\t_renderer.clear();\n\t\t_renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );\n\n\t\t// horizonal pass\n\n\t\tshadowMaterialHorizonal.uniforms.shadow_pass.value = shadow.mapPass.texture;\n\t\tshadowMaterialHorizonal.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialHorizonal.uniforms.radius.value = shadow.radius;\n\t\t_renderer.setRenderTarget( shadow.map );\n\t\t_renderer.clear();\n\t\t_renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizonal, fullScreenMesh, null );\n\n\t}\n\n\tfunction getDepthMaterialVariant( useMorphing, useSkinning, useInstancing ) {\n\n\t\tconst index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\n\t\tlet material = _depthMaterials[ index ];\n\n\t\tif ( material === undefined ) {\n\n\t\t\tmaterial = new MeshDepthMaterial( {\n\n\t\t\t\tdepthPacking: RGBADepthPacking,\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_depthMaterials[ index ] = material;\n\n\t\t}\n\n\t\treturn material;\n\n\t}\n\n\tfunction getDistanceMaterialVariant( useMorphing, useSkinning, useInstancing ) {\n\n\t\tconst index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\n\t\tlet material = _distanceMaterials[ index ];\n\n\t\tif ( material === undefined ) {\n\n\t\t\tmaterial = new MeshDistanceMaterial( {\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_distanceMaterials[ index ] = material;\n\n\t\t}\n\n\t\treturn material;\n\n\t}\n\n\tfunction getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) {\n\n\t\tlet result = null;\n\n\t\tlet getMaterialVariant = getDepthMaterialVariant;\n\t\tlet customMaterial = object.customDepthMaterial;\n\n\t\tif ( light.isPointLight === true ) {\n\n\t\t\tgetMaterialVariant = getDistanceMaterialVariant;\n\t\t\tcustomMaterial = object.customDistanceMaterial;\n\n\t\t}\n\n\t\tif ( customMaterial === undefined ) {\n\n\t\t\tlet useMorphing = false;\n\n\t\t\tif ( material.morphTargets === true ) {\n\n\t\t\t\tuseMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;\n\n\t\t\t}\n\n\t\t\tlet useSkinning = false;\n\n\t\t\tif ( object.isSkinnedMesh === true ) {\n\n\t\t\t\tif ( material.skinning === true ) {\n\n\t\t\t\t\tuseSkinning = true;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:', object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst useInstancing = object.isInstancedMesh === true;\n\n\t\t\tresult = getMaterialVariant( useMorphing, useSkinning, useInstancing );\n\n\t\t} else {\n\n\t\t\tresult = customMaterial;\n\n\t\t}\n\n\t\tif ( _renderer.localClippingEnabled &&\n\t\t\t\tmaterial.clipShadows === true &&\n\t\t\t\tmaterial.clippingPlanes.length !== 0 ) {\n\n\t\t\t// in this case we need a unique material instance reflecting the\n\t\t\t// appropriate state\n\n\t\t\tconst keyA = result.uuid, keyB = material.uuid;\n\n\t\t\tlet materialsForVariant = _materialCache[ keyA ];\n\n\t\t\tif ( materialsForVariant === undefined ) {\n\n\t\t\t\tmaterialsForVariant = {};\n\t\t\t\t_materialCache[ keyA ] = materialsForVariant;\n\n\t\t\t}\n\n\t\t\tlet cachedMaterial = materialsForVariant[ keyB ];\n\n\t\t\tif ( cachedMaterial === undefined ) {\n\n\t\t\t\tcachedMaterial = result.clone();\n\t\t\t\tmaterialsForVariant[ keyB ] = cachedMaterial;\n\n\t\t\t}\n\n\t\t\tresult = cachedMaterial;\n\n\t\t}\n\n\t\tresult.visible = material.visible;\n\t\tresult.wireframe = material.wireframe;\n\n\t\tif ( type === VSMShadowMap ) {\n\n\t\t\tresult.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side;\n\n\t\t} else {\n\n\t\t\tresult.side = ( material.shadowSide !== null ) ? material.shadowSide : shadowSide[ material.side ];\n\n\t\t}\n\n\t\tresult.clipShadows = material.clipShadows;\n\t\tresult.clippingPlanes = material.clippingPlanes;\n\t\tresult.clipIntersection = material.clipIntersection;\n\n\t\tresult.wireframeLinewidth = material.wireframeLinewidth;\n\t\tresult.linewidth = material.linewidth;\n\n\t\tif ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {\n\n\t\t\tresult.referencePosition.setFromMatrixPosition( light.matrixWorld );\n\t\t\tresult.nearDistance = shadowCameraNear;\n\t\t\tresult.farDistance = shadowCameraFar;\n\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\tfunction renderObject( object, camera, shadowCamera, light, type ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tconst visible = object.layers.test( camera.layers );\n\n\t\tif ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) {\n\n\t\t\tif ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) {\n\n\t\t\t\tobject.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );\n\n\t\t\t\tconst geometry = _objects.update( object );\n\t\t\t\tconst material = object.material;\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\tfor ( let k = 0, kl = groups.length; k < kl; k ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ k ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\tconst depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type );\n\n\t\t\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\tconst depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type );\n\n\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\trenderObject( children[ i ], camera, shadowCamera, light, type );\n\n\t\t}\n\n\t}\n\n}\n\n\nexport { WebGLShadowMap };\n","export default /* glsl */`\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n`;\n","export default /* glsl */`\nuniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n\n#include \n\nvoid main() {\n\n float mean = 0.0;\n float squared_mean = 0.0;\n\n\t// This seems totally useless but it's a crazy work around for a Adreno compiler bug\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\n #ifdef HORIZONAL_PASS\n\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\n #else\n\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n\n #endif\n\n }\n\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n\n float std_dev = sqrt( squared_mean - mean * mean );\n\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n\n}\n`;\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js';\nimport { Vector4 } from '../../math/Vector4.js';\n\nfunction WebGLState( gl, extensions, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction ColorBuffer() {\n\n\t\tlet locked = false;\n\n\t\tconst color = new Vector4();\n\t\tlet currentColorMask = null;\n\t\tconst currentColorClear = new Vector4( 0, 0, 0, 0 );\n\n\t\treturn {\n\n\t\t\tsetMask: function ( colorMask ) {\n\n\t\t\t\tif ( currentColorMask !== colorMask && ! locked ) {\n\n\t\t\t\t\tgl.colorMask( colorMask, colorMask, colorMask, colorMask );\n\t\t\t\t\tcurrentColorMask = colorMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( r, g, b, a, premultipliedAlpha ) {\n\n\t\t\t\tif ( premultipliedAlpha === true ) {\n\n\t\t\t\t\tr *= a; g *= a; b *= a;\n\n\t\t\t\t}\n\n\t\t\t\tcolor.set( r, g, b, a );\n\n\t\t\t\tif ( currentColorClear.equals( color ) === false ) {\n\n\t\t\t\t\tgl.clearColor( r, g, b, a );\n\t\t\t\t\tcurrentColorClear.copy( color );\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentColorMask = null;\n\t\t\t\tcurrentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tfunction DepthBuffer() {\n\n\t\tlet locked = false;\n\n\t\tlet currentDepthMask = null;\n\t\tlet currentDepthFunc = null;\n\t\tlet currentDepthClear = null;\n\n\t\treturn {\n\n\t\t\tsetTest: function ( depthTest ) {\n\n\t\t\t\tif ( depthTest ) {\n\n\t\t\t\t\tenable( gl.DEPTH_TEST );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdisable( gl.DEPTH_TEST );\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetMask: function ( depthMask ) {\n\n\t\t\t\tif ( currentDepthMask !== depthMask && ! locked ) {\n\n\t\t\t\t\tgl.depthMask( depthMask );\n\t\t\t\t\tcurrentDepthMask = depthMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetFunc: function ( depthFunc ) {\n\n\t\t\t\tif ( currentDepthFunc !== depthFunc ) {\n\n\t\t\t\t\tif ( depthFunc ) {\n\n\t\t\t\t\t\tswitch ( depthFunc ) {\n\n\t\t\t\t\t\t\tcase NeverDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.NEVER );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase AlwaysDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.ALWAYS );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase LessDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LESS );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase LessEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase EqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.EQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase GreaterEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.GEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase GreaterDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.GREATER );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase NotEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.NOTEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentDepthFunc = depthFunc;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( depth ) {\n\n\t\t\t\tif ( currentDepthClear !== depth ) {\n\n\t\t\t\t\tgl.clearDepth( depth );\n\t\t\t\t\tcurrentDepthClear = depth;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentDepthMask = null;\n\t\t\t\tcurrentDepthFunc = null;\n\t\t\t\tcurrentDepthClear = null;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tfunction StencilBuffer() {\n\n\t\tlet locked = false;\n\n\t\tlet currentStencilMask = null;\n\t\tlet currentStencilFunc = null;\n\t\tlet currentStencilRef = null;\n\t\tlet currentStencilFuncMask = null;\n\t\tlet currentStencilFail = null;\n\t\tlet currentStencilZFail = null;\n\t\tlet currentStencilZPass = null;\n\t\tlet currentStencilClear = null;\n\n\t\treturn {\n\n\t\t\tsetTest: function ( stencilTest ) {\n\n\t\t\t\tif ( ! locked ) {\n\n\t\t\t\t\tif ( stencilTest ) {\n\n\t\t\t\t\t\tenable( gl.STENCIL_TEST );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tdisable( gl.STENCIL_TEST );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetMask: function ( stencilMask ) {\n\n\t\t\t\tif ( currentStencilMask !== stencilMask && ! locked ) {\n\n\t\t\t\t\tgl.stencilMask( stencilMask );\n\t\t\t\t\tcurrentStencilMask = stencilMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetFunc: function ( stencilFunc, stencilRef, stencilMask ) {\n\n\t\t\t\tif ( currentStencilFunc !== stencilFunc ||\n\t\t\t\t currentStencilRef \t!== stencilRef \t||\n\t\t\t\t currentStencilFuncMask !== stencilMask ) {\n\n\t\t\t\t\tgl.stencilFunc( stencilFunc, stencilRef, stencilMask );\n\n\t\t\t\t\tcurrentStencilFunc = stencilFunc;\n\t\t\t\t\tcurrentStencilRef = stencilRef;\n\t\t\t\t\tcurrentStencilFuncMask = stencilMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetOp: function ( stencilFail, stencilZFail, stencilZPass ) {\n\n\t\t\t\tif ( currentStencilFail\t !== stencilFail \t||\n\t\t\t\t currentStencilZFail !== stencilZFail ||\n\t\t\t\t currentStencilZPass !== stencilZPass ) {\n\n\t\t\t\t\tgl.stencilOp( stencilFail, stencilZFail, stencilZPass );\n\n\t\t\t\t\tcurrentStencilFail = stencilFail;\n\t\t\t\t\tcurrentStencilZFail = stencilZFail;\n\t\t\t\t\tcurrentStencilZPass = stencilZPass;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( stencil ) {\n\n\t\t\t\tif ( currentStencilClear !== stencil ) {\n\n\t\t\t\t\tgl.clearStencil( stencil );\n\t\t\t\t\tcurrentStencilClear = stencil;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentStencilMask = null;\n\t\t\t\tcurrentStencilFunc = null;\n\t\t\t\tcurrentStencilRef = null;\n\t\t\t\tcurrentStencilFuncMask = null;\n\t\t\t\tcurrentStencilFail = null;\n\t\t\t\tcurrentStencilZFail = null;\n\t\t\t\tcurrentStencilZPass = null;\n\t\t\t\tcurrentStencilClear = null;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t//\n\n\tconst colorBuffer = new ColorBuffer();\n\tconst depthBuffer = new DepthBuffer();\n\tconst stencilBuffer = new StencilBuffer();\n\n\tlet enabledCapabilities = {};\n\n\tlet currentProgram = null;\n\n\tlet currentBlendingEnabled = null;\n\tlet currentBlending = null;\n\tlet currentBlendEquation = null;\n\tlet currentBlendSrc = null;\n\tlet currentBlendDst = null;\n\tlet currentBlendEquationAlpha = null;\n\tlet currentBlendSrcAlpha = null;\n\tlet currentBlendDstAlpha = null;\n\tlet currentPremultipledAlpha = false;\n\n\tlet currentFlipSided = null;\n\tlet currentCullFace = null;\n\n\tlet currentLineWidth = null;\n\n\tlet currentPolygonOffsetFactor = null;\n\tlet currentPolygonOffsetUnits = null;\n\n\tconst maxTextures = gl.getParameter( gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS );\n\n\tlet lineWidthAvailable = false;\n\tlet version = 0;\n\tconst glVersion = gl.getParameter( gl.VERSION );\n\n\tif ( glVersion.indexOf( 'WebGL' ) !== - 1 ) {\n\n\t\tversion = parseFloat( /^WebGL\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\tlineWidthAvailable = ( version >= 1.0 );\n\n\t} else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) {\n\n\t\tversion = parseFloat( /^OpenGL\\ ES\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\tlineWidthAvailable = ( version >= 2.0 );\n\n\t}\n\n\tlet currentTextureSlot = null;\n\tlet currentBoundTextures = {};\n\n\tconst currentScissor = new Vector4();\n\tconst currentViewport = new Vector4();\n\n\tfunction createTexture( type, target, count ) {\n\n\t\tconst data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.\n\t\tconst texture = gl.createTexture();\n\n\t\tgl.bindTexture( type, texture );\n\t\tgl.texParameteri( type, gl.TEXTURE_MIN_FILTER, gl.NEAREST );\n\t\tgl.texParameteri( type, gl.TEXTURE_MAG_FILTER, gl.NEAREST );\n\n\t\tfor ( let i = 0; i < count; i ++ ) {\n\n\t\t\tgl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );\n\n\t\t}\n\n\t\treturn texture;\n\n\t}\n\n\tconst emptyTextures = {};\n\temptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );\n\temptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );\n\n\t// init\n\n\tcolorBuffer.setClear( 0, 0, 0, 1 );\n\tdepthBuffer.setClear( 1 );\n\tstencilBuffer.setClear( 0 );\n\n\tenable( gl.DEPTH_TEST );\n\tdepthBuffer.setFunc( LessEqualDepth );\n\n\tsetFlipSided( false );\n\tsetCullFace( CullFaceBack );\n\tenable( gl.CULL_FACE );\n\n\tsetBlending( NoBlending );\n\n\t//\n\n\tfunction enable( id ) {\n\n\t\tif ( enabledCapabilities[ id ] !== true ) {\n\n\t\t\tgl.enable( id );\n\t\t\tenabledCapabilities[ id ] = true;\n\n\t\t}\n\n\t}\n\n\tfunction disable( id ) {\n\n\t\tif ( enabledCapabilities[ id ] !== false ) {\n\n\t\t\tgl.disable( id );\n\t\t\tenabledCapabilities[ id ] = false;\n\n\t\t}\n\n\t}\n\n\tfunction useProgram( program ) {\n\n\t\tif ( currentProgram !== program ) {\n\n\t\t\tgl.useProgram( program );\n\n\t\t\tcurrentProgram = program;\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tconst equationToGL = {\n\t\t[ AddEquation ]: gl.FUNC_ADD,\n\t\t[ SubtractEquation ]: gl.FUNC_SUBTRACT,\n\t\t[ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT\n\t};\n\n\tif ( isWebGL2 ) {\n\n\t\tequationToGL[ MinEquation ] = gl.MIN;\n\t\tequationToGL[ MaxEquation ] = gl.MAX;\n\n\t} else {\n\n\t\tconst extension = extensions.get( 'EXT_blend_minmax' );\n\n\t\tif ( extension !== null ) {\n\n\t\t\tequationToGL[ MinEquation ] = extension.MIN_EXT;\n\t\t\tequationToGL[ MaxEquation ] = extension.MAX_EXT;\n\n\t\t}\n\n\t}\n\n\tconst factorToGL = {\n\t\t[ ZeroFactor ]: gl.ZERO,\n\t\t[ OneFactor ]: gl.ONE,\n\t\t[ SrcColorFactor ]: gl.SRC_COLOR,\n\t\t[ SrcAlphaFactor ]: gl.SRC_ALPHA,\n\t\t[ SrcAlphaSaturateFactor ]: gl.SRC_ALPHA_SATURATE,\n\t\t[ DstColorFactor ]: gl.DST_COLOR,\n\t\t[ DstAlphaFactor ]: gl.DST_ALPHA,\n\t\t[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,\n\t\t[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,\n\t\t[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,\n\t\t[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA\n\t};\n\n\tfunction setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {\n\n\t\tif ( blending === NoBlending ) {\n\n\t\t\tif ( currentBlendingEnabled ) {\n\n\t\t\t\tdisable( gl.BLEND );\n\t\t\t\tcurrentBlendingEnabled = false;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( ! currentBlendingEnabled ) {\n\n\t\t\tenable( gl.BLEND );\n\t\t\tcurrentBlendingEnabled = true;\n\n\t\t}\n\n\t\tif ( blending !== CustomBlending ) {\n\n\t\t\tif ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) {\n\n\t\t\t\tif ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) {\n\n\t\t\t\t\tgl.blendEquation( gl.FUNC_ADD );\n\n\t\t\t\t\tcurrentBlendEquation = AddEquation;\n\t\t\t\t\tcurrentBlendEquationAlpha = AddEquation;\n\n\t\t\t\t}\n\n\t\t\t\tif ( premultipliedAlpha ) {\n\n\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ONE, gl.ONE );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ZERO, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.SRC_ALPHA, gl.ONE );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ZERO, gl.ONE_MINUS_SRC_COLOR );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ZERO, gl.SRC_COLOR );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tcurrentBlendSrc = null;\n\t\t\t\tcurrentBlendDst = null;\n\t\t\t\tcurrentBlendSrcAlpha = null;\n\t\t\t\tcurrentBlendDstAlpha = null;\n\n\t\t\t\tcurrentBlending = blending;\n\t\t\t\tcurrentPremultipledAlpha = premultipliedAlpha;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t// custom blending\n\n\t\tblendEquationAlpha = blendEquationAlpha || blendEquation;\n\t\tblendSrcAlpha = blendSrcAlpha || blendSrc;\n\t\tblendDstAlpha = blendDstAlpha || blendDst;\n\n\t\tif ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) {\n\n\t\t\tgl.blendEquationSeparate( equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] );\n\n\t\t\tcurrentBlendEquation = blendEquation;\n\t\t\tcurrentBlendEquationAlpha = blendEquationAlpha;\n\n\t\t}\n\n\t\tif ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) {\n\n\t\t\tgl.blendFuncSeparate( factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] );\n\n\t\t\tcurrentBlendSrc = blendSrc;\n\t\t\tcurrentBlendDst = blendDst;\n\t\t\tcurrentBlendSrcAlpha = blendSrcAlpha;\n\t\t\tcurrentBlendDstAlpha = blendDstAlpha;\n\n\t\t}\n\n\t\tcurrentBlending = blending;\n\t\tcurrentPremultipledAlpha = null;\n\n\t}\n\n\tfunction setMaterial( material, frontFaceCW ) {\n\n\t\tmaterial.side === DoubleSide\n\t\t\t? disable( gl.CULL_FACE )\n\t\t\t: enable( gl.CULL_FACE );\n\n\t\tlet flipSided = ( material.side === BackSide );\n\t\tif ( frontFaceCW ) flipSided = ! flipSided;\n\n\t\tsetFlipSided( flipSided );\n\n\t\t( material.blending === NormalBlending && material.transparent === false )\n\t\t\t? setBlending( NoBlending )\n\t\t\t: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );\n\n\t\tdepthBuffer.setFunc( material.depthFunc );\n\t\tdepthBuffer.setTest( material.depthTest );\n\t\tdepthBuffer.setMask( material.depthWrite );\n\t\tcolorBuffer.setMask( material.colorWrite );\n\n\t\tconst stencilWrite = material.stencilWrite;\n\t\tstencilBuffer.setTest( stencilWrite );\n\t\tif ( stencilWrite ) {\n\n\t\t\tstencilBuffer.setMask( material.stencilWriteMask );\n\t\t\tstencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask );\n\t\t\tstencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass );\n\n\t\t}\n\n\t\tsetPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );\n\n\t}\n\n\t//\n\n\tfunction setFlipSided( flipSided ) {\n\n\t\tif ( currentFlipSided !== flipSided ) {\n\n\t\t\tif ( flipSided ) {\n\n\t\t\t\tgl.frontFace( gl.CW );\n\n\t\t\t} else {\n\n\t\t\t\tgl.frontFace( gl.CCW );\n\n\t\t\t}\n\n\t\t\tcurrentFlipSided = flipSided;\n\n\t\t}\n\n\t}\n\n\tfunction setCullFace( cullFace ) {\n\n\t\tif ( cullFace !== CullFaceNone ) {\n\n\t\t\tenable( gl.CULL_FACE );\n\n\t\t\tif ( cullFace !== currentCullFace ) {\n\n\t\t\t\tif ( cullFace === CullFaceBack ) {\n\n\t\t\t\t\tgl.cullFace( gl.BACK );\n\n\t\t\t\t} else if ( cullFace === CullFaceFront ) {\n\n\t\t\t\t\tgl.cullFace( gl.FRONT );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tgl.cullFace( gl.FRONT_AND_BACK );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdisable( gl.CULL_FACE );\n\n\t\t}\n\n\t\tcurrentCullFace = cullFace;\n\n\t}\n\n\tfunction setLineWidth( width ) {\n\n\t\tif ( width !== currentLineWidth ) {\n\n\t\t\tif ( lineWidthAvailable ) gl.lineWidth( width );\n\n\t\t\tcurrentLineWidth = width;\n\n\t\t}\n\n\t}\n\n\tfunction setPolygonOffset( polygonOffset, factor, units ) {\n\n\t\tif ( polygonOffset ) {\n\n\t\t\tenable( gl.POLYGON_OFFSET_FILL );\n\n\t\t\tif ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {\n\n\t\t\t\tgl.polygonOffset( factor, units );\n\n\t\t\t\tcurrentPolygonOffsetFactor = factor;\n\t\t\t\tcurrentPolygonOffsetUnits = units;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdisable( gl.POLYGON_OFFSET_FILL );\n\n\t\t}\n\n\t}\n\n\tfunction setScissorTest( scissorTest ) {\n\n\t\tif ( scissorTest ) {\n\n\t\t\tenable( gl.SCISSOR_TEST );\n\n\t\t} else {\n\n\t\t\tdisable( gl.SCISSOR_TEST );\n\n\t\t}\n\n\t}\n\n\t// texture\n\n\tfunction activeTexture( webglSlot ) {\n\n\t\tif ( webglSlot === undefined ) webglSlot = gl.TEXTURE0 + maxTextures - 1;\n\n\t\tif ( currentTextureSlot !== webglSlot ) {\n\n\t\t\tgl.activeTexture( webglSlot );\n\t\t\tcurrentTextureSlot = webglSlot;\n\n\t\t}\n\n\t}\n\n\tfunction bindTexture( webglType, webglTexture ) {\n\n\t\tif ( currentTextureSlot === null ) {\n\n\t\t\tactiveTexture();\n\n\t\t}\n\n\t\tlet boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\tif ( boundTexture === undefined ) {\n\n\t\t\tboundTexture = { type: undefined, texture: undefined };\n\t\t\tcurrentBoundTextures[ currentTextureSlot ] = boundTexture;\n\n\t\t}\n\n\t\tif ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) {\n\n\t\t\tgl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] );\n\n\t\t\tboundTexture.type = webglType;\n\t\t\tboundTexture.texture = webglTexture;\n\n\t\t}\n\n\t}\n\n\tfunction unbindTexture() {\n\n\t\tconst boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\tif ( boundTexture !== undefined && boundTexture.type !== undefined ) {\n\n\t\t\tgl.bindTexture( boundTexture.type, null );\n\n\t\t\tboundTexture.type = undefined;\n\t\t\tboundTexture.texture = undefined;\n\n\t\t}\n\n\t}\n\n\tfunction compressedTexImage2D() {\n\n\t\ttry {\n\n\t\t\tgl.compressedTexImage2D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\tfunction texImage2D() {\n\n\t\ttry {\n\n\t\t\tgl.texImage2D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\tfunction texImage3D() {\n\n\t\ttry {\n\n\t\t\tgl.texImage3D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction scissor( scissor ) {\n\n\t\tif ( currentScissor.equals( scissor ) === false ) {\n\n\t\t\tgl.scissor( scissor.x, scissor.y, scissor.z, scissor.w );\n\t\t\tcurrentScissor.copy( scissor );\n\n\t\t}\n\n\t}\n\n\tfunction viewport( viewport ) {\n\n\t\tif ( currentViewport.equals( viewport ) === false ) {\n\n\t\t\tgl.viewport( viewport.x, viewport.y, viewport.z, viewport.w );\n\t\t\tcurrentViewport.copy( viewport );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction reset() {\n\n\t\tenabledCapabilities = {};\n\n\t\tcurrentTextureSlot = null;\n\t\tcurrentBoundTextures = {};\n\n\t\tcurrentProgram = null;\n\n\t\tcurrentBlending = null;\n\n\t\tcurrentFlipSided = null;\n\t\tcurrentCullFace = null;\n\n\t\tcolorBuffer.reset();\n\t\tdepthBuffer.reset();\n\t\tstencilBuffer.reset();\n\n\t}\n\n\treturn {\n\n\t\tbuffers: {\n\t\t\tcolor: colorBuffer,\n\t\t\tdepth: depthBuffer,\n\t\t\tstencil: stencilBuffer\n\t\t},\n\n\t\tenable: enable,\n\t\tdisable: disable,\n\n\t\tuseProgram: useProgram,\n\n\t\tsetBlending: setBlending,\n\t\tsetMaterial: setMaterial,\n\n\t\tsetFlipSided: setFlipSided,\n\t\tsetCullFace: setCullFace,\n\n\t\tsetLineWidth: setLineWidth,\n\t\tsetPolygonOffset: setPolygonOffset,\n\n\t\tsetScissorTest: setScissorTest,\n\n\t\tactiveTexture: activeTexture,\n\t\tbindTexture: bindTexture,\n\t\tunbindTexture: unbindTexture,\n\t\tcompressedTexImage2D: compressedTexImage2D,\n\t\ttexImage2D: texImage2D,\n\t\ttexImage3D: texImage3D,\n\n\t\tscissor: scissor,\n\t\tviewport: viewport,\n\n\t\treset: reset\n\n\t};\n\n}\n\nexport { WebGLState };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping } from '../../constants.js';\nimport { MathUtils } from '../../math/MathUtils.js';\n\nfunction WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst maxTextures = capabilities.maxTextures;\n\tconst maxCubemapSize = capabilities.maxCubemapSize;\n\tconst maxTextureSize = capabilities.maxTextureSize;\n\tconst maxSamples = capabilities.maxSamples;\n\n\tconst _videoTextures = new WeakMap();\n\tlet _canvas;\n\n\t// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,\n\t// also OffscreenCanvas.getContext(\"webgl\"), but not OffscreenCanvas.getContext(\"2d\")!\n\t// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).\n\n\tlet useOffscreenCanvas = false;\n\n\ttry {\n\n\t\tuseOffscreenCanvas = typeof OffscreenCanvas !== 'undefined'\n\t\t\t&& ( new OffscreenCanvas( 1, 1 ).getContext( \"2d\" ) ) !== null;\n\n\t} catch ( err ) {\n\n\t\t// Ignore any errors\n\n\t}\n\n\tfunction createCanvas( width, height ) {\n\n\t\t// Use OffscreenCanvas when available. Specially needed in web workers\n\n\t\treturn useOffscreenCanvas ?\n\t\t\tnew OffscreenCanvas( width, height ) :\n\t\t\tdocument.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t}\n\n\tfunction resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {\n\n\t\tlet scale = 1;\n\n\t\t// handle case if texture exceeds max size\n\n\t\tif ( image.width > maxSize || image.height > maxSize ) {\n\n\t\t\tscale = maxSize / Math.max( image.width, image.height );\n\n\t\t}\n\n\t\t// only perform resize if necessary\n\n\t\tif ( scale < 1 || needsPowerOfTwo === true ) {\n\n\t\t\t// only perform resize for certain image types\n\n\t\t\tif ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||\n\t\t\t\t( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||\n\t\t\t\t( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {\n\n\t\t\t\tconst floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;\n\n\t\t\t\tconst width = floor( scale * image.width );\n\t\t\t\tconst height = floor( scale * image.height );\n\n\t\t\t\tif ( _canvas === undefined ) _canvas = createCanvas( width, height );\n\n\t\t\t\t// cube textures can't reuse the same canvas\n\n\t\t\t\tconst canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas;\n\n\t\t\t\tcanvas.width = width;\n\t\t\t\tcanvas.height = height;\n\n\t\t\t\tconst context = canvas.getContext( '2d' );\n\t\t\t\tcontext.drawImage( image, 0, 0, width, height );\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );\n\n\t\t\t\treturn canvas;\n\n\t\t\t} else {\n\n\t\t\t\tif ( 'data' in image ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').' );\n\n\t\t\t\t}\n\n\t\t\t\treturn image;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn image;\n\n\t}\n\n\tfunction isPowerOfTwo( image ) {\n\n\t\treturn MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height );\n\n\t}\n\n\tfunction textureNeedsPowerOfTwo( texture ) {\n\n\t\tif ( isWebGL2 ) return false;\n\n\t\treturn ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||\n\t\t\t( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );\n\n\t}\n\n\tfunction textureNeedsGenerateMipmaps( texture, supportsMips ) {\n\n\t\treturn texture.generateMipmaps && supportsMips &&\n\t\t\ttexture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\n\t}\n\n\tfunction generateMipmap( target, texture, width, height ) {\n\n\t\t_gl.generateMipmap( target );\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\t// Note: Math.log( x ) * Math.LOG2E used instead of Math.log2( x ) which is not supported by IE11\n\t\ttextureProperties.__maxMipLevel = Math.log( Math.max( width, height ) ) * Math.LOG2E;\n\n\t}\n\n\tfunction getInternalFormat( internalFormatName, glFormat, glType ) {\n\n\t\tif ( isWebGL2 === false ) return glFormat;\n\n\t\tif ( internalFormatName !== null ) {\n\n\t\t\tif ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \\'' + internalFormatName + '\\'' );\n\n\t\t}\n\n\t\tlet internalFormat = glFormat;\n\n\t\tif ( glFormat === _gl.RED ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.R32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.R16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8;\n\n\t\t}\n\n\t\tif ( glFormat === _gl.RGB ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.RGB32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGB16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8;\n\n\t\t}\n\n\t\tif ( glFormat === _gl.RGBA ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8;\n\n\t\t}\n\n\t\tif ( internalFormat === _gl.R16F || internalFormat === _gl.R32F ||\n\t\t\tinternalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F ) {\n\n\t\t\textensions.get( 'EXT_color_buffer_float' );\n\n\t\t}\n\n\t\treturn internalFormat;\n\n\t}\n\n\t// Fallback filters for non-power-of-2 textures\n\n\tfunction filterFallback( f ) {\n\n\t\tif ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {\n\n\t\t\treturn _gl.NEAREST;\n\n\t\t}\n\n\t\treturn _gl.LINEAR;\n\n\t}\n\n\t//\n\n\tfunction onTextureDispose( event ) {\n\n\t\tconst texture = event.target;\n\n\t\ttexture.removeEventListener( 'dispose', onTextureDispose );\n\n\t\tdeallocateTexture( texture );\n\n\t\tif ( texture.isVideoTexture ) {\n\n\t\t\t_videoTextures.delete( texture );\n\n\t\t}\n\n\t\tinfo.memory.textures --;\n\n\t}\n\n\tfunction onRenderTargetDispose( event ) {\n\n\t\tconst renderTarget = event.target;\n\n\t\trenderTarget.removeEventListener( 'dispose', onRenderTargetDispose );\n\n\t\tdeallocateRenderTarget( renderTarget );\n\n\t\tinfo.memory.textures --;\n\n\t}\n\n\t//\n\n\tfunction deallocateTexture( texture ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( textureProperties.__webglInit === undefined ) return;\n\n\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\tproperties.remove( texture );\n\n\t}\n\n\tfunction deallocateRenderTarget( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst textureProperties = properties.get( renderTarget.texture );\n\n\t\tif ( ! renderTarget ) return;\n\n\t\tif ( textureProperties.__webglTexture !== undefined ) {\n\n\t\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\t}\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\trenderTarget.depthTexture.dispose();\n\n\t\t}\n\n\t\tif ( renderTarget.isWebGLCubeRenderTarget ) {\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer );\n\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer );\n\t\t\tif ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\tif ( renderTargetProperties.__webglColorRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer );\n\t\t\tif ( renderTargetProperties.__webglDepthRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer );\n\n\t\t}\n\n\t\tproperties.remove( renderTarget.texture );\n\t\tproperties.remove( renderTarget );\n\n\t}\n\n\t//\n\n\tlet textureUnits = 0;\n\n\tfunction resetTextureUnits() {\n\n\t\ttextureUnits = 0;\n\n\t}\n\n\tfunction allocateTextureUnit() {\n\n\t\tconst textureUnit = textureUnits;\n\n\t\tif ( textureUnit >= maxTextures ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );\n\n\t\t}\n\n\t\ttextureUnits += 1;\n\n\t\treturn textureUnit;\n\n\t}\n\n\t//\n\n\tfunction setTexture2D( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.isVideoTexture ) updateVideoTexture( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tconst image = texture.image;\n\n\t\t\tif ( image === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is undefined' );\n\n\t\t\t} else if ( image.complete === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' );\n\n\t\t\t} else {\n\n\t\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTexture2DArray( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\treturn;\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTexture3D( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\treturn;\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTextureCube( texture, slot ) {\n\n\t\tif ( texture.image.length !== 6 ) return;\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tinitTexture( textureProperties, texture );\n\n\t\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\n\t\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );\n\n\t\t\tconst isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) );\n\t\t\tconst isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );\n\n\t\t\tconst cubeImage = [];\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\tif ( ! isCompressed && ! isDataTexture ) {\n\n\t\t\t\t\tcubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst image = cubeImage[ 0 ],\n\t\t\t\tsupportsMips = isPowerOfTwo( image ) || isWebGL2,\n\t\t\t\tglFormat = utils.convert( texture.format ),\n\t\t\t\tglType = utils.convert( texture.type ),\n\t\t\t\tglInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );\n\n\t\t\tsetTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );\n\n\t\t\tlet mipmaps;\n\n\t\t\tif ( isCompressed ) {\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tmipmaps = cubeImage[ i ].mipmaps;\n\n\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\n\t\t\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\t\t\tif ( glFormat !== null ) {\n\n\t\t\t\t\t\t\t\tstate.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tmipmaps = texture.mipmaps;\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tif ( isDataTexture ) {\n\n\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );\n\n\t\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\t\t\t\t\t\t\tconst mipmapImage = mipmap.image[ i ].image;\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );\n\n\t\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length;\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\t\t// We assume images for cube map have the same size.\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_CUBE_MAP, texture, image.width, image.height );\n\n\t\t\t}\n\n\t\t\ttextureProperties.__version = texture.version;\n\n\t\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t\t} else {\n\n\t\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\n\t\t}\n\n\t}\n\n\tfunction setTextureCubeDynamic( texture, slot ) {\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, properties.get( texture ).__webglTexture );\n\n\t}\n\n\tconst wrappingToGL = {\n\t\t[ RepeatWrapping ]: _gl.REPEAT,\n\t\t[ ClampToEdgeWrapping ]: _gl.CLAMP_TO_EDGE,\n\t\t[ MirroredRepeatWrapping ]: _gl.MIRRORED_REPEAT\n\t};\n\n\tconst filterToGL = {\n\t\t[ NearestFilter ]: _gl.NEAREST,\n\t\t[ NearestMipmapNearestFilter ]: _gl.NEAREST_MIPMAP_NEAREST,\n\t\t[ NearestMipmapLinearFilter ]: _gl.NEAREST_MIPMAP_LINEAR,\n\n\t\t[ LinearFilter ]: _gl.LINEAR,\n\t\t[ LinearMipmapNearestFilter ]: _gl.LINEAR_MIPMAP_NEAREST,\n\t\t[ LinearMipmapLinearFilter ]: _gl.LINEAR_MIPMAP_LINEAR\n\t};\n\n\tfunction setTextureParameters( textureType, texture, supportsMips ) {\n\n\t\tif ( supportsMips ) {\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );\n\n\t\t\tif ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {\n\n\t\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );\n\n\t\t\t}\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );\n\n\t\t} else {\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );\n\n\t\t\tif ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {\n\n\t\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );\n\n\t\t\t}\n\n\t\t\tif ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );\n\n\t\t\t}\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );\n\n\t\t\tif ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\tif ( extension ) {\n\n\t\t\tif ( texture.type === FloatType && extensions.get( 'OES_texture_float_linear' ) === null ) return;\n\t\t\tif ( texture.type === HalfFloatType && ( isWebGL2 || extensions.get( 'OES_texture_half_float_linear' ) ) === null ) return;\n\n\t\t\tif ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {\n\n\t\t\t\t_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );\n\t\t\t\tproperties.get( texture ).__currentAnisotropy = texture.anisotropy;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction initTexture( textureProperties, texture ) {\n\n\t\tif ( textureProperties.__webglInit === undefined ) {\n\n\t\t\ttextureProperties.__webglInit = true;\n\n\t\t\ttexture.addEventListener( 'dispose', onTextureDispose );\n\n\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\t\tinfo.memory.textures ++;\n\n\t\t}\n\n\t}\n\n\tfunction uploadTexture( textureProperties, texture, slot ) {\n\n\t\tlet textureType = _gl.TEXTURE_2D;\n\n\t\tif ( texture.isDataTexture2DArray ) textureType = _gl.TEXTURE_2D_ARRAY;\n\t\tif ( texture.isDataTexture3D ) textureType = _gl.TEXTURE_3D;\n\n\t\tinitTexture( textureProperties, texture );\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( textureType, textureProperties.__webglTexture );\n\n\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );\n\t\t_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );\n\t\t_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );\n\n\t\tconst needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;\n\t\tconst image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );\n\n\t\tconst supportsMips = isPowerOfTwo( image ) || isWebGL2,\n\t\t\tglFormat = utils.convert( texture.format );\n\n\t\tlet glType = utils.convert( texture.type ),\n\t\t\tglInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );\n\n\t\tsetTextureParameters( textureType, texture, supportsMips );\n\n\t\tlet mipmap;\n\t\tconst mipmaps = texture.mipmaps;\n\n\t\tif ( texture.isDepthTexture ) {\n\n\t\t\t// populate depth texture with dummy data\n\n\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT;\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\n\t\t\t\t} else if ( texture.type === UnsignedIntType ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\n\t\t\t\t} else if ( texture.type === UnsignedInt248Type ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH24_STENCIL8;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tconsole.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// validation checks for WebGL 1\n\n\t\t\tif ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {\n\n\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );\n\n\t\t\t\t\ttexture.type = UnsignedShortType;\n\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {\n\n\t\t\t\t// Depth stencil textures need the DEPTH_STENCIL internal format\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tglInternalFormat = _gl.DEPTH_STENCIL;\n\n\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.type !== UnsignedInt248Type ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );\n\n\t\t\t\t\ttexture.type = UnsignedInt248Type;\n\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );\n\n\t\t} else if ( texture.isDataTexture ) {\n\n\t\t\t// use manually created mipmaps if available\n\t\t\t// if there are no manual mipmaps\n\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\tif ( mipmaps.length > 0 && supportsMips ) {\n\n\t\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t}\n\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t}\n\n\t\t} else if ( texture.isCompressedTexture ) {\n\n\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\tmipmap = mipmaps[ i ];\n\n\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\tif ( glFormat !== null ) {\n\n\t\t\t\t\t\tstate.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t} else if ( texture.isDataTexture2DArray ) {\n\n\t\t\tstate.texImage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t} else if ( texture.isDataTexture3D ) {\n\n\t\t\tstate.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t} else {\n\n\t\t\t// regular Texture (image, video, canvas)\n\n\t\t\t// use manually created mipmaps if available\n\t\t\t// if there are no manual mipmaps\n\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\tif ( mipmaps.length > 0 && supportsMips ) {\n\n\t\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap );\n\n\t\t\t\t}\n\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\tgenerateMipmap( textureType, texture, image.width, image.height );\n\n\t\t}\n\n\t\ttextureProperties.__version = texture.version;\n\n\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t}\n\n\t// Render targets\n\n\t// Setup storage for target texture and bind it to correct framebuffer\n\tfunction setupFrameBufferTexture( framebuffer, renderTarget, attachment, textureTarget ) {\n\n\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\t\tstate.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\t}\n\n\t// Setup storage for internal depth/stencil buffers and bind to correct framebuffer\n\tfunction setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {\n\n\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );\n\n\t\tif ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {\n\n\t\t\tlet glInternalFormat = _gl.DEPTH_COMPONENT16;\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst depthTexture = renderTarget.depthTexture;\n\n\t\t\t\tif ( depthTexture && depthTexture.isDepthTexture ) {\n\n\t\t\t\t\tif ( depthTexture.type === FloatType ) {\n\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\n\t\t\t\t\t} else if ( depthTexture.type === UnsignedIntType ) {\n\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );\n\n\t\t} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\n\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );\n\n\t\t} else {\n\n\t\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );\n\n\t}\n\n\t// Setup resources for a Depth Texture for a FBO (needs an extension)\n\tfunction setupDepthTexture( framebuffer, renderTarget ) {\n\n\t\tconst isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget );\n\t\tif ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );\n\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\n\t\tif ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) {\n\n\t\t\tthrow new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' );\n\n\t\t}\n\n\t\t// upload an empty depth texture with framebuffer size\n\t\tif ( ! properties.get( renderTarget.depthTexture ).__webglTexture ||\n\t\t\t\trenderTarget.depthTexture.image.width !== renderTarget.width ||\n\t\t\t\trenderTarget.depthTexture.image.height !== renderTarget.height ) {\n\n\t\t\trenderTarget.depthTexture.image.width = renderTarget.width;\n\t\t\trenderTarget.depthTexture.image.height = renderTarget.height;\n\t\t\trenderTarget.depthTexture.needsUpdate = true;\n\n\t\t}\n\n\t\tsetTexture2D( renderTarget.depthTexture, 0 );\n\n\t\tconst webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;\n\n\t\tif ( renderTarget.depthTexture.format === DepthFormat ) {\n\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );\n\n\t\t} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {\n\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );\n\n\t\t} else {\n\n\t\t\tthrow new Error( 'Unknown depthTexture format' );\n\n\t\t}\n\n\t}\n\n\t// Setup GL resources for a non-texture depth buffer\n\tfunction setupDepthRenderbuffer( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\tif ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );\n\n\t\t\tsetupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );\n\n\t\t} else {\n\n\t\t\tif ( isCube ) {\n\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = [];\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();\n\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();\n\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\t}\n\n\t// Set up GL resources for the render target\n\tfunction setupRenderTarget( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst textureProperties = properties.get( renderTarget.texture );\n\n\t\trenderTarget.addEventListener( 'dispose', onRenderTargetDispose );\n\n\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\tinfo.memory.textures ++;\n\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\t\tconst isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );\n\t\tconst supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;\n\n\t\t// Handles WebGL2 RGBFormat fallback - #18858\n\n\t\tif ( isWebGL2 && renderTarget.texture.format === RGBFormat && ( renderTarget.texture.type === FloatType || renderTarget.texture.type === HalfFloatType ) ) {\n\n\t\t\trenderTarget.texture.format = RGBAFormat;\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.' );\n\n\t\t}\n\n\t\t// Setup framebuffer\n\n\t\tif ( isCube ) {\n\n\t\t\trenderTargetProperties.__webglFramebuffer = [];\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\trenderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\trenderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\t\trenderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();\n\t\t\t\t\trenderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();\n\n\t\t\t\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );\n\n\t\t\t\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\t\t\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\t\t\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\t\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\t\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );\n\t\t\t\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );\n\n\t\t\t\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\t\t\t\trenderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();\n\t\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Setup color buffer\n\n\t\tif ( isCube ) {\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\t\t\tsetTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, supportsMips );\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i );\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) {\n\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, null );\n\n\t\t} else {\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );\n\t\t\tsetTextureParameters( _gl.TEXTURE_2D, renderTarget.texture, supportsMips );\n\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D );\n\n\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) {\n\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_2D, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_2D, null );\n\n\t\t}\n\n\t\t// Setup depth and stencil buffers\n\n\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\tsetupDepthRenderbuffer( renderTarget );\n\n\t\t}\n\n\t}\n\n\tfunction updateRenderTargetMipmap( renderTarget ) {\n\n\t\tconst texture = renderTarget.texture;\n\t\tconst supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;\n\n\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\tconst target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;\n\t\t\tconst webglTexture = properties.get( texture ).__webglTexture;\n\n\t\t\tstate.bindTexture( target, webglTexture );\n\t\t\tgenerateMipmap( target, texture, renderTarget.width, renderTarget.height );\n\t\t\tstate.bindTexture( target, null );\n\n\t\t}\n\n\t}\n\n\tfunction updateMultisampleRenderTarget( renderTarget ) {\n\n\t\tif ( renderTarget.isWebGLMultisampleRenderTarget ) {\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tconst renderTargetProperties = properties.get( renderTarget );\n\n\t\t\t\t_gl.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\t\t_gl.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );\n\n\t\t\t\tconst width = renderTarget.width;\n\t\t\t\tconst height = renderTarget.height;\n\t\t\t\tlet mask = _gl.COLOR_BUFFER_BIT;\n\n\t\t\t\tif ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;\n\t\t\t\tif ( renderTarget.stencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t\t\t_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer ); // see #18905\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction getRenderTargetSamples( renderTarget ) {\n\n\t\treturn ( isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ) ?\n\t\t\tMath.min( maxSamples, renderTarget.samples ) : 0;\n\n\t}\n\n\tfunction updateVideoTexture( texture ) {\n\n\t\tconst frame = info.render.frame;\n\n\t\t// Check the last frame we updated the VideoTexture\n\n\t\tif ( _videoTextures.get( texture ) !== frame ) {\n\n\t\t\t_videoTextures.set( texture, frame );\n\t\t\ttexture.update();\n\n\t\t}\n\n\t}\n\n\t// backwards compatibility\n\n\tlet warnedTexture2D = false;\n\tlet warnedTextureCube = false;\n\n\tfunction safeSetTexture2D( texture, slot ) {\n\n\t\tif ( texture && texture.isWebGLRenderTarget ) {\n\n\t\t\tif ( warnedTexture2D === false ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\t\twarnedTexture2D = true;\n\n\t\t\t}\n\n\t\t\ttexture = texture.texture;\n\n\t\t}\n\n\t\tsetTexture2D( texture, slot );\n\n\t}\n\n\tfunction safeSetTextureCube( texture, slot ) {\n\n\t\tif ( texture && texture.isWebGLCubeRenderTarget ) {\n\n\t\t\tif ( warnedTextureCube === false ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead.\" );\n\t\t\t\twarnedTextureCube = true;\n\n\t\t\t}\n\n\t\t\ttexture = texture.texture;\n\n\t\t}\n\n\t\t// currently relying on the fact that WebGLCubeRenderTarget.texture is a Texture and NOT a CubeTexture\n\t\t// TODO: unify these code paths\n\t\tif ( ( texture && texture.isCubeTexture ) ||\n\t\t\t( Array.isArray( texture.image ) && texture.image.length === 6 ) ) {\n\n\t\t\t// CompressedTexture can have Array in image :/\n\n\t\t\t// this function alone should take care of cube textures\n\t\t\tsetTextureCube( texture, slot );\n\n\t\t} else {\n\n\t\t\t// assumed: texture property of THREE.WebGLCubeRenderTarget\n\t\t\tsetTextureCubeDynamic( texture, slot );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tthis.allocateTextureUnit = allocateTextureUnit;\n\tthis.resetTextureUnits = resetTextureUnits;\n\n\tthis.setTexture2D = setTexture2D;\n\tthis.setTexture2DArray = setTexture2DArray;\n\tthis.setTexture3D = setTexture3D;\n\tthis.setTextureCube = setTextureCube;\n\tthis.setTextureCubeDynamic = setTextureCubeDynamic;\n\tthis.setupRenderTarget = setupRenderTarget;\n\tthis.updateRenderTargetMipmap = updateRenderTargetMipmap;\n\tthis.updateMultisampleRenderTarget = updateMultisampleRenderTarget;\n\n\tthis.safeSetTexture2D = safeSetTexture2D;\n\tthis.safeSetTextureCube = safeSetTextureCube;\n\n}\n\nexport { WebGLTextures };\n","/**\n * @author thespite / http://www.twitter.com/thespite\n */\n\nimport { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, RGBFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, SRGB8_ALPHA8_ASTC_4x4_Format, SRGB8_ALPHA8_ASTC_5x4_Format, SRGB8_ALPHA8_ASTC_5x5_Format, SRGB8_ALPHA8_ASTC_6x5_Format, SRGB8_ALPHA8_ASTC_6x6_Format, SRGB8_ALPHA8_ASTC_8x5_Format, SRGB8_ALPHA8_ASTC_8x6_Format, SRGB8_ALPHA8_ASTC_8x8_Format, SRGB8_ALPHA8_ASTC_10x5_Format, SRGB8_ALPHA8_ASTC_10x6_Format, SRGB8_ALPHA8_ASTC_10x8_Format, SRGB8_ALPHA8_ASTC_10x10_Format, SRGB8_ALPHA8_ASTC_12x10_Format, SRGB8_ALPHA8_ASTC_12x12_Format, RGBA_BPTC_Format } from '../../constants.js';\n\nfunction WebGLUtils( gl, extensions, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction convert( p ) {\n\n\t\tlet extension;\n\n\t\tif ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;\n\t\tif ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;\n\t\tif ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;\n\t\tif ( p === UnsignedShort565Type ) return gl.UNSIGNED_SHORT_5_6_5;\n\n\t\tif ( p === ByteType ) return gl.BYTE;\n\t\tif ( p === ShortType ) return gl.SHORT;\n\t\tif ( p === UnsignedShortType ) return gl.UNSIGNED_SHORT;\n\t\tif ( p === IntType ) return gl.INT;\n\t\tif ( p === UnsignedIntType ) return gl.UNSIGNED_INT;\n\t\tif ( p === FloatType ) return gl.FLOAT;\n\n\t\tif ( p === HalfFloatType ) {\n\n\t\t\tif ( isWebGL2 ) return gl.HALF_FLOAT;\n\n\t\t\textension = extensions.get( 'OES_texture_half_float' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.HALF_FLOAT_OES;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === AlphaFormat ) return gl.ALPHA;\n\t\tif ( p === RGBFormat ) return gl.RGB;\n\t\tif ( p === RGBAFormat ) return gl.RGBA;\n\t\tif ( p === LuminanceFormat ) return gl.LUMINANCE;\n\t\tif ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;\n\t\tif ( p === DepthFormat ) return gl.DEPTH_COMPONENT;\n\t\tif ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;\n\t\tif ( p === RedFormat ) return gl.RED;\n\n\t\t// WebGL2 formats.\n\n\t\tif ( p === RedIntegerFormat ) return gl.RED_INTEGER;\n\t\tif ( p === RGFormat ) return gl.RG;\n\t\tif ( p === RGIntegerFormat ) return gl.RG_INTEGER;\n\t\tif ( p === RGBIntegerFormat ) return gl.RGB_INTEGER;\n\t\tif ( p === RGBAIntegerFormat ) return gl.RGBA_INTEGER;\n\n\t\tif ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format ||\n\t\t\tp === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_s3tc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format ||\n\t\t\tp === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;\n\t\t\t\tif ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;\n\t\t\t\tif ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;\n\t\t\t\tif ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_ETC1_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc1' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.COMPRESSED_RGB_ETC1_WEBGL;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_ETC2_Format ) return extension.COMPRESSED_RGB8_ETC2;\n\t\t\t\tif ( p === RGBA_ETC2_EAC_Format ) return extension.COMPRESSED_RGBA8_ETC2_EAC;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format ||\n\t\t\tp === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format ||\n\t\t\tp === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format ||\n\t\t\tp === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format ||\n\t\t\tp === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_4x4_Format || p === SRGB8_ALPHA8_ASTC_5x4_Format || p === SRGB8_ALPHA8_ASTC_5x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_6x5_Format || p === SRGB8_ALPHA8_ASTC_6x6_Format || p === SRGB8_ALPHA8_ASTC_8x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_8x6_Format || p === SRGB8_ALPHA8_ASTC_8x8_Format || p === SRGB8_ALPHA8_ASTC_10x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_10x6_Format || p === SRGB8_ALPHA8_ASTC_10x8_Format || p === SRGB8_ALPHA8_ASTC_10x10_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_12x10_Format || p === SRGB8_ALPHA8_ASTC_12x12_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_astc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\t// TODO Complete?\n\n\t\t\t\treturn p;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGBA_BPTC_Format ) {\n\n\t\t\textension = extensions.get( 'EXT_texture_compression_bptc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\t// TODO Complete?\n\n\t\t\t\treturn p;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === UnsignedInt248Type ) {\n\n\t\t\tif ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;\n\n\t\t\textension = extensions.get( 'WEBGL_depth_texture' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.UNSIGNED_INT_24_8_WEBGL;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn { convert: convert };\n\n}\n\n\nexport { WebGLUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { PerspectiveCamera } from './PerspectiveCamera.js';\n\nfunction ArrayCamera( array ) {\n\n\tPerspectiveCamera.call( this );\n\n\tthis.cameras = array || [];\n\n}\n\nArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), {\n\n\tconstructor: ArrayCamera,\n\n\tisArrayCamera: true\n\n} );\n\n\nexport { ArrayCamera };\n","import { Object3D } from '../core/Object3D.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Group() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Group';\n\n}\n\nGroup.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Group,\n\n\tisGroup: true\n\n} );\n\n\nexport { Group };\n","import { Group } from '../../objects/Group.js';\n\n/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nfunction WebXRController() {\n\n\tthis._targetRay = null;\n\tthis._grip = null;\n\n}\n\nObject.assign( WebXRController.prototype, {\n\n\tconstructor: WebXRController,\n\n\tgetTargetRaySpace: function () {\n\n\t\tif ( this._targetRay === null ) {\n\n\t\t\tthis._targetRay = new Group();\n\t\t\tthis._targetRay.matrixAutoUpdate = false;\n\t\t\tthis._targetRay.visible = false;\n\n\t\t}\n\n\t\treturn this._targetRay;\n\n\t},\n\n\tgetGripSpace: function () {\n\n\t\tif ( this._grip === null ) {\n\n\t\t\tthis._grip = new Group();\n\t\t\tthis._grip.matrixAutoUpdate = false;\n\t\t\tthis._grip.visible = false;\n\n\t\t}\n\n\t\treturn this._grip;\n\n\t},\n\n\tdispatchEvent: function ( event ) {\n\n\t\tif ( this._targetRay !== null ) {\n\n\t\t\tthis._targetRay.dispatchEvent( event );\n\n\t\t}\n\n\t\tif ( this._grip !== null ) {\n\n\t\t\tthis._grip.dispatchEvent( event );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tdisconnect: function ( inputSource ) {\n\n\t\tthis.dispatchEvent( { type: 'disconnected', data: inputSource } );\n\n\t\tif ( this._targetRay !== null ) {\n\n\t\t\tthis._targetRay.visible = false;\n\n\t\t}\n\n\t\tif ( this._grip !== null ) {\n\n\t\t\tthis._grip.visible = false;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tupdate: function ( inputSource, frame, referenceSpace ) {\n\n\t\tlet inputPose = null;\n\t\tlet gripPose = null;\n\n\t\tconst targetRay = this._targetRay;\n\t\tconst grip = this._grip;\n\n\t\tif ( inputSource ) {\n\n\t\t\tif ( targetRay !== null ) {\n\n\t\t\t\tinputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );\n\n\t\t\t\tif ( inputPose !== null ) {\n\n\t\t\t\t\ttargetRay.matrix.fromArray( inputPose.transform.matrix );\n\t\t\t\t\ttargetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( grip !== null && inputSource.gripSpace ) {\n\n\t\t\t\tgripPose = frame.getPose( inputSource.gripSpace, referenceSpace );\n\n\t\t\t\tif ( gripPose !== null ) {\n\n\t\t\t\t\tgrip.matrix.fromArray( gripPose.transform.matrix );\n\t\t\t\t\tgrip.matrix.decompose( grip.position, grip.rotation, grip.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( targetRay !== null ) {\n\n\t\t\ttargetRay.visible = ( inputPose !== null );\n\n\t\t}\n\n\t\tif ( grip !== null ) {\n\n\t\t\tgrip.visible = ( gripPose !== null );\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { WebXRController };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { ArrayCamera } from '../../cameras/ArrayCamera.js';\nimport { EventDispatcher } from '../../core/EventDispatcher.js';\nimport { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js';\nimport { Vector3 } from '../../math/Vector3.js';\nimport { Vector4 } from '../../math/Vector4.js';\nimport { WebGLAnimation } from '../webgl/WebGLAnimation.js';\nimport { WebXRController } from './WebXRController.js';\n\nfunction WebXRManager( renderer, gl ) {\n\n\tconst scope = this;\n\n\tlet session = null;\n\n\tlet framebufferScaleFactor = 1.0;\n\n\tlet referenceSpace = null;\n\tlet referenceSpaceType = 'local-floor';\n\n\tlet pose = null;\n\n\tconst controllers = [];\n\tconst inputSourcesMap = new Map();\n\n\t//\n\n\tconst cameraL = new PerspectiveCamera();\n\tcameraL.layers.enable( 1 );\n\tcameraL.viewport = new Vector4();\n\n\tconst cameraR = new PerspectiveCamera();\n\tcameraR.layers.enable( 2 );\n\tcameraR.viewport = new Vector4();\n\n\tconst cameras = [ cameraL, cameraR ];\n\n\tconst cameraVR = new ArrayCamera();\n\tcameraVR.layers.enable( 1 );\n\tcameraVR.layers.enable( 2 );\n\n\tlet _currentDepthNear = null;\n\tlet _currentDepthFar = null;\n\n\t//\n\n\tthis.enabled = false;\n\n\tthis.isPresenting = false;\n\n\tthis.getController = function ( index ) {\n\n\t\tlet controller = controllers[ index ];\n\n\t\tif ( controller === undefined ) {\n\n\t\t\tcontroller = new WebXRController();\n\t\t\tcontrollers[ index ] = controller;\n\n\t\t}\n\n\t\treturn controller.getTargetRaySpace();\n\n\t};\n\n\tthis.getControllerGrip = function ( index ) {\n\n\t\tlet controller = controllers[ index ];\n\n\t\tif ( controller === undefined ) {\n\n\t\t\tcontroller = new WebXRController();\n\t\t\tcontrollers[ index ] = controller;\n\n\t\t}\n\n\t\treturn controller.getGripSpace();\n\n\t};\n\n\t//\n\n\tfunction onSessionEvent( event ) {\n\n\t\tconst controller = inputSourcesMap.get( event.inputSource );\n\n\t\tif ( controller ) {\n\n\t\t\tcontroller.dispatchEvent( { type: event.type } );\n\n\t\t}\n\n\t}\n\n\tfunction onSessionEnd() {\n\n\t\tinputSourcesMap.forEach( function ( controller, inputSource ) {\n\n\t\t\tcontroller.disconnect( inputSource );\n\n\t\t} );\n\n\t\tinputSourcesMap.clear();\n\n\t\t//\n\n\t\trenderer.setFramebuffer( null );\n\t\trenderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830\n\t\tanimation.stop();\n\n\t\tscope.isPresenting = false;\n\n\t\tscope.dispatchEvent( { type: 'sessionend' } );\n\n\t}\n\n\tfunction onRequestReferenceSpace( value ) {\n\n\t\treferenceSpace = value;\n\n\t\tanimation.setContext( session );\n\t\tanimation.start();\n\n\t\tscope.isPresenting = true;\n\n\t\tscope.dispatchEvent( { type: 'sessionstart' } );\n\n\t}\n\n\tthis.setFramebufferScaleFactor = function ( value ) {\n\n\t\tframebufferScaleFactor = value;\n\n\t\tif ( scope.isPresenting === true ) {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' );\n\n\t\t}\n\n\t};\n\n\tthis.setReferenceSpaceType = function ( value ) {\n\n\t\treferenceSpaceType = value;\n\n\t\tif ( scope.isPresenting === true ) {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' );\n\n\t\t}\n\n\t};\n\n\tthis.getReferenceSpace = function () {\n\n\t\treturn referenceSpace;\n\n\t};\n\n\tthis.getSession = function () {\n\n\t\treturn session;\n\n\t};\n\n\tthis.setSession = function ( value ) {\n\n\t\tsession = value;\n\n\t\tif ( session !== null ) {\n\n\t\t\tsession.addEventListener( 'select', onSessionEvent );\n\t\t\tsession.addEventListener( 'selectstart', onSessionEvent );\n\t\t\tsession.addEventListener( 'selectend', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeeze', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeezestart', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeezeend', onSessionEvent );\n\t\t\tsession.addEventListener( 'end', onSessionEnd );\n\n\t\t\tconst attributes = gl.getContextAttributes();\n\n\t\t\tif ( attributes.xrCompatible !== true ) {\n\n\t\t\t\tgl.makeXRCompatible();\n\n\t\t\t}\n\n\t\t\tconst layerInit = {\n\t\t\t\tantialias: attributes.antialias,\n\t\t\t\talpha: attributes.alpha,\n\t\t\t\tdepth: attributes.depth,\n\t\t\t\tstencil: attributes.stencil,\n\t\t\t\tframebufferScaleFactor: framebufferScaleFactor\n\t\t\t};\n\n\t\t\t// eslint-disable-next-line no-undef\n\t\t\tconst baseLayer = new XRWebGLLayer( session, gl, layerInit );\n\n\t\t\tsession.updateRenderState( { baseLayer: baseLayer } );\n\n\t\t\tsession.requestReferenceSpace( referenceSpaceType ).then( onRequestReferenceSpace );\n\n\t\t\t//\n\n\t\t\tsession.addEventListener( 'inputsourceschange', updateInputSources );\n\n\t\t}\n\n\t};\n\n\tfunction updateInputSources( event ) {\n\n\t\tconst inputSources = session.inputSources;\n\n\t\t// Assign inputSources to available controllers\n\n\t\tfor ( let i = 0; i < controllers.length; i ++ ) {\n\n\t\t\tinputSourcesMap.set( inputSources[ i ], controllers[ i ] );\n\n\t\t}\n\n\t\t// Notify disconnected\n\n\t\tfor ( let i = 0; i < event.removed.length; i ++ ) {\n\n\t\t\tconst inputSource = event.removed[ i ];\n\t\t\tconst controller = inputSourcesMap.get( inputSource );\n\n\t\t\tif ( controller ) {\n\n\t\t\t\tcontroller.dispatchEvent( { type: 'disconnected', data: inputSource } );\n\t\t\t\tinputSourcesMap.delete( inputSource );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Notify connected\n\n\t\tfor ( let i = 0; i < event.added.length; i ++ ) {\n\n\t\t\tconst inputSource = event.added[ i ];\n\t\t\tconst controller = inputSourcesMap.get( inputSource );\n\n\t\t\tif ( controller ) {\n\n\t\t\t\tcontroller.dispatchEvent( { type: 'connected', data: inputSource } );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t//\n\n\tconst cameraLPos = new Vector3();\n\tconst cameraRPos = new Vector3();\n\n\t/**\n\t * @author jsantell / https://www.jsantell.com/\n\t *\n\t * Assumes 2 cameras that are parallel and share an X-axis, and that\n\t * the cameras' projection and world matrices have already been set.\n\t * And that near and far planes are identical for both cameras.\n\t * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765\n\t */\n\tfunction setProjectionFromUnion( camera, cameraL, cameraR ) {\n\n\t\tcameraLPos.setFromMatrixPosition( cameraL.matrixWorld );\n\t\tcameraRPos.setFromMatrixPosition( cameraR.matrixWorld );\n\n\t\tconst ipd = cameraLPos.distanceTo( cameraRPos );\n\n\t\tconst projL = cameraL.projectionMatrix.elements;\n\t\tconst projR = cameraR.projectionMatrix.elements;\n\n\t\t// VR systems will have identical far and near planes, and\n\t\t// most likely identical top and bottom frustum extents.\n\t\t// Use the left camera for these values.\n\t\tconst near = projL[ 14 ] / ( projL[ 10 ] - 1 );\n\t\tconst far = projL[ 14 ] / ( projL[ 10 ] + 1 );\n\t\tconst topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];\n\t\tconst bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];\n\n\t\tconst leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];\n\t\tconst rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];\n\t\tconst left = near * leftFov;\n\t\tconst right = near * rightFov;\n\n\t\t// Calculate the new camera's position offset from the\n\t\t// left camera. xOffset should be roughly half `ipd`.\n\t\tconst zOffset = ipd / ( - leftFov + rightFov );\n\t\tconst xOffset = zOffset * - leftFov;\n\n\t\t// TODO: Better way to apply this offset?\n\t\tcameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.translateX( xOffset );\n\t\tcamera.translateZ( zOffset );\n\t\tcamera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t\t// Find the union of the frustum values of the cameras and scale\n\t\t// the values so that the near plane's position does not change in world space,\n\t\t// although must now be relative to the new union camera.\n\t\tconst near2 = near + zOffset;\n\t\tconst far2 = far + zOffset;\n\t\tconst left2 = left - xOffset;\n\t\tconst right2 = right + ( ipd - xOffset );\n\t\tconst top2 = topFov * far / far2 * near2;\n\t\tconst bottom2 = bottomFov * far / far2 * near2;\n\n\t\tcamera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );\n\n\t}\n\n\tfunction updateCamera( camera, parent ) {\n\n\t\tif ( parent === null ) {\n\n\t\t\tcamera.matrixWorld.copy( camera.matrix );\n\n\t\t} else {\n\n\t\t\tcamera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix );\n\n\t\t}\n\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t}\n\n\tthis.getCamera = function ( camera ) {\n\n\t\tcameraVR.near = cameraR.near = cameraL.near = camera.near;\n\t\tcameraVR.far = cameraR.far = cameraL.far = camera.far;\n\n\t\tif ( _currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far ) {\n\n\t\t\t// Note that the new renderState won't apply until the next frame. See #18320\n\n\t\t\tsession.updateRenderState( {\n\t\t\t\tdepthNear: cameraVR.near,\n\t\t\t\tdepthFar: cameraVR.far\n\t\t\t} );\n\n\t\t\t_currentDepthNear = cameraVR.near;\n\t\t\t_currentDepthFar = cameraVR.far;\n\n\t\t}\n\n\t\tconst parent = camera.parent;\n\t\tconst cameras = cameraVR.cameras;\n\n\t\tupdateCamera( cameraVR, parent );\n\n\t\tfor ( let i = 0; i < cameras.length; i ++ ) {\n\n\t\t\tupdateCamera( cameras[ i ], parent );\n\n\t\t}\n\n\t\t// update camera and its children\n\n\t\tcamera.matrixWorld.copy( cameraVR.matrixWorld );\n\n\t\tconst children = camera.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].updateMatrixWorld( true );\n\n\t\t}\n\n\t\t// update projection matrix for proper view frustum culling\n\n\t\tif ( cameras.length === 2 ) {\n\n\t\t\tsetProjectionFromUnion( cameraVR, cameraL, cameraR );\n\n\t\t} else {\n\n\t\t\t// assume single camera setup (AR)\n\n\t\t\tcameraVR.projectionMatrix.copy( cameraL.projectionMatrix );\n\n\t\t}\n\n\t\treturn cameraVR;\n\n\t};\n\n\t// Animation Loop\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame( time, frame ) {\n\n\t\tpose = frame.getViewerPose( referenceSpace );\n\n\t\tif ( pose !== null ) {\n\n\t\t\tconst views = pose.views;\n\t\t\tconst baseLayer = session.renderState.baseLayer;\n\n\t\t\trenderer.setFramebuffer( baseLayer.framebuffer );\n\n\t\t\tlet cameraVRNeedsUpdate = false;\n\n\t\t\t// check if it's necessary to rebuild cameraVR's camera list\n\n\t\t\tif ( views.length !== cameraVR.cameras.length ) {\n\n\t\t\t\tcameraVR.cameras.length = 0;\n\t\t\t\tcameraVRNeedsUpdate = true;\n\n\t\t\t}\n\n\t\t\tfor ( let i = 0; i < views.length; i ++ ) {\n\n\t\t\t\tconst view = views[ i ];\n\t\t\t\tconst viewport = baseLayer.getViewport( view );\n\n\t\t\t\tconst camera = cameras[ i ];\n\t\t\t\tcamera.matrix.fromArray( view.transform.matrix );\n\t\t\t\tcamera.projectionMatrix.fromArray( view.projectionMatrix );\n\t\t\t\tcamera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );\n\n\t\t\t\tif ( i === 0 ) {\n\n\t\t\t\t\tcameraVR.matrix.copy( camera.matrix );\n\n\t\t\t\t}\n\n\t\t\t\tif ( cameraVRNeedsUpdate === true ) {\n\n\t\t\t\t\tcameraVR.cameras.push( camera );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tconst inputSources = session.inputSources;\n\n\t\tfor ( let i = 0; i < controllers.length; i ++ ) {\n\n\t\t\tconst controller = controllers[ i ];\n\t\t\tconst inputSource = inputSources[ i ];\n\n\t\t\tcontroller.update( inputSource, frame, referenceSpace );\n\n\t\t}\n\n\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );\n\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop( onAnimationFrame );\n\n\tthis.setAnimationLoop = function ( callback ) {\n\n\t\tonAnimationFrameCallback = callback;\n\n\t};\n\n\tthis.dispose = function () {};\n\n}\n\nObject.assign( WebXRManager.prototype, EventDispatcher.prototype );\n\nexport { WebXRManager };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide } from \"../../constants.js\";\n\nfunction WebGLMaterials( properties ) {\n\n\tfunction refreshFogUniforms( uniforms, fog ) {\n\n\t\tuniforms.fogColor.value.copy( fog.color );\n\n\t\tif ( fog.isFog ) {\n\n\t\t\tuniforms.fogNear.value = fog.near;\n\t\t\tuniforms.fogFar.value = fog.far;\n\n\t\t} else if ( fog.isFogExp2 ) {\n\n\t\t\tuniforms.fogDensity.value = fog.density;\n\n\t\t}\n\n\t}\n\n\tfunction refreshMaterialUniforms( uniforms, material, environment, pixelRatio, height ) {\n\n\t\tif ( material.isMeshBasicMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\n\t\t} else if ( material.isMeshLambertMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsLambert( uniforms, material );\n\n\t\t} else if ( material.isMeshToonMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsToon( uniforms, material );\n\n\t\t} else if ( material.isMeshPhongMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsPhong( uniforms, material );\n\n\t\t} else if ( material.isMeshStandardMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material, environment );\n\n\t\t\tif ( material.isMeshPhysicalMaterial ) {\n\n\t\t\t\trefreshUniformsPhysical( uniforms, material, environment );\n\n\t\t\t} else {\n\n\t\t\t\trefreshUniformsStandard( uniforms, material, environment );\n\n\t\t\t}\n\n\t\t} else if ( material.isMeshMatcapMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsMatcap( uniforms, material );\n\n\t\t} else if ( material.isMeshDepthMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsDepth( uniforms, material );\n\n\t\t} else if ( material.isMeshDistanceMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsDistance( uniforms, material );\n\n\t\t} else if ( material.isMeshNormalMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsNormal( uniforms, material );\n\n\t\t} else if ( material.isLineBasicMaterial ) {\n\n\t\t\trefreshUniformsLine( uniforms, material );\n\n\t\t\tif ( material.isLineDashedMaterial ) {\n\n\t\t\t\trefreshUniformsDash( uniforms, material );\n\n\t\t\t}\n\n\t\t} else if ( material.isPointsMaterial ) {\n\n\t\t\trefreshUniformsPoints( uniforms, material, pixelRatio, height );\n\n\t\t} else if ( material.isSpriteMaterial ) {\n\n\t\t\trefreshUniformsSprites( uniforms, material );\n\n\t\t} else if ( material.isShadowMaterial ) {\n\n\t\t\tuniforms.color.value.copy( material.color );\n\t\t\tuniforms.opacity.value = material.opacity;\n\n\t\t} else if ( material.isShaderMaterial ) {\n\n\t\t\tmaterial.uniformsNeedUpdate = false; // #15581\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsCommon( uniforms, material, environment ) {\n\n\t\tuniforms.opacity.value = material.opacity;\n\n\t\tif ( material.color ) {\n\n\t\t\tuniforms.diffuse.value.copy( material.color );\n\n\t\t}\n\n\t\tif ( material.emissive ) {\n\n\t\t\tuniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity );\n\n\t\t}\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\tif ( material.specularMap ) {\n\n\t\t\tuniforms.specularMap.value = material.specularMap;\n\n\t\t}\n\n\t\tconst envMap = material.envMap || environment;\n\n\t\tif ( envMap ) {\n\n\t\t\tuniforms.envMap.value = envMap;\n\n\t\t\tuniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1;\n\n\t\t\tuniforms.reflectivity.value = material.reflectivity;\n\t\t\tuniforms.refractionRatio.value = material.refractionRatio;\n\n\t\t\tuniforms.maxMipLevel.value = properties.get( envMap ).__maxMipLevel;\n\n\t\t}\n\n\t\tif ( material.lightMap ) {\n\n\t\t\tuniforms.lightMap.value = material.lightMap;\n\t\t\tuniforms.lightMapIntensity.value = material.lightMapIntensity;\n\n\t\t}\n\n\t\tif ( material.aoMap ) {\n\n\t\t\tuniforms.aoMap.value = material.aoMap;\n\t\t\tuniforms.aoMapIntensity.value = material.aoMapIntensity;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. specular map\n\t\t// 3. normal map\n\t\t// 4. bump map\n\t\t// 5. alpha map\n\t\t// 6. emissive map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.specularMap ) {\n\n\t\t\tuvScaleMap = material.specularMap;\n\n\t\t} else if ( material.displacementMap ) {\n\n\t\t\tuvScaleMap = material.displacementMap;\n\n\t\t} else if ( material.normalMap ) {\n\n\t\t\tuvScaleMap = material.normalMap;\n\n\t\t} else if ( material.bumpMap ) {\n\n\t\t\tuvScaleMap = material.bumpMap;\n\n\t\t} else if ( material.roughnessMap ) {\n\n\t\t\tuvScaleMap = material.roughnessMap;\n\n\t\t} else if ( material.metalnessMap ) {\n\n\t\t\tuvScaleMap = material.metalnessMap;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t} else if ( material.emissiveMap ) {\n\n\t\t\tuvScaleMap = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\t// backwards compatibility\n\t\t\tif ( uvScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\tuvScaleMap = uvScaleMap.texture;\n\n\t\t\t}\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities for uv2\n\t\t// 1. ao map\n\t\t// 2. light map\n\n\t\tlet uv2ScaleMap;\n\n\t\tif ( material.aoMap ) {\n\n\t\t\tuv2ScaleMap = material.aoMap;\n\n\t\t} else if ( material.lightMap ) {\n\n\t\t\tuv2ScaleMap = material.lightMap;\n\n\t\t}\n\n\t\tif ( uv2ScaleMap !== undefined ) {\n\n\t\t\t// backwards compatibility\n\t\t\tif ( uv2ScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\tuv2ScaleMap = uv2ScaleMap.texture;\n\n\t\t\t}\n\n\t\t\tif ( uv2ScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuv2ScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uv2Transform.value.copy( uv2ScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsLine( uniforms, material ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\n\t}\n\n\tfunction refreshUniformsDash( uniforms, material ) {\n\n\t\tuniforms.dashSize.value = material.dashSize;\n\t\tuniforms.totalSize.value = material.dashSize + material.gapSize;\n\t\tuniforms.scale.value = material.scale;\n\n\t}\n\n\tfunction refreshUniformsPoints( uniforms, material, pixelRatio, height ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.size.value = material.size * pixelRatio;\n\t\tuniforms.scale.value = height * 0.5;\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsSprites( uniforms, material ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.rotation.value = material.rotation;\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsLambert( uniforms, material ) {\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsPhong( uniforms, material ) {\n\n\t\tuniforms.specular.value.copy( material.specular );\n\t\tuniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsToon( uniforms, material ) {\n\n\t\tif ( material.gradientMap ) {\n\n\t\t\tuniforms.gradientMap.value = material.gradientMap;\n\n\t\t}\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsStandard( uniforms, material, environment ) {\n\n\t\tuniforms.roughness.value = material.roughness;\n\t\tuniforms.metalness.value = material.metalness;\n\n\t\tif ( material.roughnessMap ) {\n\n\t\t\tuniforms.roughnessMap.value = material.roughnessMap;\n\n\t\t}\n\n\t\tif ( material.metalnessMap ) {\n\n\t\t\tuniforms.metalnessMap.value = material.metalnessMap;\n\n\t\t}\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t\tif ( material.envMap || environment ) {\n\n\t\t\t//uniforms.envMap.value = material.envMap; // part of uniforms common\n\t\t\tuniforms.envMapIntensity.value = material.envMapIntensity;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsPhysical( uniforms, material, environment ) {\n\n\t\trefreshUniformsStandard( uniforms, material, environment );\n\n\t\tuniforms.reflectivity.value = material.reflectivity; // also part of uniforms common\n\n\t\tuniforms.clearcoat.value = material.clearcoat;\n\t\tuniforms.clearcoatRoughness.value = material.clearcoatRoughness;\n\t\tif ( material.sheen ) uniforms.sheen.value.copy( material.sheen );\n\n\t\tif ( material.clearcoatMap ) {\n\n\t\t\tuniforms.clearcoatMap.value = material.clearcoatMap;\n\n\t\t}\n\n\t\tif ( material.clearcoatRoughnessMap ) {\n\n\t\t\tuniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap;\n\n\t\t}\n\n\t\tif ( material.clearcoatNormalMap ) {\n\n\t\t\tuniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale );\n\t\t\tuniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;\n\n\t\t\tif ( material.side === BackSide ) {\n\n\t\t\t\tuniforms.clearcoatNormalScale.value.negate();\n\n\t\t\t}\n\n\t\t}\n\n\t\tuniforms.transparency.value = material.transparency;\n\n\t}\n\n\tfunction refreshUniformsMatcap( uniforms, material ) {\n\n\t\tif ( material.matcap ) {\n\n\t\t\tuniforms.matcap.value = material.matcap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsDepth( uniforms, material ) {\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsDistance( uniforms, material ) {\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t\tuniforms.referencePosition.value.copy( material.referencePosition );\n\t\tuniforms.nearDistance.value = material.nearDistance;\n\t\tuniforms.farDistance.value = material.farDistance;\n\n\t}\n\n\tfunction refreshUniformsNormal( uniforms, material ) {\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\trefreshFogUniforms: refreshFogUniforms,\n\t\trefreshMaterialUniforms: refreshMaterialUniforms\n\t};\n\n}\n\nexport { WebGLMaterials };\n","/**\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n * @author tschw\n */\n\nimport {\n\tRGBAFormat,\n\tHalfFloatType,\n\tFloatType,\n\tUnsignedByteType,\n\tLinearEncoding,\n\tNoToneMapping\n} from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { DataTexture } from '../textures/DataTexture.js';\nimport { Frustum } from '../math/Frustum.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { UniformsLib } from './shaders/UniformsLib.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector4 } from '../math/Vector4.js';\nimport { WebGLAnimation } from './webgl/WebGLAnimation.js';\nimport { WebGLAttributes } from './webgl/WebGLAttributes.js';\nimport { WebGLBackground } from './webgl/WebGLBackground.js';\nimport { WebGLBindingStates } from './webgl/WebGLBindingStates.js';\nimport { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';\nimport { WebGLCapabilities } from './webgl/WebGLCapabilities.js';\nimport { WebGLClipping } from './webgl/WebGLClipping.js';\nimport { WebGLExtensions } from './webgl/WebGLExtensions.js';\nimport { WebGLGeometries } from './webgl/WebGLGeometries.js';\nimport { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';\nimport { WebGLInfo } from './webgl/WebGLInfo.js';\nimport { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';\nimport { WebGLObjects } from './webgl/WebGLObjects.js';\nimport { WebGLPrograms } from './webgl/WebGLPrograms.js';\nimport { WebGLProperties } from './webgl/WebGLProperties.js';\nimport { WebGLRenderLists } from './webgl/WebGLRenderLists.js';\nimport { WebGLRenderStates } from './webgl/WebGLRenderStates.js';\nimport { WebGLShadowMap } from './webgl/WebGLShadowMap.js';\nimport { WebGLState } from './webgl/WebGLState.js';\nimport { WebGLTextures } from './webgl/WebGLTextures.js';\nimport { WebGLUniforms } from './webgl/WebGLUniforms.js';\nimport { WebGLUtils } from './webgl/WebGLUtils.js';\nimport { WebXRManager } from './webxr/WebXRManager.js';\nimport { WebGLMaterials } from \"./webgl/WebGLMaterials.js\";\n\nfunction WebGLRenderer( parameters ) {\n\n\tparameters = parameters || {};\n\n\tconst _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ),\n\t\t_context = parameters.context !== undefined ? parameters.context : null,\n\n\t\t_alpha = parameters.alpha !== undefined ? parameters.alpha : false,\n\t\t_depth = parameters.depth !== undefined ? parameters.depth : true,\n\t\t_stencil = parameters.stencil !== undefined ? parameters.stencil : true,\n\t\t_antialias = parameters.antialias !== undefined ? parameters.antialias : false,\n\t\t_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,\n\t\t_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,\n\t\t_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',\n\t\t_failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;\n\n\tlet currentRenderList = null;\n\tlet currentRenderState = null;\n\n\t// public properties\n\n\tthis.domElement = _canvas;\n\n\t// Debug configuration container\n\tthis.debug = {\n\n\t\t/**\n\t\t * Enables error checking and reporting when shader programs are being compiled\n\t\t * @type {boolean}\n\t\t */\n\t\tcheckShaderErrors: true\n\t};\n\n\t// clearing\n\n\tthis.autoClear = true;\n\tthis.autoClearColor = true;\n\tthis.autoClearDepth = true;\n\tthis.autoClearStencil = true;\n\n\t// scene graph\n\n\tthis.sortObjects = true;\n\n\t// user-defined clipping\n\n\tthis.clippingPlanes = [];\n\tthis.localClippingEnabled = false;\n\n\t// physically based shading\n\n\tthis.gammaFactor = 2.0;\t// for backwards compatibility\n\tthis.outputEncoding = LinearEncoding;\n\n\t// physical lights\n\n\tthis.physicallyCorrectLights = false;\n\n\t// tone mapping\n\n\tthis.toneMapping = NoToneMapping;\n\tthis.toneMappingExposure = 1.0;\n\n\t// morphs\n\n\tthis.maxMorphTargets = 8;\n\tthis.maxMorphNormals = 4;\n\n\t// internal properties\n\n\tconst _this = this;\n\n\tlet _isContextLost = false;\n\n\t// internal state cache\n\n\tlet _framebuffer = null;\n\n\tlet _currentActiveCubeFace = 0;\n\tlet _currentActiveMipmapLevel = 0;\n\tlet _currentRenderTarget = null;\n\tlet _currentFramebuffer = null;\n\tlet _currentMaterialId = - 1;\n\n\tlet _currentCamera = null;\n\tlet _currentArrayCamera = null;\n\n\tconst _currentViewport = new Vector4();\n\tconst _currentScissor = new Vector4();\n\tlet _currentScissorTest = null;\n\n\t//\n\n\tlet _width = _canvas.width;\n\tlet _height = _canvas.height;\n\n\tlet _pixelRatio = 1;\n\tlet _opaqueSort = null;\n\tlet _transparentSort = null;\n\n\tconst _viewport = new Vector4( 0, 0, _width, _height );\n\tconst _scissor = new Vector4( 0, 0, _width, _height );\n\tlet _scissorTest = false;\n\n\t// frustum\n\n\tconst _frustum = new Frustum();\n\n\t// clipping\n\n\tconst _clipping = new WebGLClipping();\n\tlet _clippingEnabled = false;\n\tlet _localClippingEnabled = false;\n\n\t// camera matrices cache\n\n\tconst _projScreenMatrix = new Matrix4();\n\n\tconst _vector3 = new Vector3();\n\n\tconst _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };\n\n\tfunction getTargetPixelRatio() {\n\n\t\treturn _currentRenderTarget === null ? _pixelRatio : 1;\n\n\t}\n\n\t// initialize\n\n\tlet _gl = _context;\n\n\tfunction getContext( contextNames, contextAttributes ) {\n\n\t\tfor ( let i = 0; i < contextNames.length; i ++ ) {\n\n\t\t\tconst contextName = contextNames[ i ];\n\t\t\tconst context = _canvas.getContext( contextName, contextAttributes );\n\t\t\tif ( context !== null ) return context;\n\n\t\t}\n\n\t\treturn null;\n\n\t}\n\n\ttry {\n\n\t\tconst contextAttributes = {\n\t\t\talpha: _alpha,\n\t\t\tdepth: _depth,\n\t\t\tstencil: _stencil,\n\t\t\tantialias: _antialias,\n\t\t\tpremultipliedAlpha: _premultipliedAlpha,\n\t\t\tpreserveDrawingBuffer: _preserveDrawingBuffer,\n\t\t\tpowerPreference: _powerPreference,\n\t\t\tfailIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat\n\t\t};\n\n\t\t// event listeners must be registered before WebGL context is created, see #12753\n\n\t\t_canvas.addEventListener( 'webglcontextlost', onContextLost, false );\n\t\t_canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\tif ( _gl === null ) {\n\n\t\t\tconst contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];\n\n\t\t\tif ( _this.isWebGL1Renderer === true ) {\n\n\t\t\t\tcontextNames.shift();\n\n\t\t\t}\n\n\t\t\t_gl = getContext( contextNames, contextAttributes );\n\n\t\t\tif ( _gl === null ) {\n\n\t\t\t\tif ( getContext( contextNames ) ) {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context with your selected attributes.' );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Some experimental-webgl implementations do not have getShaderPrecisionFormat\n\n\t\tif ( _gl.getShaderPrecisionFormat === undefined ) {\n\n\t\t\t_gl.getShaderPrecisionFormat = function () {\n\n\t\t\t\treturn { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };\n\n\t\t\t};\n\n\t\t}\n\n\t} catch ( error ) {\n\n\t\tconsole.error( 'THREE.WebGLRenderer: ' + error.message );\n\t\tthrow error;\n\n\t}\n\n\tlet extensions, capabilities, state, info;\n\tlet properties, textures, attributes, geometries, objects;\n\tlet programCache, materials, renderLists, renderStates;\n\n\tlet background, morphtargets, bufferRenderer, indexedBufferRenderer;\n\n\tlet utils, bindingStates;\n\n\tfunction initGLContext() {\n\n\t\textensions = new WebGLExtensions( _gl );\n\n\t\tcapabilities = new WebGLCapabilities( _gl, extensions, parameters );\n\n\t\tif ( capabilities.isWebGL2 === false ) {\n\n\t\t\textensions.get( 'WEBGL_depth_texture' );\n\t\t\textensions.get( 'OES_texture_float' );\n\t\t\textensions.get( 'OES_texture_half_float' );\n\t\t\textensions.get( 'OES_texture_half_float_linear' );\n\t\t\textensions.get( 'OES_standard_derivatives' );\n\t\t\textensions.get( 'OES_element_index_uint' );\n\t\t\textensions.get( 'OES_vertex_array_object' );\n\t\t\textensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t}\n\n\t\textensions.get( 'OES_texture_float_linear' );\n\n\t\tutils = new WebGLUtils( _gl, extensions, capabilities );\n\n\t\tstate = new WebGLState( _gl, extensions, capabilities );\n\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );\n\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );\n\n\t\tinfo = new WebGLInfo( _gl );\n\t\tproperties = new WebGLProperties();\n\t\ttextures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );\n\t\tattributes = new WebGLAttributes( _gl, capabilities );\n\t\tbindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );\n\t\tgeometries = new WebGLGeometries( _gl, attributes, info, bindingStates );\n\t\tobjects = new WebGLObjects( _gl, geometries, attributes, info );\n\t\tmorphtargets = new WebGLMorphtargets( _gl );\n\t\tprogramCache = new WebGLPrograms( _this, extensions, capabilities, bindingStates );\n\t\tmaterials = new WebGLMaterials( properties );\n\t\trenderLists = new WebGLRenderLists();\n\t\trenderStates = new WebGLRenderStates();\n\n\t\tbackground = new WebGLBackground( _this, state, objects, _premultipliedAlpha );\n\n\t\tbufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );\n\t\tindexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );\n\n\t\tinfo.programs = programCache.programs;\n\n\t\t_this.capabilities = capabilities;\n\t\t_this.extensions = extensions;\n\t\t_this.properties = properties;\n\t\t_this.renderLists = renderLists;\n\t\t_this.state = state;\n\t\t_this.info = info;\n\n\t}\n\n\tinitGLContext();\n\n\t// xr\n\n\tconst xr = new WebXRManager( _this, _gl );\n\n\tthis.xr = xr;\n\n\t// shadow map\n\n\tconst shadowMap = new WebGLShadowMap( _this, objects, capabilities.maxTextureSize );\n\n\tthis.shadowMap = shadowMap;\n\n\t// API\n\n\tthis.getContext = function () {\n\n\t\treturn _gl;\n\n\t};\n\n\tthis.getContextAttributes = function () {\n\n\t\treturn _gl.getContextAttributes();\n\n\t};\n\n\tthis.forceContextLoss = function () {\n\n\t\tconst extension = extensions.get( 'WEBGL_lose_context' );\n\t\tif ( extension ) extension.loseContext();\n\n\t};\n\n\tthis.forceContextRestore = function () {\n\n\t\tconst extension = extensions.get( 'WEBGL_lose_context' );\n\t\tif ( extension ) extension.restoreContext();\n\n\t};\n\n\tthis.getPixelRatio = function () {\n\n\t\treturn _pixelRatio;\n\n\t};\n\n\tthis.setPixelRatio = function ( value ) {\n\n\t\tif ( value === undefined ) return;\n\n\t\t_pixelRatio = value;\n\n\t\tthis.setSize( _width, _height, false );\n\n\t};\n\n\tthis.getSize = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getsize() now requires a Vector2 as an argument' );\n\n\t\t\ttarget = new Vector2();\n\n\t\t}\n\n\t\treturn target.set( _width, _height );\n\n\t};\n\n\tthis.setSize = function ( width, height, updateStyle ) {\n\n\t\tif ( xr.isPresenting ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Can\\'t change size while VR device is presenting.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\t_width = width;\n\t\t_height = height;\n\n\t\t_canvas.width = Math.floor( width * _pixelRatio );\n\t\t_canvas.height = Math.floor( height * _pixelRatio );\n\n\t\tif ( updateStyle !== false ) {\n\n\t\t\t_canvas.style.width = width + 'px';\n\t\t\t_canvas.style.height = height + 'px';\n\n\t\t}\n\n\t\tthis.setViewport( 0, 0, width, height );\n\n\t};\n\n\tthis.getDrawingBufferSize = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument' );\n\n\t\t\ttarget = new Vector2();\n\n\t\t}\n\n\t\treturn target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();\n\n\t};\n\n\tthis.setDrawingBufferSize = function ( width, height, pixelRatio ) {\n\n\t\t_width = width;\n\t\t_height = height;\n\n\t\t_pixelRatio = pixelRatio;\n\n\t\t_canvas.width = Math.floor( width * pixelRatio );\n\t\t_canvas.height = Math.floor( height * pixelRatio );\n\n\t\tthis.setViewport( 0, 0, width, height );\n\n\t};\n\n\tthis.getCurrentViewport = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument' );\n\n\t\t\ttarget = new Vector4();\n\n\t\t}\n\n\t\treturn target.copy( _currentViewport );\n\n\t};\n\n\tthis.getViewport = function ( target ) {\n\n\t\treturn target.copy( _viewport );\n\n\t};\n\n\tthis.setViewport = function ( x, y, width, height ) {\n\n\t\tif ( x.isVector4 ) {\n\n\t\t\t_viewport.set( x.x, x.y, x.z, x.w );\n\n\t\t} else {\n\n\t\t\t_viewport.set( x, y, width, height );\n\n\t\t}\n\n\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );\n\n\t};\n\n\tthis.getScissor = function ( target ) {\n\n\t\treturn target.copy( _scissor );\n\n\t};\n\n\tthis.setScissor = function ( x, y, width, height ) {\n\n\t\tif ( x.isVector4 ) {\n\n\t\t\t_scissor.set( x.x, x.y, x.z, x.w );\n\n\t\t} else {\n\n\t\t\t_scissor.set( x, y, width, height );\n\n\t\t}\n\n\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );\n\n\t};\n\n\tthis.getScissorTest = function () {\n\n\t\treturn _scissorTest;\n\n\t};\n\n\tthis.setScissorTest = function ( boolean ) {\n\n\t\tstate.setScissorTest( _scissorTest = boolean );\n\n\t};\n\n\tthis.setOpaqueSort = function ( method ) {\n\n\t\t_opaqueSort = method;\n\n\t};\n\n\tthis.setTransparentSort = function ( method ) {\n\n\t\t_transparentSort = method;\n\n\t};\n\n\t// Clearing\n\n\tthis.getClearColor = function () {\n\n\t\treturn background.getClearColor();\n\n\t};\n\n\tthis.setClearColor = function () {\n\n\t\tbackground.setClearColor.apply( background, arguments );\n\n\t};\n\n\tthis.getClearAlpha = function () {\n\n\t\treturn background.getClearAlpha();\n\n\t};\n\n\tthis.setClearAlpha = function () {\n\n\t\tbackground.setClearAlpha.apply( background, arguments );\n\n\t};\n\n\tthis.clear = function ( color, depth, stencil ) {\n\n\t\tlet bits = 0;\n\n\t\tif ( color === undefined || color ) bits |= _gl.COLOR_BUFFER_BIT;\n\t\tif ( depth === undefined || depth ) bits |= _gl.DEPTH_BUFFER_BIT;\n\t\tif ( stencil === undefined || stencil ) bits |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t_gl.clear( bits );\n\n\t};\n\n\tthis.clearColor = function () {\n\n\t\tthis.clear( true, false, false );\n\n\t};\n\n\tthis.clearDepth = function () {\n\n\t\tthis.clear( false, true, false );\n\n\t};\n\n\tthis.clearStencil = function () {\n\n\t\tthis.clear( false, false, true );\n\n\t};\n\n\t//\n\n\tthis.dispose = function () {\n\n\t\t_canvas.removeEventListener( 'webglcontextlost', onContextLost, false );\n\t\t_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\trenderLists.dispose();\n\t\trenderStates.dispose();\n\t\tproperties.dispose();\n\t\tobjects.dispose();\n\t\tbindingStates.dispose();\n\n\t\txr.dispose();\n\n\t\tanimation.stop();\n\n\t};\n\n\t// Events\n\n\tfunction onContextLost( event ) {\n\n\t\tevent.preventDefault();\n\n\t\tconsole.log( 'THREE.WebGLRenderer: Context Lost.' );\n\n\t\t_isContextLost = true;\n\n\t}\n\n\tfunction onContextRestore( /* event */ ) {\n\n\t\tconsole.log( 'THREE.WebGLRenderer: Context Restored.' );\n\n\t\t_isContextLost = false;\n\n\t\tinitGLContext();\n\n\t}\n\n\tfunction onMaterialDispose( event ) {\n\n\t\tconst material = event.target;\n\n\t\tmaterial.removeEventListener( 'dispose', onMaterialDispose );\n\n\t\tdeallocateMaterial( material );\n\n\t}\n\n\t// Buffer deallocation\n\n\tfunction deallocateMaterial( material ) {\n\n\t\treleaseMaterialProgramReference( material );\n\n\t\tproperties.remove( material );\n\n\t}\n\n\n\tfunction releaseMaterialProgramReference( material ) {\n\n\t\tconst programInfo = properties.get( material ).program;\n\n\t\tmaterial.program = undefined;\n\n\t\tif ( programInfo !== undefined ) {\n\n\t\t\tprogramCache.releaseProgram( programInfo );\n\n\t\t}\n\n\t}\n\n\t// Buffer rendering\n\n\tfunction renderObjectImmediate( object, program ) {\n\n\t\tobject.render( function ( object ) {\n\n\t\t\t_this.renderBufferImmediate( object, program );\n\n\t\t} );\n\n\t}\n\n\tthis.renderBufferImmediate = function ( object, program ) {\n\n\t\tbindingStates.initAttributes();\n\n\t\tconst buffers = properties.get( object );\n\n\t\tif ( object.hasPositions && ! buffers.position ) buffers.position = _gl.createBuffer();\n\t\tif ( object.hasNormals && ! buffers.normal ) buffers.normal = _gl.createBuffer();\n\t\tif ( object.hasUvs && ! buffers.uv ) buffers.uv = _gl.createBuffer();\n\t\tif ( object.hasColors && ! buffers.color ) buffers.color = _gl.createBuffer();\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tif ( object.hasPositions ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.position );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.position );\n\t\t\t_gl.vertexAttribPointer( programAttributes.position, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasNormals ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.normal );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.normal );\n\t\t\t_gl.vertexAttribPointer( programAttributes.normal, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasUvs ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.uv );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.uvArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.uv );\n\t\t\t_gl.vertexAttribPointer( programAttributes.uv, 2, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasColors ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.color );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.colorArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.color );\n\t\t\t_gl.vertexAttribPointer( programAttributes.color, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tbindingStates.disableUnusedAttributes();\n\n\t\t_gl.drawArrays( _gl.TRIANGLES, 0, object.count );\n\n\t\tobject.count = 0;\n\n\t};\n\n\tthis.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {\n\n\t\tif ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)\n\n\t\tconst frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );\n\n\t\tconst program = setProgram( camera, scene, material, object );\n\n\t\tstate.setMaterial( material, frontFaceCW );\n\n\t\t//\n\n\t\tlet index = geometry.index;\n\t\tconst position = geometry.attributes.position;\n\n\t\t//\n\n\t\tif ( index === null ) {\n\n\t\t\tif ( position === undefined || position.count === 0 ) return;\n\n\t\t} else if ( index.count === 0 ) {\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t//\n\n\t\tlet rangeFactor = 1;\n\n\t\tif ( material.wireframe === true ) {\n\n\t\t\tindex = geometries.getWireframeAttribute( geometry );\n\t\t\trangeFactor = 2;\n\n\t\t}\n\n\t\tif ( material.morphTargets || material.morphNormals ) {\n\n\t\t\tmorphtargets.update( object, geometry, material, program );\n\n\t\t}\n\n\t\tbindingStates.setup( object, material, program, geometry, index );\n\n\t\tlet attribute;\n\t\tlet renderer = bufferRenderer;\n\n\t\tif ( index !== null ) {\n\n\t\t\tattribute = attributes.get( index );\n\n\t\t\trenderer = indexedBufferRenderer;\n\t\t\trenderer.setIndex( attribute );\n\n\t\t}\n\n\t\t//\n\n\t\tconst dataCount = ( index !== null ) ? index.count : position.count;\n\n\t\tconst rangeStart = geometry.drawRange.start * rangeFactor;\n\t\tconst rangeCount = geometry.drawRange.count * rangeFactor;\n\n\t\tconst groupStart = group !== null ? group.start * rangeFactor : 0;\n\t\tconst groupCount = group !== null ? group.count * rangeFactor : Infinity;\n\n\t\tconst drawStart = Math.max( rangeStart, groupStart );\n\t\tconst drawEnd = Math.min( dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1;\n\n\t\tconst drawCount = Math.max( 0, drawEnd - drawStart + 1 );\n\n\t\tif ( drawCount === 0 ) return;\n\n\t\t//\n\n\t\tif ( object.isMesh ) {\n\n\t\t\tif ( material.wireframe === true ) {\n\n\t\t\t\tstate.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );\n\t\t\t\trenderer.setMode( _gl.LINES );\n\n\t\t\t} else {\n\n\t\t\t\trenderer.setMode( _gl.TRIANGLES );\n\n\t\t\t}\n\n\t\t} else if ( object.isLine ) {\n\n\t\t\tlet lineWidth = material.linewidth;\n\n\t\t\tif ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material\n\n\t\t\tstate.setLineWidth( lineWidth * getTargetPixelRatio() );\n\n\t\t\tif ( object.isLineSegments ) {\n\n\t\t\t\trenderer.setMode( _gl.LINES );\n\n\t\t\t} else if ( object.isLineLoop ) {\n\n\t\t\t\trenderer.setMode( _gl.LINE_LOOP );\n\n\t\t\t} else {\n\n\t\t\t\trenderer.setMode( _gl.LINE_STRIP );\n\n\t\t\t}\n\n\t\t} else if ( object.isPoints ) {\n\n\t\t\trenderer.setMode( _gl.POINTS );\n\n\t\t} else if ( object.isSprite ) {\n\n\t\t\trenderer.setMode( _gl.TRIANGLES );\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh ) {\n\n\t\t\trenderer.renderInstances( geometry, drawStart, drawCount, object.count );\n\n\t\t} else if ( geometry.isInstancedBufferGeometry ) {\n\n\t\t\tconst instanceCount = Math.min( geometry.instanceCount, geometry._maxInstanceCount );\n\n\t\t\trenderer.renderInstances( geometry, drawStart, drawCount, instanceCount );\n\n\t\t} else {\n\n\t\t\trenderer.render( drawStart, drawCount );\n\n\t\t}\n\n\t};\n\n\t// Compile\n\n\tthis.compile = function ( scene, camera ) {\n\n\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\tcurrentRenderState.init();\n\n\t\tscene.traverse( function ( object ) {\n\n\t\t\tif ( object.isLight ) {\n\n\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\tcurrentRenderState.setupLights( camera );\n\n\t\tconst compiled = new WeakMap();\n\n\t\tscene.traverse( function ( object ) {\n\n\t\t\tlet material = object.material;\n\n\t\t\tif ( material ) {\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0; i < material.length; i ++ ) {\n\n\t\t\t\t\t\tlet material2 = material[ i ];\n\n\t\t\t\t\t\tif ( compiled.has( material2 ) === false ) {\n\n\t\t\t\t\t\t\tinitMaterial( material2, scene, object );\n\t\t\t\t\t\t\tcompiled.set( material2 );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( compiled.has( material ) === false ) {\n\n\t\t\t\t\tinitMaterial( material, scene, object );\n\t\t\t\t\tcompiled.set( material );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t};\n\n\t// Animation Loop\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame( time ) {\n\n\t\tif ( xr.isPresenting ) return;\n\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time );\n\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop( onAnimationFrame );\n\n\tif ( typeof window !== 'undefined' ) animation.setContext( window );\n\n\tthis.setAnimationLoop = function ( callback ) {\n\n\t\tonAnimationFrameCallback = callback;\n\t\txr.setAnimationLoop( callback );\n\n\t\t( callback === null ) ? animation.stop() : animation.start();\n\n\t};\n\n\t// Rendering\n\n\tthis.render = function ( scene, camera ) {\n\n\t\tlet renderTarget, forceClear;\n\n\t\tif ( arguments[ 2 ] !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.' );\n\t\t\trenderTarget = arguments[ 2 ];\n\n\t\t}\n\n\t\tif ( arguments[ 3 ] !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.' );\n\t\t\tforceClear = arguments[ 3 ];\n\n\t\t}\n\n\t\tif ( camera !== undefined && camera.isCamera !== true ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( _isContextLost === true ) return;\n\n\t\t// reset caching for this frame\n\n\t\tbindingStates.resetDefaultState();\n\t\t_currentMaterialId = - 1;\n\t\t_currentCamera = null;\n\n\t\t// update scene graph\n\n\t\tif ( scene.autoUpdate === true ) scene.updateMatrixWorld();\n\n\t\t// update camera matrices and frustum\n\n\t\tif ( camera.parent === null ) camera.updateMatrixWorld();\n\n\t\tif ( xr.enabled === true && xr.isPresenting === true ) {\n\n\t\t\tcamera = xr.getCamera( camera );\n\n\t\t}\n\n\t\t//\n\t\tif ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget );\n\n\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\tcurrentRenderState.init();\n\n\t\t_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );\n\t\t_frustum.setFromProjectionMatrix( _projScreenMatrix );\n\n\t\t_localClippingEnabled = this.localClippingEnabled;\n\t\t_clippingEnabled = _clipping.init( this.clippingPlanes, _localClippingEnabled, camera );\n\n\t\tcurrentRenderList = renderLists.get( scene, camera );\n\t\tcurrentRenderList.init();\n\n\t\tprojectObject( scene, camera, 0, _this.sortObjects );\n\n\t\tcurrentRenderList.finish();\n\n\t\tif ( _this.sortObjects === true ) {\n\n\t\t\tcurrentRenderList.sort( _opaqueSort, _transparentSort );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( _clippingEnabled === true ) _clipping.beginShadows();\n\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\tshadowMap.render( shadowsArray, scene, camera );\n\n\t\tcurrentRenderState.setupLights( camera );\n\n\t\tif ( _clippingEnabled === true ) _clipping.endShadows();\n\n\t\t//\n\n\t\tif ( this.info.autoReset === true ) this.info.reset();\n\n\t\tif ( renderTarget !== undefined ) {\n\n\t\t\tthis.setRenderTarget( renderTarget );\n\n\t\t}\n\n\t\t//\n\n\t\tbackground.render( currentRenderList, scene, camera, forceClear );\n\n\t\t// render scene\n\n\t\tconst opaqueObjects = currentRenderList.opaque;\n\t\tconst transparentObjects = currentRenderList.transparent;\n\n\t\tif ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );\n\t\tif ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera );\n\n\t\t//\n\n\t\tif ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );\n\n\t\t//\n\n\t\tif ( _currentRenderTarget !== null ) {\n\n\t\t\t// Generate mipmap if we're using any kind of mipmap filtering\n\n\t\t\ttextures.updateRenderTargetMipmap( _currentRenderTarget );\n\n\t\t\t// resolve multisample renderbuffers to a single-sample texture if necessary\n\n\t\t\ttextures.updateMultisampleRenderTarget( _currentRenderTarget );\n\n\t\t}\n\n\t\t// Ensure depth buffer writing is enabled so it can be cleared on next render\n\n\t\tstate.buffers.depth.setTest( true );\n\t\tstate.buffers.depth.setMask( true );\n\t\tstate.buffers.color.setMask( true );\n\n\t\tstate.setPolygonOffset( false );\n\n\t\t// _gl.finish();\n\n\t\tcurrentRenderList = null;\n\t\tcurrentRenderState = null;\n\n\t};\n\n\tfunction projectObject( object, camera, groupOrder, sortObjects ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tconst visible = object.layers.test( camera.layers );\n\n\t\tif ( visible ) {\n\n\t\t\tif ( object.isGroup ) {\n\n\t\t\t\tgroupOrder = object.renderOrder;\n\n\t\t\t} else if ( object.isLOD ) {\n\n\t\t\t\tif ( object.autoUpdate === true ) object.update( camera );\n\n\t\t\t} else if ( object.isLight ) {\n\n\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isSprite ) {\n\n\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update( object );\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif ( material.visible ) {\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isImmediateRenderObject ) {\n\n\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t}\n\n\t\t\t\tcurrentRenderList.push( object, null, object.material, groupOrder, _vector3.z, null );\n\n\t\t\t} else if ( object.isMesh || object.isLine || object.isPoints ) {\n\n\t\t\t\tif ( object.isSkinnedMesh ) {\n\n\t\t\t\t\t// update skeleton only once in a frame\n\n\t\t\t\t\tif ( object.skeleton.frame !== info.render.frame ) {\n\n\t\t\t\t\t\tobject.skeleton.update();\n\t\t\t\t\t\tobject.skeleton.frame = info.render.frame;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update( object );\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\t\tcurrentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tprojectObject( children[ i ], camera, groupOrder, sortObjects );\n\n\t\t}\n\n\t}\n\n\tfunction renderObjects( renderList, scene, camera ) {\n\n\t\tconst overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;\n\n\t\tfor ( let i = 0, l = renderList.length; i < l; i ++ ) {\n\n\t\t\tconst renderItem = renderList[ i ];\n\n\t\t\tconst object = renderItem.object;\n\t\t\tconst geometry = renderItem.geometry;\n\t\t\tconst material = overrideMaterial === null ? renderItem.material : overrideMaterial;\n\t\t\tconst group = renderItem.group;\n\n\t\t\tif ( camera.isArrayCamera ) {\n\n\t\t\t\t_currentArrayCamera = camera;\n\n\t\t\t\tconst cameras = camera.cameras;\n\n\t\t\t\tfor ( let j = 0, jl = cameras.length; j < jl; j ++ ) {\n\n\t\t\t\t\tconst camera2 = cameras[ j ];\n\n\t\t\t\t\tif ( object.layers.test( camera2.layers ) ) {\n\n\t\t\t\t\t\tstate.viewport( _currentViewport.copy( camera2.viewport ) );\n\n\t\t\t\t\t\tcurrentRenderState.setupLights( camera2 );\n\n\t\t\t\t\t\trenderObject( object, scene, camera2, geometry, material, group );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_currentArrayCamera = null;\n\n\t\t\t\trenderObject( object, scene, camera, geometry, material, group );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction renderObject( object, scene, camera, geometry, material, group ) {\n\n\t\tobject.onBeforeRender( _this, scene, camera, geometry, material, group );\n\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t\tobject.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );\n\t\tobject.normalMatrix.getNormalMatrix( object.modelViewMatrix );\n\n\t\tif ( object.isImmediateRenderObject ) {\n\n\t\t\tconst program = setProgram( camera, scene, material, object );\n\n\t\t\tstate.setMaterial( material );\n\n\t\t\tbindingStates.reset();\n\n\t\t\trenderObjectImmediate( object, program );\n\n\t\t} else {\n\n\t\t\t_this.renderBufferDirect( camera, scene, geometry, material, object, group );\n\n\t\t}\n\n\t\tobject.onAfterRender( _this, scene, camera, geometry, material, group );\n\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t}\n\n\tfunction initMaterial( material, scene, object ) {\n\n\t\tif ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\tconst materialProperties = properties.get( material );\n\n\t\tconst lights = currentRenderState.state.lights;\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\tconst lightsStateVersion = lights.state.version;\n\n\t\tconst parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object );\n\t\tconst programCacheKey = programCache.getProgramCacheKey( parameters );\n\n\t\tlet program = materialProperties.program;\n\t\tlet programChange = true;\n\n\t\tif ( program === undefined ) {\n\n\t\t\t// new material\n\t\t\tmaterial.addEventListener( 'dispose', onMaterialDispose );\n\n\t\t} else if ( program.cacheKey !== programCacheKey ) {\n\n\t\t\t// changed glsl or parameters\n\t\t\treleaseMaterialProgramReference( material );\n\n\t\t} else if ( materialProperties.lightsStateVersion !== lightsStateVersion ) {\n\n\t\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\t\tprogramChange = false;\n\n\t\t} else if ( parameters.shaderID !== undefined ) {\n\n\t\t\t// same glsl and uniform list\n\t\t\treturn;\n\n\t\t} else {\n\n\t\t\t// only rebuild uniform list\n\t\t\tprogramChange = false;\n\n\t\t}\n\n\t\tif ( programChange ) {\n\n\t\t\tprogram = programCache.acquireProgram( parameters, programCacheKey );\n\n\t\t\tmaterialProperties.program = program;\n\t\t\tmaterialProperties.uniforms = parameters.uniforms;\n\t\t\tmaterialProperties.outputEncoding = parameters.outputEncoding;\n\t\t\tmaterial.program = program;\n\n\t\t}\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tif ( material.morphTargets ) {\n\n\t\t\tmaterial.numSupportedMorphTargets = 0;\n\n\t\t\tfor ( let i = 0; i < _this.maxMorphTargets; i ++ ) {\n\n\t\t\t\tif ( programAttributes[ 'morphTarget' + i ] >= 0 ) {\n\n\t\t\t\t\tmaterial.numSupportedMorphTargets ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( material.morphNormals ) {\n\n\t\t\tmaterial.numSupportedMorphNormals = 0;\n\n\t\t\tfor ( let i = 0; i < _this.maxMorphNormals; i ++ ) {\n\n\t\t\t\tif ( programAttributes[ 'morphNormal' + i ] >= 0 ) {\n\n\t\t\t\t\tmaterial.numSupportedMorphNormals ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst uniforms = materialProperties.uniforms;\n\n\t\tif ( ! material.isShaderMaterial &&\n\t\t\t! material.isRawShaderMaterial ||\n\t\t\tmaterial.clipping === true ) {\n\n\t\t\tmaterialProperties.numClippingPlanes = _clipping.numPlanes;\n\t\t\tmaterialProperties.numIntersection = _clipping.numIntersection;\n\t\t\tuniforms.clippingPlanes = _clipping.uniform;\n\n\t\t}\n\n\t\tmaterialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tmaterialProperties.fog = scene.fog;\n\n\t\t// store the light setup it was created for\n\n\t\tmaterialProperties.needsLights = materialNeedsLights( material );\n\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\tif ( materialProperties.needsLights ) {\n\n\t\t\t// wire up the material to this renderer's lighting state\n\n\t\t\tuniforms.ambientLightColor.value = lights.state.ambient;\n\t\t\tuniforms.lightProbe.value = lights.state.probe;\n\t\t\tuniforms.directionalLights.value = lights.state.directional;\n\t\t\tuniforms.directionalLightShadows.value = lights.state.directionalShadow;\n\t\t\tuniforms.spotLights.value = lights.state.spot;\n\t\t\tuniforms.spotLightShadows.value = lights.state.spotShadow;\n\t\t\tuniforms.rectAreaLights.value = lights.state.rectArea;\n\t\t\tuniforms.pointLights.value = lights.state.point;\n\t\t\tuniforms.pointLightShadows.value = lights.state.pointShadow;\n\t\t\tuniforms.hemisphereLights.value = lights.state.hemi;\n\n\t\t\tuniforms.directionalShadowMap.value = lights.state.directionalShadowMap;\n\t\t\tuniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;\n\t\t\tuniforms.spotShadowMap.value = lights.state.spotShadowMap;\n\t\t\tuniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix;\n\t\t\tuniforms.pointShadowMap.value = lights.state.pointShadowMap;\n\t\t\tuniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;\n\t\t\t// TODO (abelnation): add area lights shadow info to uniforms\n\n\t\t}\n\n\t\tconst progUniforms = materialProperties.program.getUniforms(),\n\t\t\tuniformsList =\n\t\t\t\tWebGLUniforms.seqWithValue( progUniforms.seq, uniforms );\n\n\t\tmaterialProperties.uniformsList = uniformsList;\n\n\t}\n\n\tfunction setProgram( camera, scene, material, object ) {\n\n\t\tif ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\ttextures.resetTextureUnits();\n\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tconst encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding;\n\n\t\tconst materialProperties = properties.get( material );\n\t\tconst lights = currentRenderState.state.lights;\n\n\t\tif ( _clippingEnabled === true ) {\n\n\t\t\tif ( _localClippingEnabled === true || camera !== _currentCamera ) {\n\n\t\t\t\tconst useCache =\n\t\t\t\t\tcamera === _currentCamera &&\n\t\t\t\t\tmaterial.id === _currentMaterialId;\n\n\t\t\t\t// we might want to call this function with some ClippingGroup\n\t\t\t\t// object instead of the material, once it becomes feasible\n\t\t\t\t// (#8465, #8379)\n\t\t\t\t_clipping.setState(\n\t\t\t\t\tmaterial.clippingPlanes, material.clipIntersection, material.clipShadows,\n\t\t\t\t\tcamera, materialProperties, useCache );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( material.version === materialProperties.__version ) {\n\n\t\t\tif ( materialProperties.program === undefined ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( material.fog && materialProperties.fog !== fog ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.environment !== environment ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.numClippingPlanes !== undefined &&\n\t\t\t\t( materialProperties.numClippingPlanes !== _clipping.numPlanes ||\n\t\t\t\tmaterialProperties.numIntersection !== _clipping.numIntersection ) ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.outputEncoding !== encoding ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tinitMaterial( material, scene, object );\n\t\t\tmaterialProperties.__version = material.version;\n\n\t\t}\n\n\t\tlet refreshProgram = false;\n\t\tlet refreshMaterial = false;\n\t\tlet refreshLights = false;\n\n\t\tconst program = materialProperties.program,\n\t\t\tp_uniforms = program.getUniforms(),\n\t\t\tm_uniforms = materialProperties.uniforms;\n\n\t\tif ( state.useProgram( program.program ) ) {\n\n\t\t\trefreshProgram = true;\n\t\t\trefreshMaterial = true;\n\t\t\trefreshLights = true;\n\n\t\t}\n\n\t\tif ( material.id !== _currentMaterialId ) {\n\n\t\t\t_currentMaterialId = material.id;\n\n\t\t\trefreshMaterial = true;\n\n\t\t}\n\n\t\tif ( refreshProgram || _currentCamera !== camera ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );\n\n\t\t\tif ( capabilities.logarithmicDepthBuffer ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'logDepthBufFC',\n\t\t\t\t\t2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );\n\n\t\t\t}\n\n\t\t\tif ( _currentCamera !== camera ) {\n\n\t\t\t\t_currentCamera = camera;\n\n\t\t\t\t// lighting uniforms depend on the camera so enforce an update\n\t\t\t\t// now, in case this material supports lights - or later, when\n\t\t\t\t// the next material that does gets activated:\n\n\t\t\t\trefreshMaterial = true;\t\t// set to true on material change\n\t\t\t\trefreshLights = true;\t\t// remains set until update done\n\n\t\t\t}\n\n\t\t\t// load material specific uniforms\n\t\t\t// (shader material also gets them for the sake of genericity)\n\n\t\t\tif ( material.isShaderMaterial ||\n\t\t\t\tmaterial.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.envMap ) {\n\n\t\t\t\tconst uCamPos = p_uniforms.map.cameraPosition;\n\n\t\t\t\tif ( uCamPos !== undefined ) {\n\n\t\t\t\t\tuCamPos.setValue( _gl,\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( camera.matrixWorld ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.isShaderMaterial ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true );\n\n\t\t\t}\n\n\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.isShaderMaterial ||\n\t\t\t\tmaterial.isShadowMaterial ||\n\t\t\t\tmaterial.skinning ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// skinning uniforms must be set even if material didn't change\n\t\t// auto-setting of texture unit for bone texture must go before other textures\n\t\t// otherwise textures used for skinning can take over texture units reserved for other material textures\n\n\t\tif ( material.skinning ) {\n\n\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrix' );\n\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );\n\n\t\t\tconst skeleton = object.skeleton;\n\n\t\t\tif ( skeleton ) {\n\n\t\t\t\tconst bones = skeleton.bones;\n\n\t\t\t\tif ( capabilities.floatVertexTextures ) {\n\n\t\t\t\t\tif ( skeleton.boneTexture === undefined ) {\n\n\t\t\t\t\t\t// layout (1 matrix = 4 pixels)\n\t\t\t\t\t\t// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)\n\t\t\t\t\t\t// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)\n\t\t\t\t\t\t// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)\n\t\t\t\t\t\t// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)\n\t\t\t\t\t\t// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)\n\n\n\t\t\t\t\t\tlet size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix\n\t\t\t\t\t\tsize = MathUtils.ceilPowerOfTwo( size );\n\t\t\t\t\t\tsize = Math.max( size, 4 );\n\n\t\t\t\t\t\tconst boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel\n\t\t\t\t\t\tboneMatrices.set( skeleton.boneMatrices ); // copy current values\n\n\t\t\t\t\t\tconst boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );\n\n\t\t\t\t\t\tskeleton.boneMatrices = boneMatrices;\n\t\t\t\t\t\tskeleton.boneTexture = boneTexture;\n\t\t\t\t\t\tskeleton.boneTextureSize = size;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );\n\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tp_uniforms.setOptional( _gl, skeleton, 'boneMatrices' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) {\n\n\t\t\tmaterialProperties.receiveShadow = object.receiveShadow;\n\t\t\tp_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );\n\n\t\t}\n\n\t\tif ( refreshMaterial ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );\n\n\t\t\tif ( materialProperties.needsLights ) {\n\n\t\t\t\t// the current material requires lighting info\n\n\t\t\t\t// note: all lighting uniforms are always set correctly\n\t\t\t\t// they simply reference the renderer's state for their\n\t\t\t\t// values\n\t\t\t\t//\n\t\t\t\t// use the current material's .needsUpdate flags to set\n\t\t\t\t// the GL state when required\n\n\t\t\t\tmarkUniformsLightsNeedsUpdate( m_uniforms, refreshLights );\n\n\t\t\t}\n\n\t\t\t// refresh uniforms common to several materials\n\n\t\t\tif ( fog && material.fog ) {\n\n\t\t\t\tmaterials.refreshFogUniforms( m_uniforms, fog );\n\n\t\t\t}\n\n\t\t\tmaterials.refreshMaterialUniforms( m_uniforms, material, environment, _pixelRatio, _height );\n\n\t\t\t// RectAreaLight Texture\n\t\t\t// TODO (mrdoob): Find a nicer implementation\n\n\t\t\tif ( m_uniforms.ltc_1 !== undefined ) m_uniforms.ltc_1.value = UniformsLib.LTC_1;\n\t\t\tif ( m_uniforms.ltc_2 !== undefined ) m_uniforms.ltc_2.value = UniformsLib.LTC_2;\n\n\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );\n\n\t\t}\n\n\t\tif ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {\n\n\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );\n\t\t\tmaterial.uniformsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( material.isSpriteMaterial ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'center', object.center );\n\n\t\t}\n\n\t\t// common matrices\n\n\t\tp_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );\n\t\tp_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );\n\t\tp_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );\n\n\t\treturn program;\n\n\t}\n\n\t// If uniforms are marked as clean, they don't need to be loaded to the GPU.\n\n\tfunction markUniformsLightsNeedsUpdate( uniforms, value ) {\n\n\t\tuniforms.ambientLightColor.needsUpdate = value;\n\t\tuniforms.lightProbe.needsUpdate = value;\n\n\t\tuniforms.directionalLights.needsUpdate = value;\n\t\tuniforms.directionalLightShadows.needsUpdate = value;\n\t\tuniforms.pointLights.needsUpdate = value;\n\t\tuniforms.pointLightShadows.needsUpdate = value;\n\t\tuniforms.spotLights.needsUpdate = value;\n\t\tuniforms.spotLightShadows.needsUpdate = value;\n\t\tuniforms.rectAreaLights.needsUpdate = value;\n\t\tuniforms.hemisphereLights.needsUpdate = value;\n\n\t}\n\n\tfunction materialNeedsLights( material ) {\n\n\t\treturn material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial ||\n\t\t\tmaterial.isMeshStandardMaterial || material.isShadowMaterial ||\n\t\t\t( material.isShaderMaterial && material.lights === true );\n\n\t}\n\n\t//\n\tthis.setFramebuffer = function ( value ) {\n\n\t\tif ( _framebuffer !== value && _currentRenderTarget === null ) _gl.bindFramebuffer( _gl.FRAMEBUFFER, value );\n\n\t\t_framebuffer = value;\n\n\t};\n\n\tthis.getActiveCubeFace = function () {\n\n\t\treturn _currentActiveCubeFace;\n\n\t};\n\n\tthis.getActiveMipmapLevel = function () {\n\n\t\treturn _currentActiveMipmapLevel;\n\n\t};\n\n\tthis.getRenderTarget = function () {\n\n\t\treturn _currentRenderTarget;\n\n\t};\n\n\tthis.setRenderTarget = function ( renderTarget, activeCubeFace, activeMipmapLevel ) {\n\n\t\t_currentRenderTarget = renderTarget;\n\t\t_currentActiveCubeFace = activeCubeFace;\n\t\t_currentActiveMipmapLevel = activeMipmapLevel;\n\n\t\tif ( renderTarget && properties.get( renderTarget ).__webglFramebuffer === undefined ) {\n\n\t\t\ttextures.setupRenderTarget( renderTarget );\n\n\t\t}\n\n\t\tlet framebuffer = _framebuffer;\n\t\tlet isCube = false;\n\n\t\tif ( renderTarget ) {\n\n\t\t\tconst __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\t\tif ( renderTarget.isWebGLCubeRenderTarget ) {\n\n\t\t\t\tframebuffer = __webglFramebuffer[ activeCubeFace || 0 ];\n\t\t\t\tisCube = true;\n\n\t\t\t} else if ( renderTarget.isWebGLMultisampleRenderTarget ) {\n\n\t\t\t\tframebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;\n\n\t\t\t} else {\n\n\t\t\t\tframebuffer = __webglFramebuffer;\n\n\t\t\t}\n\n\t\t\t_currentViewport.copy( renderTarget.viewport );\n\t\t\t_currentScissor.copy( renderTarget.scissor );\n\t\t\t_currentScissorTest = renderTarget.scissorTest;\n\n\t\t} else {\n\n\t\t\t_currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor();\n\t\t\t_currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();\n\t\t\t_currentScissorTest = _scissorTest;\n\n\t\t}\n\n\t\tif ( _currentFramebuffer !== framebuffer ) {\n\n\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\t\t\t_currentFramebuffer = framebuffer;\n\n\t\t}\n\n\t\tstate.viewport( _currentViewport );\n\t\tstate.scissor( _currentScissor );\n\t\tstate.setScissorTest( _currentScissorTest );\n\n\t\tif ( isCube ) {\n\n\t\t\tconst textureProperties = properties.get( renderTarget.texture );\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + ( activeCubeFace || 0 ), textureProperties.__webglTexture, activeMipmapLevel || 0 );\n\n\t\t}\n\n\t};\n\n\tthis.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {\n\n\t\tif ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet framebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\tif ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {\n\n\t\t\tframebuffer = framebuffer[ activeCubeFaceIndex ];\n\n\t\t}\n\n\t\tif ( framebuffer ) {\n\n\t\t\tlet restore = false;\n\n\t\t\tif ( framebuffer !== _currentFramebuffer ) {\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\n\t\t\t\trestore = true;\n\n\t\t\t}\n\n\t\t\ttry {\n\n\t\t\t\tconst texture = renderTarget.texture;\n\t\t\t\tconst textureFormat = texture.format;\n\t\t\t\tconst textureType = texture.type;\n\n\t\t\t\tif ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // IE11, Edge and Chrome Mac < 52 (#9513)\n\t\t\t\t\t! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_float' ) || extensions.get( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox\n\t\t\t\t\t! ( textureType === HalfFloatType && ( capabilities.isWebGL2 ? extensions.get( 'EXT_color_buffer_float' ) : extensions.get( 'EXT_color_buffer_half_float' ) ) ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( _gl.checkFramebufferStatus( _gl.FRAMEBUFFER ) === _gl.FRAMEBUFFER_COMPLETE ) {\n\n\t\t\t\t\t// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)\n\n\t\t\t\t\tif ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {\n\n\t\t\t\t\t\t_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' );\n\n\t\t\t\t}\n\n\t\t\t} finally {\n\n\t\t\t\tif ( restore ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, _currentFramebuffer );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\tthis.copyFramebufferToTexture = function ( position, texture, level ) {\n\n\t\tif ( level === undefined ) level = 0;\n\n\t\tconst levelScale = Math.pow( 2, - level );\n\t\tconst width = Math.floor( texture.image.width * levelScale );\n\t\tconst height = Math.floor( texture.image.height * levelScale );\n\t\tconst glFormat = utils.convert( texture.format );\n\n\t\ttextures.setTexture2D( texture, 0 );\n\n\t\t_gl.copyTexImage2D( _gl.TEXTURE_2D, level, glFormat, position.x, position.y, width, height, 0 );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tthis.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) {\n\n\t\tif ( level === undefined ) level = 0;\n\n\t\tconst width = srcTexture.image.width;\n\t\tconst height = srcTexture.image.height;\n\t\tconst glFormat = utils.convert( dstTexture.format );\n\t\tconst glType = utils.convert( dstTexture.type );\n\n\t\ttextures.setTexture2D( dstTexture, 0 );\n\n\t\t// As another texture upload may have changed pixelStorei\n\t\t// parameters, make sure they are correct for the dstTexture\n\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );\n\t\t_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );\n\t\t_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );\n\n\t\tif ( srcTexture.isDataTexture ) {\n\n\t\t\t_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );\n\n\t\t} else {\n\n\t\t\tif ( srcTexture.isCompressedTexture ) {\n\n\t\t\t\t_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Generate mipmaps only when copying level 0\n\t\tif ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tthis.initTexture = function ( texture ) {\n\n\t\ttextures.setTexture2D( texture, 0 );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef\n\n\t}\n\n}\n\nexport { WebGLRenderer };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nimport { Color } from '../math/Color.js';\n\nfunction Fog( color, near, far ) {\n\n\tthis.name = '';\n\n\tthis.color = new Color( color );\n\n\tthis.near = ( near !== undefined ) ? near : 1;\n\tthis.far = ( far !== undefined ) ? far : 1000;\n\n}\n\nObject.assign( Fog.prototype, {\n\n\tisFog: true,\n\n\tclone: function () {\n\n\t\treturn new Fog( this.color, this.near, this.far );\n\n\t},\n\n\ttoJSON: function ( /* meta */ ) {\n\n\t\treturn {\n\t\t\ttype: 'Fog',\n\t\t\tcolor: this.color.getHex(),\n\t\t\tnear: this.near,\n\t\t\tfar: this.far\n\t\t};\n\n\t}\n\n} );\n\nexport { Fog };\n","import { Material } from './Material.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n *\n * linewidth: ,\n * linecap: \"round\",\n * linejoin: \"round\"\n * }\n */\n\nfunction LineBasicMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'LineBasicMaterial';\n\n\tthis.color = new Color( 0xffffff );\n\n\tthis.linewidth = 1;\n\tthis.linecap = 'round';\n\tthis.linejoin = 'round';\n\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nLineBasicMaterial.prototype = Object.create( Material.prototype );\nLineBasicMaterial.prototype.constructor = LineBasicMaterial;\n\nLineBasicMaterial.prototype.isLineBasicMaterial = true;\n\nLineBasicMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.linewidth = source.linewidth;\n\tthis.linecap = source.linecap;\n\tthis.linejoin = source.linejoin;\n\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { LineBasicMaterial };\n","import { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { LineBasicMaterial } from '../materials/LineBasicMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _start = new Vector3();\nconst _end = new Vector3();\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\n\nfunction Line( geometry, material, mode ) {\n\n\tif ( mode === 1 ) {\n\n\t\tconsole.error( 'THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.' );\n\n\t}\n\n\tObject3D.call( this );\n\n\tthis.type = 'Line';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new LineBasicMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nLine.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Line,\n\n\tisLine: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\tcomputeLineDistances: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t// we assume non-indexed geometry\n\n\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\t\tconst lineDistances = [ 0 ];\n\n\t\t\t\tfor ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {\n\n\t\t\t\t\t_start.fromBufferAttribute( positionAttribute, i - 1 );\n\t\t\t\t\t_end.fromBufferAttribute( positionAttribute, i );\n\n\t\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\t\tlineDistances[ i ] += _start.distanceTo( _end );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst lineDistances = geometry.lineDistances;\n\n\t\t\tlineDistances[ 0 ] = 0;\n\n\t\t\tfor ( let i = 1, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\tlineDistances[ i ] += vertices[ i - 1 ].distanceTo( vertices[ i ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Line.threshold;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\t\t_sphere.radius += threshold;\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\tconst localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\n\t\tconst vStart = new Vector3();\n\t\tconst vEnd = new Vector3();\n\t\tconst interSegment = new Vector3();\n\t\tconst interRay = new Vector3();\n\t\tconst step = ( this && this.isLineSegments ) ? 2 : 1;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst attributes = geometry.attributes;\n\t\t\tconst positions = attributes.position.array;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tconst indices = index.array;\n\n\t\t\t\tfor ( let i = 0, l = indices.length - 1; i < l; i += step ) {\n\n\t\t\t\t\tconst a = indices[ i ];\n\t\t\t\t\tconst b = indices[ i + 1 ];\n\n\t\t\t\t\tvStart.fromArray( positions, a * 3 );\n\t\t\t\t\tvEnd.fromArray( positions, b * 3 );\n\n\t\t\t\t\tconst distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0, l = positions.length / 3 - 1; i < l; i += step ) {\n\n\t\t\t\t\tvStart.fromArray( positions, 3 * i );\n\t\t\t\t\tvEnd.fromArray( positions, 3 * i + 3 );\n\n\t\t\t\t\tconst distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst nbVertices = vertices.length;\n\n\t\t\tfor ( let i = 0; i < nbVertices - 1; i += step ) {\n\n\t\t\t\tconst distSq = _ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );\n\n\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\tintersects.push( {\n\n\t\t\t\t\tdistance: distance,\n\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\tindex: i,\n\t\t\t\t\tface: null,\n\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\tobject: this\n\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\n\nexport { Line };\n","import { Line } from './Line.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _start = new Vector3();\nconst _end = new Vector3();\n\nfunction LineSegments( geometry, material ) {\n\n\tLine.call( this, geometry, material );\n\n\tthis.type = 'LineSegments';\n\n}\n\nLineSegments.prototype = Object.assign( Object.create( Line.prototype ), {\n\n\tconstructor: LineSegments,\n\n\tisLineSegments: true,\n\n\tcomputeLineDistances: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t// we assume non-indexed geometry\n\n\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\t\tconst lineDistances = [];\n\n\t\t\t\tfor ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {\n\n\t\t\t\t\t_start.fromBufferAttribute( positionAttribute, i );\n\t\t\t\t\t_end.fromBufferAttribute( positionAttribute, i + 1 );\n\n\t\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst lineDistances = geometry.lineDistances;\n\n\t\t\tfor ( let i = 0, l = vertices.length; i < l; i += 2 ) {\n\n\t\t\t\t_start.copy( vertices[ i ] );\n\t\t\t\t_end.copy( vertices[ i + 1 ] );\n\n\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { LineSegments };\n","import { Material } from './Material.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n * map: new THREE.Texture( ),\n * alphaMap: new THREE.Texture( ),\n *\n * size: ,\n * sizeAttenuation: \n *\n * morphTargets: \n * }\n */\n\nfunction PointsMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'PointsMaterial';\n\n\tthis.color = new Color( 0xffffff );\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.size = 1;\n\tthis.sizeAttenuation = true;\n\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nPointsMaterial.prototype = Object.create( Material.prototype );\nPointsMaterial.prototype.constructor = PointsMaterial;\n\nPointsMaterial.prototype.isPointsMaterial = true;\n\nPointsMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.size = source.size;\n\tthis.sizeAttenuation = source.sizeAttenuation;\n\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { PointsMaterial };\n","import { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { PointsMaterial } from '../materials/PointsMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\nconst _position = new Vector3();\n\nfunction Points( geometry, material ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Points';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new PointsMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nPoints.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Points,\n\n\tisPoints: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Points.threshold;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\t\t_sphere.radius += threshold;\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\tconst localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst attributes = geometry.attributes;\n\t\t\tconst positions = attributes.position.array;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tconst indices = index.array;\n\n\t\t\t\tfor ( let i = 0, il = indices.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst a = indices[ i ];\n\n\t\t\t\t\t_position.fromArray( positions, a * 3 );\n\n\t\t\t\t\ttestPoint( _position, a, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0, l = positions.length / 3; i < l; i ++ ) {\n\n\t\t\t\t\t_position.fromArray( positions, i * 3 );\n\n\t\t\t\t\ttestPoint( _position, i, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst vertices = geometry.vertices;\n\n\t\t\tfor ( let i = 0, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\ttestPoint( vertices[ i ], i, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\nfunction testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) {\n\n\tconst rayPointDistanceSq = _ray.distanceSqToPoint( point );\n\n\tif ( rayPointDistanceSq < localThresholdSq ) {\n\n\t\tconst intersectPoint = new Vector3();\n\n\t\t_ray.closestPointToPoint( point, intersectPoint );\n\t\tintersectPoint.applyMatrix4( matrixWorld );\n\n\t\tconst distance = raycaster.ray.origin.distanceTo( intersectPoint );\n\n\t\tif ( distance < raycaster.near || distance > raycaster.far ) return;\n\n\t\tintersects.push( {\n\n\t\t\tdistance: distance,\n\t\t\tdistanceToRay: Math.sqrt( rayPointDistanceSq ),\n\t\t\tpoint: intersectPoint,\n\t\t\tindex: index,\n\t\t\tface: null,\n\t\t\tobject: object\n\n\t\t} );\n\n\t}\n\n}\n\nexport { Points };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Texture } from './Texture.js';\n\nfunction CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {\n\n\tTexture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );\n\n\tthis.needsUpdate = true;\n\n}\n\nCanvasTexture.prototype = Object.create( Texture.prototype );\nCanvasTexture.prototype.constructor = CanvasTexture;\nCanvasTexture.prototype.isCanvasTexture = true;\n\nexport { CanvasTexture };\n","/**\n * @author clockworkgeek / https://github.com/clockworkgeek\n * @author timothypratley / https://github.com/timothypratley\n * @author WestLangley / http://github.com/WestLangley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\n\n// PolyhedronGeometry\n\nfunction PolyhedronGeometry( vertices, indices, radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'PolyhedronGeometry';\n\n\tthis.parameters = {\n\t\tvertices: vertices,\n\t\tindices: indices,\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new PolyhedronBufferGeometry( vertices, indices, radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nPolyhedronGeometry.prototype = Object.create( Geometry.prototype );\nPolyhedronGeometry.prototype.constructor = PolyhedronGeometry;\n\n// PolyhedronBufferGeometry\n\nfunction PolyhedronBufferGeometry( vertices, indices, radius, detail ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'PolyhedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tvertices: vertices,\n\t\tindices: indices,\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tradius = radius || 1;\n\tdetail = detail || 0;\n\n\t// default buffer data\n\n\tconst vertexBuffer = [];\n\tconst uvBuffer = [];\n\n\t// the subdivision creates the vertex buffer data\n\n\tsubdivide( detail );\n\n\t// all vertices should lie on a conceptual sphere with a given radius\n\n\tapplyRadius( radius );\n\n\t// finally, create the uv data\n\n\tgenerateUVs();\n\n\t// build non-indexed geometry\n\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );\n\n\tif ( detail === 0 ) {\n\n\t\tthis.computeVertexNormals(); // flat normals\n\n\t} else {\n\n\t\tthis.normalizeNormals(); // smooth normals\n\n\t}\n\n\t// helper functions\n\n\tfunction subdivide( detail ) {\n\n\t\tconst a = new Vector3();\n\t\tconst b = new Vector3();\n\t\tconst c = new Vector3();\n\n\t\t// iterate over all faces and apply a subdivison with the given detail value\n\n\t\tfor ( let i = 0; i < indices.length; i += 3 ) {\n\n\t\t\t// get the vertices of the face\n\n\t\t\tgetVertexByIndex( indices[ i + 0 ], a );\n\t\t\tgetVertexByIndex( indices[ i + 1 ], b );\n\t\t\tgetVertexByIndex( indices[ i + 2 ], c );\n\n\t\t\t// perform subdivision\n\n\t\t\tsubdivideFace( a, b, c, detail );\n\n\t\t}\n\n\t}\n\n\tfunction subdivideFace( a, b, c, detail ) {\n\n\t\tconst cols = Math.pow( 2, detail );\n\n\t\t// we use this multidimensional array as a data structure for creating the subdivision\n\n\t\tconst v = [];\n\n\t\t// construct all of the vertices for this subdivision\n\n\t\tfor ( let i = 0; i <= cols; i ++ ) {\n\n\t\t\tv[ i ] = [];\n\n\t\t\tconst aj = a.clone().lerp( c, i / cols );\n\t\t\tconst bj = b.clone().lerp( c, i / cols );\n\n\t\t\tconst rows = cols - i;\n\n\t\t\tfor ( let j = 0; j <= rows; j ++ ) {\n\n\t\t\t\tif ( j === 0 && i === cols ) {\n\n\t\t\t\t\tv[ i ][ j ] = aj;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tv[ i ][ j ] = aj.clone().lerp( bj, j / rows );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// construct all of the faces\n\n\t\tfor ( let i = 0; i < cols; i ++ ) {\n\n\t\t\tfor ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {\n\n\t\t\t\tconst k = Math.floor( j / 2 );\n\n\t\t\t\tif ( j % 2 === 0 ) {\n\n\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\t\t\t\t\tpushVertex( v[ i ][ k ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction applyRadius( radius ) {\n\n\t\tconst vertex = new Vector3();\n\n\t\t// iterate over the entire buffer and apply the radius to each vertex\n\n\t\tfor ( let i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\tvertex.normalize().multiplyScalar( radius );\n\n\t\t\tvertexBuffer[ i + 0 ] = vertex.x;\n\t\t\tvertexBuffer[ i + 1 ] = vertex.y;\n\t\t\tvertexBuffer[ i + 2 ] = vertex.z;\n\n\t\t}\n\n\t}\n\n\tfunction generateUVs() {\n\n\t\tconst vertex = new Vector3();\n\n\t\tfor ( let i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\tconst u = azimuth( vertex ) / 2 / Math.PI + 0.5;\n\t\t\tconst v = inclination( vertex ) / Math.PI + 0.5;\n\t\t\tuvBuffer.push( u, 1 - v );\n\n\t\t}\n\n\t\tcorrectUVs();\n\n\t\tcorrectSeam();\n\n\t}\n\n\tfunction correctSeam() {\n\n\t\t// handle case when face straddles the seam, see #3269\n\n\t\tfor ( let i = 0; i < uvBuffer.length; i += 6 ) {\n\n\t\t\t// uv data of a single face\n\n\t\t\tconst x0 = uvBuffer[ i + 0 ];\n\t\t\tconst x1 = uvBuffer[ i + 2 ];\n\t\t\tconst x2 = uvBuffer[ i + 4 ];\n\n\t\t\tconst max = Math.max( x0, x1, x2 );\n\t\t\tconst min = Math.min( x0, x1, x2 );\n\n\t\t\t// 0.9 is somewhat arbitrary\n\n\t\t\tif ( max > 0.9 && min < 0.1 ) {\n\n\t\t\t\tif ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1;\n\t\t\t\tif ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1;\n\t\t\t\tif ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction pushVertex( vertex ) {\n\n\t\tvertexBuffer.push( vertex.x, vertex.y, vertex.z );\n\n\t}\n\n\tfunction getVertexByIndex( index, vertex ) {\n\n\t\tconst stride = index * 3;\n\n\t\tvertex.x = vertices[ stride + 0 ];\n\t\tvertex.y = vertices[ stride + 1 ];\n\t\tvertex.z = vertices[ stride + 2 ];\n\n\t}\n\n\tfunction correctUVs() {\n\n\t\tconst a = new Vector3();\n\t\tconst b = new Vector3();\n\t\tconst c = new Vector3();\n\n\t\tconst centroid = new Vector3();\n\n\t\tconst uvA = new Vector2();\n\t\tconst uvB = new Vector2();\n\t\tconst uvC = new Vector2();\n\n\t\tfor ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {\n\n\t\t\ta.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] );\n\t\t\tb.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] );\n\t\t\tc.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] );\n\n\t\t\tuvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] );\n\t\t\tuvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] );\n\t\t\tuvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] );\n\n\t\t\tcentroid.copy( a ).add( b ).add( c ).divideScalar( 3 );\n\n\t\t\tconst azi = azimuth( centroid );\n\n\t\t\tcorrectUV( uvA, j + 0, a, azi );\n\t\t\tcorrectUV( uvB, j + 2, b, azi );\n\t\t\tcorrectUV( uvC, j + 4, c, azi );\n\n\t\t}\n\n\t}\n\n\tfunction correctUV( uv, stride, vector, azimuth ) {\n\n\t\tif ( ( azimuth < 0 ) && ( uv.x === 1 ) ) {\n\n\t\t\tuvBuffer[ stride ] = uv.x - 1;\n\n\t\t}\n\n\t\tif ( ( vector.x === 0 ) && ( vector.z === 0 ) ) {\n\n\t\t\tuvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5;\n\n\t\t}\n\n\t}\n\n\t// Angle around the Y axis, counter-clockwise when looking from above.\n\n\tfunction azimuth( vector ) {\n\n\t\treturn Math.atan2( vector.z, - vector.x );\n\n\t}\n\n\n\t// Angle above the XZ plane.\n\n\tfunction inclination( vector ) {\n\n\t\treturn Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) );\n\n\t}\n\n}\n\nPolyhedronBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nPolyhedronBufferGeometry.prototype.constructor = PolyhedronBufferGeometry;\n\n\nexport { PolyhedronGeometry, PolyhedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// TetrahedronGeometry\n\nfunction TetrahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'TetrahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new TetrahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nTetrahedronGeometry.prototype = Object.create( Geometry.prototype );\nTetrahedronGeometry.prototype.constructor = TetrahedronGeometry;\n\n// TetrahedronBufferGeometry\n\nfunction TetrahedronBufferGeometry( radius, detail ) {\n\n\tconst vertices = [\n\t\t1, 1, 1, \t- 1, - 1, 1, \t- 1, 1, - 1, \t1, - 1, - 1\n\t];\n\n\tconst indices = [\n\t\t2, 1, 0, \t0, 3, 2,\t1, 3, 0,\t2, 3, 1\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'TetrahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nTetrahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nTetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry;\n\n\nexport { TetrahedronGeometry, TetrahedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// OctahedronGeometry\n\nfunction OctahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'OctahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nOctahedronGeometry.prototype = Object.create( Geometry.prototype );\nOctahedronGeometry.prototype.constructor = OctahedronGeometry;\n\n// OctahedronBufferGeometry\n\nfunction OctahedronBufferGeometry( radius, detail ) {\n\n\tconst vertices = [\n\t\t1, 0, 0, \t- 1, 0, 0,\t0, 1, 0,\n\t\t0, - 1, 0, \t0, 0, 1,\t0, 0, - 1\n\t];\n\n\tconst indices = [\n\t\t0, 2, 4,\t0, 4, 3,\t0, 3, 5,\n\t\t0, 5, 2,\t1, 2, 5,\t1, 5, 3,\n\t\t1, 3, 4,\t1, 4, 2\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'OctahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nOctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nOctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;\n\n\nexport { OctahedronGeometry, OctahedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// IcosahedronGeometry\n\nfunction IcosahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'IcosahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nIcosahedronGeometry.prototype = Object.create( Geometry.prototype );\nIcosahedronGeometry.prototype.constructor = IcosahedronGeometry;\n\n// IcosahedronBufferGeometry\n\nfunction IcosahedronBufferGeometry( radius, detail ) {\n\n\tconst t = ( 1 + Math.sqrt( 5 ) ) / 2;\n\n\tconst vertices = [\n\t\t- 1, t, 0, \t1, t, 0, \t- 1, - t, 0, \t1, - t, 0,\n\t\t 0, - 1, t, \t0, 1, t,\t0, - 1, - t, \t0, 1, - t,\n\t\t t, 0, - 1, \tt, 0, 1, \t- t, 0, - 1, \t- t, 0, 1\n\t];\n\n\tconst indices = [\n\t\t 0, 11, 5, \t0, 5, 1, \t0, 1, 7, \t0, 7, 10, \t0, 10, 11,\n\t\t 1, 5, 9, \t5, 11, 4,\t11, 10, 2,\t10, 7, 6,\t7, 1, 8,\n\t\t 3, 9, 4, \t3, 4, 2,\t3, 2, 6,\t3, 6, 8,\t3, 8, 9,\n\t\t 4, 9, 5, \t2, 4, 11,\t6, 2, 10,\t8, 6, 7,\t9, 8, 1\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'IcosahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nIcosahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nIcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;\n\n\nexport { IcosahedronGeometry, IcosahedronBufferGeometry };\n","/**\n * @author oosmoxiecode\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n// TorusGeometry\n\nfunction TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'TorusGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\ttube: tube,\n\t\tradialSegments: radialSegments,\n\t\ttubularSegments: tubularSegments,\n\t\tarc: arc\n\t};\n\n\tthis.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );\n\tthis.mergeVertices();\n\n}\n\nTorusGeometry.prototype = Object.create( Geometry.prototype );\nTorusGeometry.prototype.constructor = TorusGeometry;\n\n// TorusBufferGeometry\n\nfunction TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'TorusBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\ttube: tube,\n\t\tradialSegments: radialSegments,\n\t\ttubularSegments: tubularSegments,\n\t\tarc: arc\n\t};\n\n\tradius = radius || 1;\n\ttube = tube || 0.4;\n\tradialSegments = Math.floor( radialSegments ) || 8;\n\ttubularSegments = Math.floor( tubularSegments ) || 6;\n\tarc = arc || Math.PI * 2;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// helper variables\n\n\tconst center = new Vector3();\n\tconst vertex = new Vector3();\n\tconst normal = new Vector3();\n\n\t// generate vertices, normals and uvs\n\n\tfor ( let j = 0; j <= radialSegments; j ++ ) {\n\n\t\tfor ( let i = 0; i <= tubularSegments; i ++ ) {\n\n\t\t\tconst u = i / tubularSegments * arc;\n\t\t\tconst v = j / radialSegments * Math.PI * 2;\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = ( radius + tube * Math.cos( v ) ) * Math.cos( u );\n\t\t\tvertex.y = ( radius + tube * Math.cos( v ) ) * Math.sin( u );\n\t\t\tvertex.z = tube * Math.sin( v );\n\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tcenter.x = radius * Math.cos( u );\n\t\t\tcenter.y = radius * Math.sin( u );\n\t\t\tnormal.subVectors( vertex, center ).normalize();\n\n\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t// uv\n\n\t\t\tuvs.push( i / tubularSegments );\n\t\t\tuvs.push( j / radialSegments );\n\n\t\t}\n\n\t}\n\n\t// generate indices\n\n\tfor ( let j = 1; j <= radialSegments; j ++ ) {\n\n\t\tfor ( let i = 1; i <= tubularSegments; i ++ ) {\n\n\t\t\t// indices\n\n\t\t\tconst a = ( tubularSegments + 1 ) * j + i - 1;\n\t\t\tconst b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;\n\t\t\tconst c = ( tubularSegments + 1 ) * ( j - 1 ) + i;\n\t\t\tconst d = ( tubularSegments + 1 ) * j + i;\n\n\t\t\t// faces\n\n\t\t\tindices.push( a, b, d );\n\t\t\tindices.push( b, c, d );\n\n\t\t}\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n}\n\nTorusBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nTorusBufferGeometry.prototype.constructor = TorusBufferGeometry;\n\n\nexport { TorusGeometry, TorusBufferGeometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\n\n// CylinderGeometry\n\nfunction CylinderGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'CylinderGeometry';\n\n\tthis.parameters = {\n\t\tradiusTop: radiusTop,\n\t\tradiusBottom: radiusBottom,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n\tthis.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );\n\tthis.mergeVertices();\n\n}\n\nCylinderGeometry.prototype = Object.create( Geometry.prototype );\nCylinderGeometry.prototype.constructor = CylinderGeometry;\n\n// CylinderBufferGeometry\n\nfunction CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'CylinderBufferGeometry';\n\n\tthis.parameters = {\n\t\tradiusTop: radiusTop,\n\t\tradiusBottom: radiusBottom,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n\tconst scope = this;\n\n\tradiusTop = radiusTop !== undefined ? radiusTop : 1;\n\tradiusBottom = radiusBottom !== undefined ? radiusBottom : 1;\n\theight = height || 1;\n\n\tradialSegments = Math.floor( radialSegments ) || 8;\n\theightSegments = Math.floor( heightSegments ) || 1;\n\n\topenEnded = openEnded !== undefined ? openEnded : false;\n\tthetaStart = thetaStart !== undefined ? thetaStart : 0.0;\n\tthetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// helper variables\n\n\tlet index = 0;\n\tconst indexArray = [];\n\tconst halfHeight = height / 2;\n\tlet groupStart = 0;\n\n\t// generate geometry\n\n\tgenerateTorso();\n\n\tif ( openEnded === false ) {\n\n\t\tif ( radiusTop > 0 ) generateCap( true );\n\t\tif ( radiusBottom > 0 ) generateCap( false );\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\tfunction generateTorso() {\n\n\t\tconst normal = new Vector3();\n\t\tconst vertex = new Vector3();\n\n\t\tlet groupCount = 0;\n\n\t\t// this will be used to calculate the normal\n\t\tconst slope = ( radiusBottom - radiusTop ) / height;\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( let y = 0; y <= heightSegments; y ++ ) {\n\n\t\t\tconst indexRow = [];\n\n\t\t\tconst v = y / heightSegments;\n\n\t\t\t// calculate the radius of the current row\n\n\t\t\tconst radius = v * ( radiusBottom - radiusTop ) + radiusTop;\n\n\t\t\tfor ( let x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\t\tconst u = x / radialSegments;\n\n\t\t\t\tconst theta = u * thetaLength + thetaStart;\n\n\t\t\t\tconst sinTheta = Math.sin( theta );\n\t\t\t\tconst cosTheta = Math.cos( theta );\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\tvertex.y = - v * height + halfHeight;\n\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormal.set( sinTheta, slope, cosTheta ).normalize();\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( u, 1 - v );\n\n\t\t\t\t// save index of vertex in respective row\n\n\t\t\t\tindexRow.push( index ++ );\n\n\t\t\t}\n\n\t\t\t// now save vertices of the row in our index array\n\n\t\t\tindexArray.push( indexRow );\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( let x = 0; x < radialSegments; x ++ ) {\n\n\t\t\tfor ( let y = 0; y < heightSegments; y ++ ) {\n\n\t\t\t\t// we use the index array to access the correct indices\n\n\t\t\t\tconst a = indexArray[ y ][ x ];\n\t\t\t\tconst b = indexArray[ y + 1 ][ x ];\n\t\t\t\tconst c = indexArray[ y + 1 ][ x + 1 ];\n\t\t\t\tconst d = indexArray[ y ][ x + 1 ];\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t// update group counter\n\n\t\t\t\tgroupCount += 6;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\tscope.addGroup( groupStart, groupCount, 0 );\n\n\t\t// calculate new start value for groups\n\n\t\tgroupStart += groupCount;\n\n\t}\n\n\tfunction generateCap( top ) {\n\n\t\tlet centerIndexStart, centerIndexEnd;\n\n\t\tconst uv = new Vector2();\n\t\tconst vertex = new Vector3();\n\n\t\tlet groupCount = 0;\n\n\t\tconst radius = ( top === true ) ? radiusTop : radiusBottom;\n\t\tconst sign = ( top === true ) ? 1 : - 1;\n\n\t\t// save the index of the first center vertex\n\t\tcenterIndexStart = index;\n\n\t\t// first we generate the center vertex data of the cap.\n\t\t// because the geometry needs one set of uvs per face,\n\t\t// we must generate a center vertex per face/segment\n\n\t\tfor ( let x = 1; x <= radialSegments; x ++ ) {\n\n\t\t\t// vertex\n\n\t\t\tvertices.push( 0, halfHeight * sign, 0 );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t// uv\n\n\t\t\tuvs.push( 0.5, 0.5 );\n\n\t\t\t// increase index\n\n\t\t\tindex ++;\n\n\t\t}\n\n\t\t// save the index of the last center vertex\n\n\t\tcenterIndexEnd = index;\n\n\t\t// now we generate the surrounding vertices, normals and uvs\n\n\t\tfor ( let x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\tconst u = x / radialSegments;\n\t\t\tconst theta = u * thetaLength + thetaStart;\n\n\t\t\tconst cosTheta = Math.cos( theta );\n\t\t\tconst sinTheta = Math.sin( theta );\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = radius * sinTheta;\n\t\t\tvertex.y = halfHeight * sign;\n\t\t\tvertex.z = radius * cosTheta;\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t// uv\n\n\t\t\tuv.x = ( cosTheta * 0.5 ) + 0.5;\n\t\t\tuv.y = ( sinTheta * 0.5 * sign ) + 0.5;\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\t// increase index\n\n\t\t\tindex ++;\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( let x = 0; x < radialSegments; x ++ ) {\n\n\t\t\tconst c = centerIndexStart + x;\n\t\t\tconst i = centerIndexEnd + x;\n\n\t\t\tif ( top === true ) {\n\n\t\t\t\t// face top\n\n\t\t\t\tindices.push( i, i + 1, c );\n\n\t\t\t} else {\n\n\t\t\t\t// face bottom\n\n\t\t\t\tindices.push( i + 1, i, c );\n\n\t\t\t}\n\n\t\t\tgroupCount += 3;\n\n\t\t}\n\n\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\tscope.addGroup( groupStart, groupCount, top === true ? 1 : 2 );\n\n\t\t// calculate new start value for groups\n\n\t\tgroupStart += groupCount;\n\n\t}\n\n}\n\nCylinderBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nCylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;\n\n\nexport { CylinderGeometry, CylinderBufferGeometry };\n","/**\n * @author abelnation / http://github.com/abelnation\n */\n\nimport { CylinderGeometry } from './CylinderGeometry.js';\nimport { CylinderBufferGeometry } from './CylinderGeometry.js';\n\n// ConeGeometry\n\nfunction ConeGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tCylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\tthis.type = 'ConeGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n}\n\nConeGeometry.prototype = Object.create( CylinderGeometry.prototype );\nConeGeometry.prototype.constructor = ConeGeometry;\n\n// ConeBufferGeometry\n\nfunction ConeBufferGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tCylinderBufferGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\tthis.type = 'ConeBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n}\n\nConeBufferGeometry.prototype = Object.create( CylinderBufferGeometry.prototype );\nConeBufferGeometry.prototype.constructor = ConeBufferGeometry;\n\n\nexport { ConeGeometry, ConeBufferGeometry };\n","import { Object3D } from '../core/Object3D.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction Light( color, intensity ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Light';\n\n\tthis.color = new Color( color );\n\tthis.intensity = intensity !== undefined ? intensity : 1;\n\n\tthis.receiveShadow = undefined;\n\n}\n\nLight.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Light,\n\n\tisLight: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\t\tthis.intensity = source.intensity;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.color = this.color.getHex();\n\t\tdata.object.intensity = this.intensity;\n\n\t\tif ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();\n\n\t\tif ( this.distance !== undefined ) data.object.distance = this.distance;\n\t\tif ( this.angle !== undefined ) data.object.angle = this.angle;\n\t\tif ( this.decay !== undefined ) data.object.decay = this.decay;\n\t\tif ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;\n\n\t\tif ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { Light };\n","import { Matrix4 } from '../math/Matrix4.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector4 } from '../math/Vector4.js';\nimport { Frustum } from '../math/Frustum.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction LightShadow( camera ) {\n\n\tthis.camera = camera;\n\n\tthis.bias = 0;\n\tthis.normalBias = 0;\n\tthis.radius = 1;\n\n\tthis.mapSize = new Vector2( 512, 512 );\n\n\tthis.map = null;\n\tthis.mapPass = null;\n\tthis.matrix = new Matrix4();\n\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\n\tthis._frustum = new Frustum();\n\tthis._frameExtents = new Vector2( 1, 1 );\n\n\tthis._viewportCount = 1;\n\n\tthis._viewports = [\n\n\t\tnew Vector4( 0, 0, 1, 1 )\n\n\t];\n\n}\n\nObject.assign( LightShadow.prototype, {\n\n\t_projScreenMatrix: new Matrix4(),\n\n\t_lightPositionWorld: new Vector3(),\n\n\t_lookTarget: new Vector3(),\n\n\tgetViewportCount: function () {\n\n\t\treturn this._viewportCount;\n\n\t},\n\n\tgetFrustum: function () {\n\n\t\treturn this._frustum;\n\n\t},\n\n\tupdateMatrices: function ( light ) {\n\n\t\tconst shadowCamera = this.camera,\n\t\t\tshadowMatrix = this.matrix,\n\t\t\tprojScreenMatrix = this._projScreenMatrix,\n\t\t\tlookTarget = this._lookTarget,\n\t\t\tlightPositionWorld = this._lightPositionWorld;\n\n\t\tlightPositionWorld.setFromMatrixPosition( light.matrixWorld );\n\t\tshadowCamera.position.copy( lightPositionWorld );\n\n\t\tlookTarget.setFromMatrixPosition( light.target.matrixWorld );\n\t\tshadowCamera.lookAt( lookTarget );\n\t\tshadowCamera.updateMatrixWorld();\n\n\t\tprojScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );\n\t\tthis._frustum.setFromProjectionMatrix( projScreenMatrix );\n\n\t\tshadowMatrix.set(\n\t\t\t0.5, 0.0, 0.0, 0.5,\n\t\t\t0.0, 0.5, 0.0, 0.5,\n\t\t\t0.0, 0.0, 0.5, 0.5,\n\t\t\t0.0, 0.0, 0.0, 1.0\n\t\t);\n\n\t\tshadowMatrix.multiply( shadowCamera.projectionMatrix );\n\t\tshadowMatrix.multiply( shadowCamera.matrixWorldInverse );\n\n\t},\n\n\tgetViewport: function ( viewportIndex ) {\n\n\t\treturn this._viewports[ viewportIndex ];\n\n\t},\n\n\tgetFrameExtents: function () {\n\n\t\treturn this._frameExtents;\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.camera = source.camera.clone();\n\n\t\tthis.bias = source.bias;\n\t\tthis.radius = source.radius;\n\n\t\tthis.mapSize.copy( source.mapSize );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst object = {};\n\n\t\tif ( this.bias !== 0 ) object.bias = this.bias;\n\t\tif ( this.normalBias !== 0 ) object.normalBias = this.normalBias;\n\t\tif ( this.radius !== 1 ) object.radius = this.radius;\n\t\tif ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray();\n\n\t\tobject.camera = this.camera.toJSON( false ).object;\n\t\tdelete object.camera.matrix;\n\n\t\treturn object;\n\n\t}\n\n} );\n\n\nexport { LightShadow };\n","import { LightShadow } from './LightShadow.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction SpotLightShadow() {\n\n\tLightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) );\n\n}\n\nSpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {\n\n\tconstructor: SpotLightShadow,\n\n\tisSpotLightShadow: true,\n\n\tupdateMatrices: function ( light ) {\n\n\t\tconst camera = this.camera;\n\n\t\tconst fov = MathUtils.RAD2DEG * 2 * light.angle;\n\t\tconst aspect = this.mapSize.width / this.mapSize.height;\n\t\tconst far = light.distance || camera.far;\n\n\t\tif ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {\n\n\t\t\tcamera.fov = fov;\n\t\t\tcamera.aspect = aspect;\n\t\t\tcamera.far = far;\n\t\t\tcamera.updateProjectionMatrix();\n\n\t\t}\n\n\t\tLightShadow.prototype.updateMatrices.call( this, light );\n\n\t}\n\n} );\n\n\nexport { SpotLightShadow };\n","import { Light } from './Light.js';\nimport { SpotLightShadow } from './SpotLightShadow.js';\nimport { Object3D } from '../core/Object3D.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction SpotLight( color, intensity, distance, angle, penumbra, decay ) {\n\n\tLight.call( this, color, intensity );\n\n\tthis.type = 'SpotLight';\n\n\tthis.position.copy( Object3D.DefaultUp );\n\tthis.updateMatrix();\n\n\tthis.target = new Object3D();\n\n\tObject.defineProperty( this, 'power', {\n\t\tget: function () {\n\n\t\t\t// intensity = power per solid angle.\n\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\treturn this.intensity * Math.PI;\n\n\t\t},\n\t\tset: function ( power ) {\n\n\t\t\t// intensity = power per solid angle.\n\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\tthis.intensity = power / Math.PI;\n\n\t\t}\n\t} );\n\n\tthis.distance = ( distance !== undefined ) ? distance : 0;\n\tthis.angle = ( angle !== undefined ) ? angle : Math.PI / 3;\n\tthis.penumbra = ( penumbra !== undefined ) ? penumbra : 0;\n\tthis.decay = ( decay !== undefined ) ? decay : 1;\t// for physically correct lights, should be 2.\n\n\tthis.shadow = new SpotLightShadow();\n\n}\n\nSpotLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\tconstructor: SpotLight,\n\n\tisSpotLight: true,\n\n\tcopy: function ( source ) {\n\n\t\tLight.prototype.copy.call( this, source );\n\n\t\tthis.distance = source.distance;\n\t\tthis.angle = source.angle;\n\t\tthis.penumbra = source.penumbra;\n\t\tthis.decay = source.decay;\n\n\t\tthis.target = source.target.clone();\n\n\t\tthis.shadow = source.shadow.clone();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { SpotLight };\n","import { Camera } from './Camera.js';\nimport { Object3D } from '../core/Object3D.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author arose / http://github.com/arose\n */\n\nfunction OrthographicCamera( left, right, top, bottom, near, far ) {\n\n\tCamera.call( this );\n\n\tthis.type = 'OrthographicCamera';\n\n\tthis.zoom = 1;\n\tthis.view = null;\n\n\tthis.left = ( left !== undefined ) ? left : - 1;\n\tthis.right = ( right !== undefined ) ? right : 1;\n\tthis.top = ( top !== undefined ) ? top : 1;\n\tthis.bottom = ( bottom !== undefined ) ? bottom : - 1;\n\n\tthis.near = ( near !== undefined ) ? near : 0.1;\n\tthis.far = ( far !== undefined ) ? far : 2000;\n\n\tthis.updateProjectionMatrix();\n\n}\n\nOrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\tconstructor: OrthographicCamera,\n\n\tisOrthographicCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\tthis.left = source.left;\n\t\tthis.right = source.right;\n\t\tthis.top = source.top;\n\t\tthis.bottom = source.bottom;\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\n\t\tthis.zoom = source.zoom;\n\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\treturn this;\n\n\t},\n\n\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\tif ( this.view === null ) {\n\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tclearViewOffset: function () {\n\n\t\tif ( this.view !== null ) {\n\n\t\t\tthis.view.enabled = false;\n\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tupdateProjectionMatrix: function () {\n\n\t\tconst dx = ( this.right - this.left ) / ( 2 * this.zoom );\n\t\tconst dy = ( this.top - this.bottom ) / ( 2 * this.zoom );\n\t\tconst cx = ( this.right + this.left ) / 2;\n\t\tconst cy = ( this.top + this.bottom ) / 2;\n\n\t\tlet left = cx - dx;\n\t\tlet right = cx + dx;\n\t\tlet top = cy + dy;\n\t\tlet bottom = cy - dy;\n\n\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\tconst scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom;\n\t\t\tconst scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom;\n\n\t\t\tleft += scaleW * this.view.offsetX;\n\t\t\tright = left + scaleW * this.view.width;\n\t\t\ttop -= scaleH * this.view.offsetY;\n\t\t\tbottom = top - scaleH * this.view.height;\n\n\t\t}\n\n\t\tthis.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far );\n\n\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.zoom = this.zoom;\n\t\tdata.object.left = this.left;\n\t\tdata.object.right = this.right;\n\t\tdata.object.top = this.top;\n\t\tdata.object.bottom = this.bottom;\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\n\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { OrthographicCamera };\n","import { Light } from './Light.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction AmbientLight( color, intensity ) {\n\n\tLight.call( this, color, intensity );\n\n\tthis.type = 'AmbientLight';\n\n\tthis.castShadow = undefined;\n\n}\n\nAmbientLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\tconstructor: AmbientLight,\n\n\tisAmbientLight: true\n\n} );\n\n\nexport { AmbientLight };\n","import { Matrix4 } from '../math/Matrix4.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { PerspectiveCamera } from './PerspectiveCamera.js';\n\nconst _eyeRight = new Matrix4();\nconst _eyeLeft = new Matrix4();\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction StereoCamera() {\n\n\tthis.type = 'StereoCamera';\n\n\tthis.aspect = 1;\n\n\tthis.eyeSep = 0.064;\n\n\tthis.cameraL = new PerspectiveCamera();\n\tthis.cameraL.layers.enable( 1 );\n\tthis.cameraL.matrixAutoUpdate = false;\n\n\tthis.cameraR = new PerspectiveCamera();\n\tthis.cameraR.layers.enable( 2 );\n\tthis.cameraR.matrixAutoUpdate = false;\n\n\tthis._cache = {\n\t\tfocus: null,\n\t\tfov: null,\n\t\taspect: null,\n\t\tnear: null,\n\t\tfar: null,\n\t\tzoom: null,\n\t\teyeSep: null\n\t};\n\n}\n\nObject.assign( StereoCamera.prototype, {\n\n\tupdate: function ( camera ) {\n\n\t\tconst cache = this._cache;\n\n\t\tconst needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov ||\n\t\t\tcache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near ||\n\t\t\tcache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep;\n\n\t\tif ( needsUpdate ) {\n\n\t\t\tcache.focus = camera.focus;\n\t\t\tcache.fov = camera.fov;\n\t\t\tcache.aspect = camera.aspect * this.aspect;\n\t\t\tcache.near = camera.near;\n\t\t\tcache.far = camera.far;\n\t\t\tcache.zoom = camera.zoom;\n\t\t\tcache.eyeSep = this.eyeSep;\n\n\t\t\t// Off-axis stereoscopic effect based on\n\t\t\t// http://paulbourke.net/stereographics/stereorender/\n\n\t\t\tconst projectionMatrix = camera.projectionMatrix.clone();\n\t\t\tconst eyeSepHalf = cache.eyeSep / 2;\n\t\t\tconst eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;\n\t\t\tconst ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;\n\t\t\tlet xmin, xmax;\n\n\t\t\t// translate xOffset\n\n\t\t\t_eyeLeft.elements[ 12 ] = - eyeSepHalf;\n\t\t\t_eyeRight.elements[ 12 ] = eyeSepHalf;\n\n\t\t\t// for left eye\n\n\t\t\txmin = - ymax * cache.aspect + eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect + eyeSepOnProjection;\n\n\t\t\tprojectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );\n\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\tthis.cameraL.projectionMatrix.copy( projectionMatrix );\n\n\t\t\t// for right eye\n\n\t\t\txmin = - ymax * cache.aspect - eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect - eyeSepOnProjection;\n\n\t\t\tprojectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );\n\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\tthis.cameraR.projectionMatrix.copy( projectionMatrix );\n\n\t\t}\n\n\t\tthis.cameraL.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeLeft );\n\t\tthis.cameraR.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeRight );\n\n\t}\n\n} );\n\n\nexport { StereoCamera };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Uniform( value ) {\n\n\tif ( typeof value === 'string' ) {\n\n\t\tconsole.warn( 'THREE.Uniform: Type parameter is no longer needed.' );\n\t\tvalue = arguments[ 1 ];\n\n\t}\n\n\tthis.value = value;\n\n}\n\nUniform.prototype.clone = function () {\n\n\treturn new Uniform( this.value.clone === undefined ? this.value : this.value.clone() );\n\n};\n\nexport { Uniform };\n","/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","\n/**\n * @license\n *\n * chroma.js - JavaScript library for color conversions\n * \n * Copyright (c) 2011-2017, Gregor Aisch\n * All rights reserved.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n * \n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * \n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n * \n * 3. The name Gregor Aisch may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n(function() {\n var Color, DEG2RAD, LAB_CONSTANTS, PI, PITHIRD, RAD2DEG, TWOPI, _average_lrgb, _guess_formats, _guess_formats_sorted, _input, _interpolators, abs, atan2, bezier, blend, blend_f, brewer, burn, chroma, clip_rgb, cmyk2rgb, colors, cos, css2rgb, darken, dodge, each, floor, hcg2rgb, hex2rgb, hsi2rgb, hsl2css, hsl2rgb, hsv2rgb, interpolate, interpolate_hsx, interpolate_lab, interpolate_lrgb, interpolate_num, interpolate_rgb, lab2lch, lab2rgb, lab_xyz, lch2lab, lch2rgb, lighten, limit, log, luminance_x, m, max, multiply, normal, num2rgb, overlay, pow, rgb2cmyk, rgb2css, rgb2hcg, rgb2hex, rgb2hsi, rgb2hsl, rgb2hsv, rgb2lab, rgb2lch, rgb2luminance, rgb2num, rgb2temperature, rgb2xyz, rgb_xyz, rnd, root, round, screen, sin, sqrt, temperature2rgb, type, unpack, w3cx11, xyz_lab, xyz_rgb,\n slice = [].slice;\n\n type = (function() {\n\n /*\n for browser-safe type checking+\n ported from jQuery's $.type\n */\n var classToType, len, name, o, ref;\n classToType = {};\n ref = \"Boolean Number String Function Array Date RegExp Undefined Null\".split(\" \");\n for (o = 0, len = ref.length; o < len; o++) {\n name = ref[o];\n classToType[\"[object \" + name + \"]\"] = name.toLowerCase();\n }\n return function(obj) {\n var strType;\n strType = Object.prototype.toString.call(obj);\n return classToType[strType] || \"object\";\n };\n })();\n\n limit = function(x, min, max) {\n if (min == null) {\n min = 0;\n }\n if (max == null) {\n max = 1;\n }\n if (x < min) {\n x = min;\n }\n if (x > max) {\n x = max;\n }\n return x;\n };\n\n unpack = function(args) {\n if (args.length >= 3) {\n return Array.prototype.slice.call(args);\n } else {\n return args[0];\n }\n };\n\n clip_rgb = function(rgb) {\n var i, o;\n rgb._clipped = false;\n rgb._unclipped = rgb.slice(0);\n for (i = o = 0; o < 3; i = ++o) {\n if (i < 3) {\n if (rgb[i] < 0 || rgb[i] > 255) {\n rgb._clipped = true;\n }\n if (rgb[i] < 0) {\n rgb[i] = 0;\n }\n if (rgb[i] > 255) {\n rgb[i] = 255;\n }\n } else if (i === 3) {\n if (rgb[i] < 0) {\n rgb[i] = 0;\n }\n if (rgb[i] > 1) {\n rgb[i] = 1;\n }\n }\n }\n if (!rgb._clipped) {\n delete rgb._unclipped;\n }\n return rgb;\n };\n\n PI = Math.PI, round = Math.round, cos = Math.cos, floor = Math.floor, pow = Math.pow, log = Math.log, sin = Math.sin, sqrt = Math.sqrt, atan2 = Math.atan2, max = Math.max, abs = Math.abs;\n\n TWOPI = PI * 2;\n\n PITHIRD = PI / 3;\n\n DEG2RAD = PI / 180;\n\n RAD2DEG = 180 / PI;\n\n chroma = function() {\n if (arguments[0] instanceof Color) {\n return arguments[0];\n }\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, arguments, function(){});\n };\n\n chroma[\"default\"] = chroma;\n\n _interpolators = [];\n\n if ((typeof module !== \"undefined\" && module !== null) && (module.exports != null)) {\n module.exports = chroma;\n }\n\n if (typeof define === 'function' && define.amd) {\n define([], function() {\n return chroma;\n });\n } else {\n root = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n root.chroma = chroma;\n }\n\n chroma.version = '1.4.1';\n\n _input = {};\n\n _guess_formats = [];\n\n _guess_formats_sorted = false;\n\n Color = (function() {\n function Color() {\n var arg, args, chk, len, len1, me, mode, o, w;\n me = this;\n args = [];\n for (o = 0, len = arguments.length; o < len; o++) {\n arg = arguments[o];\n if (arg != null) {\n args.push(arg);\n }\n }\n if (args.length > 1) {\n mode = args[args.length - 1];\n }\n if (_input[mode] != null) {\n me._rgb = clip_rgb(_input[mode](unpack(args.slice(0, -1))));\n } else {\n if (!_guess_formats_sorted) {\n _guess_formats = _guess_formats.sort(function(a, b) {\n return b.p - a.p;\n });\n _guess_formats_sorted = true;\n }\n for (w = 0, len1 = _guess_formats.length; w < len1; w++) {\n chk = _guess_formats[w];\n mode = chk.test.apply(chk, args);\n if (mode) {\n break;\n }\n }\n if (mode) {\n me._rgb = clip_rgb(_input[mode].apply(_input, args));\n }\n }\n if (me._rgb == null) {\n console.warn('unknown format: ' + args);\n }\n if (me._rgb == null) {\n me._rgb = [0, 0, 0];\n }\n if (me._rgb.length === 3) {\n me._rgb.push(1);\n }\n }\n\n Color.prototype.toString = function() {\n return this.hex();\n };\n\n return Color;\n\n })();\n\n chroma._input = _input;\n\n\n /**\n \tColorBrewer colors for chroma.js\n \n \tCopyright (c) 2002 Cynthia Brewer, Mark Harrower, and The \n \tPennsylvania State University.\n \n \tLicensed under the Apache License, Version 2.0 (the \"License\"); \n \tyou may not use this file except in compliance with the License.\n \tYou may obtain a copy of the License at\t\n \thttp://www.apache.org/licenses/LICENSE-2.0\n \n \tUnless required by applicable law or agreed to in writing, software distributed\n \tunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n \tCONDITIONS OF ANY KIND, either express or implied. See the License for the\n \tspecific language governing permissions and limitations under the License.\n \n @preserve\n */\n\n chroma.brewer = brewer = {\n OrRd: ['#fff7ec', '#fee8c8', '#fdd49e', '#fdbb84', '#fc8d59', '#ef6548', '#d7301f', '#b30000', '#7f0000'],\n PuBu: ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858'],\n BuPu: ['#f7fcfd', '#e0ecf4', '#bfd3e6', '#9ebcda', '#8c96c6', '#8c6bb1', '#88419d', '#810f7c', '#4d004b'],\n Oranges: ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'],\n BuGn: ['#f7fcfd', '#e5f5f9', '#ccece6', '#99d8c9', '#66c2a4', '#41ae76', '#238b45', '#006d2c', '#00441b'],\n YlOrBr: ['#ffffe5', '#fff7bc', '#fee391', '#fec44f', '#fe9929', '#ec7014', '#cc4c02', '#993404', '#662506'],\n YlGn: ['#ffffe5', '#f7fcb9', '#d9f0a3', '#addd8e', '#78c679', '#41ab5d', '#238443', '#006837', '#004529'],\n Reds: ['#fff5f0', '#fee0d2', '#fcbba1', '#fc9272', '#fb6a4a', '#ef3b2c', '#cb181d', '#a50f15', '#67000d'],\n RdPu: ['#fff7f3', '#fde0dd', '#fcc5c0', '#fa9fb5', '#f768a1', '#dd3497', '#ae017e', '#7a0177', '#49006a'],\n Greens: ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b'],\n YlGnBu: ['#ffffd9', '#edf8b1', '#c7e9b4', '#7fcdbb', '#41b6c4', '#1d91c0', '#225ea8', '#253494', '#081d58'],\n Purples: ['#fcfbfd', '#efedf5', '#dadaeb', '#bcbddc', '#9e9ac8', '#807dba', '#6a51a3', '#54278f', '#3f007d'],\n GnBu: ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081'],\n Greys: ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525', '#000000'],\n YlOrRd: ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026'],\n PuRd: ['#f7f4f9', '#e7e1ef', '#d4b9da', '#c994c7', '#df65b0', '#e7298a', '#ce1256', '#980043', '#67001f'],\n Blues: ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'],\n PuBuGn: ['#fff7fb', '#ece2f0', '#d0d1e6', '#a6bddb', '#67a9cf', '#3690c0', '#02818a', '#016c59', '#014636'],\n Viridis: ['#440154', '#482777', '#3f4a8a', '#31678e', '#26838f', '#1f9d8a', '#6cce5a', '#b6de2b', '#fee825'],\n Spectral: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'],\n RdYlGn: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850', '#006837'],\n RdBu: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#f7f7f7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061'],\n PiYG: ['#8e0152', '#c51b7d', '#de77ae', '#f1b6da', '#fde0ef', '#f7f7f7', '#e6f5d0', '#b8e186', '#7fbc41', '#4d9221', '#276419'],\n PRGn: ['#40004b', '#762a83', '#9970ab', '#c2a5cf', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#a6dba0', '#5aae61', '#1b7837', '#00441b'],\n RdYlBu: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee090', '#ffffbf', '#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695'],\n BrBG: ['#543005', '#8c510a', '#bf812d', '#dfc27d', '#f6e8c3', '#f5f5f5', '#c7eae5', '#80cdc1', '#35978f', '#01665e', '#003c30'],\n RdGy: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#ffffff', '#e0e0e0', '#bababa', '#878787', '#4d4d4d', '#1a1a1a'],\n PuOr: ['#7f3b08', '#b35806', '#e08214', '#fdb863', '#fee0b6', '#f7f7f7', '#d8daeb', '#b2abd2', '#8073ac', '#542788', '#2d004b'],\n Set2: ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3'],\n Accent: ['#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f', '#bf5b17', '#666666'],\n Set1: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'],\n Set3: ['#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f'],\n Dark2: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666'],\n Paired: ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928'],\n Pastel2: ['#b3e2cd', '#fdcdac', '#cbd5e8', '#f4cae4', '#e6f5c9', '#fff2ae', '#f1e2cc', '#cccccc'],\n Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2']\n };\n\n (function() {\n var key, results;\n results = [];\n for (key in brewer) {\n results.push(brewer[key.toLowerCase()] = brewer[key]);\n }\n return results;\n })();\n\n\n /**\n \tX11 color names\n \n \thttp://www.w3.org/TR/css3-color/#svg-color\n */\n\n w3cx11 = {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflower: '#6495ed',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkgrey: '#a9a9a9',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkslategrey: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n grey: '#808080',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n indianred: '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n laserlemon: '#ffff54',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrod: '#fafad2',\n lightgoldenrodyellow: '#fafad2',\n lightgray: '#d3d3d3',\n lightgreen: '#90ee90',\n lightgrey: '#d3d3d3',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightslategrey: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n maroon2: '#7f0000',\n maroon3: '#b03060',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370db',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#db7093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n purple2: '#7f007f',\n purple3: '#a020f0',\n rebeccapurple: '#663399',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32'\n };\n\n chroma.colors = colors = w3cx11;\n\n lab2rgb = function() {\n var a, args, b, g, l, r, x, y, z;\n args = unpack(arguments);\n l = args[0], a = args[1], b = args[2];\n y = (l + 16) / 116;\n x = isNaN(a) ? y : y + a / 500;\n z = isNaN(b) ? y : y - b / 200;\n y = LAB_CONSTANTS.Yn * lab_xyz(y);\n x = LAB_CONSTANTS.Xn * lab_xyz(x);\n z = LAB_CONSTANTS.Zn * lab_xyz(z);\n r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z);\n g = xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);\n b = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n xyz_rgb = function(r) {\n return 255 * (r <= 0.00304 ? 12.92 * r : 1.055 * pow(r, 1 / 2.4) - 0.055);\n };\n\n lab_xyz = function(t) {\n if (t > LAB_CONSTANTS.t1) {\n return t * t * t;\n } else {\n return LAB_CONSTANTS.t2 * (t - LAB_CONSTANTS.t0);\n }\n };\n\n LAB_CONSTANTS = {\n Kn: 18,\n Xn: 0.950470,\n Yn: 1,\n Zn: 1.088830,\n t0: 0.137931034,\n t1: 0.206896552,\n t2: 0.12841855,\n t3: 0.008856452\n };\n\n rgb2lab = function() {\n var b, g, r, ref, ref1, x, y, z;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n ref1 = rgb2xyz(r, g, b), x = ref1[0], y = ref1[1], z = ref1[2];\n return [116 * y - 16, 500 * (x - y), 200 * (y - z)];\n };\n\n rgb_xyz = function(r) {\n if ((r /= 255) <= 0.04045) {\n return r / 12.92;\n } else {\n return pow((r + 0.055) / 1.055, 2.4);\n }\n };\n\n xyz_lab = function(t) {\n if (t > LAB_CONSTANTS.t3) {\n return pow(t, 1 / 3);\n } else {\n return t / LAB_CONSTANTS.t2 + LAB_CONSTANTS.t0;\n }\n };\n\n rgb2xyz = function() {\n var b, g, r, ref, x, y, z;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = rgb_xyz(r);\n g = rgb_xyz(g);\n b = rgb_xyz(b);\n x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / LAB_CONSTANTS.Xn);\n y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / LAB_CONSTANTS.Yn);\n z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / LAB_CONSTANTS.Zn);\n return [x, y, z];\n };\n\n chroma.lab = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['lab']), function(){});\n };\n\n _input.lab = lab2rgb;\n\n Color.prototype.lab = function() {\n return rgb2lab(this._rgb);\n };\n\n bezier = function(colors) {\n var I, I0, I1, c, lab0, lab1, lab2, lab3, ref, ref1, ref2;\n colors = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(chroma(c));\n }\n return results;\n })();\n if (colors.length === 2) {\n ref = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref[0], lab1 = ref[1];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push(lab0[i] + t * (lab1[i] - lab0[i]));\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 3) {\n ref1 = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref1[0], lab1 = ref1[1], lab2 = ref1[2];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push((1 - t) * (1 - t) * lab0[i] + 2 * (1 - t) * t * lab1[i] + t * t * lab2[i]);\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 4) {\n ref2 = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref2[0], lab1 = ref2[1], lab2 = ref2[2], lab3 = ref2[3];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push((1 - t) * (1 - t) * (1 - t) * lab0[i] + 3 * (1 - t) * (1 - t) * t * lab1[i] + 3 * (1 - t) * t * t * lab2[i] + t * t * t * lab3[i]);\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 5) {\n I0 = bezier(colors.slice(0, 3));\n I1 = bezier(colors.slice(2, 5));\n I = function(t) {\n if (t < 0.5) {\n return I0(t * 2);\n } else {\n return I1((t - 0.5) * 2);\n }\n };\n }\n return I;\n };\n\n chroma.bezier = function(colors) {\n var f;\n f = bezier(colors);\n f.scale = function() {\n return chroma.scale(f);\n };\n return f;\n };\n\n chroma.cubehelix = function(start, rotations, hue, gamma, lightness) {\n var dh, dl, f;\n if (start == null) {\n start = 300;\n }\n if (rotations == null) {\n rotations = -1.5;\n }\n if (hue == null) {\n hue = 1;\n }\n if (gamma == null) {\n gamma = 1;\n }\n if (lightness == null) {\n lightness = [0, 1];\n }\n dh = 0;\n if (type(lightness) === 'array') {\n dl = lightness[1] - lightness[0];\n } else {\n dl = 0;\n lightness = [lightness, lightness];\n }\n f = function(fract) {\n var a, amp, b, cos_a, g, h, l, r, sin_a;\n a = TWOPI * ((start + 120) / 360 + rotations * fract);\n l = pow(lightness[0] + dl * fract, gamma);\n h = dh !== 0 ? hue[0] + fract * dh : hue;\n amp = h * l * (1 - l) / 2;\n cos_a = cos(a);\n sin_a = sin(a);\n r = l + amp * (-0.14861 * cos_a + 1.78277 * sin_a);\n g = l + amp * (-0.29227 * cos_a - 0.90649 * sin_a);\n b = l + amp * (+1.97294 * cos_a);\n return chroma(clip_rgb([r * 255, g * 255, b * 255, 1]));\n };\n f.start = function(s) {\n if (s == null) {\n return start;\n }\n start = s;\n return f;\n };\n f.rotations = function(r) {\n if (r == null) {\n return rotations;\n }\n rotations = r;\n return f;\n };\n f.gamma = function(g) {\n if (g == null) {\n return gamma;\n }\n gamma = g;\n return f;\n };\n f.hue = function(h) {\n if (h == null) {\n return hue;\n }\n hue = h;\n if (type(hue) === 'array') {\n dh = hue[1] - hue[0];\n if (dh === 0) {\n hue = hue[1];\n }\n } else {\n dh = 0;\n }\n return f;\n };\n f.lightness = function(h) {\n if (h == null) {\n return lightness;\n }\n if (type(h) === 'array') {\n lightness = h;\n dl = h[1] - h[0];\n } else {\n lightness = [h, h];\n dl = 0;\n }\n return f;\n };\n f.scale = function() {\n return chroma.scale(f);\n };\n f.hue(hue);\n return f;\n };\n\n chroma.random = function() {\n var code, digits, i, o;\n digits = '0123456789abcdef';\n code = '#';\n for (i = o = 0; o < 6; i = ++o) {\n code += digits.charAt(floor(Math.random() * 16));\n }\n return new Color(code);\n };\n\n _interpolators = [];\n\n interpolate = function(col1, col2, f, m) {\n var interpol, len, o, res;\n if (f == null) {\n f = 0.5;\n }\n if (m == null) {\n m = 'rgb';\n }\n\n /*\n interpolates between colors\n f = 0 --> me\n f = 1 --> col\n */\n if (type(col1) !== 'object') {\n col1 = chroma(col1);\n }\n if (type(col2) !== 'object') {\n col2 = chroma(col2);\n }\n for (o = 0, len = _interpolators.length; o < len; o++) {\n interpol = _interpolators[o];\n if (m === interpol[0]) {\n res = interpol[1](col1, col2, f, m);\n break;\n }\n }\n if (res == null) {\n throw \"color mode \" + m + \" is not supported\";\n }\n return res.alpha(col1.alpha() + f * (col2.alpha() - col1.alpha()));\n };\n\n chroma.interpolate = interpolate;\n\n Color.prototype.interpolate = function(col2, f, m) {\n return interpolate(this, col2, f, m);\n };\n\n chroma.mix = interpolate;\n\n Color.prototype.mix = Color.prototype.interpolate;\n\n _input.rgb = function() {\n var k, ref, results, v;\n ref = unpack(arguments);\n results = [];\n for (k in ref) {\n v = ref[k];\n results.push(v);\n }\n return results;\n };\n\n chroma.rgb = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['rgb']), function(){});\n };\n\n Color.prototype.rgb = function(round) {\n if (round == null) {\n round = true;\n }\n if (round) {\n return this._rgb.map(Math.round).slice(0, 3);\n } else {\n return this._rgb.slice(0, 3);\n }\n };\n\n Color.prototype.rgba = function(round) {\n if (round == null) {\n round = true;\n }\n if (!round) {\n return this._rgb.slice(0);\n }\n return [Math.round(this._rgb[0]), Math.round(this._rgb[1]), Math.round(this._rgb[2]), this._rgb[3]];\n };\n\n _guess_formats.push({\n p: 3,\n test: function(n) {\n var a;\n a = unpack(arguments);\n if (type(a) === 'array' && a.length === 3) {\n return 'rgb';\n }\n if (a.length === 4 && type(a[3]) === \"number\" && a[3] >= 0 && a[3] <= 1) {\n return 'rgb';\n }\n }\n });\n\n _input.lrgb = _input.rgb;\n\n interpolate_lrgb = function(col1, col2, f, m) {\n var xyz0, xyz1;\n xyz0 = col1._rgb;\n xyz1 = col2._rgb;\n return new Color(sqrt(pow(xyz0[0], 2) * (1 - f) + pow(xyz1[0], 2) * f), sqrt(pow(xyz0[1], 2) * (1 - f) + pow(xyz1[1], 2) * f), sqrt(pow(xyz0[2], 2) * (1 - f) + pow(xyz1[2], 2) * f), m);\n };\n\n _average_lrgb = function(colors) {\n var col, f, len, o, rgb, xyz;\n f = 1 / colors.length;\n xyz = [0, 0, 0, 0];\n for (o = 0, len = colors.length; o < len; o++) {\n col = colors[o];\n rgb = col._rgb;\n xyz[0] += pow(rgb[0], 2) * f;\n xyz[1] += pow(rgb[1], 2) * f;\n xyz[2] += pow(rgb[2], 2) * f;\n xyz[3] += rgb[3] * f;\n }\n xyz[0] = sqrt(xyz[0]);\n xyz[1] = sqrt(xyz[1]);\n xyz[2] = sqrt(xyz[2]);\n if (xyz[3] > 1) {\n xyz[3] = 1;\n }\n return new Color(clip_rgb(xyz));\n };\n\n _interpolators.push(['lrgb', interpolate_lrgb]);\n\n chroma.average = function(colors, mode) {\n var A, alpha, c, cnt, dx, dy, first, i, l, len, o, xyz, xyz2;\n if (mode == null) {\n mode = 'rgb';\n }\n l = colors.length;\n colors = colors.map(function(c) {\n return chroma(c);\n });\n first = colors.splice(0, 1)[0];\n if (mode === 'lrgb') {\n return _average_lrgb(colors);\n }\n xyz = first.get(mode);\n cnt = [];\n dx = 0;\n dy = 0;\n for (i in xyz) {\n xyz[i] = xyz[i] || 0;\n cnt.push(isNaN(xyz[i]) ? 0 : 1);\n if (mode.charAt(i) === 'h' && !isNaN(xyz[i])) {\n A = xyz[i] / 180 * PI;\n dx += cos(A);\n dy += sin(A);\n }\n }\n alpha = first.alpha();\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n xyz2 = c.get(mode);\n alpha += c.alpha();\n for (i in xyz) {\n if (!isNaN(xyz2[i])) {\n cnt[i] += 1;\n if (mode.charAt(i) === 'h') {\n A = xyz2[i] / 180 * PI;\n dx += cos(A);\n dy += sin(A);\n } else {\n xyz[i] += xyz2[i];\n }\n }\n }\n }\n for (i in xyz) {\n if (mode.charAt(i) === 'h') {\n A = atan2(dy / cnt[i], dx / cnt[i]) / PI * 180;\n while (A < 0) {\n A += 360;\n }\n while (A >= 360) {\n A -= 360;\n }\n xyz[i] = A;\n } else {\n xyz[i] = xyz[i] / cnt[i];\n }\n }\n return chroma(xyz, mode).alpha(alpha / l);\n };\n\n hex2rgb = function(hex) {\n var a, b, g, r, rgb, u;\n if (hex.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)) {\n if (hex.length === 4 || hex.length === 7) {\n hex = hex.substr(1);\n }\n if (hex.length === 3) {\n hex = hex.split(\"\");\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\n }\n u = parseInt(hex, 16);\n r = u >> 16;\n g = u >> 8 & 0xFF;\n b = u & 0xFF;\n return [r, g, b, 1];\n }\n if (hex.match(/^#?([A-Fa-f0-9]{8})$/)) {\n if (hex.length === 9) {\n hex = hex.substr(1);\n }\n u = parseInt(hex, 16);\n r = u >> 24 & 0xFF;\n g = u >> 16 & 0xFF;\n b = u >> 8 & 0xFF;\n a = round((u & 0xFF) / 0xFF * 100) / 100;\n return [r, g, b, a];\n }\n if ((_input.css != null) && (rgb = _input.css(hex))) {\n return rgb;\n }\n throw \"unknown color: \" + hex;\n };\n\n rgb2hex = function(channels, mode) {\n var a, b, g, hxa, r, str, u;\n if (mode == null) {\n mode = 'auto';\n }\n r = channels[0], g = channels[1], b = channels[2], a = channels[3];\n if (mode === 'auto') {\n mode = a < 1 ? 'rgba' : 'rgb';\n }\n r = Math.round(r);\n g = Math.round(g);\n b = Math.round(b);\n u = r << 16 | g << 8 | b;\n str = \"000000\" + u.toString(16);\n str = str.substr(str.length - 6);\n hxa = '0' + round(a * 255).toString(16);\n hxa = hxa.substr(hxa.length - 2);\n return \"#\" + (function() {\n switch (mode.toLowerCase()) {\n case 'rgba':\n return str + hxa;\n case 'argb':\n return hxa + str;\n default:\n return str;\n }\n })();\n };\n\n _input.hex = function(h) {\n return hex2rgb(h);\n };\n\n chroma.hex = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hex']), function(){});\n };\n\n Color.prototype.hex = function(mode) {\n if (mode == null) {\n mode = 'auto';\n }\n return rgb2hex(this._rgb, mode);\n };\n\n _guess_formats.push({\n p: 4,\n test: function(n) {\n if (arguments.length === 1 && type(n) === \"string\") {\n return 'hex';\n }\n }\n });\n\n hsl2rgb = function() {\n var args, b, c, g, h, i, l, o, r, ref, s, t1, t2, t3;\n args = unpack(arguments);\n h = args[0], s = args[1], l = args[2];\n if (s === 0) {\n r = g = b = l * 255;\n } else {\n t3 = [0, 0, 0];\n c = [0, 0, 0];\n t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n t1 = 2 * l - t2;\n h /= 360;\n t3[0] = h + 1 / 3;\n t3[1] = h;\n t3[2] = h - 1 / 3;\n for (i = o = 0; o <= 2; i = ++o) {\n if (t3[i] < 0) {\n t3[i] += 1;\n }\n if (t3[i] > 1) {\n t3[i] -= 1;\n }\n if (6 * t3[i] < 1) {\n c[i] = t1 + (t2 - t1) * 6 * t3[i];\n } else if (2 * t3[i] < 1) {\n c[i] = t2;\n } else if (3 * t3[i] < 2) {\n c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6;\n } else {\n c[i] = t1;\n }\n }\n ref = [round(c[0] * 255), round(c[1] * 255), round(c[2] * 255)], r = ref[0], g = ref[1], b = ref[2];\n }\n if (args.length > 3) {\n return [r, g, b, args[3]];\n } else {\n return [r, g, b];\n }\n };\n\n rgb2hsl = function(r, g, b) {\n var h, l, min, ref, s;\n if (r !== void 0 && r.length >= 3) {\n ref = r, r = ref[0], g = ref[1], b = ref[2];\n }\n r /= 255;\n g /= 255;\n b /= 255;\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n l = (max + min) / 2;\n if (max === min) {\n s = 0;\n h = Number.NaN;\n } else {\n s = l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min);\n }\n if (r === max) {\n h = (g - b) / (max - min);\n } else if (g === max) {\n h = 2 + (b - r) / (max - min);\n } else if (b === max) {\n h = 4 + (r - g) / (max - min);\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n return [h, s, l];\n };\n\n chroma.hsl = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsl']), function(){});\n };\n\n _input.hsl = hsl2rgb;\n\n Color.prototype.hsl = function() {\n return rgb2hsl(this._rgb);\n };\n\n hsv2rgb = function() {\n var args, b, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, s, t, v;\n args = unpack(arguments);\n h = args[0], s = args[1], v = args[2];\n v *= 255;\n if (s === 0) {\n r = g = b = v;\n } else {\n if (h === 360) {\n h = 0;\n }\n if (h > 360) {\n h -= 360;\n }\n if (h < 0) {\n h += 360;\n }\n h /= 60;\n i = floor(h);\n f = h - i;\n p = v * (1 - s);\n q = v * (1 - s * f);\n t = v * (1 - s * (1 - f));\n switch (i) {\n case 0:\n ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];\n break;\n case 1:\n ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];\n break;\n case 2:\n ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];\n break;\n case 3:\n ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];\n break;\n case 4:\n ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];\n break;\n case 5:\n ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hsv = function() {\n var b, delta, g, h, min, r, ref, s, v;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n delta = max - min;\n v = max / 255.0;\n if (max === 0) {\n h = Number.NaN;\n s = 0;\n } else {\n s = delta / max;\n if (r === max) {\n h = (g - b) / delta;\n }\n if (g === max) {\n h = 2 + (b - r) / delta;\n }\n if (b === max) {\n h = 4 + (r - g) / delta;\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n }\n return [h, s, v];\n };\n\n chroma.hsv = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsv']), function(){});\n };\n\n _input.hsv = hsv2rgb;\n\n Color.prototype.hsv = function() {\n return rgb2hsv(this._rgb);\n };\n\n num2rgb = function(num) {\n var b, g, r;\n if (type(num) === \"number\" && num >= 0 && num <= 0xFFFFFF) {\n r = num >> 16;\n g = (num >> 8) & 0xFF;\n b = num & 0xFF;\n return [r, g, b, 1];\n }\n console.warn(\"unknown num color: \" + num);\n return [0, 0, 0, 1];\n };\n\n rgb2num = function() {\n var b, g, r, ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n return (r << 16) + (g << 8) + b;\n };\n\n chroma.num = function(num) {\n return new Color(num, 'num');\n };\n\n Color.prototype.num = function(mode) {\n if (mode == null) {\n mode = 'rgb';\n }\n return rgb2num(this._rgb, mode);\n };\n\n _input.num = num2rgb;\n\n _guess_formats.push({\n p: 1,\n test: function(n) {\n if (arguments.length === 1 && type(n) === \"number\" && n >= 0 && n <= 0xFFFFFF) {\n return 'num';\n }\n }\n });\n\n hcg2rgb = function() {\n var _c, _g, args, b, c, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, t, v;\n args = unpack(arguments);\n h = args[0], c = args[1], _g = args[2];\n c = c / 100;\n g = g / 100 * 255;\n _c = c * 255;\n if (c === 0) {\n r = g = b = _g;\n } else {\n if (h === 360) {\n h = 0;\n }\n if (h > 360) {\n h -= 360;\n }\n if (h < 0) {\n h += 360;\n }\n h /= 60;\n i = floor(h);\n f = h - i;\n p = _g * (1 - c);\n q = p + _c * (1 - f);\n t = p + _c * f;\n v = p + _c;\n switch (i) {\n case 0:\n ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];\n break;\n case 1:\n ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];\n break;\n case 2:\n ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];\n break;\n case 3:\n ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];\n break;\n case 4:\n ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];\n break;\n case 5:\n ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hcg = function() {\n var _g, b, c, delta, g, h, min, r, ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n delta = max - min;\n c = delta * 100 / 255;\n _g = min / (255 - delta) * 100;\n if (delta === 0) {\n h = Number.NaN;\n } else {\n if (r === max) {\n h = (g - b) / delta;\n }\n if (g === max) {\n h = 2 + (b - r) / delta;\n }\n if (b === max) {\n h = 4 + (r - g) / delta;\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n }\n return [h, c, _g];\n };\n\n chroma.hcg = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hcg']), function(){});\n };\n\n _input.hcg = hcg2rgb;\n\n Color.prototype.hcg = function() {\n return rgb2hcg(this._rgb);\n };\n\n css2rgb = function(css) {\n var aa, ab, hsl, i, m, o, rgb, w;\n css = css.toLowerCase();\n if ((chroma.colors != null) && chroma.colors[css]) {\n return hex2rgb(chroma.colors[css]);\n }\n if (m = css.match(/rgb\\(\\s*(\\-?\\d+),\\s*(\\-?\\d+)\\s*,\\s*(\\-?\\d+)\\s*\\)/)) {\n rgb = m.slice(1, 4);\n for (i = o = 0; o <= 2; i = ++o) {\n rgb[i] = +rgb[i];\n }\n rgb[3] = 1;\n } else if (m = css.match(/rgba\\(\\s*(\\-?\\d+),\\s*(\\-?\\d+)\\s*,\\s*(\\-?\\d+)\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n rgb = m.slice(1, 5);\n for (i = w = 0; w <= 3; i = ++w) {\n rgb[i] = +rgb[i];\n }\n } else if (m = css.match(/rgb\\(\\s*(\\-?\\d+(?:\\.\\d+)?)%,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*\\)/)) {\n rgb = m.slice(1, 4);\n for (i = aa = 0; aa <= 2; i = ++aa) {\n rgb[i] = round(rgb[i] * 2.55);\n }\n rgb[3] = 1;\n } else if (m = css.match(/rgba\\(\\s*(\\-?\\d+(?:\\.\\d+)?)%,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n rgb = m.slice(1, 5);\n for (i = ab = 0; ab <= 2; i = ++ab) {\n rgb[i] = round(rgb[i] * 2.55);\n }\n rgb[3] = +rgb[3];\n } else if (m = css.match(/hsl\\(\\s*(\\-?\\d+(?:\\.\\d+)?),\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*\\)/)) {\n hsl = m.slice(1, 4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n rgb = hsl2rgb(hsl);\n rgb[3] = 1;\n } else if (m = css.match(/hsla\\(\\s*(\\-?\\d+(?:\\.\\d+)?),\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n hsl = m.slice(1, 4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n rgb = hsl2rgb(hsl);\n rgb[3] = +m[4];\n }\n return rgb;\n };\n\n rgb2css = function(rgba) {\n var mode;\n mode = rgba[3] < 1 ? 'rgba' : 'rgb';\n if (mode === 'rgb') {\n return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ')';\n } else if (mode === 'rgba') {\n return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ',' + rgba[3] + ')';\n } else {\n\n }\n };\n\n rnd = function(a) {\n return round(a * 100) / 100;\n };\n\n hsl2css = function(hsl, alpha) {\n var mode;\n mode = alpha < 1 ? 'hsla' : 'hsl';\n hsl[0] = rnd(hsl[0] || 0);\n hsl[1] = rnd(hsl[1] * 100) + '%';\n hsl[2] = rnd(hsl[2] * 100) + '%';\n if (mode === 'hsla') {\n hsl[3] = alpha;\n }\n return mode + '(' + hsl.join(',') + ')';\n };\n\n _input.css = function(h) {\n return css2rgb(h);\n };\n\n chroma.css = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['css']), function(){});\n };\n\n Color.prototype.css = function(mode) {\n if (mode == null) {\n mode = 'rgb';\n }\n if (mode.slice(0, 3) === 'rgb') {\n return rgb2css(this._rgb);\n } else if (mode.slice(0, 3) === 'hsl') {\n return hsl2css(this.hsl(), this.alpha());\n }\n };\n\n _input.named = function(name) {\n return hex2rgb(w3cx11[name]);\n };\n\n _guess_formats.push({\n p: 5,\n test: function(n) {\n if (arguments.length === 1 && (w3cx11[n] != null)) {\n return 'named';\n }\n }\n });\n\n Color.prototype.name = function(n) {\n var h, k;\n if (arguments.length) {\n if (w3cx11[n]) {\n this._rgb = hex2rgb(w3cx11[n]);\n }\n this._rgb[3] = 1;\n this;\n }\n h = this.hex('rgb');\n for (k in w3cx11) {\n if (h === w3cx11[k]) {\n return k;\n }\n }\n return h;\n };\n\n lch2lab = function() {\n\n /*\n Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.\n These formulas were invented by David Dalrymple to obtain maximum contrast without going\n out of gamut if the parameters are in the range 0-1.\n \n A saturation multiplier was added by Gregor Aisch\n */\n var c, h, l, ref;\n ref = unpack(arguments), l = ref[0], c = ref[1], h = ref[2];\n h = h * DEG2RAD;\n return [l, cos(h) * c, sin(h) * c];\n };\n\n lch2rgb = function() {\n var L, a, args, b, c, g, h, l, r, ref, ref1;\n args = unpack(arguments);\n l = args[0], c = args[1], h = args[2];\n ref = lch2lab(l, c, h), L = ref[0], a = ref[1], b = ref[2];\n ref1 = lab2rgb(L, a, b), r = ref1[0], g = ref1[1], b = ref1[2];\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n lab2lch = function() {\n var a, b, c, h, l, ref;\n ref = unpack(arguments), l = ref[0], a = ref[1], b = ref[2];\n c = sqrt(a * a + b * b);\n h = (atan2(b, a) * RAD2DEG + 360) % 360;\n if (round(c * 10000) === 0) {\n h = Number.NaN;\n }\n return [l, c, h];\n };\n\n rgb2lch = function() {\n var a, b, g, l, r, ref, ref1;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n ref1 = rgb2lab(r, g, b), l = ref1[0], a = ref1[1], b = ref1[2];\n return lab2lch(l, a, b);\n };\n\n chroma.lch = function() {\n var args;\n args = unpack(arguments);\n return new Color(args, 'lch');\n };\n\n chroma.hcl = function() {\n var args;\n args = unpack(arguments);\n return new Color(args, 'hcl');\n };\n\n _input.lch = lch2rgb;\n\n _input.hcl = function() {\n var c, h, l, ref;\n ref = unpack(arguments), h = ref[0], c = ref[1], l = ref[2];\n return lch2rgb([l, c, h]);\n };\n\n Color.prototype.lch = function() {\n return rgb2lch(this._rgb);\n };\n\n Color.prototype.hcl = function() {\n return rgb2lch(this._rgb).reverse();\n };\n\n rgb2cmyk = function(mode) {\n var b, c, f, g, k, m, r, ref, y;\n if (mode == null) {\n mode = 'rgb';\n }\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = r / 255;\n g = g / 255;\n b = b / 255;\n k = 1 - Math.max(r, Math.max(g, b));\n f = k < 1 ? 1 / (1 - k) : 0;\n c = (1 - r - k) * f;\n m = (1 - g - k) * f;\n y = (1 - b - k) * f;\n return [c, m, y, k];\n };\n\n cmyk2rgb = function() {\n var alpha, args, b, c, g, k, m, r, y;\n args = unpack(arguments);\n c = args[0], m = args[1], y = args[2], k = args[3];\n alpha = args.length > 4 ? args[4] : 1;\n if (k === 1) {\n return [0, 0, 0, alpha];\n }\n r = c >= 1 ? 0 : 255 * (1 - c) * (1 - k);\n g = m >= 1 ? 0 : 255 * (1 - m) * (1 - k);\n b = y >= 1 ? 0 : 255 * (1 - y) * (1 - k);\n return [r, g, b, alpha];\n };\n\n _input.cmyk = function() {\n return cmyk2rgb(unpack(arguments));\n };\n\n chroma.cmyk = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['cmyk']), function(){});\n };\n\n Color.prototype.cmyk = function() {\n return rgb2cmyk(this._rgb);\n };\n\n _input.gl = function() {\n var i, k, o, rgb, v;\n rgb = (function() {\n var ref, results;\n ref = unpack(arguments);\n results = [];\n for (k in ref) {\n v = ref[k];\n results.push(v);\n }\n return results;\n }).apply(this, arguments);\n for (i = o = 0; o <= 2; i = ++o) {\n rgb[i] *= 255;\n }\n return rgb;\n };\n\n chroma.gl = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['gl']), function(){});\n };\n\n Color.prototype.gl = function() {\n var rgb;\n rgb = this._rgb;\n return [rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, rgb[3]];\n };\n\n rgb2luminance = function(r, g, b) {\n var ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = luminance_x(r);\n g = luminance_x(g);\n b = luminance_x(b);\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n };\n\n luminance_x = function(x) {\n x /= 255;\n if (x <= 0.03928) {\n return x / 12.92;\n } else {\n return pow((x + 0.055) / 1.055, 2.4);\n }\n };\n\n interpolate_rgb = function(col1, col2, f, m) {\n var xyz0, xyz1;\n xyz0 = col1._rgb;\n xyz1 = col2._rgb;\n return new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);\n };\n\n _interpolators.push(['rgb', interpolate_rgb]);\n\n Color.prototype.luminance = function(lum, mode) {\n var cur_lum, eps, max_iter, rgba, test;\n if (mode == null) {\n mode = 'rgb';\n }\n if (!arguments.length) {\n return rgb2luminance(this._rgb);\n }\n rgba = this._rgb;\n if (lum === 0) {\n rgba = [0, 0, 0, this._rgb[3]];\n } else if (lum === 1) {\n rgba = [255, 255, 255, this[3]];\n } else {\n cur_lum = rgb2luminance(this._rgb);\n eps = 1e-7;\n max_iter = 20;\n test = function(l, h) {\n var lm, m;\n m = l.interpolate(h, 0.5, mode);\n lm = m.luminance();\n if (Math.abs(lum - lm) < eps || !max_iter--) {\n return m;\n }\n if (lm > lum) {\n return test(l, m);\n }\n return test(m, h);\n };\n if (cur_lum > lum) {\n rgba = test(chroma('black'), this).rgba();\n } else {\n rgba = test(this, chroma('white')).rgba();\n }\n }\n return chroma(rgba).alpha(this.alpha());\n };\n\n temperature2rgb = function(kelvin) {\n var b, g, r, temp;\n temp = kelvin / 100;\n if (temp < 66) {\n r = 255;\n g = -155.25485562709179 - 0.44596950469579133 * (g = temp - 2) + 104.49216199393888 * log(g);\n b = temp < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (b = temp - 10) + 115.67994401066147 * log(b);\n } else {\n r = 351.97690566805693 + 0.114206453784165 * (r = temp - 55) - 40.25366309332127 * log(r);\n g = 325.4494125711974 + 0.07943456536662342 * (g = temp - 50) - 28.0852963507957 * log(g);\n b = 255;\n }\n return [r, g, b];\n };\n\n rgb2temperature = function() {\n var b, eps, g, maxTemp, minTemp, r, ref, rgb, temp;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n minTemp = 1000;\n maxTemp = 40000;\n eps = 0.4;\n while (maxTemp - minTemp > eps) {\n temp = (maxTemp + minTemp) * 0.5;\n rgb = temperature2rgb(temp);\n if ((rgb[2] / rgb[0]) >= (b / r)) {\n maxTemp = temp;\n } else {\n minTemp = temp;\n }\n }\n return round(temp);\n };\n\n chroma.temperature = chroma.kelvin = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['temperature']), function(){});\n };\n\n _input.temperature = _input.kelvin = _input.K = temperature2rgb;\n\n Color.prototype.temperature = function() {\n return rgb2temperature(this._rgb);\n };\n\n Color.prototype.kelvin = Color.prototype.temperature;\n\n chroma.contrast = function(a, b) {\n var l1, l2, ref, ref1;\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n l1 = a.luminance();\n l2 = b.luminance();\n if (l1 > l2) {\n return (l1 + 0.05) / (l2 + 0.05);\n } else {\n return (l2 + 0.05) / (l1 + 0.05);\n }\n };\n\n chroma.distance = function(a, b, mode) {\n var d, i, l1, l2, ref, ref1, sum_sq;\n if (mode == null) {\n mode = 'lab';\n }\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n l1 = a.get(mode);\n l2 = b.get(mode);\n sum_sq = 0;\n for (i in l1) {\n d = (l1[i] || 0) - (l2[i] || 0);\n sum_sq += d * d;\n }\n return Math.sqrt(sum_sq);\n };\n\n chroma.deltaE = function(a, b, L, C) {\n var L1, L2, a1, a2, b1, b2, c1, c2, c4, dH2, delA, delB, delC, delL, f, h1, ref, ref1, ref2, ref3, sc, sh, sl, t, v1, v2, v3;\n if (L == null) {\n L = 1;\n }\n if (C == null) {\n C = 1;\n }\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n ref2 = a.lab(), L1 = ref2[0], a1 = ref2[1], b1 = ref2[2];\n ref3 = b.lab(), L2 = ref3[0], a2 = ref3[1], b2 = ref3[2];\n c1 = sqrt(a1 * a1 + b1 * b1);\n c2 = sqrt(a2 * a2 + b2 * b2);\n sl = L1 < 16.0 ? 0.511 : (0.040975 * L1) / (1.0 + 0.01765 * L1);\n sc = (0.0638 * c1) / (1.0 + 0.0131 * c1) + 0.638;\n h1 = c1 < 0.000001 ? 0.0 : (atan2(b1, a1) * 180.0) / PI;\n while (h1 < 0) {\n h1 += 360;\n }\n while (h1 >= 360) {\n h1 -= 360;\n }\n t = (h1 >= 164.0) && (h1 <= 345.0) ? 0.56 + abs(0.2 * cos((PI * (h1 + 168.0)) / 180.0)) : 0.36 + abs(0.4 * cos((PI * (h1 + 35.0)) / 180.0));\n c4 = c1 * c1 * c1 * c1;\n f = sqrt(c4 / (c4 + 1900.0));\n sh = sc * (f * t + 1.0 - f);\n delL = L1 - L2;\n delC = c1 - c2;\n delA = a1 - a2;\n delB = b1 - b2;\n dH2 = delA * delA + delB * delB - delC * delC;\n v1 = delL / (L * sl);\n v2 = delC / (C * sc);\n v3 = sh;\n return sqrt(v1 * v1 + v2 * v2 + (dH2 / (v3 * v3)));\n };\n\n Color.prototype.get = function(modechan) {\n var channel, i, me, mode, ref, src;\n me = this;\n ref = modechan.split('.'), mode = ref[0], channel = ref[1];\n src = me[mode]();\n if (channel) {\n i = mode.indexOf(channel);\n if (i > -1) {\n return src[i];\n } else {\n return console.warn('unknown channel ' + channel + ' in mode ' + mode);\n }\n } else {\n return src;\n }\n };\n\n Color.prototype.set = function(modechan, value) {\n var channel, i, me, mode, ref, src;\n me = this;\n ref = modechan.split('.'), mode = ref[0], channel = ref[1];\n if (channel) {\n src = me[mode]();\n i = mode.indexOf(channel);\n if (i > -1) {\n if (type(value) === 'string') {\n switch (value.charAt(0)) {\n case '+':\n src[i] += +value;\n break;\n case '-':\n src[i] += +value;\n break;\n case '*':\n src[i] *= +(value.substr(1));\n break;\n case '/':\n src[i] /= +(value.substr(1));\n break;\n default:\n src[i] = +value;\n }\n } else {\n src[i] = value;\n }\n } else {\n console.warn('unknown channel ' + channel + ' in mode ' + mode);\n }\n } else {\n src = value;\n }\n return chroma(src, mode).alpha(me.alpha());\n };\n\n Color.prototype.clipped = function() {\n return this._rgb._clipped || false;\n };\n\n Color.prototype.alpha = function(a) {\n if (arguments.length) {\n return chroma.rgb([this._rgb[0], this._rgb[1], this._rgb[2], a]);\n }\n return this._rgb[3];\n };\n\n Color.prototype.darken = function(amount) {\n var lab, me;\n if (amount == null) {\n amount = 1;\n }\n me = this;\n lab = me.lab();\n lab[0] -= LAB_CONSTANTS.Kn * amount;\n return chroma.lab(lab).alpha(me.alpha());\n };\n\n Color.prototype.brighten = function(amount) {\n if (amount == null) {\n amount = 1;\n }\n return this.darken(-amount);\n };\n\n Color.prototype.darker = Color.prototype.darken;\n\n Color.prototype.brighter = Color.prototype.brighten;\n\n Color.prototype.saturate = function(amount) {\n var lch, me;\n if (amount == null) {\n amount = 1;\n }\n me = this;\n lch = me.lch();\n lch[1] += amount * LAB_CONSTANTS.Kn;\n if (lch[1] < 0) {\n lch[1] = 0;\n }\n return chroma.lch(lch).alpha(me.alpha());\n };\n\n Color.prototype.desaturate = function(amount) {\n if (amount == null) {\n amount = 1;\n }\n return this.saturate(-amount);\n };\n\n Color.prototype.premultiply = function() {\n var a, rgb;\n rgb = this.rgb();\n a = this.alpha();\n return chroma(rgb[0] * a, rgb[1] * a, rgb[2] * a, a);\n };\n\n blend = function(bottom, top, mode) {\n if (!blend[mode]) {\n throw 'unknown blend mode ' + mode;\n }\n return blend[mode](bottom, top);\n };\n\n blend_f = function(f) {\n return function(bottom, top) {\n var c0, c1;\n c0 = chroma(top).rgb();\n c1 = chroma(bottom).rgb();\n return chroma(f(c0, c1), 'rgb');\n };\n };\n\n each = function(f) {\n return function(c0, c1) {\n var i, o, out;\n out = [];\n for (i = o = 0; o <= 3; i = ++o) {\n out[i] = f(c0[i], c1[i]);\n }\n return out;\n };\n };\n\n normal = function(a, b) {\n return a;\n };\n\n multiply = function(a, b) {\n return a * b / 255;\n };\n\n darken = function(a, b) {\n if (a > b) {\n return b;\n } else {\n return a;\n }\n };\n\n lighten = function(a, b) {\n if (a > b) {\n return a;\n } else {\n return b;\n }\n };\n\n screen = function(a, b) {\n return 255 * (1 - (1 - a / 255) * (1 - b / 255));\n };\n\n overlay = function(a, b) {\n if (b < 128) {\n return 2 * a * b / 255;\n } else {\n return 255 * (1 - 2 * (1 - a / 255) * (1 - b / 255));\n }\n };\n\n burn = function(a, b) {\n return 255 * (1 - (1 - b / 255) / (a / 255));\n };\n\n dodge = function(a, b) {\n if (a === 255) {\n return 255;\n }\n a = 255 * (b / 255) / (1 - a / 255);\n if (a > 255) {\n return 255;\n } else {\n return a;\n }\n };\n\n blend.normal = blend_f(each(normal));\n\n blend.multiply = blend_f(each(multiply));\n\n blend.screen = blend_f(each(screen));\n\n blend.overlay = blend_f(each(overlay));\n\n blend.darken = blend_f(each(darken));\n\n blend.lighten = blend_f(each(lighten));\n\n blend.dodge = blend_f(each(dodge));\n\n blend.burn = blend_f(each(burn));\n\n chroma.blend = blend;\n\n chroma.analyze = function(data) {\n var len, o, r, val;\n r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE * -1,\n sum: 0,\n values: [],\n count: 0\n };\n for (o = 0, len = data.length; o < len; o++) {\n val = data[o];\n if ((val != null) && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) {\n r.min = val;\n }\n if (val > r.max) {\n r.max = val;\n }\n r.count += 1;\n }\n }\n r.domain = [r.min, r.max];\n r.limits = function(mode, num) {\n return chroma.limits(r, mode, num);\n };\n return r;\n };\n\n chroma.scale = function(colors, positions) {\n var _classes, _colorCache, _colors, _correctLightness, _domain, _fixed, _gamma, _max, _min, _mode, _nacol, _out, _padding, _pos, _spread, _useCache, classifyValue, f, getClass, getColor, resetCache, setColors, tmap;\n _mode = 'rgb';\n _nacol = chroma('#ccc');\n _spread = 0;\n _fixed = false;\n _domain = [0, 1];\n _pos = [];\n _padding = [0, 0];\n _classes = false;\n _colors = [];\n _out = false;\n _min = 0;\n _max = 1;\n _correctLightness = false;\n _colorCache = {};\n _useCache = true;\n _gamma = 1;\n setColors = function(colors) {\n var c, col, o, ref, ref1, w;\n if (colors == null) {\n colors = ['#fff', '#000'];\n }\n if ((colors != null) && type(colors) === 'string' && (chroma.brewer != null)) {\n colors = chroma.brewer[colors] || chroma.brewer[colors.toLowerCase()] || colors;\n }\n if (type(colors) === 'array') {\n if (colors.length === 1) {\n colors = [colors[0], colors[0]];\n }\n colors = colors.slice(0);\n for (c = o = 0, ref = colors.length - 1; 0 <= ref ? o <= ref : o >= ref; c = 0 <= ref ? ++o : --o) {\n col = colors[c];\n if (type(col) === \"string\") {\n colors[c] = chroma(col);\n }\n }\n _pos.length = 0;\n for (c = w = 0, ref1 = colors.length - 1; 0 <= ref1 ? w <= ref1 : w >= ref1; c = 0 <= ref1 ? ++w : --w) {\n _pos.push(c / (colors.length - 1));\n }\n }\n resetCache();\n return _colors = colors;\n };\n getClass = function(value) {\n var i, n;\n if (_classes != null) {\n n = _classes.length - 1;\n i = 0;\n while (i < n && value >= _classes[i]) {\n i++;\n }\n return i - 1;\n }\n return 0;\n };\n tmap = function(t) {\n return t;\n };\n classifyValue = function(value) {\n var i, maxc, minc, n, val;\n val = value;\n if (_classes.length > 2) {\n n = _classes.length - 1;\n i = getClass(value);\n minc = _classes[0] + (_classes[1] - _classes[0]) * (0 + _spread * 0.5);\n maxc = _classes[n - 1] + (_classes[n] - _classes[n - 1]) * (1 - _spread * 0.5);\n val = _min + ((_classes[i] + (_classes[i + 1] - _classes[i]) * 0.5 - minc) / (maxc - minc)) * (_max - _min);\n }\n return val;\n };\n getColor = function(val, bypassMap) {\n var c, col, i, k, o, p, ref, t;\n if (bypassMap == null) {\n bypassMap = false;\n }\n if (isNaN(val) || val === null) {\n return _nacol;\n }\n if (!bypassMap) {\n if (_classes && _classes.length > 2) {\n c = getClass(val);\n t = c / (_classes.length - 2);\n } else if (_max !== _min) {\n t = (val - _min) / (_max - _min);\n } else {\n t = 1;\n }\n } else {\n t = val;\n }\n if (!bypassMap) {\n t = tmap(t);\n }\n if (_gamma !== 1) {\n t = pow(t, _gamma);\n }\n t = _padding[0] + (t * (1 - _padding[0] - _padding[1]));\n t = Math.min(1, Math.max(0, t));\n k = Math.floor(t * 10000);\n if (_useCache && _colorCache[k]) {\n col = _colorCache[k];\n } else {\n if (type(_colors) === 'array') {\n for (i = o = 0, ref = _pos.length - 1; 0 <= ref ? o <= ref : o >= ref; i = 0 <= ref ? ++o : --o) {\n p = _pos[i];\n if (t <= p) {\n col = _colors[i];\n break;\n }\n if (t >= p && i === _pos.length - 1) {\n col = _colors[i];\n break;\n }\n if (t > p && t < _pos[i + 1]) {\n t = (t - p) / (_pos[i + 1] - p);\n col = chroma.interpolate(_colors[i], _colors[i + 1], t, _mode);\n break;\n }\n }\n } else if (type(_colors) === 'function') {\n col = _colors(t);\n }\n if (_useCache) {\n _colorCache[k] = col;\n }\n }\n return col;\n };\n resetCache = function() {\n return _colorCache = {};\n };\n setColors(colors);\n f = function(v) {\n var c;\n c = chroma(getColor(v));\n if (_out && c[_out]) {\n return c[_out]();\n } else {\n return c;\n }\n };\n f.classes = function(classes) {\n var d;\n if (classes != null) {\n if (type(classes) === 'array') {\n _classes = classes;\n _domain = [classes[0], classes[classes.length - 1]];\n } else {\n d = chroma.analyze(_domain);\n if (classes === 0) {\n _classes = [d.min, d.max];\n } else {\n _classes = chroma.limits(d, 'e', classes);\n }\n }\n return f;\n }\n return _classes;\n };\n f.domain = function(domain) {\n var c, d, k, len, o, ref, w;\n if (!arguments.length) {\n return _domain;\n }\n _min = domain[0];\n _max = domain[domain.length - 1];\n _pos = [];\n k = _colors.length;\n if (domain.length === k && _min !== _max) {\n for (o = 0, len = domain.length; o < len; o++) {\n d = domain[o];\n _pos.push((d - _min) / (_max - _min));\n }\n } else {\n for (c = w = 0, ref = k - 1; 0 <= ref ? w <= ref : w >= ref; c = 0 <= ref ? ++w : --w) {\n _pos.push(c / (k - 1));\n }\n }\n _domain = [_min, _max];\n return f;\n };\n f.mode = function(_m) {\n if (!arguments.length) {\n return _mode;\n }\n _mode = _m;\n resetCache();\n return f;\n };\n f.range = function(colors, _pos) {\n setColors(colors, _pos);\n return f;\n };\n f.out = function(_o) {\n _out = _o;\n return f;\n };\n f.spread = function(val) {\n if (!arguments.length) {\n return _spread;\n }\n _spread = val;\n return f;\n };\n f.correctLightness = function(v) {\n if (v == null) {\n v = true;\n }\n _correctLightness = v;\n resetCache();\n if (_correctLightness) {\n tmap = function(t) {\n var L0, L1, L_actual, L_diff, L_ideal, max_iter, pol, t0, t1;\n L0 = getColor(0, true).lab()[0];\n L1 = getColor(1, true).lab()[0];\n pol = L0 > L1;\n L_actual = getColor(t, true).lab()[0];\n L_ideal = L0 + (L1 - L0) * t;\n L_diff = L_actual - L_ideal;\n t0 = 0;\n t1 = 1;\n max_iter = 20;\n while (Math.abs(L_diff) > 1e-2 && max_iter-- > 0) {\n (function() {\n if (pol) {\n L_diff *= -1;\n }\n if (L_diff < 0) {\n t0 = t;\n t += (t1 - t) * 0.5;\n } else {\n t1 = t;\n t += (t0 - t) * 0.5;\n }\n L_actual = getColor(t, true).lab()[0];\n return L_diff = L_actual - L_ideal;\n })();\n }\n return t;\n };\n } else {\n tmap = function(t) {\n return t;\n };\n }\n return f;\n };\n f.padding = function(p) {\n if (p != null) {\n if (type(p) === 'number') {\n p = [p, p];\n }\n _padding = p;\n return f;\n } else {\n return _padding;\n }\n };\n f.colors = function(numColors, out) {\n var dd, dm, i, o, ref, result, results, samples, w;\n if (arguments.length < 2) {\n out = 'hex';\n }\n result = [];\n if (arguments.length === 0) {\n result = _colors.slice(0);\n } else if (numColors === 1) {\n result = [f(0.5)];\n } else if (numColors > 1) {\n dm = _domain[0];\n dd = _domain[1] - dm;\n result = (function() {\n results = [];\n for (var o = 0; 0 <= numColors ? o < numColors : o > numColors; 0 <= numColors ? o++ : o--){ results.push(o); }\n return results;\n }).apply(this).map(function(i) {\n return f(dm + i / (numColors - 1) * dd);\n });\n } else {\n colors = [];\n samples = [];\n if (_classes && _classes.length > 2) {\n for (i = w = 1, ref = _classes.length; 1 <= ref ? w < ref : w > ref; i = 1 <= ref ? ++w : --w) {\n samples.push((_classes[i - 1] + _classes[i]) * 0.5);\n }\n } else {\n samples = _domain;\n }\n result = samples.map(function(v) {\n return f(v);\n });\n }\n if (chroma[out]) {\n result = result.map(function(c) {\n return c[out]();\n });\n }\n return result;\n };\n f.cache = function(c) {\n if (c != null) {\n _useCache = c;\n return f;\n } else {\n return _useCache;\n }\n };\n f.gamma = function(g) {\n if (g != null) {\n _gamma = g;\n return f;\n } else {\n return _gamma;\n }\n };\n f.nodata = function(d) {\n if (d != null) {\n _nacol = chroma(d);\n return f;\n } else {\n return _nacol;\n }\n };\n return f;\n };\n\n if (chroma.scales == null) {\n chroma.scales = {};\n }\n\n chroma.scales.cool = function() {\n return chroma.scale([chroma.hsl(180, 1, .9), chroma.hsl(250, .7, .4)]);\n };\n\n chroma.scales.hot = function() {\n return chroma.scale(['#000', '#f00', '#ff0', '#fff'], [0, .25, .75, 1]).mode('rgb');\n };\n\n chroma.analyze = function(data, key, filter) {\n var add, k, len, o, r, val, visit;\n r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE * -1,\n sum: 0,\n values: [],\n count: 0\n };\n if (filter == null) {\n filter = function() {\n return true;\n };\n }\n add = function(val) {\n if ((val != null) && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) {\n r.min = val;\n }\n if (val > r.max) {\n r.max = val;\n }\n r.count += 1;\n }\n };\n visit = function(val, k) {\n if (filter(val, k)) {\n if ((key != null) && type(key) === 'function') {\n return add(key(val));\n } else if ((key != null) && type(key) === 'string' || type(key) === 'number') {\n return add(val[key]);\n } else {\n return add(val);\n }\n }\n };\n if (type(data) === 'array') {\n for (o = 0, len = data.length; o < len; o++) {\n val = data[o];\n visit(val);\n }\n } else {\n for (k in data) {\n val = data[k];\n visit(val, k);\n }\n }\n r.domain = [r.min, r.max];\n r.limits = function(mode, num) {\n return chroma.limits(r, mode, num);\n };\n return r;\n };\n\n chroma.limits = function(data, mode, num) {\n var aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, assignments, best, centroids, cluster, clusterSizes, dist, i, j, kClusters, limits, max_log, min, min_log, mindist, n, nb_iters, newCentroids, o, p, pb, pr, ref, ref1, ref10, ref11, ref12, ref13, ref14, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, repeat, sum, tmpKMeansBreaks, v, value, values, w;\n if (mode == null) {\n mode = 'equal';\n }\n if (num == null) {\n num = 7;\n }\n if (type(data) === 'array') {\n data = chroma.analyze(data);\n }\n min = data.min;\n max = data.max;\n sum = data.sum;\n values = data.values.sort(function(a, b) {\n return a - b;\n });\n if (num === 1) {\n return [min, max];\n }\n limits = [];\n if (mode.substr(0, 1) === 'c') {\n limits.push(min);\n limits.push(max);\n }\n if (mode.substr(0, 1) === 'e') {\n limits.push(min);\n for (i = o = 1, ref = num - 1; 1 <= ref ? o <= ref : o >= ref; i = 1 <= ref ? ++o : --o) {\n limits.push(min + (i / num) * (max - min));\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'l') {\n if (min <= 0) {\n throw 'Logarithmic scales are only possible for values > 0';\n }\n min_log = Math.LOG10E * log(min);\n max_log = Math.LOG10E * log(max);\n limits.push(min);\n for (i = w = 1, ref1 = num - 1; 1 <= ref1 ? w <= ref1 : w >= ref1; i = 1 <= ref1 ? ++w : --w) {\n limits.push(pow(10, min_log + (i / num) * (max_log - min_log)));\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'q') {\n limits.push(min);\n for (i = aa = 1, ref2 = num - 1; 1 <= ref2 ? aa <= ref2 : aa >= ref2; i = 1 <= ref2 ? ++aa : --aa) {\n p = (values.length - 1) * i / num;\n pb = floor(p);\n if (pb === p) {\n limits.push(values[pb]);\n } else {\n pr = p - pb;\n limits.push(values[pb] * (1 - pr) + values[pb + 1] * pr);\n }\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'k') {\n\n /*\n implementation based on\n http://code.google.com/p/figue/source/browse/trunk/figue.js#336\n simplified for 1-d input values\n */\n n = values.length;\n assignments = new Array(n);\n clusterSizes = new Array(num);\n repeat = true;\n nb_iters = 0;\n centroids = null;\n centroids = [];\n centroids.push(min);\n for (i = ab = 1, ref3 = num - 1; 1 <= ref3 ? ab <= ref3 : ab >= ref3; i = 1 <= ref3 ? ++ab : --ab) {\n centroids.push(min + (i / num) * (max - min));\n }\n centroids.push(max);\n while (repeat) {\n for (j = ac = 0, ref4 = num - 1; 0 <= ref4 ? ac <= ref4 : ac >= ref4; j = 0 <= ref4 ? ++ac : --ac) {\n clusterSizes[j] = 0;\n }\n for (i = ad = 0, ref5 = n - 1; 0 <= ref5 ? ad <= ref5 : ad >= ref5; i = 0 <= ref5 ? ++ad : --ad) {\n value = values[i];\n mindist = Number.MAX_VALUE;\n for (j = ae = 0, ref6 = num - 1; 0 <= ref6 ? ae <= ref6 : ae >= ref6; j = 0 <= ref6 ? ++ae : --ae) {\n dist = abs(centroids[j] - value);\n if (dist < mindist) {\n mindist = dist;\n best = j;\n }\n }\n clusterSizes[best]++;\n assignments[i] = best;\n }\n newCentroids = new Array(num);\n for (j = af = 0, ref7 = num - 1; 0 <= ref7 ? af <= ref7 : af >= ref7; j = 0 <= ref7 ? ++af : --af) {\n newCentroids[j] = null;\n }\n for (i = ag = 0, ref8 = n - 1; 0 <= ref8 ? ag <= ref8 : ag >= ref8; i = 0 <= ref8 ? ++ag : --ag) {\n cluster = assignments[i];\n if (newCentroids[cluster] === null) {\n newCentroids[cluster] = values[i];\n } else {\n newCentroids[cluster] += values[i];\n }\n }\n for (j = ah = 0, ref9 = num - 1; 0 <= ref9 ? ah <= ref9 : ah >= ref9; j = 0 <= ref9 ? ++ah : --ah) {\n newCentroids[j] *= 1 / clusterSizes[j];\n }\n repeat = false;\n for (j = ai = 0, ref10 = num - 1; 0 <= ref10 ? ai <= ref10 : ai >= ref10; j = 0 <= ref10 ? ++ai : --ai) {\n if (newCentroids[j] !== centroids[i]) {\n repeat = true;\n break;\n }\n }\n centroids = newCentroids;\n nb_iters++;\n if (nb_iters > 200) {\n repeat = false;\n }\n }\n kClusters = {};\n for (j = aj = 0, ref11 = num - 1; 0 <= ref11 ? aj <= ref11 : aj >= ref11; j = 0 <= ref11 ? ++aj : --aj) {\n kClusters[j] = [];\n }\n for (i = ak = 0, ref12 = n - 1; 0 <= ref12 ? ak <= ref12 : ak >= ref12; i = 0 <= ref12 ? ++ak : --ak) {\n cluster = assignments[i];\n kClusters[cluster].push(values[i]);\n }\n tmpKMeansBreaks = [];\n for (j = al = 0, ref13 = num - 1; 0 <= ref13 ? al <= ref13 : al >= ref13; j = 0 <= ref13 ? ++al : --al) {\n tmpKMeansBreaks.push(kClusters[j][0]);\n tmpKMeansBreaks.push(kClusters[j][kClusters[j].length - 1]);\n }\n tmpKMeansBreaks = tmpKMeansBreaks.sort(function(a, b) {\n return a - b;\n });\n limits.push(tmpKMeansBreaks[0]);\n for (i = am = 1, ref14 = tmpKMeansBreaks.length - 1; am <= ref14; i = am += 2) {\n v = tmpKMeansBreaks[i];\n if (!isNaN(v) && limits.indexOf(v) === -1) {\n limits.push(v);\n }\n }\n }\n return limits;\n };\n\n hsi2rgb = function(h, s, i) {\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp\n */\n var args, b, g, r;\n args = unpack(arguments);\n h = args[0], s = args[1], i = args[2];\n if (isNaN(h)) {\n h = 0;\n }\n h /= 360;\n if (h < 1 / 3) {\n b = (1 - s) / 3;\n r = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n g = 1 - (b + r);\n } else if (h < 2 / 3) {\n h -= 1 / 3;\n r = (1 - s) / 3;\n g = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n b = 1 - (r + g);\n } else {\n h -= 2 / 3;\n g = (1 - s) / 3;\n b = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n r = 1 - (g + b);\n }\n r = limit(i * r * 3);\n g = limit(i * g * 3);\n b = limit(i * b * 3);\n return [r * 255, g * 255, b * 255, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hsi = function() {\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/rgb2hsi.cpp\n */\n var b, g, h, i, min, r, ref, s;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n TWOPI = Math.PI * 2;\n r /= 255;\n g /= 255;\n b /= 255;\n min = Math.min(r, g, b);\n i = (r + g + b) / 3;\n s = 1 - min / i;\n if (s === 0) {\n h = 0;\n } else {\n h = ((r - g) + (r - b)) / 2;\n h /= Math.sqrt((r - g) * (r - g) + (r - b) * (g - b));\n h = Math.acos(h);\n if (b > g) {\n h = TWOPI - h;\n }\n h /= TWOPI;\n }\n return [h * 360, s, i];\n };\n\n chroma.hsi = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsi']), function(){});\n };\n\n _input.hsi = hsi2rgb;\n\n Color.prototype.hsi = function() {\n return rgb2hsi(this._rgb);\n };\n\n interpolate_hsx = function(col1, col2, f, m) {\n var dh, hue, hue0, hue1, lbv, lbv0, lbv1, res, sat, sat0, sat1, xyz0, xyz1;\n if (m === 'hsl') {\n xyz0 = col1.hsl();\n xyz1 = col2.hsl();\n } else if (m === 'hsv') {\n xyz0 = col1.hsv();\n xyz1 = col2.hsv();\n } else if (m === 'hcg') {\n xyz0 = col1.hcg();\n xyz1 = col2.hcg();\n } else if (m === 'hsi') {\n xyz0 = col1.hsi();\n xyz1 = col2.hsi();\n } else if (m === 'lch' || m === 'hcl') {\n m = 'hcl';\n xyz0 = col1.hcl();\n xyz1 = col2.hcl();\n }\n if (m.substr(0, 1) === 'h') {\n hue0 = xyz0[0], sat0 = xyz0[1], lbv0 = xyz0[2];\n hue1 = xyz1[0], sat1 = xyz1[1], lbv1 = xyz1[2];\n }\n if (!isNaN(hue0) && !isNaN(hue1)) {\n if (hue1 > hue0 && hue1 - hue0 > 180) {\n dh = hue1 - (hue0 + 360);\n } else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh = hue1 + 360 - hue0;\n } else {\n dh = hue1 - hue0;\n }\n hue = hue0 + f * dh;\n } else if (!isNaN(hue0)) {\n hue = hue0;\n if ((lbv1 === 1 || lbv1 === 0) && m !== 'hsv') {\n sat = sat0;\n }\n } else if (!isNaN(hue1)) {\n hue = hue1;\n if ((lbv0 === 1 || lbv0 === 0) && m !== 'hsv') {\n sat = sat1;\n }\n } else {\n hue = Number.NaN;\n }\n if (sat == null) {\n sat = sat0 + f * (sat1 - sat0);\n }\n lbv = lbv0 + f * (lbv1 - lbv0);\n return res = chroma[m](hue, sat, lbv);\n };\n\n _interpolators = _interpolators.concat((function() {\n var len, o, ref, results;\n ref = ['hsv', 'hsl', 'hsi', 'hcl', 'lch', 'hcg'];\n results = [];\n for (o = 0, len = ref.length; o < len; o++) {\n m = ref[o];\n results.push([m, interpolate_hsx]);\n }\n return results;\n })());\n\n interpolate_num = function(col1, col2, f, m) {\n var n1, n2;\n n1 = col1.num();\n n2 = col2.num();\n return chroma.num(n1 + (n2 - n1) * f, 'num');\n };\n\n _interpolators.push(['num', interpolate_num]);\n\n interpolate_lab = function(col1, col2, f, m) {\n var res, xyz0, xyz1;\n xyz0 = col1.lab();\n xyz1 = col2.lab();\n return res = new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);\n };\n\n _interpolators.push(['lab', interpolate_lab]);\n\n}).call(this);\n","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */\n/*global define:false, require:false, exports:false, module:false, signals:false */\n\n/** @license\n * JS Signals \n * Released under the MIT license\n * Author: Miller Medeiros\n * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM)\n */\n\n(function(global){\n\n // SignalBinding -------------------------------------------------\n //================================================================\n\n /**\n * Object that represents a binding between a Signal and a listener function.\n *
- This is an internal constructor and shouldn't be called by regular users.\n *
- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.\n * @author Miller Medeiros\n * @constructor\n * @internal\n * @name SignalBinding\n * @param {Signal} signal Reference to Signal object that listener is currently bound to.\n * @param {Function} listener Handler function bound to the signal.\n * @param {boolean} isOnce If binding should be executed just once.\n * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @param {Number} [priority] The priority level of the event listener. (default = 0).\n */\n function SignalBinding(signal, listener, isOnce, listenerContext, priority) {\n\n /**\n * Handler function bound to the signal.\n * @type Function\n * @private\n */\n this._listener = listener;\n\n /**\n * If binding should be executed just once.\n * @type boolean\n * @private\n */\n this._isOnce = isOnce;\n\n /**\n * Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @memberOf SignalBinding.prototype\n * @name context\n * @type Object|undefined|null\n */\n this.context = listenerContext;\n\n /**\n * Reference to Signal object that listener is currently bound to.\n * @type Signal\n * @private\n */\n this._signal = signal;\n\n /**\n * Listener priority\n * @type Number\n * @private\n */\n this._priority = priority || 0;\n }\n\n SignalBinding.prototype = {\n\n /**\n * If binding is active and should be executed.\n * @type boolean\n */\n active : true,\n\n /**\n * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)\n * @type Array|null\n */\n params : null,\n\n /**\n * Call listener passing arbitrary parameters.\n *

If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

\n * @param {Array} [paramsArr] Array of parameters that should be passed to the listener\n * @return {*} Value returned by the listener.\n */\n execute : function (paramsArr) {\n var handlerReturn, params;\n if (this.active && !!this._listener) {\n params = this.params? this.params.concat(paramsArr) : paramsArr;\n handlerReturn = this._listener.apply(this.context, params);\n if (this._isOnce) {\n this.detach();\n }\n }\n return handlerReturn;\n },\n\n /**\n * Detach binding from signal.\n * - alias to: mySignal.remove(myBinding.getListener());\n * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.\n */\n detach : function () {\n return this.isBound()? this._signal.remove(this._listener, this.context) : null;\n },\n\n /**\n * @return {Boolean} `true` if binding is still bound to the signal and have a listener.\n */\n isBound : function () {\n return (!!this._signal && !!this._listener);\n },\n\n /**\n * @return {boolean} If SignalBinding will only be executed once.\n */\n isOnce : function () {\n return this._isOnce;\n },\n\n /**\n * @return {Function} Handler function bound to the signal.\n */\n getListener : function () {\n return this._listener;\n },\n\n /**\n * @return {Signal} Signal that listener is currently bound to.\n */\n getSignal : function () {\n return this._signal;\n },\n\n /**\n * Delete instance properties\n * @private\n */\n _destroy : function () {\n delete this._signal;\n delete this._listener;\n delete this.context;\n },\n\n /**\n * @return {string} String representation of the object.\n */\n toString : function () {\n return '[SignalBinding isOnce:' + this._isOnce +', isBound:'+ this.isBound() +', active:' + this.active + ']';\n }\n\n };\n\n\n/*global SignalBinding:false*/\n\n // Signal --------------------------------------------------------\n //================================================================\n\n function validateListener(listener, fnName) {\n if (typeof listener !== 'function') {\n throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) );\n }\n }\n\n /**\n * Custom event broadcaster\n *
- inspired by Robert Penner's AS3 Signals.\n * @name Signal\n * @author Miller Medeiros\n * @constructor\n */\n function Signal() {\n /**\n * @type Array.\n * @private\n */\n this._bindings = [];\n this._prevParams = null;\n\n // enforce dispatch to aways work on same context (#47)\n var self = this;\n this.dispatch = function(){\n Signal.prototype.dispatch.apply(self, arguments);\n };\n }\n\n Signal.prototype = {\n\n /**\n * Signals Version Number\n * @type String\n * @const\n */\n VERSION : '1.0.0',\n\n /**\n * If Signal should keep record of previously dispatched parameters and\n * automatically execute listener during `add()`/`addOnce()` if Signal was\n * already dispatched before.\n * @type boolean\n */\n memorize : false,\n\n /**\n * @type boolean\n * @private\n */\n _shouldPropagate : true,\n\n /**\n * If Signal is active and should broadcast events.\n *

IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

\n * @type boolean\n */\n active : true,\n\n /**\n * @param {Function} listener\n * @param {boolean} isOnce\n * @param {Object} [listenerContext]\n * @param {Number} [priority]\n * @return {SignalBinding}\n * @private\n */\n _registerListener : function (listener, isOnce, listenerContext, priority) {\n\n var prevIndex = this._indexOfListener(listener, listenerContext),\n binding;\n\n if (prevIndex !== -1) {\n binding = this._bindings[prevIndex];\n if (binding.isOnce() !== isOnce) {\n throw new Error('You cannot add'+ (isOnce? '' : 'Once') +'() then add'+ (!isOnce? '' : 'Once') +'() the same listener without removing the relationship first.');\n }\n } else {\n binding = new SignalBinding(this, listener, isOnce, listenerContext, priority);\n this._addBinding(binding);\n }\n\n if(this.memorize && this._prevParams){\n binding.execute(this._prevParams);\n }\n\n return binding;\n },\n\n /**\n * @param {SignalBinding} binding\n * @private\n */\n _addBinding : function (binding) {\n //simplified insertion sort\n var n = this._bindings.length;\n do { --n; } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);\n this._bindings.splice(n + 1, 0, binding);\n },\n\n /**\n * @param {Function} listener\n * @return {number}\n * @private\n */\n _indexOfListener : function (listener, context) {\n var n = this._bindings.length,\n cur;\n while (n--) {\n cur = this._bindings[n];\n if (cur._listener === listener && cur.context === context) {\n return n;\n }\n }\n return -1;\n },\n\n /**\n * Check if listener was attached to Signal.\n * @param {Function} listener\n * @param {Object} [context]\n * @return {boolean} if Signal has the specified listener.\n */\n has : function (listener, context) {\n return this._indexOfListener(listener, context) !== -1;\n },\n\n /**\n * Add a listener to the signal.\n * @param {Function} listener Signal handler function.\n * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)\n * @return {SignalBinding} An Object representing the binding between the Signal and listener.\n */\n add : function (listener, listenerContext, priority) {\n validateListener(listener, 'add');\n return this._registerListener(listener, false, listenerContext, priority);\n },\n\n /**\n * Add listener to the signal that should be removed after first execution (will be executed only once).\n * @param {Function} listener Signal handler function.\n * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)\n * @return {SignalBinding} An Object representing the binding between the Signal and listener.\n */\n addOnce : function (listener, listenerContext, priority) {\n validateListener(listener, 'addOnce');\n return this._registerListener(listener, true, listenerContext, priority);\n },\n\n /**\n * Remove a single listener from the dispatch queue.\n * @param {Function} listener Handler function that should be removed.\n * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).\n * @return {Function} Listener handler function.\n */\n remove : function (listener, context) {\n validateListener(listener, 'remove');\n\n var i = this._indexOfListener(listener, context);\n if (i !== -1) {\n this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal\n this._bindings.splice(i, 1);\n }\n return listener;\n },\n\n /**\n * Remove all listeners from the Signal.\n */\n removeAll : function () {\n var n = this._bindings.length;\n while (n--) {\n this._bindings[n]._destroy();\n }\n this._bindings.length = 0;\n },\n\n /**\n * @return {number} Number of listeners attached to the Signal.\n */\n getNumListeners : function () {\n return this._bindings.length;\n },\n\n /**\n * Stop propagation of the event, blocking the dispatch to next listeners on the queue.\n *

IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

\n * @see Signal.prototype.disable\n */\n halt : function () {\n this._shouldPropagate = false;\n },\n\n /**\n * Dispatch/Broadcast Signal to all listeners added to the queue.\n * @param {...*} [params] Parameters that should be passed to each handler.\n */\n dispatch : function (params) {\n if (! this.active) {\n return;\n }\n\n var paramsArr = Array.prototype.slice.call(arguments),\n n = this._bindings.length,\n bindings;\n\n if (this.memorize) {\n this._prevParams = paramsArr;\n }\n\n if (! n) {\n //should come after memorize\n return;\n }\n\n bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch\n this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch.\n\n //execute all callbacks until end of the list or until a callback returns `false` or stops propagation\n //reverse loop since listeners with higher priority will be added at the end of the list\n do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);\n },\n\n /**\n * Forget memorized arguments.\n * @see Signal.memorize\n */\n forget : function(){\n this._prevParams = null;\n },\n\n /**\n * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).\n *

IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

\n */\n dispose : function () {\n this.removeAll();\n delete this._bindings;\n delete this._prevParams;\n },\n\n /**\n * @return {string} String representation of the object.\n */\n toString : function () {\n return '[Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']';\n }\n\n };\n\n\n // Namespace -----------------------------------------------------\n //================================================================\n\n /**\n * Signals namespace\n * @namespace\n * @name signals\n */\n var signals = Signal;\n\n /**\n * Custom event broadcaster\n * @see Signal\n */\n // alias for backwards compatibility (see #gh-44)\n signals.Signal = Signal;\n\n\n\n //exports to multiple environments\n if(typeof define === 'function' && define.amd){ //AMD\n define(function () { return signals; });\n } else if (typeof module !== 'undefined' && module.exports){ //node\n module.exports = signals;\n } else { //browser\n //use string because of Google closure compiler ADVANCED_MODE\n /*jslint sub:true */\n global['signals'] = signals;\n }\n\n}(this));\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/* global window, exports, define */\n\n!function() {\n 'use strict'\n\n var re = {\n not_string: /[^s]/,\n not_bool: /[^t]/,\n not_type: /[^T]/,\n not_primitive: /[^v]/,\n number: /[diefg]/,\n numeric_arg: /[bcdiefguxX]/,\n json: /[j]/,\n not_json: /[^j]/,\n text: /^[^\\x25]+/,\n modulo: /^\\x25{2}/,\n placeholder: /^\\x25(?:([1-9]\\d*)\\$|\\(([^)]+)\\))?(\\+)?(0|'[^$])?(-)?(\\d+)?(?:\\.(\\d+))?([b-gijostTuvxX])/,\n key: /^([a-z_][a-z_\\d]*)/i,\n key_access: /^\\.([a-z_][a-z_\\d]*)/i,\n index_access: /^\\[(\\d+)\\]/,\n sign: /^[+-]/\n }\n\n function sprintf(key) {\n // `arguments` is not an array, but should be fine for this call\n return sprintf_format(sprintf_parse(key), arguments)\n }\n\n function vsprintf(fmt, argv) {\n return sprintf.apply(null, [fmt].concat(argv || []))\n }\n\n function sprintf_format(parse_tree, argv) {\n var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign\n for (i = 0; i < tree_length; i++) {\n if (typeof parse_tree[i] === 'string') {\n output += parse_tree[i]\n }\n else if (typeof parse_tree[i] === 'object') {\n ph = parse_tree[i] // convenience purposes only\n if (ph.keys) { // keyword argument\n arg = argv[cursor]\n for (k = 0; k < ph.keys.length; k++) {\n if (arg == undefined) {\n throw new Error(sprintf('[sprintf] Cannot access property \"%s\" of undefined value \"%s\"', ph.keys[k], ph.keys[k-1]))\n }\n arg = arg[ph.keys[k]]\n }\n }\n else if (ph.param_no) { // positional argument (explicit)\n arg = argv[ph.param_no]\n }\n else { // positional argument (implicit)\n arg = argv[cursor++]\n }\n\n if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {\n arg = arg()\n }\n\n if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {\n throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))\n }\n\n if (re.number.test(ph.type)) {\n is_positive = arg >= 0\n }\n\n switch (ph.type) {\n case 'b':\n arg = parseInt(arg, 10).toString(2)\n break\n case 'c':\n arg = String.fromCharCode(parseInt(arg, 10))\n break\n case 'd':\n case 'i':\n arg = parseInt(arg, 10)\n break\n case 'j':\n arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)\n break\n case 'e':\n arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential()\n break\n case 'f':\n arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg)\n break\n case 'g':\n arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg)\n break\n case 'o':\n arg = (parseInt(arg, 10) >>> 0).toString(8)\n break\n case 's':\n arg = String(arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 't':\n arg = String(!!arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'T':\n arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'u':\n arg = parseInt(arg, 10) >>> 0\n break\n case 'v':\n arg = arg.valueOf()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'x':\n arg = (parseInt(arg, 10) >>> 0).toString(16)\n break\n case 'X':\n arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()\n break\n }\n if (re.json.test(ph.type)) {\n output += arg\n }\n else {\n if (re.number.test(ph.type) && (!is_positive || ph.sign)) {\n sign = is_positive ? '+' : '-'\n arg = arg.toString().replace(re.sign, '')\n }\n else {\n sign = ''\n }\n pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '\n pad_length = ph.width - (sign + arg).length\n pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''\n output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)\n }\n }\n }\n return output\n }\n\n var sprintf_cache = Object.create(null)\n\n function sprintf_parse(fmt) {\n if (sprintf_cache[fmt]) {\n return sprintf_cache[fmt]\n }\n\n var _fmt = fmt, match, parse_tree = [], arg_names = 0\n while (_fmt) {\n if ((match = re.text.exec(_fmt)) !== null) {\n parse_tree.push(match[0])\n }\n else if ((match = re.modulo.exec(_fmt)) !== null) {\n parse_tree.push('%')\n }\n else if ((match = re.placeholder.exec(_fmt)) !== null) {\n if (match[2]) {\n arg_names |= 1\n var field_list = [], replacement_field = match[2], field_match = []\n if ((field_match = re.key.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {\n if ((field_match = re.key_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else if ((field_match = re.index_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n }\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n match[2] = field_list\n }\n else {\n arg_names |= 2\n }\n if (arg_names === 3) {\n throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')\n }\n\n parse_tree.push(\n {\n placeholder: match[0],\n param_no: match[1],\n keys: match[2],\n sign: match[3],\n pad_char: match[4],\n align: match[5],\n width: match[6],\n precision: match[7],\n type: match[8]\n }\n )\n }\n else {\n throw new SyntaxError('[sprintf] unexpected placeholder')\n }\n _fmt = _fmt.substring(match[0].length)\n }\n return sprintf_cache[fmt] = parse_tree\n }\n\n /**\n * export to either browser or node.js\n */\n /* eslint-disable quote-props */\n if (typeof exports !== 'undefined') {\n exports['sprintf'] = sprintf\n exports['vsprintf'] = vsprintf\n }\n if (typeof window !== 'undefined') {\n window['sprintf'] = sprintf\n window['vsprintf'] = vsprintf\n\n if (typeof define === 'function' && define['amd']) {\n define(function() {\n return {\n 'sprintf': sprintf,\n 'vsprintf': vsprintf\n }\n })\n }\n }\n /* eslint-enable quote-props */\n}(); // eslint-disable-line\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] === undefined) continue\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#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+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure) {\n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false) {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n const bonds = r.getBonds()\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const nn = atomIndices1.length\n\n for (let i = 0; i < nn; ++i) {\n const rai1 = atomIndices1[ i ]\n const rai2 = atomIndices2[ i ]\n const ai1 = rai1 + offset\n const ai2 = rai2 + offset\n const tmp = atomBondMap[ ai1 ]\n if (tmp !== undefined && tmp[ ai2 ] !== undefined) {\n bp.index = tmp[ ai2 ]\n const residueTypeBondIndex = r.residueType.getBondIndex(rai1, rai2)! // TODO\n // overwrite residueType bondOrder with value from existing bond\n bondOrders[ residueTypeBondIndex ] = bp.bondOrder\n } else {\n a1.index = ai1\n a2.index = ai2\n // only add bond if not already in bondStore\n bondStore.addBond(a1, a2, bondOrders[ i ])\n }\n }\n }\n\n // get RNA/DNA rung pseudo bonds\n const traceAtomIndex = r.residueType.traceAtomIndex\n const rungEndAtomIndex = r.residueType.rungEndAtomIndex\n if (traceAtomIndex !== -1 && rungEndAtomIndex !== -1) {\n a1.index = r.traceAtomIndex\n a2.index = r.rungEndAtomIndex\n rungBondStore.addBond(a1, a2)\n rungAtomSet.set(a1.index)\n rungAtomSet.set(a2.index)\n }\n })\n\n structure.atomSetDict.rung = rungAtomSet\n\n if (Debug) Log.timeEnd('calculateBondsWithin')\n}\n\nexport function calculateBondsBetween (structure: Structure, onlyAddBackbone = false, useExistingBonds = false) {\n if (Debug) Log.time('calculateBondsBetween')\n\n const bondStore = structure.bondStore\n const backboneBondStore = structure.backboneBondStore\n const backboneAtomSet = structure.getAtomSet(false)\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n if (backboneBondStore.count === 0) {\n backboneBondStore.resize(structure.residueStore.count)\n }\n\n function addBondIfConnected (rp1: ResidueProxy, rp2: ResidueProxy) {\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if ((useExistingBonds && ap1.hasBondTo(ap2)) || ap1.connectedTo(ap2)) {\n if (!onlyAddBackbone) {\n bondStore.addBond(ap1, ap2, 1) // assume single bond\n }\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n backboneBondStore.addBond(ap1, ap2)\n backboneAtomSet.set(ap1.index)\n backboneAtomSet.set(ap2.index)\n }\n }\n }\n\n structure.eachResidueN(2, addBondIfConnected)\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n\n // check for cyclic chains\n structure.eachChain(function (cp) {\n if (cp.residueCount === 0) return\n rp1.index = cp.residueOffset\n rp2.index = cp.residueOffset + cp.residueCount - 1\n addBondIfConnected(rp2, rp1)\n })\n\n structure.atomSetDict.backbone = backboneAtomSet\n\n if (!onlyAddBackbone) {\n if (Debug) Log.time('calculateBondsBetween inter')\n const spatialHash = structure.spatialHash\n structure.eachResidue(function (rp) {\n if (rp.backboneType === UnknownBackboneType && !rp.isWater()) {\n rp.eachAtom(function (ap) {\n if (ap.isMetal()) return\n spatialHash!.eachWithin(ap.x, ap.y, ap.z, 4, function (idx) { // TODO\n ap2.index = idx\n if (ap.modelIndex === ap2.modelIndex &&\n ap.residueIndex !== ap2.residueIndex &&\n !ap2.isMetal()\n ) {\n bondStore.addBondIfConnected(ap, ap2, 1) // assume single bond\n }\n })\n })\n }\n })\n if (Debug) Log.timeEnd('calculateBondsBetween inter')\n }\n\n if (Debug) Log.timeEnd('calculateBondsBetween')\n}\n\nexport function buildUnitcellAssembly (structure: Structure) {\n if (!structure.unitcell) return\n\n if (Debug) Log.time('buildUnitcellAssembly')\n\n const uc = structure.unitcell\n\n const structureCenterFrac = structure.center.clone().applyMatrix4(uc.cartToFrac)\n const centerFrac = structureCenterFrac.clone().floor()\n const symopDict: { [K: string]: Matrix4 } = getSymmetryOperations(uc.spacegroup)\n\n const centerFracSymop = new Vector3()\n const positionFracSymop = new Vector3()\n\n function getMatrixList (shift?: Vector3) {\n const matrixList: Matrix4[] = []\n\n Object.keys(symopDict).forEach(function (name) {\n const m = symopDict[ name ].clone()\n\n centerFracSymop.copy(structureCenterFrac).applyMatrix4(m).floor()\n positionFracSymop.setFromMatrixPosition(m)\n positionFracSymop.sub(centerFracSymop)\n positionFracSymop.add(centerFrac)\n\n if (shift) positionFracSymop.add(shift)\n\n m.setPosition(positionFracSymop)\n m.multiplyMatrices(uc.fracToCart, m)\n m.multiply(uc.cartToFrac)\n\n matrixList.push(m)\n })\n\n return matrixList\n }\n\n const unitcellAssembly = new Assembly('UNITCELL')\n const unitcellMatrixList = getMatrixList()\n const ncsMatrixList: Matrix4[] = []\n if (structure.biomolDict.NCS) {\n ncsMatrixList.push(\n new Matrix4(), ...structure.biomolDict.NCS.partList[ 0 ].matrixList\n )\n const ncsUnitcellMatrixList: Matrix4[] = []\n unitcellMatrixList.forEach(sm => {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n}\n\nclass PdbParser extends StructureParser {\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: number, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H') ? 1 : 0\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, 0, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, 1)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, 1)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file ngl\n * @private\n * @author Alexander Rose \n */\n\nimport './polyfills'\nimport _Promise from 'promise-polyfill'\n\n/**\n * The NGL module. These members are available in the `NGL` namespace when using the {@link https://github.com/umdjs/umd|UMD} build in the `ngl.js` file.\n * @module NGL\n */\n\nexport {\n Debug, setDebug,\n MeasurementDefaultParams, setMeasurementDefaultParams,\n ScriptExtensions, ColormakerRegistry,\n DatasourceRegistry, DecompressorRegistry,\n ParserRegistry, RepresentationRegistry,\n setListingDatasource, setTrajectoryDatasource,\n ListingDatasource, TrajectoryDatasource\n} from './globals'\nexport { autoLoad, getDataInfo, getFileInfo } from './loader/loader-utils'\nimport Selection from './selection/selection'\nimport PdbWriter from './writer/pdb-writer'\nimport SdfWriter from './writer/sdf-writer'\nimport StlWriter from './writer/stl-writer'\nimport Stage from './stage/stage'\nimport Viewer from './viewer/viewer'\nimport Collection from './component/collection'\nimport ComponentCollection from './component/component-collection'\nimport Component from './component/component'\nimport ShapeComponent from './component/shape-component'\nimport StructureComponent, {StructureRepresentationType} from './component/structure-component'\nimport SurfaceComponent from './component/surface-component'\nimport VolumeComponent, {VolumeRepresentationType} from './component/volume-component'\nimport RepresentationCollection from './component/representation-collection'\nimport RepresentationElement from './component/representation-element'\nimport Assembly from './symmetry/assembly'\nimport TrajectoryPlayer from './trajectory/trajectory-player'\nimport Superposition from './align/superposition'\nexport { superpose } from './align/align-utils'\nexport { guessElement, concatStructures } from './structure/structure-utils'\n\nexport { flatten, throttle, download, getQuery, uniqueArray } from './utils'\nimport Queue from './utils/queue'\nimport Counter from './utils/counter'\nimport Frames from './trajectory/frames'\n\n//\n\nimport Colormaker from './color/colormaker'\n\nimport './color/atomindex-colormaker'\nimport './color/bfactor-colormaker'\nimport './color/chainid-colormaker'\nimport './color/chainindex-colormaker'\nimport './color/chainname-colormaker'\nimport './color/densityfit-colormaker'\nimport './color/electrostatic-colormaker'\nimport './color/element-colormaker'\nimport './color/entityindex-colormaker'\nimport './color/entitytype-colormaker'\nimport './color/geoquality-colormaker'\nimport './color/hydrophobicity-colormaker'\nimport './color/modelindex-colormaker'\nimport './color/moleculetype-colormaker'\nimport './color/occupancy-colormaker'\nimport './color/partialcharge-colormaker'\nimport './color/random-colormaker'\nimport './color/randomcoilindex-colormaker'\nimport './color/residueindex-colormaker'\nimport './color/resname-colormaker'\nimport './color/sstruc-colormaker'\nimport './color/structuredata-colormaker'\nimport './color/uniform-colormaker'\nimport './color/value-colormaker'\nimport './color/volume-colormaker'\n\n//\n\nimport './component/shape-component'\nimport './component/structure-component'\nimport './component/surface-component'\nimport './component/volume-component'\n\n//\n\nimport AngleRepresentation, {AngleRepresentationParameters} from './representation/angle-representation'\nimport AxesRepresentation, {AxesRepresentationParameters} from './representation/axes-representation'\nimport BackboneRepresentation from './representation/backbone-representation'\nimport BallAndStickRepresentation, {BallAndStickRepresentationParameters} from './representation/ballandstick-representation'\nimport BaseRepresentation from './representation/base-representation'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './representation/cartoon-representation'\nimport ContactRepresentation, {ContactRepresentationParameters} from './representation/contact-representation'\nimport DihedralRepresentation, {DihedralRepresentationParameters} from './representation/dihedral-representation'\nimport DihedralHistogramRepresentation, {DihedralHistogramRepresentationParameters} from './representation/dihedral-histogram-representation'\nimport DistanceRepresentation, {DistanceRepresentationParameters} from './representation/distance-representation'\nimport HelixorientRepresentation from './representation/helixorient-representation'\nimport HyperballRepresentation, {HyperballRepresentationParameters} from './representation/hyperball-representation'\nimport LabelRepresentation, {LabelRepresentationParameters} from './representation/label-representation'\nimport LicoriceRepresentation from './representation/licorice-representation'\nimport LineRepresentation, {LineRepresentationParameters} from './representation/line-representation'\nimport MolecularSurfaceRepresentation, {MolecularSurfaceRepresentationParameters} from './representation/molecularsurface-representation'\nimport PointRepresentation, {PointRepresentationParameters} from './representation/point-representation'\nimport RibbonRepresentation, {RibbonRepresentationParameters} from './representation/ribbon-representation'\nimport RocketRepresentation, {RocketRepresentationParameters} from './representation/rocket-representation'\nimport RopeRepresentation from './representation/rope-representation'\nimport SpacefillRepresentation from './representation/spacefill-representation'\nimport StructureRepresentation, {StructureRepresentationParameters} from './representation/structure-representation'\nimport TraceRepresentation, {TraceRepresentationParameters} from './representation/trace-representation'\nimport TubeRepresentation from './representation/tube-representation'\nimport UnitcellRepresentation, {UnitcellRepresentationParameters} from './representation/unitcell-representation'\nimport ValidationRepresentation from './representation/validation-representation'\n\nimport BufferRepresentation from './representation/buffer-representation'\nimport ArrowBuffer from './buffer/arrow-buffer'\nimport BoxBuffer from './buffer/box-buffer'\nimport ConeBuffer from './buffer/cone-buffer'\nimport CylinderBuffer from './buffer/cylinder-buffer'\nimport EllipsoidBuffer from './buffer/ellipsoid-buffer'\nimport MeshBuffer from './buffer/mesh-buffer'\nimport OctahedronBuffer from './buffer/octahedron-buffer'\nimport PointBuffer from './buffer/point-buffer'\nimport SphereBuffer from './buffer/sphere-buffer'\nimport TetrahedronBuffer from './buffer/tetrahedron-buffer'\nimport TextBuffer from './buffer/text-buffer'\nimport TorusBuffer from './buffer/torus-buffer'\nimport WidelineBuffer from './buffer/wideline-buffer'\n\n//\n\nimport './parser/cif-parser'\nimport './parser/gro-parser'\nimport './parser/mmtf-parser'\nimport './parser/mol2-parser'\nimport './parser/pdb-parser'\nimport './parser/pdbqt-parser'\nimport './parser/pqr-parser'\nimport './parser/sdf-parser'\n\nimport './parser/prmtop-parser'\nimport './parser/psf-parser'\nimport './parser/top-parser'\n\nimport './parser/dcd-parser'\nimport './parser/nctraj-parser'\nimport './parser/trr-parser'\nimport './parser/xtc-parser'\n\nimport './parser/cube-parser'\nimport './parser/dsn6-parser'\nimport './parser/dx-parser'\nimport './parser/dxbin-parser'\nimport './parser/mrc-parser'\nimport './parser/xplor-parser'\n\nimport './parser/kin-parser'\nimport './parser/obj-parser'\nimport './parser/ply-parser'\n\nimport './parser/csv-parser'\nimport './parser/json-parser'\nimport './parser/msgpack-parser'\nimport './parser/netcdf-parser'\nimport './parser/text-parser'\nimport './parser/xml-parser'\n\nimport './parser/validation-parser'\n\n//\n\nimport Shape from './geometry/shape'\nimport Kdtree from './geometry/kdtree'\nimport SpatialHash from './geometry/spatial-hash'\nimport Structure from './structure/structure'\nimport MolecularSurface from './surface/molecular-surface'\nimport Volume from './surface/volume'\n\n//\n\nimport './utils/gzip-decompressor'\n\n//\n\nimport './datasource/rcsb-datasource'\nimport './datasource/pubchem-datasource'\nimport './datasource/passthrough-datasource'\nimport './datasource/alphafold-datasource'\nimport StaticDatasource from './datasource/static-datasource'\nimport MdsrvDatasource from './datasource/mdsrv-datasource'\n\n//\n\nexport {\n LeftMouseButton, MiddleMouseButton, RightMouseButton\n} from './constants'\nexport {MouseActionCallback} from './controls/mouse-actions'\nimport MouseActions from './controls/mouse-actions'\nimport KeyActions from './controls/key-actions'\nimport PickingProxy from './controls/picking-proxy'\n\n//\n\nexport { Signal } from 'signals'\nexport {\n Matrix3, Matrix4, Vector2, Vector3, Box3, Quaternion, Euler, Plane, Color\n} from 'three'\n\n//\n\nexport { UIStageParameters } from './ui/parameters'\nexport { StageParameters } from './stage/stage'\nexport { StructureComponentDefaultParameters } from './component/structure-component'\n\n//\n\nimport Version from './version'\n\nif (!(window as any).Promise) {\n (window as any).Promise = _Promise\n}\n\nexport {\n Version,\n StaticDatasource,\n MdsrvDatasource,\n Colormaker,\n Selection,\n PdbWriter,\n SdfWriter,\n StlWriter,\n Stage,\n Viewer,\n Collection,\n ComponentCollection,\n RepresentationCollection,\n RepresentationElement,\n Component,\n ShapeComponent,\n StructureComponent,\n SurfaceComponent,\n VolumeComponent,\n StructureRepresentationType,\n VolumeRepresentationType,\n\n Assembly,\n TrajectoryPlayer,\n Superposition,\n Frames,\n\n Queue,\n Counter,\n\n AngleRepresentation,\n AngleRepresentationParameters,\n AxesRepresentation,\n AxesRepresentationParameters,\n BackboneRepresentation,\n BallAndStickRepresentation,\n BallAndStickRepresentationParameters,\n BaseRepresentation,\n CartoonRepresentation,\n CartoonRepresentationParameters,\n ContactRepresentation,\n ContactRepresentationParameters,\n DihedralRepresentation,\n DihedralRepresentationParameters,\n DihedralHistogramRepresentation,\n DihedralHistogramRepresentationParameters,\n DistanceRepresentation,\n DistanceRepresentationParameters,\n HelixorientRepresentation,\n HyperballRepresentation,\n HyperballRepresentationParameters,\n LabelRepresentation,\n LabelRepresentationParameters,\n LicoriceRepresentation,\n LineRepresentation,\n LineRepresentationParameters,\n MolecularSurfaceRepresentation,\n MolecularSurfaceRepresentationParameters,\n PointRepresentation,\n PointRepresentationParameters,\n RibbonRepresentation,\n RibbonRepresentationParameters,\n RocketRepresentation,\n RocketRepresentationParameters,\n RopeRepresentation,\n SpacefillRepresentation,\n StructureRepresentation,\n StructureRepresentationParameters,\n TraceRepresentation,\n TraceRepresentationParameters,\n TubeRepresentation,\n UnitcellRepresentation,\n UnitcellRepresentationParameters,\n ValidationRepresentation,\n\n BufferRepresentation,\n ArrowBuffer,\n BoxBuffer,\n ConeBuffer,\n CylinderBuffer,\n EllipsoidBuffer,\n MeshBuffer,\n OctahedronBuffer,\n PointBuffer,\n SphereBuffer,\n TetrahedronBuffer,\n TextBuffer,\n TorusBuffer,\n WidelineBuffer,\n\n Shape,\n\n Structure,\n Kdtree,\n SpatialHash,\n MolecularSurface,\n Volume,\n\n MouseActions,\n KeyActions,\n PickingProxy\n}\n"],"names":["toStr","isCallable","maxSafeInteger","toLength","start","window","console","prop","method","con","empty","dummy","properties","split","methods","pop","HTMLCanvasElement","prototype","toBlob","Object","defineProperty","value","callback","type","quality","bin","atob","this","toDataURL","len","length","len32","a8","Uint8Array","a32","Uint32Array","buffer","i","j","charCodeAt","tailLength","Blob","Math","cbrt","x","y","pow","abs","sign","isNaN","Number","isInteger","nVal","isFinite","floor","assign","enumerable","configurable","writable","target","TypeError","pendingException","to","hasPendingException","arguments","nextSource","keysArray","keys","nextIndex","nextKey","desc","getOwnPropertyDescriptor","undefined","e","String","startsWith","result","object","$defineProperty","error","toString","search","string","call","stringLength","searchString","searchLength","position","pos","min","max","index","endsWith","subjectString","lastIndex","indexOf","repeat","count","str","RangeError","Infinity","rpt","includes","Array","searchElement","O","parseInt","k","currentElement","n","from","fn","number","toInteger","arrayLike","C","items","T","mapFn","kValue","A","lastTime","vendors","requestAnimationFrame","cancelAnimationFrame","currTime","Date","getTime","timeToCall","id","setTimeout","clearTimeout","Function","name","get","match","performance","self","now","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","setTimeoutFunc","isArray","Boolean","noop","Promise","_state","_handled","_value","_deferreds","doResolve","handle","deferred","_immediateFn","cb","onFulfilled","onRejected","ret","reject","promise","resolve","push","newValue","then","finale","thisArg","apply","_unhandledRejectionFn","Handler","done","reason","ex","Promise$1","prom","constructor","all","arr","args","slice","remaining","res","val","allSettled","status","race","setImmediate","err","warn","const","AddEquation","RepeatWrapping","ClampToEdgeWrapping","MirroredRepeatWrapping","NearestFilter","LinearFilter","UnsignedByteType","UnsignedShortType","UnsignedIntType","FloatType","HalfFloatType","UnsignedInt248Type","RGBFormat","RGBAFormat","DepthFormat","DepthStencilFormat","LinearEncoding","KeepStencilOp","EventDispatcher","addEventListener","listener","_listeners","listeners","hasEventListener","removeEventListener","listenerArray","splice","dispatchEvent","event","array","l","_lut","_canvas","MathUtils","DEG2RAD","PI","RAD2DEG","generateUUID","d0","random","d1","d2","d3","toUpperCase","clamp","euclideanModulo","m","mapLinear","a1","a2","b1","b2","lerp","t","smoothstep","smootherstep","randInt","low","high","randFloat","randFloatSpread","range","degToRad","degrees","radToDeg","radians","isPowerOfTwo","ceilPowerOfTwo","ceil","log","LN2","floorPowerOfTwo","setQuaternionFromProperEuler","q","a","b","c","order","cos","sin","c2","s2","c13","s13","c1_3","s1_3","c3_1","s3_1","set","Vector2","Matrix3","elements","defineProperties","width","height","isVector2","setScalar","scalar","setX","setY","setComponent","Error","getComponent","clone","copy","v","add","w","addVectors","addScalar","s","addScaledVector","sub","subVectors","subScalar","multiply","multiplyScalar","divide","divideScalar","applyMatrix3","clampScalar","minVal","maxVal","clampLength","round","roundToZero","negate","dot","cross","lengthSq","sqrt","manhattanLength","normalize","angle","atan2","distanceTo","distanceToSquared","dx","dy","manhattanDistanceTo","setLength","alpha","lerpVectors","v1","v2","equals","fromArray","offset","toArray","fromBufferAttribute","attribute","getX","getY","rotateAround","center","isMatrix3","n11","n12","n13","n21","n22","n23","n31","n32","n33","te","identity","me","extractBasis","xAxis","yAxis","zAxis","setFromMatrix3Column","setFromMatrix4","multiplyMatrices","premultiply","ae","be","a11","a12","a13","a21","a22","a23","a31","a33","b11","b12","b13","b21","b22","b23","b31","b32","b33","determinant","d","f","g","h","getInverse","matrix","throwOnDegenerate","t11","t12","t13","det","detInv","transpose","let","tmp","getNormalMatrix","matrix4","transposeIntoArray","r","setUvTransform","tx","ty","sx","sy","rotation","cx","cy","scale","rotate","theta","translate","ImageUtils","image","test","src","canvas","document","createElementNS","context","getContext","ImageData","putImageData","drawImage","textureId","Texture","mapping","wrapS","wrapT","magFilter","minFilter","format","anisotropy","encoding","uuid","DEFAULT_IMAGE","mipmaps","DEFAULT_MAPPING","internalFormat","matrixAutoUpdate","generateMipmaps","premultiplyAlpha","flipY","unpackAlignment","version","onUpdate","Vector4","z","WebGLRenderTarget","options","scissor","scissorTest","viewport","texture","depthBuffer","stencilBuffer","depthTexture","Quaternion","_x","_y","_z","_w","create","isTexture","updateMatrix","source","toJSON","meta","isRootObject","textures","output","metadata","generator","wrap","images","url","dispose","transformUv","uv","isVector4","setZ","setW","applyMatrix4","setAxisAngleFromQuaternion","acos","setAxisAngleFromRotationMatrix","epsilon","epsilon2","m11","m12","m13","m21","m22","m23","m31","m32","m33","xx","yy","zz","xy","xz","yz","getZ","getW","isWebGLRenderTarget","setSize","slerp","qa","qb","qm","slerpFlat","dst","dstOffset","src0","srcOffset0","src1","srcOffset1","x0","y0","z0","w0","x1","y1","z1","w1","dir","sqrSin","EPSILON","tDir","multiplyQuaternionsFlat","_onChangeCallback","isQuaternion","quaternion","setFromEuler","euler","update","isEuler","c1","c3","s1","s3","setFromAxisAngle","axis","halfAngle","setFromRotationMatrix","trace","setFromUnitVectors","vFrom","vTo","angleTo","rotateTowards","step","inverse","conjugate","p","multiplyQuaternions","qax","qay","qaz","qaw","qbx","qby","qbz","qbw","cosHalfTheta","sqrSinHalfTheta","sinHalfTheta","halfTheta","ratioA","ratioB","_onChange","_vector","Vector3","_quaternion","isVector3","multiplyVectors","applyEuler","applyQuaternion","applyAxisAngle","applyNormalMatrix","qx","qy","qz","qw","ix","iy","iz","iw","project","camera","matrixWorldInverse","projectionMatrix","unproject","projectionMatrixInverse","matrixWorld","transformDirection","crossVectors","ax","ay","az","bx","by","bz","projectOnVector","denominator","projectOnPlane","planeNormal","reflect","normal","dz","setFromSpherical","setFromSphericalCoords","radius","phi","sinPhiRadius","setFromCylindrical","setFromCylindricalCoords","setFromMatrixPosition","setFromMatrixScale","setFromMatrixColumn","sz","_v1","_m1","Matrix4","_zero","_one","isMatrix4","n14","n24","n34","n41","n42","n43","n44","copyPosition","makeBasis","extractRotation","scaleX","scaleY","scaleZ","makeRotationFromEuler","af","bf","ce","cf","de","df","ac","ad","bc","bd","makeRotationFromQuaternion","compose","lookAt","eye","up","a14","a24","a34","a41","a42","a43","a44","b14","b24","b34","b41","b42","b43","b44","setPosition","t14","getMaxScaleOnAxis","scaleXSq","scaleYSq","scaleZSq","makeTranslation","makeRotationX","makeRotationY","makeRotationZ","makeRotationAxis","makeScale","makeShear","x2","y2","z2","wx","wy","wz","decompose","invSX","invSY","invSZ","makePerspective","left","right","top","bottom","near","far","makeOrthographic","_matrix","Euler","DefaultOrder","_order","Layers","mask","RotationOrders","asin","setFromQuaternion","setFromVector3","reorder","newOrder","toVector3","optionalResult","channel","enable","enableAll","toggle","disable","disableAll","layers","_object3DId","_q1","_target","_position","_scale","_xAxis","_yAxis","_zAxis","_addedEvent","_removedEvent","Object3D","parent","children","DefaultUp","modelViewMatrix","normalMatrix","DefaultMatrixAutoUpdate","matrixWorldNeedsUpdate","visible","castShadow","receiveShadow","frustumCulled","renderOrder","userData","Scene","background","environment","fog","overrideMaterial","autoUpdate","__THREE_DEVTOOLS__","CustomEvent","detail","isObject3D","onBeforeRender","onAfterRender","setRotationFromAxisAngle","setRotationFromEuler","setRotationFromMatrix","setRotationFromQuaternion","rotateOnAxis","rotateOnWorldAxis","rotateX","rotateY","rotateZ","translateOnAxis","distance","translateX","translateY","translateZ","localToWorld","vector","worldToLocal","updateWorldMatrix","isCamera","isLight","remove","attach","getObjectById","getObjectByProperty","getObjectByName","getWorldPosition","updateMatrixWorld","getWorldQuaternion","getWorldScale","getWorldDirection","raycast","traverse","traverseVisible","traverseAncestors","force","updateParents","updateChildren","geometries","materials","shapes","serialize","library","element","JSON","stringify","isInstancedMesh","instanceMatrix","isMesh","isLine","isPoints","geometry","parameters","shape","material","uuids","extractFromCache","cache","values","key","data","recursive","parse","child","isScene","_points","_box","Box3","_v0","_v2","_f0","_f1","_f2","_center","_extents","_triangleNormal","_testAxis","satForAxes","axes","v0","extents","p0","p1","p2","isBox3","setFromArray","minX","minY","minZ","maxX","maxY","maxZ","setFromBufferAttribute","setFromPoints","points","makeEmpty","il","expandByPoint","setFromCenterAndSize","size","halfSize","setFromObject","expandByObject","box","isEmpty","getCenter","getSize","point","expandByVector","expandByScalar","boundingBox","computeBoundingBox","union","containsPoint","containsBox","getParameter","intersectsBox","intersectsSphere","sphere","clampPoint","intersectsPlane","plane","constant","intersectsTriangle","triangle","distanceToPoint","getBoundingSphere","intersect","Sphere","optionalCenter","maxRadiusSq","radiusSum","deltaLengthSq","getBoundingBox","_segCenter","_segDir","_diff","_edge1","_edge2","_normal","Ray","origin","direction","ray","at","recast","closestPointToPoint","directionDistance","distanceSqToPoint","distanceSqToSegment","optionalPointOnRay","optionalPointOnSegment","s0","sqrDist","extDet","segExtent","a01","b0","invDet","intersectSphere","tca","radius2","thc","t0","t1","distanceToPlane","intersectPlane","distToPoint","intersectBox","tmin","tmax","tymin","tymax","tzmin","tzmax","invdirx","invdiry","invdirz","intersectTriangle","backfaceCulling","DdN","DdQxE2","DdE1xQ","QdN","_vector1","_vector2","_normalMatrix","Plane","isPlane","setComponents","setFromNormalAndCoplanarPoint","setFromCoplanarPoints","inverseNormalLength","distanceToSphere","projectPoint","intersectLine","line","delta","intersectsLine","startSign","endSign","end","coplanarPoint","optionalNormalMatrix","referencePoint","_v3","_vab","_vac","_vbc","_vap","_vbp","_vcp","Triangle","getNormal","targetLengthSq","getBarycoord","dot00","dot01","dot02","dot11","dot12","denom","invDenom","u","getUV","p3","uv1","uv2","uv3","isFrontFacing","setFromPointsAndIndices","i0","i1","i2","getArea","getMidpoint","getPlane","d4","vc","d5","d6","vb","va","_colorKeywords","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","_hslA","_hslB","Color","setRGB","hue2rgb","SRGBToLinear","LinearToSRGB","Face3","color","materialIndex","vertexNormals","isColor","vertexColors","setHex","setStyle","hex","setHSL","style","handleAlpha","parseFloat","exec","components","charAt","setColorName","copyGammaToLinear","gammaFactor","copyLinearToGamma","safeInverse","convertGammaToLinear","convertLinearToGamma","copySRGBToLinear","copyLinearToSRGB","convertSRGBToLinear","convertLinearToSRGB","getHex","getHexString","getHSL","hue","saturation","lightness","getStyle","offsetHSL","addColors","color1","color2","lerpHSL","normalized","NAMES","materialId","Material","blending","side","flatShading","opacity","transparent","blendSrc","blendDst","blendEquation","blendSrcAlpha","blendDstAlpha","blendEquationAlpha","depthFunc","depthTest","depthWrite","stencilWriteMask","stencilFunc","stencilRef","stencilFuncMask","stencilFail","stencilZFail","stencilZPass","stencilWrite","clippingPlanes","clipIntersection","clipShadows","shadowSide","colorWrite","precision","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","dithering","alphaTest","premultipliedAlpha","toneMapped","MeshBasicMaterial","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","specularMap","alphaMap","envMap","combine","reflectivity","refractionRatio","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin","skinning","morphTargets","setValues","isMaterial","onBeforeCompile","customProgramCacheKey","currentValue","isRoot","roughness","metalness","sheen","emissive","emissiveIntensity","specular","shininess","clearcoat","clearcoatRoughness","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","clearcoatNormalScale","matcap","bumpMap","bumpScale","normalMap","normalMapType","normalScale","displacementMap","displacementScale","displacementBias","roughnessMap","metalnessMap","emissiveMap","envMapIntensity","gradientMap","sizeAttenuation","linewidth","dashSize","gapSize","morphNormals","srcPlanes","dstPlanes","isMeshBasicMaterial","BufferAttribute","itemSize","usage","updateRange","Int8BufferAttribute","Int8Array","Uint8BufferAttribute","Uint8ClampedBufferAttribute","Uint8ClampedArray","Int16BufferAttribute","Int16Array","Uint16BufferAttribute","Uint16Array","Int32BufferAttribute","Int32Array","Uint32BufferAttribute","Float32BufferAttribute","Float32Array","Float64BufferAttribute","Float64Array","DirectGeometry","vertices","normals","colors","uvs","uvs2","groups","skinWeights","skinIndices","boundingSphere","verticesNeedUpdate","normalsNeedUpdate","colorsNeedUpdate","uvsNeedUpdate","groupsNeedUpdate","arrayMax","isBufferAttribute","onUploadCallback","setUsage","copyAt","index1","index2","copyArray","copyColorsArray","copyVector2sArray","vectors","copyVector3sArray","copyVector4sArray","setXY","setXYZ","setXYZW","onUpload","computeGroups","group","faces","face","fromGeometry","morphTargetsPosition","faceVertexUvs","hasFaceVertexUv","hasFaceVertexUv2","morphTargetsLength","morphTargetsNormal","morphNormalsLength","hasSkinIndices","hasSkinWeights","vertexUvs","morphTarget","morphNormal","_bufferGeometryId","_obj","_offset","_boxMorphTargets","BufferGeometry","attributes","morphAttributes","morphTargetsRelative","drawRange","isBufferGeometry","getIndex","setIndex","getAttribute","setAttribute","deleteAttribute","addGroup","clearGroups","setDrawRange","needsUpdate","tangent","computeBoundingSphere","positions","lineDistances","isGeometry","updateFromObject","direct","__directGeometry","elementsNeedUpdate","lineDistancesNeedUpdate","lineDistance","fromDirectGeometry","morphAttributesPosition","morphAttribute","jl","computeFaceNormals","computeVertexNormals","positionAttribute","normalAttribute","pA","pB","pC","nA","nB","nC","ab","vA","vB","vC","normalizeNormals","merge","attributeArray1","attribute2","attributeArray2","attributeOffset","toNonIndexed","convertBufferAttribute","indices","array2","geometry2","newAttribute","morphArray","attributeData","hasMorphAttributes","attributeArray","_inverseMatrix","_ray","_sphere","_vA","_vB","_vC","_tempA","_tempB","_tempC","_morphA","_morphB","_morphC","_uvA","_uvB","_uvC","_intersectionPoint","_intersectionPointWorld","Mesh","updateMorphTargets","checkIntersection","raycaster","checkBufferGeometryIntersection","morphPosition","morphInfluences","morphTargetInfluences","influence","isSkinnedMesh","boneTransform","intersection","morphTargetDictionary","ml","intersects","groupMaterial","faceIndex","isMultiMaterial","fl","faceMaterial","fvA","fvB","fvC","uvs_f","_geometryId","Geometry","fromBufferGeometry","scope","addFace","areaWeighted","vl","computeFlatVertexNormals","computeMorphNormals","__originalFaceNormal","__originalVertexNormals","tmpGeo","faceNormals","dstNormalsFace","dstNormalsVertex","faceNormal","materialIndexOffset","vertexOffset","vertices1","vertices2","faces1","faces2","colors1","colors2","vertexCopy","faceCopy","faceVertexNormals","faceVertexColors","faceVertexUvs2","uvsCopy","kl","mergeMesh","mesh","mergeVertices","verticesMap","unique","changes","faceIndicesToRemove","idx","diff","sortFacesByMaterialIndex","_id","sort","newUvs1","newUvs2","uvs1","vertex","normalsHash","colorsHash","uvsHash","hasFaceNormal","hasFaceVertexNormal","hasFaceColor","hasFaceVertexColor","faceType","setBit","getUvIndex","getNormalIndex","getColorIndex","enabled","hash","srcVertexNormal","destVertexNormal","BoxBufferGeometry","depth","widthSegments","heightSegments","depthSegments","super","numberOfVertices","groupStart","buildPlane","udir","vdir","gridX","gridY","segmentWidth","segmentHeight","widthHalf","heightHalf","depthHalf","gridX1","gridY1","vertexCounter","groupCount","cloneUniforms","property","mergeUniforms","uniforms","merged","UniformsUtils","ShaderMaterial","defines","vertexShader","fragmentShader","lights","clipping","extensions","derivatives","fragDepth","drawBuffers","shaderTextureLOD","defaultAttributeValues","index0AttributeName","uniformsNeedUpdate","Camera","PerspectiveCamera","fov","aspect","zoom","focus","view","filmGauge","filmOffset","updateProjectionMatrix","DataTexture","isShaderMaterial","isPerspectiveCamera","setFocalLength","focalLength","vExtentSlope","getFilmHeight","atan","getFocalLength","getEffectiveFOV","getFilmWidth","setViewOffset","fullWidth","fullHeight","offsetX","offsetY","clearViewOffset","skew","isDataTexture","Frustum","p4","p5","planes","frustum","setFromProjectionMatrix","me0","me1","me2","me3","me4","me5","me6","me7","me8","me9","me10","me11","me12","me13","me14","me15","intersectsObject","intersectsSprite","sprite","negRadius","UniformsLib","common","diffuse","uvTransform","uv2Transform","specularmap","envmap","flipEnvMap","maxMipLevel","aomap","lightmap","emissivemap","bumpmap","normalmap","displacementmap","roughnessmap","metalnessmap","gradientmap","fogDensity","fogNear","fogFar","fogColor","ambientLightColor","lightProbe","directionalLights","directionalLightShadows","shadowBias","shadowNormalBias","shadowRadius","shadowMapSize","directionalShadowMap","directionalShadowMatrix","spotLights","coneCos","penumbraCos","decay","spotLightShadows","spotShadowMap","spotShadowMatrix","pointLights","pointLightShadows","shadowCameraNear","shadowCameraFar","pointShadowMap","pointShadowMatrix","hemisphereLights","skyColor","groundColor","rectAreaLights","WebGLAnimation","isAnimating","animationLoop","requestId","onAnimationFrame","time","frame","stop","setAnimationLoop","setContext","WebGLAttributes","gl","capabilities","isWebGL2","buffers","WeakMap","isInterleavedBufferAttribute","deleteBuffer","delete","bufferType","createBuffer","bindBuffer","bufferData","bytesPerElement","BYTES_PER_ELEMENT","bufferSubData","subarray","updateBuffer","PlaneGeometry","PlaneBufferGeometry","width_half","height_half","segment_width","segment_height","ShaderChunk","alphamap_fragment","alphamap_pars_fragment","alphatest_fragment","aomap_fragment","aomap_pars_fragment","begin_vertex","beginnormal_vertex","bsdfs","bumpmap_pars_fragment","clipping_planes_fragment","clipping_planes_pars_fragment","clipping_planes_pars_vertex","clipping_planes_vertex","color_fragment","color_pars_fragment","color_pars_vertex","color_vertex","cube_uv_reflection_fragment","defaultnormal_vertex","displacementmap_pars_vertex","displacementmap_vertex","emissivemap_fragment","emissivemap_pars_fragment","encodings_fragment","encodings_pars_fragment","envmap_fragment","envmap_common_pars_fragment","envmap_pars_fragment","envmap_pars_vertex","envmap_physical_pars_fragment","envmap_vertex","fog_vertex","fog_pars_vertex","fog_fragment","fog_pars_fragment","gradientmap_pars_fragment","lightmap_fragment","lightmap_pars_fragment","lights_lambert_vertex","lights_pars_begin","lights_toon_fragment","lights_toon_pars_fragment","lights_phong_fragment","lights_phong_pars_fragment","lights_physical_fragment","lights_physical_pars_fragment","lights_fragment_begin","lights_fragment_maps","lights_fragment_end","logdepthbuf_fragment","logdepthbuf_pars_fragment","logdepthbuf_pars_vertex","logdepthbuf_vertex","map_fragment","map_pars_fragment","map_particle_fragment","map_particle_pars_fragment","metalnessmap_fragment","metalnessmap_pars_fragment","morphnormal_vertex","morphtarget_pars_vertex","morphtarget_vertex","normal_fragment_begin","normal_fragment_maps","normalmap_pars_fragment","clearcoat_normal_fragment_begin","clearcoat_normal_fragment_maps","clearcoat_pars_fragment","packing","premultiplied_alpha_fragment","project_vertex","dithering_fragment","dithering_pars_fragment","roughnessmap_fragment","roughnessmap_pars_fragment","shadowmap_pars_fragment","shadowmap_pars_vertex","shadowmap_vertex","shadowmask_pars_fragment","skinbase_vertex","skinning_pars_vertex","skinning_vertex","skinnormal_vertex","specularmap_fragment","specularmap_pars_fragment","tonemapping_fragment","tonemapping_pars_fragment","uv_pars_fragment","uv_pars_vertex","uv_vertex","uv2_pars_fragment","uv2_pars_vertex","uv2_vertex","worldpos_vertex","background_frag","background_vert","cube_frag","cube_vert","depth_frag","depth_vert","distanceRGBA_frag","distanceRGBA_vert","equirect_frag","equirect_vert","linedashed_frag","linedashed_vert","meshbasic_frag","meshbasic_vert","meshlambert_frag","meshlambert_vert","meshmatcap_frag","meshmatcap_vert","meshtoon_frag","meshtoon_vert","meshphong_frag","meshphong_vert","meshphysical_frag","meshphysical_vert","normal_frag","normal_vert","points_frag","points_vert","shadow_frag","shadow_vert","sprite_frag","sprite_vert","ShaderLib","basic","lambert","phong","standard","toon","dashed","totalSize","t2D","cube","equirect","tEquirect","distanceRGBA","referencePosition","nearDistance","farDistance","shadow","WebGLBackground","renderer","state","objects","planeMesh","boxMesh","clearColor","clearAlpha","currentBackground","currentBackgroundVersion","currentTonemapping","setClear","getClearColor","setClearColor","getClearAlpha","setClearAlpha","render","renderList","scene","forceClear","xr","session","getSession","environmentBlendMode","autoClear","clear","autoClearColor","autoClearDepth","autoClearStencil","isCubeTexture","isWebGLCubeRenderTarget","toneMapping","unshift","WebGLBindingStates","maxVertexAttributes","extension","vaoAvailable","bindingStates","defaultState","createBindingState","currentState","bindVertexArrayObject","vao","bindVertexArray","bindVertexArrayOES","deleteVertexArrayObject","deleteVertexArray","deleteVertexArrayOES","newAttributes","enabledAttributes","attributeDivisors","program","initAttributes","enableAttribute","enableAttributeAndDivisor","meshPerAttribute","enableVertexAttribArray","disableUnusedAttributes","disableVertexAttribArray","vertexAttribPointer","stride","vertexAttribIPointer","reset","resetDefaultState","setup","updateBuffers","programMap","stateMap","createVertexArray","createVertexArrayOES","createVertexArrayObject","getBindingState","cachedAttributes","geometryAttributes","cachedAttribute","geometryAttribute","saveCache","isInstancedBufferGeometry","programAttributes","getAttributes","materialDefaultAttributeValues","programAttribute","isInstancedInterleavedBuffer","_maxInstanceCount","isInstancedBufferAttribute","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","vertexAttrib1fv","setupVertexAttributes","geometryId","programId","releaseStatesOfGeometry","releaseStatesOfProgram","WebGLBufferRenderer","info","mode","setMode","drawArrays","renderInstances","primcount","methodName","WebGLCapabilities","maxAnisotropy","getMaxPrecision","getShaderPrecisionFormat","WebGL2RenderingContext","WebGL2ComputeRenderingContext","maxPrecision","logarithmicDepthBuffer","maxTextures","maxVertexTextures","maxTextureSize","maxCubemapSize","maxAttributes","maxVertexUniforms","maxVaryings","maxFragmentUniforms","vertexTextures","floatFragmentTextures","getMaxAnisotropy","MAX_TEXTURE_MAX_ANISOTROPY_EXT","floatVertexTextures","maxSamples","WebGLClipping","globalState","numGlobalPlanes","localClippingEnabled","renderingShadows","viewNormalMatrix","uniform","resetGlobalState","numPlanes","numIntersection","projectPlanes","skipTransform","nPlanes","dstArray","flatSize","viewMatrix","i4","init","enableLocalClipping","beginShadows","endShadows","setState","fromCache","nGlobal","lGlobal","clippingState","WebGLExtensions","getExtension","WebGLGeometries","wireframeAttributes","onGeometryDispose","buffergeometry","memory","updateWireframeAttribute","geometryIndex","geometryPosition","previousAttribute","_bufferGeometry","getWireframeAttribute","currentAttribute","WebGLIndexedBufferRenderer","drawElements","WebGLInfo","calls","triangles","lines","programs","autoReset","instanceCount","numericalSort","absNumericalSort","WebGLMorphtargets","influencesList","workInfluences","objectInfluences","influences","morphInfluencesSum","morphBaseInfluence","getUniforms","setValue","WebGLObjects","updateMap","CubeTexture","DataTexture2DArray","wrapR","DataTexture3D","physical","transparency","isDataTexture2DArray","isDataTexture3D","emptyTexture","emptyTexture2dArray","emptyTexture3d","emptyCubeTexture","arrayCacheF32","arrayCacheI32","mat4array","mat3array","mat2array","flatten","nBlocks","blockSize","firstElem","arraysEqual","allocTexUnits","allocateTextureUnit","setValueV1f","uniform1f","addr","setValueV2f","uniform2f","uniform2fv","setValueV3f","uniform3f","uniform3fv","setValueV4f","uniform4f","uniform4fv","setValueM2","uniformMatrix2fv","setValueM3","uniformMatrix3fv","setValueM4","uniformMatrix4fv","setValueT1","unit","uniform1i","safeSetTexture2D","setValueT2DArray1","setTexture2DArray","setValueT3D1","setTexture3D","setValueT6","safeSetTextureCube","setValueV1i","setValueV2i","uniform2iv","setValueV3i","uniform3iv","setValueV4i","uniform4iv","setValueV1ui","uniform1ui","setValueV1fArray","uniform1fv","setValueV1iArray","uniform1iv","setValueV2iArray","setValueV3iArray","setValueV4iArray","setValueV2fArray","setValueV3fArray","setValueV4fArray","setValueM2Array","setValueM3Array","setValueM4Array","setValueT1Array","units","setValueT6Array","SingleUniform","activeInfo","getSingularSetter","PureArrayUniform","getPureArraySetter","StructuredUniform","seq","updateCache","RePathPart","addUniform","container","uniformObject","parseUniform","path","pathLength","matchEnd","idIsIndex","subscript","next","WebGLUniforms","getProgramParameter","getActiveUniform","getUniformLocation","WebGLShader","shader","createShader","shaderSource","compileShader","setOptional","upload","seqWithValue","programIdCount","getEncodingComponents","getShaderErrors","getShaderParameter","getShaderInfoLog","trim","join","addLineNumbers","getShaderSource","getTexelDecodingFunction","functionName","getToneMappingFunction","toneMappingName","filterEmptyLine","replaceLightNums","replace","numDirLights","numSpotLights","numRectAreaLights","numPointLights","numHemiLights","numDirLightShadows","numSpotLightShadows","numPointLightShadows","replaceClippingPlaneNums","numClippingPlanes","numClipIntersection","includePattern","resolveIncludes","includeReplacer","include","deprecatedUnrollLoopPattern","unrollLoopPattern","unrollLoops","loopReplacer","deprecatedLoopReplacer","snippet","generatePrecision","precisionstring","WebGLProgram","cacheKey","prefixVertex","prefixFragment","shadowMapTypeDefine","shadowMapType","generateShadowMapTypeDefine","envMapTypeDefine","envMapMode","generateEnvMapTypeDefine","envMapModeDefine","generateEnvMapModeDefine","envMapBlendingDefine","generateEnvMapBlendingDefine","gammaFactorDefine","customExtensions","extensionDerivatives","envMapCubeUV","tangentSpaceNormalMap","shaderID","extensionFragDepth","rendererExtensionFragDepth","extensionDrawBuffers","rendererExtensionDrawBuffers","extensionShaderTextureLOD","rendererExtensionShaderTextureLod","filter","generateExtensions","customDefines","chunks","generateDefines","createProgram","isRawShaderMaterial","shaderName","instancing","supportsVertexTextures","maxBones","useFog","fogExp2","objectSpaceNormalMap","vertexTangents","uvsVertexOnly","useVertexTexture","doubleSided","flipSided","shadowMapEnabled","physicallyCorrectLights","mapEncoding","matcapEncoding","envMapEncoding","emissiveMapEncoding","lightMapEncoding","outputEncoding","depthPacking","isGLSL3ShaderMaterial","versionRegex","cachedUniforms","fragmentGlsl","glVertexShader","glFragmentShader","attachShader","bindAttribLocation","linkProgram","debug","checkShaderErrors","programLog","getProgramInfoLog","vertexLog","fragmentLog","runnable","haveDiagnostics","vertexErrors","fragmentErrors","getError","diagnostics","prefix","deleteShader","getActiveAttrib","getAttribLocation","fetchAttributeLocations","destroy","deleteProgram","usedTimes","WebGLPrograms","shaderIDs","MeshDepthMaterial","MeshDistanceMaterial","MeshNormalMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial","MeshStandardMaterial","MeshPhysicalMaterial","MeshMatcapMaterial","LineBasicMaterial","LineDashedMaterial","PointsMaterial","ShadowMaterial","SpriteMaterial","parameterNames","getTextureEncodingFromMap","getParameters","shadows","nClipPlanes","nClipIntersection","isMeshStandardMaterial","bones","skeleton","nVertexUniforms","nVertexMatrices","allocateBones","shaderobject","getShaderObject","currentRenderTarget","getRenderTarget","isFogExp2","maxMorphTargets","maxMorphNormals","directional","spot","rectArea","hemi","shadowMap","getProgramCacheKey","acquireProgram","pl","preexistingProgram","releaseProgram","WebGLProperties","painterSortStable","groupOrder","reversePainterSortStable","WebGLRenderList","renderItems","renderItemsIndex","opaque","defaultProgram","getNextRenderItem","renderItem","finish","customOpaqueSort","customTransparentSort","WebGLRenderLists","lists","onSceneDispose","list","cameras","UniformsCache","light","halfWidth","halfHeight","nextVersion","shadowCastingLightsFirst","lightA","lightB","WebGLLights","shadowCache","directionalLength","pointLength","spotLength","rectAreaLength","hemiLength","numDirectionalShadows","numPointShadows","numSpotShadows","ambient","probe","directionalShadow","spotShadow","pointShadow","vector3","matrix42","intensity","isAmbientLight","isLightProbe","sh","coefficients","isDirectionalLight","shadowUniforms","bias","normalBias","mapSize","isSpotLight","penumbra","isRectAreaLight","isPointLight","isHemisphereLight","WebGLRenderState","lightsArray","shadowsArray","setupLights","pushLight","pushShadow","shadowLight","WebGLRenderStates","renderStates","renderState","has","isMeshDepthMaterial","isMeshDistanceMaterial","WebGLShadowMap","_renderer","_objects","_frustum","_shadowMapSize","_viewportSize","_viewport","_depthMaterials","_distanceMaterials","_materialCache","shadowMaterialVertical","SAMPLE_RATE","HALF_SAMPLE_RATE","shadow_pass","resolution","shadowMaterialHorizonal","HORIZONAL_PASS","fullScreenTri","fullScreenMesh","VSMPass","setRenderTarget","mapPass","renderBufferDirect","getDepthMaterialVariant","useMorphing","useSkinning","useInstancing","getDistanceMaterialVariant","getDepthMaterial","getMaterialVariant","customMaterial","customDepthMaterial","customDistanceMaterial","keyA","keyB","materialsForVariant","cachedMaterial","renderObject","shadowCamera","depthMaterial","activeCubeFace","getActiveCubeFace","activeMipmapLevel","getActiveMipmapLevel","setBlending","setTest","setScissorTest","shadowFrameExtents","getFrameExtents","isPointLightShadow","pars","viewportCount","getViewportCount","vp","getViewport","updateMatrices","getFrustum","WebGLState","colorBuffer","locked","currentColorMask","currentColorClear","setMask","colorMask","setLocked","lock","currentDepthMask","currentDepthFunc","currentDepthClear","depthMask","setFunc","clearDepth","currentStencilMask","currentStencilFunc","currentStencilRef","currentStencilFuncMask","currentStencilFail","currentStencilZFail","currentStencilZPass","currentStencilClear","stencilTest","stencilMask","setOp","stencilOp","stencil","clearStencil","enabledCapabilities","currentProgram","currentBlendingEnabled","currentBlending","currentBlendEquation","currentBlendSrc","currentBlendDst","currentBlendEquationAlpha","currentBlendSrcAlpha","currentBlendDstAlpha","currentPremultipledAlpha","currentFlipSided","currentCullFace","currentLineWidth","currentPolygonOffsetFactor","currentPolygonOffsetUnits","lineWidthAvailable","glVersion","currentTextureSlot","currentBoundTextures","currentScissor","currentViewport","createTexture","bindTexture","texParameteri","texImage2D","emptyTextures","setFlipSided","setCullFace","equationToGL","MIN_EXT","MAX_EXT","factorToGL","blendEquationSeparate","blendFuncSeparate","blendFunc","frontFace","cullFace","setPolygonOffset","factor","activeTexture","webglSlot","useProgram","setMaterial","frontFaceCW","setLineWidth","lineWidth","webglType","webglTexture","boundTexture","unbindTexture","compressedTexImage2D","texImage3D","WebGLTextures","_gl","utils","_videoTextures","useOffscreenCanvas","OffscreenCanvas","createCanvas","resizeImage","needsPowerOfTwo","needsNewCanvas","maxSize","HTMLImageElement","ImageBitmap","textureNeedsGenerateMipmaps","supportsMips","generateMipmap","__maxMipLevel","LOG2E","getInternalFormat","internalFormatName","glFormat","glType","filterFallback","onTextureDispose","textureProperties","__webglInit","deleteTexture","__webglTexture","deallocateTexture","isVideoTexture","onRenderTargetDispose","renderTarget","renderTargetProperties","deleteFramebuffer","__webglFramebuffer","__webglDepthbuffer","deleteRenderbuffer","__webglMultisampledFramebuffer","__webglColorRenderbuffer","__webglDepthRenderbuffer","deallocateRenderTarget","textureUnits","setTexture2D","slot","updateVideoTexture","__version","complete","uploadTexture","setTextureCube","initTexture","pixelStorei","isCompressed","isCompressedTexture","cubeImage","convert","glInternalFormat","setTextureParameters","mipmap","mipmapImage","setTextureCubeDynamic","wrappingToGL","filterToGL","textureType","__currentAnisotropy","texParameterf","TEXTURE_MAX_ANISOTROPY_EXT","textureNeedsPowerOfTwo","isDepthTexture","setupFrameBufferTexture","framebuffer","attachment","textureTarget","bindFramebuffer","framebufferTexture2D","setupRenderBufferStorage","renderbuffer","isMultisample","bindRenderbuffer","samples","getRenderTargetSamples","renderbufferStorageMultisample","renderbufferStorage","framebufferRenderbuffer","setupDepthRenderbuffer","isCube","webglDepthTexture","setupDepthTexture","createRenderbuffer","isWebGLMultisampleRenderTarget","warnedTexture2D","warnedTextureCube","textureUnit","resetTextureUnits","setupRenderTarget","createFramebuffer","updateRenderTargetMipmap","updateMultisampleRenderTarget","blitFramebuffer","WebGLUtils","HALF_FLOAT_OES","COMPRESSED_RGB_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT3_EXT","COMPRESSED_RGBA_S3TC_DXT5_EXT","COMPRESSED_RGB_PVRTC_4BPPV1_IMG","COMPRESSED_RGB_PVRTC_2BPPV1_IMG","COMPRESSED_RGBA_PVRTC_4BPPV1_IMG","COMPRESSED_RGBA_PVRTC_2BPPV1_IMG","COMPRESSED_RGB_ETC1_WEBGL","COMPRESSED_RGB8_ETC2","COMPRESSED_RGBA8_ETC2_EAC","UNSIGNED_INT_24_8_WEBGL","ArrayCamera","Group","WebXRController","_targetRay","_grip","WebXRManager","framebufferScaleFactor","referenceSpace","referenceSpaceType","pose","controllers","inputSourcesMap","Map","cameraL","cameraR","cameraVR","_currentDepthNear","_currentDepthFar","onSessionEvent","controller","inputSource","onSessionEnd","forEach","disconnect","setFramebuffer","animation","isPresenting","onRequestReferenceSpace","updateInputSources","inputSources","removed","added","getController","getTargetRaySpace","getControllerGrip","getGripSpace","setFramebufferScaleFactor","setReferenceSpaceType","getReferenceSpace","setSession","getContextAttributes","xrCompatible","makeXRCompatible","layerInit","antialias","baseLayer","XRWebGLLayer","updateRenderState","requestReferenceSpace","cameraLPos","cameraRPos","updateCamera","getCamera","depthNear","depthFar","ipd","projL","projR","topFov","bottomFov","leftFov","rightFov","zOffset","xOffset","near2","far2","left2","right2","top2","bottom2","setProjectionFromUnion","onAnimationFrameCallback","getViewerPose","views","cameraVRNeedsUpdate","transform","WebGLMaterials","refreshUniformsCommon","uvScaleMap","uv2ScaleMap","refreshUniformsStandard","refreshFogUniforms","isFog","density","refreshMaterialUniforms","pixelRatio","isMeshLambertMaterial","refreshUniformsLambert","isMeshToonMaterial","refreshUniformsToon","isMeshPhongMaterial","refreshUniformsPhong","isMeshPhysicalMaterial","refreshUniformsPhysical","isMeshMatcapMaterial","refreshUniformsMatcap","refreshUniformsDepth","refreshUniformsDistance","isMeshNormalMaterial","refreshUniformsNormal","isLineBasicMaterial","refreshUniformsLine","isLineDashedMaterial","refreshUniformsDash","isPointsMaterial","refreshUniformsPoints","isSpriteMaterial","refreshUniformsSprites","isShadowMaterial","WebGLRenderer","_context","_alpha","_depth","_stencil","_antialias","_premultipliedAlpha","_preserveDrawingBuffer","preserveDrawingBuffer","_powerPreference","powerPreference","_failIfMajorPerformanceCaveat","failIfMajorPerformanceCaveat","currentRenderList","currentRenderState","domElement","sortObjects","toneMappingExposure","_this","_isContextLost","_framebuffer","_currentActiveCubeFace","_currentActiveMipmapLevel","_currentRenderTarget","_currentFramebuffer","_currentMaterialId","_currentCamera","_currentArrayCamera","_currentViewport","_currentScissor","_currentScissorTest","_width","_height","_pixelRatio","_opaqueSort","_transparentSort","_scissor","_scissorTest","_clipping","_clippingEnabled","_localClippingEnabled","_projScreenMatrix","_vector3","_emptyScene","getTargetPixelRatio","programCache","renderLists","morphtargets","bufferRenderer","indexedBufferRenderer","contextNames","contextAttributes","contextName","onContextLost","onContextRestore","isWebGL1Renderer","shift","rangeMin","rangeMax","message","initGLContext","preventDefault","onMaterialDispose","releaseMaterialProgramReference","deallocateMaterial","programInfo","forceContextLoss","loseContext","forceContextRestore","restoreContext","getPixelRatio","setPixelRatio","updateStyle","setViewport","getDrawingBufferSize","setDrawingBufferSize","getCurrentViewport","getScissor","setScissor","getScissorTest","boolean","setOpaqueSort","setTransparentSort","bits","renderBufferImmediate","hasPositions","hasNormals","hasUvs","hasColors","setProgram","rangeFactor","dataCount","rangeStart","rangeCount","drawStart","drawEnd","drawCount","isLineSegments","isLineLoop","isSprite","compile","compiled","material2","initMaterial","projectObject","isGroup","isLOD","isImmediateRenderObject","renderObjects","isArrayCamera","camera2","renderObjectImmediate","materialProperties","lightsStateVersion","programCacheKey","programChange","numSupportedMorphTargets","numSupportedMorphNormals","needsLights","materialNeedsLights","progUniforms","uniformsList","useCache","refreshProgram","refreshMaterial","refreshLights","p_uniforms","m_uniforms","uCamPos","cameraPosition","isOrthographicCamera","boneTexture","boneMatrices","boneTextureSize","ltc_1","LTC_1","ltc_2","LTC_2","opaqueObjects","transparentObjects","readRenderTargetPixels","activeCubeFaceIndex","restore","textureFormat","checkFramebufferStatus","readPixels","copyFramebufferToTexture","level","levelScale","copyTexImage2D","copyTextureToTexture","srcTexture","dstTexture","texSubImage2D","compressedTexSubImage2D","Fog","linecap","linejoin","inputPose","gripPose","targetRay","grip","getPose","targetRaySpace","gripSpace","_start","_end","Line","computeLineDistances","threshold","params","localThreshold","localThresholdSq","vStart","vEnd","interSegment","interRay","nbVertices","LineSegments","Points","testPoint","rayPointDistanceSq","intersectPoint","distanceToRay","CanvasTexture","PolyhedronGeometry","PolyhedronBufferGeometry","vertexBuffer","uvBuffer","subdivideFace","cols","aj","bj","rows","pushVertex","getVertexByIndex","correctUV","azimuth","subdivide","applyRadius","centroid","uvA","uvB","uvC","azi","correctUVs","correctSeam","generateUVs","TetrahedronGeometry","TetrahedronBufferGeometry","OctahedronGeometry","OctahedronBufferGeometry","IcosahedronGeometry","IcosahedronBufferGeometry","TorusGeometry","tube","radialSegments","tubularSegments","arc","TorusBufferGeometry","CylinderGeometry","radiusTop","radiusBottom","openEnded","thetaStart","thetaLength","CylinderBufferGeometry","indexArray","generateCap","centerIndexStart","centerIndexEnd","cosTheta","sinTheta","slope","indexRow","generateTorso","ConeGeometry","ConeBufferGeometry","Light","LightShadow","_frameExtents","_viewportCount","_viewports","SpotLightShadow","SpotLight","power","OrthographicCamera","AmbientLight","isCanvasTexture","_lightPositionWorld","_lookTarget","shadowMatrix","projScreenMatrix","lookTarget","lightPositionWorld","viewportIndex","isSpotLightShadow","scaleW","scaleH","_eyeRight","_eyeLeft","StereoCamera","eyeSep","_cache","Uniform","getQuery","RegExp","location","decodeURIComponent","defaults","defaultValue","createParams","defaultParams","o","updateParams","newParams","getProtocol","protocol","getBrowser","ua","navigator","userAgent","openUrl","open","href","download","downloadName","isSafari","isChromeIos","createElement","msSaveOrOpenBlob","FileReader","reader","onloadend","readAsDataURL","objectUrlCreated","URL","createObjectURL","display","body","appendChild","click","removeChild","revokeObjectURL","lexicographicCompare","elm1","elm2","binarySearchIndexOf","compareFunction","mid","cmp","rangeInSortedArray","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sorted","uint8ToString","u8a","chunkSize","fromCharCode","getTypedArray","arrayType","arraySize","getUintArray","sizeOrArray","maxUint","ensureBuffer","ArrayBuffer","_ensureClassFromArray","ensureVector3","ensureMatrix4","ensureQuaternion","ensureFloat32Array","arg","toLowerCaseString","toLowerCase","xmin","xmax","eyeSepHalf","eyeSepOnProjection","ymax","Registry","_dict","prototypeAccessors","names","deg","chars","rnd","spline","tension","t2","LAB_CONSTANTS","PITHIRD","TWOPI","_average_lrgb","_guess_formats","_guess_formats_sorted","_input","_interpolators","bezier","blend","blend_f","brewer","burn","chroma","clip_rgb","cmyk2rgb","css2rgb","darken","dodge","each","hcg2rgb","hex2rgb","hsi2rgb","hsl2css","hsl2rgb","hsv2rgb","interpolate","interpolate_hsx","interpolate_lab","interpolate_lrgb","interpolate_num","interpolate_rgb","lab2lch","lab2rgb","lab_xyz","lch2lab","lch2rgb","lighten","limit","luminance_x","num2rgb","overlay","rgb2cmyk","rgb2css","rgb2hcg","rgb2hex","rgb2hsi","rgb2hsl","rgb2hsv","rgb2lab","rgb2lch","rgb2luminance","rgb2num","rgb2temperature","rgb2xyz","rgb_xyz","screen","temperature2rgb","unpack","w3cx11","xyz_lab","xyz_rgb","classToType","ref","obj","strType","rgb","_clipped","_unclipped","func","ctor","module","exports","chk","len1","_rgb","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set2","Accent","Set1","Set3","Dark2","Paired","Pastel2","Pastel1","results","cornflower","laserlemon","lightgoldenrod","maroon2","maroon3","purple2","purple3","Yn","Xn","Zn","Kn","t3","ref1","lab","concat","I","I0","I1","lab0","lab1","lab2","lab3","ref2","cubehelix","rotations","gamma","dh","dl","fract","amp","cos_a","sin_a","code","col1","col2","interpol","mix","rgba","lrgb","xyz0","xyz1","xyz","average","cnt","first","xyz2","substr","css","channels","hxa","NaN","hsl","ref3","ref4","ref5","hsv","num","_c","_g","hcg","aa","named","L","lch","hcl","reverse","cmyk","luminance","lum","cur_lum","eps","max_iter","lm","kelvin","temp","maxTemp","minTemp","temperature","K","contrast","l1","l2","sum_sq","deltaE","L1","L2","c4","delA","delB","delC","h1","sc","sl","v3","modechan","clipped","amount","brighten","darker","brighter","saturate","desaturate","c0","out","analyze","MAX_VALUE","sum","domain","limits","_classes","_colorCache","_colors","_correctLightness","_domain","_gamma","_max","_min","_mode","_nacol","_out","_padding","_pos","_spread","_useCache","getClass","getColor","resetCache","setColors","tmap","col","bypassMap","classes","_m","_o","spread","correctLightness","L0","L_actual","L_diff","L_ideal","pol","padding","numColors","dd","dm","nodata","scales","cool","hot","visit","ag","ah","ai","ak","al","am","assignments","best","centroids","cluster","clusterSizes","dist","kClusters","max_log","min_log","mindist","nb_iters","newCentroids","pb","pr","ref10","ref11","ref12","ref13","ref14","ref6","ref7","ref8","ref9","tmpKMeansBreaks","LOG10E","hsi","hue0","hue1","lbv0","lbv1","sat","sat0","sat1","n1","n2","colorSpace","ScaleDefaultParameters","tmpColor","manageColor","_name","descriptor","originalMethod","fromTo","bind","Colormaker","structure","atomProxy","getAtomProxy","getScale","chroma\n .scale","colorToArray","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","global","SignalBinding","signal","isOnce","listenerContext","priority","_listener","_isOnce","_signal","_priority","validateListener","fnName","Signal","_bindings","_prevParams","dispatch","active","execute","paramsArr","handlerReturn","detach","isBound","getListener","getSignal","_destroy","VERSION","memorize","_shouldPropagate","_registerListener","binding","prevIndex","_indexOfListener","_addBinding","cur","addOnce","removeAll","getNumListeners","halt","bindings","forget","signals","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","rules","subTests","hasOwnProperty","and","operator","na","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","stringChanged","setString","prototypeAccessors$z","silent","retSelection","newSelection","oldSelection","selectionStack","createNewContext","getPrevContext","pushRule","rule","not","cu","sele","substring","chain","negate2","resi","resiSingle","resiRange","resnameList","indexList","lastRule","parseSele","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","isAllSelection","isNoneSelection","SelectionColormaker","colormakerList","selectionList","dataList","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","rainbow","rwb","ColormakerModes","schemes","userSchemes","getSchemes","types","getScales","getModes","ColormakerRegistry$1","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","MySelectionColormaker","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","getWorkerDeps","vars","deps","sym","__deps","makeWorkerString","onmessage","__name","postId","__postId","aMessage","transferList","postMessage","makeWorkerBlob","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","Browser","SupportsPassiveEventHandler","opts","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","labelUnit","arcVisible","planeVisible","Debug","ScriptExtensions","_WorkerRegistry","_ColormakerRegistry","DatasourceRegistry","RepresentationRegistry","_ParserRegistry","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","ListingDatasource","TrajectoryDatasource","Streamer","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","decompressFn","_chunk","chunk","peekLines","chunkToLines","chunkCount","asText","partialLine","isLast","lastIndexOf","str2","nextChunk","nextChunkOfLines","eachChunk","eachChunkOfLines","chunkNo","FileStreamer","file","onload","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","response","statusText","responseType","send","Loader","ext","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","load","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","re","not_string","not_bool","not_type","not_primitive","numeric_arg","not_json","text","modulo","placeholder","key_access","index_access","sprintf","sprintf_format","sprintf_parse","vsprintf","fmt","argv","parse_tree","ph","pad","pad_character","pad_length","is_positive","cursor","tree_length","param_no","toExponential","toFixed","toPrecision","valueOf","pad_char","align","sprintf_cache","_fmt","arg_names","SyntaxError","field_list","replacement_field","field_match","Writer","getBlob","getData","mimeType","defaultName","defaultExt","PdbWriter","renumberSerial","remarks","ensureArray","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","trajectory","ia","im","charge","chargeSign","hasModels","modelStore","eachModel","eachAtom","formatString","hetero","serial","formalCharge","occupancy","bfactor","getSelection","getString","SdfWriter","idString","titleString","countsString","chargeLines","title","atomCount","bondCount","pairs","ap","nCharges","formatAtom","formatBond","bp","bondOrder","_writeHeader","_writeCTab","_writeFooter","eachBond","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","StlWriter","surface","vectorNorm1","vectorNorm2","vectorNorm3","Counter","countChanged","signalsWrapper.Signal","change","increment","decrement","listen","counter","unlisten","onZeroOnce","Stats","updated","maxDuration","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","startTime","currentTime","reInclude","shaderCache","getShader","definesText","getDefines","shaderText","WebGLRenderingContext","wrcp","_getShaderParameter","_getShaderInfoLog","_getProgramParameter","pname","LINK_STATUS","_getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","viewer","_viewer","_factor","_onProgress","onProgress","_onFinish","onFinish","_n","_ctx","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","_finalize","renderAsync","TwoPI","circularMean","cosMean","sinMean","calculateCenterArray","array1","calculateDirectionArray","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","srcOffset","copyWithin","arrayMin","arraySum","arrayMean","ImageDefaultParameters","makeImage","originalClearAlpha","backgroundColor","setLineWidthAndPixelSize","invert","__seen","trimCanvas","bg","doBreak","off","canvasHeight","canvasWidth","pixels","getImageData","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","blob","requestRender","modelViewProjectionMatrix","projectionMatrixTranspose","updateCameraUniforms","loadShader","shaderType","COMPILE_STATUS","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","attrib","positionLocation","colorLoc","positionBuffer","ARRAY_BUFFER","STATIC_DRAW","FLOAT","whiteTex","whiteData","TEXTURE_2D","RGBA","UNSIGNED_BYTE","tex","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","FRAMEBUFFER","COLOR_ATTACHMENT0","FRAMEBUFFER_COMPLETE","TRIANGLES","COLOR_BUFFER_BIT","pixel","floatPixel","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","pu","Viewer","idOrElement","boundingBoxSize","boundingBoxLength","distVector","ticked","rendered","elm","getElementById","HTMLElement","innerWidth","innerHeight","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","cameraDistance","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","perspectiveCamera","orthographicCamera","stereoCamera","stats","rotationGroup","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","spotLight","ambientLight","dpr","devicePixelRatio","innerHTML","supportsHalfFloat","dprWidth","dprHeight","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","sampleTarget","holdTarget","compositeUniforms","tForeground","compositeMaterial","compositeCamera","compositeScene","bbGeometry","bbMaterial","uColor","boundingBoxMesh","updateHelper","instanceList","instance","addBuffer","wireframeGroup","pickable","setUserData","getMesh","wireframeMesh","getWireframeMesh","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","updateGeometry","geoBoundingBox","updateNode","node","getPickingPixels","imgBuffer","getImage","picking","imgBuffer2","ctx","imgData","setLight","setOutputEncoding","setColorWorkflow","setCamera","updateZoom","setClip","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","pick","pid","picker","pixelBuffer","oid","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","ortho","nearClip","updateMaterialUniforms","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","tmpTab","__zArray","__sortArray","__cmpFn","bi","stack","sp","swap","tmp2","quicksortCmp","attr","sortProjectedPosition","__setVisibility","helper","__updateLights","__renderPickingGroup","__renderModelGroup","__renderSuperSample","baseSampleWeight","sampleWeight","__renderStereo","_renderTarget","__render","lastRenderedPicking","rendering","getTouchDistance","touches","pageX","pageY","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","lastTouchDistance","touchDistance","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","_getRotateXY","_getCameraRotation","_transformPanVector","pan","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","applyMatrix","zRotate","rotateComponent","tmpVec","PickingProxy","pickingData","closestBondAtom","closeAtom","arrow","cone","clash","contact","cylinder","ellipsoid","octahedron","tetrahedron","torus","unitcell","unknown","volume","wideline","getComponentsByObject","getObject","getPosition","atom1","atom2","acp1","getPositionOnCanvas","acp2","ca","acp","getMaxRepresentationRadius","_objectIfType","getLabel","msg","qualifiedName","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","getCameraDistance","getOrientation","orient","spin","basis","Animation","duration","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","prototypeAccessors$1","every","AnimationControls","animationList","finishedList","rock","move","zoomMove","orientTo","timeout","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","kill","Representation","lazy","clipRadius","clipCenter","flatShaded","front","back","double","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","setColor","lazyProps","build","bufferParams","what","tp","sphereDetail","disableImpostor","getColorParams","getBufferParams","prepare","updateWhat","_make","manualAttach","disposed","setVisibility","noRenderRequest","updateParameters","int","float","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","calculateMeanVector3","projectPointOnVector","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","rad","getFixedLengthWrappedDashData","drawing","k3","kprev","inv","getNextWorker","nextWorker","minPending","Primitive","staticAccessors","Picker","Buffer","getShapeKey","expandBoundingBox","valueToShape","_primitiveData","fields","objectToShape","valueFromShape","objectFromShape","arrayFromShape","dataFromShape","bufferFromShape","SpherePrimitive","positionFromShape","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","dSq","Store","_fields","_defaultFields","prototypeAccessors$r","size$1","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","addFeature","features","centers","atomSets","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","getIntersectionSize","makeIntersection","wordsA","answer","toSeleString","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","HE","LI","BE","B","N","F","NE","NA","MG","AL","SI","P","S","CL","AR","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","calcAngles","ap1","ap2","angles","eachBondedAtom","calcPlaneAngle","v12","neighbours","ni","ValenceModel","implicitH","totalH","idealGeometry","hydrogenCount","bondToElementCount","assignCharge","assignH","degree","valence","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","flag","getOtherAtom","atomicNumber2","isConjugated","multiBond","implicitHCount","geom","ba","oa","calculateHydrogensCharge","chg","implH","totH","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","addChargedContacts","contacts","maxIonicDist","ContactDefaultParams","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","masterIdx","masterModelIndex","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","spatialHash","contactStore","featureSet","atomStore","atoms","getOffset","ct","loop","invalidAtomContact","ti","tj","isIonicInteraction","atomSet1","atomSet2","maxDist","sn","sm","si","sj","areAtomSetsWithinDist","isPiStacking","isCationPi","isHistidineNitrogen","IonicTypeMetals","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","isMasterContact","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","createContacts","maxHbondDistSq","donor","acceptor","isWeak","isWeakHydrogenBond","isHydrogenBond","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","lineOfSightDist","lineOfSightDistFactorSq","cz","as1","as2","vdw","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","contactColor","ContactPicker","prototypeAccessors$q","_applyTransformations","_getPosition","ShapePicker","primitive","CylinderPicker","prototypeAccessors$2","ArrowPicker","prototypeAccessors$3","AtomPicker","prototypeAccessors$4","AxesPicker","prototypeAccessors$5","BondPicker","bondStore","prototypeAccessors$6","prototypeAccessors$7","center1","center2","ConePicker","prototypeAccessors$8","ClashPicker","validation","prototypeAccessors$9","clashArray","_getAtomProxyFromSele","getAtomIndices","sele1","sele2","DistancePicker","prototypeAccessors$10","EllipsoidPicker","prototypeAccessors$11","OctahedronPicker","prototypeAccessors$12","BoxPicker","prototypeAccessors$13","IgnorePicker","prototypeAccessors$14","MeshPicker","prototypeAccessors$15","__position","SpherePicker","prototypeAccessors$16","SurfacePicker","prototypeAccessors$17","TetrahedronPicker","prototypeAccessors$18","TorusPicker","prototypeAccessors$19","UnitcellPicker","prototypeAccessors$20","VolumePicker","prototypeAccessors$22","vol","dp","SlicePicker","prototypeAccessors$23","PointPicker","prototypeAccessors$24","WidelinePicker","prototypeAccessors$25","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_contour","_wrap","vIndexLength","Matrix","At","nrows","ncols","Ai","Ati","pAt","atd","multiplyABt","Ap","Cp","mrows","cd","multiply3x3","Cd","Ad","Bd","m10","m14","m15","m16","m17","m18","m20","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","hypot","copyTo","svd","amt","wmt","vmt","astep","_W","Vt","vstep","iter","maxIter","Aj","Vi","Vj","sd","beta","seed","val0","asum","JacobiSVDImpl","m4new","m4set","m4multiply","m4makeScale","m4makeTranslation","m4makeRotationY","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","flagvert","tps","vertdeg","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","nv3","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","tmpSize","tran","mroty","mscale","mtrans","Surface","VolumeSurface","mc","getSurface","smooth","prototypeAccessors$p","geo","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","getAtomindex","volsurf","Volume","inverseMatrix","setData","rms","getThreeSide","prototypeAccessors$o","setAtomindex","_mean","_rms","setStats","setMatrix","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","setObjectMatrix","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","dynamic","wireframeIndexCount","defaultParameters","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","prototypeAccessors$n","nindex","DYNAMIC_DRAW","makeMaterial","wm","pm","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","checkEdge","updateWireframeIndex","getRenderOrder","_getMesh","materialName","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","wu","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","zoomScroll","trackballControls","clipNearScroll","focusScroll","getFocus","almostIdentity","setFocus","zoomFocusScroll","eachRepresentation","reprElem","comp","repr","panDrag","rotateDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","panAtomDrag","rotateComponentDrag","movePick","pickingProxy","animationControls","tooltipPick","tt","tooltip","mp","innerText","MouseActionPresets","default","measurePick","measureClear","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleAnimations","toggleRock","KeyActionPresets","toggleSpin","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","fontFamily","_clientRect","getVisibility","cr","zIndex","ComponentControls","RadiusFactoryTypes","covalent","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","getRotationQuaternion","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredAtomindex","filteredData","filteredPosition","BondHash","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","getAtomIndexByType","a3","a4","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","parentN","elemScore","child1Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","pivotIndex","pivotValue","storeIndex","arrMedian","currentDim","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","Kdtree$1","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityIndex","chainIndex","residue","atomType","partialCharge","aromatic","euclideanDistSq","euclideanDist","entityList","residueTypeId","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","connectedAtomIndex","connectedAtomIndices","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","noResname","toObject","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","prototypeAccessors$i","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","isIdentity","structureChainList","eachChain","partBox","prototypeAccessors$1$1","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","assignSecondaryStructure","secStruct","chainnames","chainnamesSorted","chainnamesIndex","helices","h2","helix","helixRun","chainChange","sheets","strandCharCode","sheet","sheetRun","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","zhangSkolnickSS","isHelical","calculateSecondaryStructure","distances","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","rStart","rEnd","chainData","mIndex","rCount","eachResidueN","newChain","bbType1","bbType2","backboneEndAtomIndex","backboneStartAtomIndex","fill","rOffset","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","spacegroup","encodedSymopList","matrixDict","symopList","symop","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","unitcellAssembly","unitcellMatrixList","getMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","fracToCart","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","rungEndIndex","bbEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","residueEnd","getModelProxy","_rp","rNextIndex","ModelProxy","chainEnd","_cp","Structure","refreshed","extraData","atomSetCache","boxes","bondSet","prototypeAccessors$c","finalizeAtoms","finalizeBonds","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","getChainnameCount","Set","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","prototypeAccessors$b","BufferRepresentation","GeometryBuffer","meshIndex","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","applyPositionTransform","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","_radius","MappedBuffer","mappingType","indexSize","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","PointBufferDefaultParameters","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","pickingTex","pickingMap","CUBIC_INTERPOLATION","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","VolumeSlice","positionType","getPositionFromCoordinate","coord","vn","ms","dimLen","setVec","tMin","tMax","pickingArray","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","prototypeAccessors$a","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","setScale","setTransform","getCenterUntransformed","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","invA","t4","t5","t8","t9","t15","t17","t18","t20","t21","t23","t26","md","mean1","mean2","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","_s1","_s2","_i","_j","ali","calc","ali1","aliIdx1","aliIdx2","ali2","_atoms1","_atoms2","initMatrices","score","gap","makeScoreFn","Vi1","Si1","Hi","Si","gap0","scoreFn","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","pointer","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","item","pickDict","del","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","Stage","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","assembly","sizeScore","backboneOnly","radiusScale","surfaceType","probeRadius","lineOnly","loadFile","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","lastFullscreenElement","getFullscreenElement","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","dataset","normalWidth","normalHeight","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","resizeElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","setSpin","setRock","pclamp","bbSize","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","ShapeComponent","__decorate","decorators","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","countSetBits","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","StructureRepresentation","radiusSize","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","selected","_break","calcArcPoint","edt","edt1d","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","iChar","nChar","iCharAll","textAtlas","txt","xadvance","xShift","yShift","inputMapping","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","CylinderGeometryBufferDefaultParameters","getGeo","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","getNormals","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","v34","inPlane1","inPlane2","improperStart","improperEnd","v3angle","nLines","line1","line2","sector","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","createWideLineBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","createMeshBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","Float32Concat","arrays","lengths","accumulatedOffset","linesList","startPoints","endPoints","startColors","endColors","triangleColors","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","opaqueCircleSectorAngleStep","sectionIndex","startOffset","setOneSideHistogram","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","scalingFactor","discHistogram","binBorders","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","positionN","sizeN","colorN","labelFactory","LineRepresentation","crosses","lone","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","ngTorus","lastClip","_probePositions","rExt","surfGrid","fillGridDim","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","_position1","_position2","GeometryGroup","geometryList","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vSplit","fullLength","coneLength","BoxBuffer","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","TetrahedronBuffer","TorusBufferDefaultParameters","radiusRatio","TorusBuffer","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","isLegacy","headerLine","headerId","legacyId","currentCoord","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","currentEntityData","currentEntityKey","chainIdx","currentChainname","currentSeqresChainname","isPqr","isPdbqt","sb","serialRadix","resnoRadix","doFrames","serialDict","unitcellDict","entityDataList","hetnameDict","modresDict","chainDict","seqresDict","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","identityMatrix","covalentI","i$1","parseCore","begIcode","struct_conf","beg_auth_seq_id","pdbx_PDB_helix_class","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsName","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","experimentalMethods","GroParser","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","decodeInt32","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","MmtfParser","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","du","un","Mol2Parser","moleculeLineNo","modelAtomIdxStart","currentRecordType","PdbqtParser","PqrParser","reItem","SdfParser","headerLines","mItem","atomStart","bondStart","bondEnd","sdfData","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","atomNames","radii","pointersDict","pointers","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","PsfParser","lastSegid","segid","reField","TopParser","currentMoleculetype","molecules","moleculetypeDict","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","DcdParser","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","notNetcdf","statement","readName","nameLength","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","TrrParser","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","lastBB0","lastBB1","_tmpIntBytes","decodeInts","nums","XtcParser","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","ymin","zmin","hx","hy","hz","DxbinParser","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","sea","sky","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","KinParser","currentGroupMasters","currentSubgroupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","ref$1","listMasters$1","listName$1","listColor$1","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","ref$2","listName$2","listColor$2","listMasters$2","radiusArray","ref$3","listMasters$3","listName$3","listColor$3","breakArray","ref$4","splitLine","ref$5","label$1","color$1","position$1","ref$6","label$2","color$2","position$2","ref$7","label$3","color$3","position$3","ref$8","dominant","ref$9","groupName$1","groupFlags$1","groupMasters$1","ref$10","groupName$2","groupFlags$2","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","ObjParser","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","elementName","vertexIndices","vertex_indices","binaryRead","dataview","binaryReadElement","loc","PlyParser","CsvParser","table","reDelimiter","JsonParser","MsgpackParser","msgpack","NetcdfParser","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","ValidationParser","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","inflate_fast","strm","_in","last","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","Z_STREAM_ERROR","TYPE","BAD","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","messages","ZStream","GZheader","Inflate","sources","raw","ended","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","RcsbDatasource","pdbid","baseUrl","suffixUrl","PubchemDatasource","PassThroughDatasource","suffixURL","AlphafoldDatasource","uniprotid","reProtocol","StaticDatasource","relativePath","pn","basePath","pathname","MdsrvDatasource","getListing","jsonData","frameIndex","getPathUrl","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","_Promise","atomIndexDict","modelCount","structures","wait","previous","later","leading","trailing"],"mappings":"2OA4TgB,IACRA,EACAC,EASAC,EACAC,EAqIEC,EApcY,oBAAXC,QACT,WAMEA,OAAOC,QAAUD,OAAOC,SAAW,CAAE,EAYrC,IAXA,IACIC,EAAMC,EADNC,EAAMJ,OAAOC,QAEbI,EAAQ,CAAE,EACVC,EAAQ,WAAc,EACtBC,EAAa,SAASC,MAAM,KAC5BC,EAAU,wMAIZD,MAAM,KAEAN,EAAOK,EAAWG,OAAaN,EAAIF,KAAOE,EAAIF,GAAQG,GAC9D,KAAQF,EAASM,EAAQC,OAAaN,EAAID,KAASC,EAAID,GAAUG,EAClE,CApBD,GAuBoB,oBAAXN,aAA8D,IAA7BA,OAAOW,mBAAsCX,OAAOW,kBAAkBC,UAAUC,QAE1HC,OAAOC,eAAef,OAAOW,kBAAkBC,UAAW,SAAU,CAElEI,MAAO,SAAUC,EAAUC,EAAMC,GAO/B,IANA,IAAIC,EAAMpB,OAAOqB,KAAKC,KAAKC,UAAUL,EAAMC,GAASX,MAAM,KAAM,IAC5DgB,EAAMJ,EAAIK,OACVC,EAAQF,GAAO,EACfG,EAAK,IAAIC,WAAWJ,GACpBK,EAAM,IAAIC,YAAYH,EAAGI,OAAQ,EAAGL,GAE/BM,EAAI,EAAGC,EAAI,EAAGD,EAAIN,EAAOM,IAChCH,EAAIG,G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C,IACPD,GAA+B,IAApB98P,EAAQg9P,QAAoB,EAAIvxQ,KAAKY,MAChDmuI,EAAU,KACVjyI,EAAS4hG,EAAKl8F,MAAMiQ,EAAStP,GACxB4rI,IAASt8H,EAAUtP,EAAO,KAChC,CAED,OATKoR,IAASA,EAAU,CAAA,GASjB,WACL,IAAI3T,EAAMZ,KAAKY,MACVywQ,IAAgC,IAApB98P,EAAQg9P,UAAmBF,EAAWzwQ,GACvD,IAAIyC,EAAY+tQ,GAAQxwQ,EAAMywQ,GAe9B,OAdA5+P,EAAU5Y,KACVsJ,EAAOjH,UACHmH,GAAa,GAAKA,EAAY+tQ,GAC5BriI,IACF1uI,aAAa0uI,GACbA,EAAU,MAEZsiI,EAAWzwQ,EACX9D,EAAS4hG,EAAKl8F,MAAMiQ,EAAStP,GACxB4rI,IAASt8H,EAAUtP,EAAO,OACrB4rI,IAAgC,IAArBx6H,EAAQi9P,WAC7BziI,EAAU3uI,WAAWkxQ,EAAOjuQ,IAGvBvG,CACT,CACF"} \ No newline at end of file +{"version":3,"file":"ngl.js","sources":["../node_modules/three/src/constants.js","../node_modules/three/src/core/EventDispatcher.js","../node_modules/three/src/math/MathUtils.js","../node_modules/three/src/math/Vector2.js","../node_modules/three/src/math/Matrix3.js","../node_modules/three/src/extras/ImageUtils.js","../node_modules/three/src/textures/Texture.js","../node_modules/three/src/math/Vector4.js","../node_modules/three/src/renderers/WebGLRenderTarget.js","../node_modules/three/src/math/Quaternion.js","../node_modules/three/src/math/Vector3.js","../node_modules/three/src/math/Matrix4.js","../node_modules/three/src/math/Euler.js","../node_modules/three/src/core/Layers.js","../node_modules/three/src/core/Object3D.js","../node_modules/three/src/scenes/Scene.js","../node_modules/three/src/math/Box3.js","../node_modules/three/src/math/Sphere.js","../node_modules/three/src/math/Ray.js","../node_modules/three/src/math/Plane.js","../node_modules/three/src/math/Triangle.js","../node_modules/three/src/math/Color.js","../node_modules/three/src/core/Face3.js","../node_modules/three/src/materials/Material.js","../node_modules/three/src/materials/MeshBasicMaterial.js","../node_modules/three/src/core/BufferAttribute.js","../node_modules/three/src/core/DirectGeometry.js","../node_modules/three/src/utils.js","../node_modules/three/src/core/BufferGeometry.js","../node_modules/three/src/objects/Mesh.js","../node_modules/three/src/core/Geometry.js","../node_modules/three/src/geometries/BoxGeometry.js","../node_modules/three/src/renderers/shaders/UniformsUtils.js","../node_modules/three/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js","../node_modules/three/src/materials/ShaderMaterial.js","../node_modules/three/src/cameras/Camera.js","../node_modules/three/src/cameras/PerspectiveCamera.js","../node_modules/three/src/textures/DataTexture.js","../node_modules/three/src/math/Frustum.js","../node_modules/three/src/renderers/shaders/UniformsLib.js","../node_modules/three/src/renderers/webgl/WebGLAnimation.js","../node_modules/three/src/renderers/webgl/WebGLAttributes.js","../node_modules/three/src/geometries/PlaneGeometry.js","../node_modules/three/src/renderers/shaders/ShaderChunk.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/common.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/packing.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/background_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/background_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/cube_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/cube_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/depth_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/depth_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/equirect_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/equirect_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/linedashed_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/linedashed_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshbasic_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshlambert_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshtoon_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshtoon_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphong_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphong_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphysical_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/normal_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/normal_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/points_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/points_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/shadow_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/shadow_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/sprite_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/sprite_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib.js","../node_modules/three/src/renderers/webgl/WebGLBackground.js","../node_modules/three/src/renderers/webgl/WebGLBindingStates.js","../node_modules/three/src/renderers/webgl/WebGLBufferRenderer.js","../node_modules/three/src/renderers/webgl/WebGLCapabilities.js","../node_modules/three/src/renderers/webgl/WebGLClipping.js","../node_modules/three/src/renderers/webgl/WebGLExtensions.js","../node_modules/three/src/renderers/webgl/WebGLGeometries.js","../node_modules/three/src/renderers/webgl/WebGLIndexedBufferRenderer.js","../node_modules/three/src/renderers/webgl/WebGLInfo.js","../node_modules/three/src/renderers/webgl/WebGLMorphtargets.js","../node_modules/three/src/renderers/webgl/WebGLObjects.js","../node_modules/three/src/textures/CubeTexture.js","../node_modules/three/src/textures/DataTexture2DArray.js","../node_modules/three/src/textures/DataTexture3D.js","../node_modules/three/src/renderers/webgl/WebGLUniforms.js","../node_modules/three/src/renderers/webgl/WebGLShader.js","../node_modules/three/src/renderers/webgl/WebGLProgram.js","../node_modules/three/src/renderers/webgl/WebGLPrograms.js","../node_modules/three/src/renderers/webgl/WebGLProperties.js","../node_modules/three/src/renderers/webgl/WebGLRenderLists.js","../node_modules/three/src/renderers/webgl/WebGLLights.js","../node_modules/three/src/renderers/webgl/WebGLRenderStates.js","../node_modules/three/src/materials/MeshDepthMaterial.js","../node_modules/three/src/materials/MeshDistanceMaterial.js","../node_modules/three/src/renderers/shaders/ShaderLib/vsm_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/vsm_vert.glsl.js","../node_modules/three/src/renderers/webgl/WebGLShadowMap.js","../node_modules/three/src/renderers/webgl/WebGLState.js","../node_modules/three/src/renderers/webgl/WebGLTextures.js","../node_modules/three/src/renderers/webgl/WebGLUtils.js","../node_modules/three/src/cameras/ArrayCamera.js","../node_modules/three/src/objects/Group.js","../node_modules/three/src/renderers/webxr/WebXRController.js","../node_modules/three/src/renderers/webxr/WebXRManager.js","../node_modules/three/src/renderers/webgl/WebGLMaterials.js","../node_modules/three/src/renderers/WebGLRenderer.js","../node_modules/three/src/scenes/Fog.js","../node_modules/three/src/materials/LineBasicMaterial.js","../node_modules/three/src/objects/Line.js","../node_modules/three/src/objects/LineSegments.js","../node_modules/three/src/materials/PointsMaterial.js","../node_modules/three/src/objects/Points.js","../node_modules/three/src/textures/CanvasTexture.js","../node_modules/three/src/geometries/PolyhedronGeometry.js","../node_modules/three/src/geometries/TetrahedronGeometry.js","../node_modules/three/src/geometries/OctahedronGeometry.js","../node_modules/three/src/geometries/IcosahedronGeometry.js","../node_modules/three/src/geometries/TorusGeometry.js","../node_modules/three/src/geometries/CylinderGeometry.js","../node_modules/three/src/geometries/ConeGeometry.js","../node_modules/three/src/lights/Light.js","../node_modules/three/src/lights/LightShadow.js","../node_modules/three/src/lights/SpotLightShadow.js","../node_modules/three/src/lights/SpotLight.js","../node_modules/three/src/cameras/OrthographicCamera.js","../node_modules/three/src/lights/AmbientLight.js","../node_modules/three/src/cameras/StereoCamera.js","../node_modules/three/src/core/Uniform.js","../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../node_modules/chroma-js/chroma.js","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../node_modules/signals/dist/signals.js","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../node_modules/sprintf-js/src/sprintf.js","../src/writer/writer.ts","../src/utils/io-buffer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/stage/mouse-observer.ts","../src/constants.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/ui/parameters.ts","../src/datasource/mdsrv-datasource.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/writer/stl-writer.ts"],"sourcesContent":["export const REVISION = '118';\nexport const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };\nexport const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };\nexport const CullFaceNone = 0;\nexport const CullFaceBack = 1;\nexport const CullFaceFront = 2;\nexport const CullFaceFrontBack = 3;\nexport const FrontFaceDirectionCW = 0;\nexport const FrontFaceDirectionCCW = 1;\nexport const BasicShadowMap = 0;\nexport const PCFShadowMap = 1;\nexport const PCFSoftShadowMap = 2;\nexport const VSMShadowMap = 3;\nexport const FrontSide = 0;\nexport const BackSide = 1;\nexport const DoubleSide = 2;\nexport const FlatShading = 1;\nexport const SmoothShading = 2;\nexport const NoBlending = 0;\nexport const NormalBlending = 1;\nexport const AdditiveBlending = 2;\nexport const SubtractiveBlending = 3;\nexport const MultiplyBlending = 4;\nexport const CustomBlending = 5;\nexport const AddEquation = 100;\nexport const SubtractEquation = 101;\nexport const ReverseSubtractEquation = 102;\nexport const MinEquation = 103;\nexport const MaxEquation = 104;\nexport const ZeroFactor = 200;\nexport const OneFactor = 201;\nexport const SrcColorFactor = 202;\nexport const OneMinusSrcColorFactor = 203;\nexport const SrcAlphaFactor = 204;\nexport const OneMinusSrcAlphaFactor = 205;\nexport const DstAlphaFactor = 206;\nexport const OneMinusDstAlphaFactor = 207;\nexport const DstColorFactor = 208;\nexport const OneMinusDstColorFactor = 209;\nexport const SrcAlphaSaturateFactor = 210;\nexport const NeverDepth = 0;\nexport const AlwaysDepth = 1;\nexport const LessDepth = 2;\nexport const LessEqualDepth = 3;\nexport const EqualDepth = 4;\nexport const GreaterEqualDepth = 5;\nexport const GreaterDepth = 6;\nexport const NotEqualDepth = 7;\nexport const MultiplyOperation = 0;\nexport const MixOperation = 1;\nexport const AddOperation = 2;\nexport const NoToneMapping = 0;\nexport const LinearToneMapping = 1;\nexport const ReinhardToneMapping = 2;\nexport const CineonToneMapping = 3;\nexport const ACESFilmicToneMapping = 4;\nexport const CustomToneMapping = 5;\n\nexport const UVMapping = 300;\nexport const CubeReflectionMapping = 301;\nexport const CubeRefractionMapping = 302;\nexport const EquirectangularReflectionMapping = 303;\nexport const EquirectangularRefractionMapping = 304;\nexport const CubeUVReflectionMapping = 306;\nexport const CubeUVRefractionMapping = 307;\nexport const RepeatWrapping = 1000;\nexport const ClampToEdgeWrapping = 1001;\nexport const MirroredRepeatWrapping = 1002;\nexport const NearestFilter = 1003;\nexport const NearestMipmapNearestFilter = 1004;\nexport const NearestMipMapNearestFilter = 1004;\nexport const NearestMipmapLinearFilter = 1005;\nexport const NearestMipMapLinearFilter = 1005;\nexport const LinearFilter = 1006;\nexport const LinearMipmapNearestFilter = 1007;\nexport const LinearMipMapNearestFilter = 1007;\nexport const LinearMipmapLinearFilter = 1008;\nexport const LinearMipMapLinearFilter = 1008;\nexport const UnsignedByteType = 1009;\nexport const ByteType = 1010;\nexport const ShortType = 1011;\nexport const UnsignedShortType = 1012;\nexport const IntType = 1013;\nexport const UnsignedIntType = 1014;\nexport const FloatType = 1015;\nexport const HalfFloatType = 1016;\nexport const UnsignedShort4444Type = 1017;\nexport const UnsignedShort5551Type = 1018;\nexport const UnsignedShort565Type = 1019;\nexport const UnsignedInt248Type = 1020;\nexport const AlphaFormat = 1021;\nexport const RGBFormat = 1022;\nexport const RGBAFormat = 1023;\nexport const LuminanceFormat = 1024;\nexport const LuminanceAlphaFormat = 1025;\nexport const RGBEFormat = RGBAFormat;\nexport const DepthFormat = 1026;\nexport const DepthStencilFormat = 1027;\nexport const RedFormat = 1028;\nexport const RedIntegerFormat = 1029;\nexport const RGFormat = 1030;\nexport const RGIntegerFormat = 1031;\nexport const RGBIntegerFormat = 1032;\nexport const RGBAIntegerFormat = 1033;\n\nexport const RGB_S3TC_DXT1_Format = 33776;\nexport const RGBA_S3TC_DXT1_Format = 33777;\nexport const RGBA_S3TC_DXT3_Format = 33778;\nexport const RGBA_S3TC_DXT5_Format = 33779;\nexport const RGB_PVRTC_4BPPV1_Format = 35840;\nexport const RGB_PVRTC_2BPPV1_Format = 35841;\nexport const RGBA_PVRTC_4BPPV1_Format = 35842;\nexport const RGBA_PVRTC_2BPPV1_Format = 35843;\nexport const RGB_ETC1_Format = 36196;\nexport const RGB_ETC2_Format = 37492;\nexport const RGBA_ETC2_EAC_Format = 37496;\nexport const RGBA_ASTC_4x4_Format = 37808;\nexport const RGBA_ASTC_5x4_Format = 37809;\nexport const RGBA_ASTC_5x5_Format = 37810;\nexport const RGBA_ASTC_6x5_Format = 37811;\nexport const RGBA_ASTC_6x6_Format = 37812;\nexport const RGBA_ASTC_8x5_Format = 37813;\nexport const RGBA_ASTC_8x6_Format = 37814;\nexport const RGBA_ASTC_8x8_Format = 37815;\nexport const RGBA_ASTC_10x5_Format = 37816;\nexport const RGBA_ASTC_10x6_Format = 37817;\nexport const RGBA_ASTC_10x8_Format = 37818;\nexport const RGBA_ASTC_10x10_Format = 37819;\nexport const RGBA_ASTC_12x10_Format = 37820;\nexport const RGBA_ASTC_12x12_Format = 37821;\nexport const RGBA_BPTC_Format = 36492;\nexport const SRGB8_ALPHA8_ASTC_4x4_Format = 37840;\nexport const SRGB8_ALPHA8_ASTC_5x4_Format = 37841;\nexport const SRGB8_ALPHA8_ASTC_5x5_Format = 37842;\nexport const SRGB8_ALPHA8_ASTC_6x5_Format = 37843;\nexport const SRGB8_ALPHA8_ASTC_6x6_Format = 37844;\nexport const SRGB8_ALPHA8_ASTC_8x5_Format = 37845;\nexport const SRGB8_ALPHA8_ASTC_8x6_Format = 37846;\nexport const SRGB8_ALPHA8_ASTC_8x8_Format = 37847;\nexport const SRGB8_ALPHA8_ASTC_10x5_Format = 37848;\nexport const SRGB8_ALPHA8_ASTC_10x6_Format = 37849;\nexport const SRGB8_ALPHA8_ASTC_10x8_Format = 37850;\nexport const SRGB8_ALPHA8_ASTC_10x10_Format = 37851;\nexport const SRGB8_ALPHA8_ASTC_12x10_Format = 37852;\nexport const SRGB8_ALPHA8_ASTC_12x12_Format = 37853;\nexport const LoopOnce = 2200;\nexport const LoopRepeat = 2201;\nexport const LoopPingPong = 2202;\nexport const InterpolateDiscrete = 2300;\nexport const InterpolateLinear = 2301;\nexport const InterpolateSmooth = 2302;\nexport const ZeroCurvatureEnding = 2400;\nexport const ZeroSlopeEnding = 2401;\nexport const WrapAroundEnding = 2402;\nexport const NormalAnimationBlendMode = 2500;\nexport const AdditiveAnimationBlendMode = 2501;\nexport const TrianglesDrawMode = 0;\nexport const TriangleStripDrawMode = 1;\nexport const TriangleFanDrawMode = 2;\nexport const LinearEncoding = 3000;\nexport const sRGBEncoding = 3001;\nexport const GammaEncoding = 3007;\nexport const RGBEEncoding = 3002;\nexport const LogLuvEncoding = 3003;\nexport const RGBM7Encoding = 3004;\nexport const RGBM16Encoding = 3005;\nexport const RGBDEncoding = 3006;\nexport const BasicDepthPacking = 3200;\nexport const RGBADepthPacking = 3201;\nexport const TangentSpaceNormalMap = 0;\nexport const ObjectSpaceNormalMap = 1;\n\nexport const ZeroStencilOp = 0;\nexport const KeepStencilOp = 7680;\nexport const ReplaceStencilOp = 7681;\nexport const IncrementStencilOp = 7682;\nexport const DecrementStencilOp = 7683;\nexport const IncrementWrapStencilOp = 34055;\nexport const DecrementWrapStencilOp = 34056;\nexport const InvertStencilOp = 5386;\n\nexport const NeverStencilFunc = 512;\nexport const LessStencilFunc = 513;\nexport const EqualStencilFunc = 514;\nexport const LessEqualStencilFunc = 515;\nexport const GreaterStencilFunc = 516;\nexport const NotEqualStencilFunc = 517;\nexport const GreaterEqualStencilFunc = 518;\nexport const AlwaysStencilFunc = 519;\n\nexport const StaticDrawUsage = 35044;\nexport const DynamicDrawUsage = 35048;\nexport const StreamDrawUsage = 35040;\nexport const StaticReadUsage = 35045;\nexport const DynamicReadUsage = 35049;\nexport const StreamReadUsage = 35041;\nexport const StaticCopyUsage = 35046;\nexport const DynamicCopyUsage = 35050;\nexport const StreamCopyUsage = 35042;\n","/**\n * https://github.com/mrdoob/eventdispatcher.js/\n */\n\nfunction EventDispatcher() {}\n\nObject.assign( EventDispatcher.prototype, {\n\n\taddEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) this._listeners = {};\n\n\t\tconst listeners = this._listeners;\n\n\t\tif ( listeners[ type ] === undefined ) {\n\n\t\t\tlisteners[ type ] = [];\n\n\t\t}\n\n\t\tif ( listeners[ type ].indexOf( listener ) === - 1 ) {\n\n\t\t\tlisteners[ type ].push( listener );\n\n\t\t}\n\n\t},\n\n\thasEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) return false;\n\n\t\tconst listeners = this._listeners;\n\n\t\treturn listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;\n\n\t},\n\n\tremoveEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) return;\n\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[ type ];\n\n\t\tif ( listenerArray !== undefined ) {\n\n\t\t\tconst index = listenerArray.indexOf( listener );\n\n\t\t\tif ( index !== - 1 ) {\n\n\t\t\t\tlistenerArray.splice( index, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tdispatchEvent: function ( event ) {\n\n\t\tif ( this._listeners === undefined ) return;\n\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[ event.type ];\n\n\t\tif ( listenerArray !== undefined ) {\n\n\t\t\tevent.target = this;\n\n\t\t\t// Make a copy, in case listeners are removed while iterating.\n\t\t\tconst array = listenerArray.slice( 0 );\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\tarray[ i ].call( this, event );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\n\nexport { EventDispatcher };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author thezwap\n */\n\nconst _lut = [];\n\nfor ( let i = 0; i < 256; i ++ ) {\n\n\t_lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );\n\n}\n\nconst MathUtils = {\n\n\tDEG2RAD: Math.PI / 180,\n\tRAD2DEG: 180 / Math.PI,\n\n\tgenerateUUID: function () {\n\n\t\t// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136\n\n\t\tconst d0 = Math.random() * 0xffffffff | 0;\n\t\tconst d1 = Math.random() * 0xffffffff | 0;\n\t\tconst d2 = Math.random() * 0xffffffff | 0;\n\t\tconst d3 = Math.random() * 0xffffffff | 0;\n\t\tconst uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +\n\t\t\t_lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' +\n\t\t\t_lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] +\n\t\t\t_lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ];\n\n\t\t// .toUpperCase() here flattens concatenated strings to save heap memory space.\n\t\treturn uuid.toUpperCase();\n\n\t},\n\n\tclamp: function ( value, min, max ) {\n\n\t\treturn Math.max( min, Math.min( max, value ) );\n\n\t},\n\n\t// compute euclidian modulo of m % n\n\t// https://en.wikipedia.org/wiki/Modulo_operation\n\n\teuclideanModulo: function ( n, m ) {\n\n\t\treturn ( ( n % m ) + m ) % m;\n\n\t},\n\n\t// Linear mapping from range to range \n\n\tmapLinear: function ( x, a1, a2, b1, b2 ) {\n\n\t\treturn b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );\n\n\t},\n\n\t// https://en.wikipedia.org/wiki/Linear_interpolation\n\n\tlerp: function ( x, y, t ) {\n\n\t\treturn ( 1 - t ) * x + t * y;\n\n\t},\n\n\t// http://en.wikipedia.org/wiki/Smoothstep\n\n\tsmoothstep: function ( x, min, max ) {\n\n\t\tif ( x <= min ) return 0;\n\t\tif ( x >= max ) return 1;\n\n\t\tx = ( x - min ) / ( max - min );\n\n\t\treturn x * x * ( 3 - 2 * x );\n\n\t},\n\n\tsmootherstep: function ( x, min, max ) {\n\n\t\tif ( x <= min ) return 0;\n\t\tif ( x >= max ) return 1;\n\n\t\tx = ( x - min ) / ( max - min );\n\n\t\treturn x * x * x * ( x * ( x * 6 - 15 ) + 10 );\n\n\t},\n\n\t// Random integer from interval\n\n\trandInt: function ( low, high ) {\n\n\t\treturn low + Math.floor( Math.random() * ( high - low + 1 ) );\n\n\t},\n\n\t// Random float from interval\n\n\trandFloat: function ( low, high ) {\n\n\t\treturn low + Math.random() * ( high - low );\n\n\t},\n\n\t// Random float from <-range/2, range/2> interval\n\n\trandFloatSpread: function ( range ) {\n\n\t\treturn range * ( 0.5 - Math.random() );\n\n\t},\n\n\tdegToRad: function ( degrees ) {\n\n\t\treturn degrees * MathUtils.DEG2RAD;\n\n\t},\n\n\tradToDeg: function ( radians ) {\n\n\t\treturn radians * MathUtils.RAD2DEG;\n\n\t},\n\n\tisPowerOfTwo: function ( value ) {\n\n\t\treturn ( value & ( value - 1 ) ) === 0 && value !== 0;\n\n\t},\n\n\tceilPowerOfTwo: function ( value ) {\n\n\t\treturn Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );\n\n\t},\n\n\tfloorPowerOfTwo: function ( value ) {\n\n\t\treturn Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );\n\n\t},\n\n\tsetQuaternionFromProperEuler: function ( q, a, b, c, order ) {\n\n\t\t// Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles\n\n\t\t// rotations are applied to the axes in the order specified by 'order'\n\t\t// rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'\n\t\t// angles are in radians\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\n\t\tconst c2 = cos( b / 2 );\n\t\tconst s2 = sin( b / 2 );\n\n\t\tconst c13 = cos( ( a + c ) / 2 );\n\t\tconst s13 = sin( ( a + c ) / 2 );\n\n\t\tconst c1_3 = cos( ( a - c ) / 2 );\n\t\tconst s1_3 = sin( ( a - c ) / 2 );\n\n\t\tconst c3_1 = cos( ( c - a ) / 2 );\n\t\tconst s3_1 = sin( ( c - a ) / 2 );\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYX':\n\t\t\t\tq.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZY':\n\t\t\t\tq.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXZ':\n\t\t\t\tq.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZX':\n\t\t\t\tq.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXY':\n\t\t\t\tq.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYZ':\n\t\t\t\tq.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t}\n\n};\n\n\nexport { MathUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author philogb / http://blog.thejit.org/\n * @author egraether / http://egraether.com/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n */\n\nfunction Vector2( x = 0, y = 0 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\n}\n\nObject.defineProperties( Vector2.prototype, {\n\n\t\"width\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.x = value;\n\n\t\t}\n\n\t},\n\n\t\"height\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.y = value;\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Vector2.prototype, {\n\n\tisVector2: true,\n\n\tset: function ( x, y ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( v ) {\n\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tdivide: function ( v ) {\n\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tconst x = this.x, y = this.y;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];\n\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];\n\n\t\treturn this;\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y;\n\n\t},\n\n\tcross: function ( v ) {\n\n\t\treturn this.x * v.y - this.y * v.x;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tangle: function () {\n\n\t\t// computes the angle in radians with respect to the positive x-axis\n\n\t\tconst angle = Math.atan2( - this.y, - this.x ) + Math.PI;\n\n\t\treturn angle;\n\n\t},\n\n\tdistanceTo: function ( v ) {\n\n\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t},\n\n\tdistanceToSquared: function ( v ) {\n\n\t\tconst dx = this.x - v.x, dy = this.y - v.y;\n\t\treturn dx * dx + dy * dy;\n\n\t},\n\n\tmanhattanDistanceTo: function ( v ) {\n\n\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\n\t\treturn this;\n\n\t},\n\n\trotateAround: function ( center, angle ) {\n\n\t\tconst c = Math.cos( angle ), s = Math.sin( angle );\n\n\t\tconst x = this.x - center.x;\n\t\tconst y = this.y - center.y;\n\n\t\tthis.x = x * c - y * s + center.x;\n\t\tthis.y = x * s + y * c + center.y;\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector2 };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n * @author tschw\n */\n\nfunction Matrix3() {\n\n\tthis.elements = [\n\n\t\t1, 0, 0,\n\t\t0, 1, 0,\n\t\t0, 0, 1\n\n\t];\n\n\tif ( arguments.length > 0 ) {\n\n\t\tconsole.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );\n\n\t}\n\n}\n\nObject.assign( Matrix3.prototype, {\n\n\tisMatrix3: true,\n\n\tset: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;\n\t\tte[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;\n\t\tte[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;\n\n\t\treturn this;\n\n\t},\n\n\tidentity: function () {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0,\n\t\t\t0, 1, 0,\n\t\t\t0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().fromArray( this.elements );\n\n\t},\n\n\tcopy: function ( m ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];\n\t\tte[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];\n\t\tte[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\txAxis.setFromMatrix3Column( this, 0 );\n\t\tyAxis.setFromMatrix3Column( this, 1 );\n\t\tzAxis.setFromMatrix3Column( this, 2 );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrix4: function ( m ) {\n\n\t\tconst me = m.elements;\n\n\t\tthis.set(\n\n\t\t\tme[ 0 ], me[ 4 ], me[ 8 ],\n\t\t\tme[ 1 ], me[ 5 ], me[ 9 ],\n\t\t\tme[ 2 ], me[ 6 ], me[ 10 ]\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( this, m );\n\n\t},\n\n\tpremultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( m, this );\n\n\t},\n\n\tmultiplyMatrices: function ( a, b ) {\n\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\n\t\tconst a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];\n\t\tconst a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];\n\t\tconst a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];\n\n\t\tconst b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];\n\t\tconst b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];\n\t\tconst b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];\n\n\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;\n\t\tte[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;\n\t\tte[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;\n\n\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;\n\t\tte[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;\n\t\tte[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;\n\n\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;\n\t\tte[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;\n\t\tte[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;\n\t\tte[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;\n\t\tte[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;\n\n\t\treturn this;\n\n\t},\n\n\tdeterminant: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],\n\t\t\td = te[ 3 ], e = te[ 4 ], f = te[ 5 ],\n\t\t\tg = te[ 6 ], h = te[ 7 ], i = te[ 8 ];\n\n\t\treturn a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;\n\n\t},\n\n\tgetInverse: function ( matrix, throwOnDegenerate ) {\n\n\t\tif ( throwOnDegenerate !== undefined ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.\" );\n\n\t\t}\n\n\t\tconst me = matrix.elements,\n\t\t\tte = this.elements,\n\n\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],\n\t\t\tn12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],\n\t\t\tn13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],\n\n\t\t\tt11 = n33 * n22 - n32 * n23,\n\t\t\tt12 = n32 * n13 - n33 * n12,\n\t\t\tt13 = n23 * n12 - n22 * n13,\n\n\t\t\tdet = n11 * t11 + n21 * t12 + n31 * t13;\n\n\t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n\t\tconst detInv = 1 / det;\n\n\t\tte[ 0 ] = t11 * detInv;\n\t\tte[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;\n\t\tte[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;\n\n\t\tte[ 3 ] = t12 * detInv;\n\t\tte[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;\n\t\tte[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;\n\n\t\tte[ 6 ] = t13 * detInv;\n\t\tte[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;\n\t\tte[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;\n\n\t\treturn this;\n\n\t},\n\n\ttranspose: function () {\n\n\t\tlet tmp;\n\t\tconst m = this.elements;\n\n\t\ttmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;\n\t\ttmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;\n\t\ttmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;\n\n\t\treturn this;\n\n\t},\n\n\tgetNormalMatrix: function ( matrix4 ) {\n\n\t\treturn this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();\n\n\t},\n\n\ttransposeIntoArray: function ( r ) {\n\n\t\tconst m = this.elements;\n\n\t\tr[ 0 ] = m[ 0 ];\n\t\tr[ 1 ] = m[ 3 ];\n\t\tr[ 2 ] = m[ 6 ];\n\t\tr[ 3 ] = m[ 1 ];\n\t\tr[ 4 ] = m[ 4 ];\n\t\tr[ 5 ] = m[ 7 ];\n\t\tr[ 6 ] = m[ 2 ];\n\t\tr[ 7 ] = m[ 5 ];\n\t\tr[ 8 ] = m[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\tsetUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {\n\n\t\tconst c = Math.cos( rotation );\n\t\tconst s = Math.sin( rotation );\n\n\t\tthis.set(\n\t\t\tsx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,\n\t\t\t- sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,\n\t\t\t0, 0, 1\n\t\t);\n\n\t},\n\n\tscale: function ( sx, sy ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;\n\t\tte[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;\n\n\t\treturn this;\n\n\t},\n\n\trotate: function ( theta ) {\n\n\t\tconst c = Math.cos( theta );\n\t\tconst s = Math.sin( theta );\n\n\t\tconst te = this.elements;\n\n\t\tconst a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];\n\t\tconst a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];\n\n\t\tte[ 0 ] = c * a11 + s * a21;\n\t\tte[ 3 ] = c * a12 + s * a22;\n\t\tte[ 6 ] = c * a13 + s * a23;\n\n\t\tte[ 1 ] = - s * a11 + c * a21;\n\t\tte[ 4 ] = - s * a12 + c * a22;\n\t\tte[ 7 ] = - s * a13 + c * a23;\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( tx, ty ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];\n\t\tte[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( matrix ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) {\n\n\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) {\n\n\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tconst te = this.elements;\n\n\t\tarray[ offset ] = te[ 0 ];\n\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\tarray[ offset + 2 ] = te[ 2 ];\n\n\t\tarray[ offset + 3 ] = te[ 3 ];\n\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\tarray[ offset + 5 ] = te[ 5 ];\n\n\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\tarray[ offset + 7 ] = te[ 7 ];\n\t\tarray[ offset + 8 ] = te[ 8 ];\n\n\t\treturn array;\n\n\t}\n\n} );\n\n\nexport { Matrix3 };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n */\n\nlet _canvas;\n\nconst ImageUtils = {\n\n\tgetDataURL: function ( image ) {\n\n\t\tif ( /^data:/i.test( image.src ) ) {\n\n\t\t\treturn image.src;\n\n\t\t}\n\n\t\tif ( typeof HTMLCanvasElement == 'undefined' ) {\n\n\t\t\treturn image.src;\n\n\t\t}\n\n\t\tlet canvas;\n\n\t\tif ( image instanceof HTMLCanvasElement ) {\n\n\t\t\tcanvas = image;\n\n\t\t} else {\n\n\t\t\tif ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t\t\t_canvas.width = image.width;\n\t\t\t_canvas.height = image.height;\n\n\t\t\tconst context = _canvas.getContext( '2d' );\n\n\t\t\tif ( image instanceof ImageData ) {\n\n\t\t\t\tcontext.putImageData( image, 0, 0 );\n\n\t\t\t} else {\n\n\t\t\t\tcontext.drawImage( image, 0, 0, image.width, image.height );\n\n\t\t\t}\n\n\t\t\tcanvas = _canvas;\n\n\t\t}\n\n\t\tif ( canvas.width > 2048 || canvas.height > 2048 ) {\n\n\t\t\treturn canvas.toDataURL( 'image/jpeg', 0.6 );\n\n\t\t} else {\n\n\t\t\treturn canvas.toDataURL( 'image/png' );\n\n\t\t}\n\n\t}\n\n};\n\nexport { ImageUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n */\n\nimport { EventDispatcher } from '../core/EventDispatcher.js';\nimport {\n\tMirroredRepeatWrapping,\n\tClampToEdgeWrapping,\n\tRepeatWrapping,\n\tLinearEncoding,\n\tUnsignedByteType,\n\tRGBAFormat,\n\tLinearMipmapLinearFilter,\n\tLinearFilter,\n\tUVMapping\n} from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { ImageUtils } from '../extras/ImageUtils.js';\n\nlet textureId = 0;\n\nfunction Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\tObject.defineProperty( this, 'id', { value: textureId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\n\tthis.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;\n\tthis.mipmaps = [];\n\n\tthis.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;\n\n\tthis.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;\n\tthis.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;\n\n\tthis.magFilter = magFilter !== undefined ? magFilter : LinearFilter;\n\tthis.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter;\n\n\tthis.anisotropy = anisotropy !== undefined ? anisotropy : 1;\n\n\tthis.format = format !== undefined ? format : RGBAFormat;\n\tthis.internalFormat = null;\n\tthis.type = type !== undefined ? type : UnsignedByteType;\n\n\tthis.offset = new Vector2( 0, 0 );\n\tthis.repeat = new Vector2( 1, 1 );\n\tthis.center = new Vector2( 0, 0 );\n\tthis.rotation = 0;\n\n\tthis.matrixAutoUpdate = true;\n\tthis.matrix = new Matrix3();\n\n\tthis.generateMipmaps = true;\n\tthis.premultiplyAlpha = false;\n\tthis.flipY = true;\n\tthis.unpackAlignment = 4;\t// valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)\n\n\t// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.\n\t//\n\t// Also changing the encoding after already used by a Material will not automatically make the Material\n\t// update. You need to explicitly call Material.needsUpdate to trigger it to recompile.\n\tthis.encoding = encoding !== undefined ? encoding : LinearEncoding;\n\n\tthis.version = 0;\n\tthis.onUpdate = null;\n\n}\n\nTexture.DEFAULT_IMAGE = undefined;\nTexture.DEFAULT_MAPPING = UVMapping;\n\nTexture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Texture,\n\n\tisTexture: true,\n\n\tupdateMatrix: function () {\n\n\t\tthis.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\n\t\tthis.image = source.image;\n\t\tthis.mipmaps = source.mipmaps.slice( 0 );\n\n\t\tthis.mapping = source.mapping;\n\n\t\tthis.wrapS = source.wrapS;\n\t\tthis.wrapT = source.wrapT;\n\n\t\tthis.magFilter = source.magFilter;\n\t\tthis.minFilter = source.minFilter;\n\n\t\tthis.anisotropy = source.anisotropy;\n\n\t\tthis.format = source.format;\n\t\tthis.internalFormat = source.internalFormat;\n\t\tthis.type = source.type;\n\n\t\tthis.offset.copy( source.offset );\n\t\tthis.repeat.copy( source.repeat );\n\t\tthis.center.copy( source.center );\n\t\tthis.rotation = source.rotation;\n\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrix.copy( source.matrix );\n\n\t\tthis.generateMipmaps = source.generateMipmaps;\n\t\tthis.premultiplyAlpha = source.premultiplyAlpha;\n\t\tthis.flipY = source.flipY;\n\t\tthis.unpackAlignment = source.unpackAlignment;\n\t\tthis.encoding = source.encoding;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\tif ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {\n\n\t\t\treturn meta.textures[ this.uuid ];\n\n\t\t}\n\n\t\tconst output = {\n\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Texture',\n\t\t\t\tgenerator: 'Texture.toJSON'\n\t\t\t},\n\n\t\t\tuuid: this.uuid,\n\t\t\tname: this.name,\n\n\t\t\tmapping: this.mapping,\n\n\t\t\trepeat: [ this.repeat.x, this.repeat.y ],\n\t\t\toffset: [ this.offset.x, this.offset.y ],\n\t\t\tcenter: [ this.center.x, this.center.y ],\n\t\t\trotation: this.rotation,\n\n\t\t\twrap: [ this.wrapS, this.wrapT ],\n\n\t\t\tformat: this.format,\n\t\t\ttype: this.type,\n\t\t\tencoding: this.encoding,\n\n\t\t\tminFilter: this.minFilter,\n\t\t\tmagFilter: this.magFilter,\n\t\t\tanisotropy: this.anisotropy,\n\n\t\t\tflipY: this.flipY,\n\n\t\t\tpremultiplyAlpha: this.premultiplyAlpha,\n\t\t\tunpackAlignment: this.unpackAlignment\n\n\t\t};\n\n\t\tif ( this.image !== undefined ) {\n\n\t\t\t// TODO: Move to THREE.Image\n\n\t\t\tconst image = this.image;\n\n\t\t\tif ( image.uuid === undefined ) {\n\n\t\t\t\timage.uuid = MathUtils.generateUUID(); // UGH\n\n\t\t\t}\n\n\t\t\tif ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {\n\n\t\t\t\tlet url;\n\n\t\t\t\tif ( Array.isArray( image ) ) {\n\n\t\t\t\t\t// process array of images e.g. CubeTexture\n\n\t\t\t\t\turl = [];\n\n\t\t\t\t\tfor ( let i = 0, l = image.length; i < l; i ++ ) {\n\n\t\t\t\t\t\turl.push( ImageUtils.getDataURL( image[ i ] ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// process single image\n\n\t\t\t\t\turl = ImageUtils.getDataURL( image );\n\n\t\t\t\t}\n\n\t\t\t\tmeta.images[ image.uuid ] = {\n\t\t\t\t\tuuid: image.uuid,\n\t\t\t\t\turl: url\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\toutput.image = image.uuid;\n\n\t\t}\n\n\t\tif ( ! isRootObject ) {\n\n\t\t\tmeta.textures[ this.uuid ] = output;\n\n\t\t}\n\n\t\treturn output;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t},\n\n\ttransformUv: function ( uv ) {\n\n\t\tif ( this.mapping !== UVMapping ) return uv;\n\n\t\tuv.applyMatrix3( this.matrix );\n\n\t\tif ( uv.x < 0 || uv.x > 1 ) {\n\n\t\t\tswitch ( this.wrapS ) {\n\n\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\tuv.x = uv.x < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\tif ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\tuv.x = Math.ceil( uv.x ) - uv.x;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( uv.y < 0 || uv.y > 1 ) {\n\n\t\t\tswitch ( this.wrapT ) {\n\n\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\tuv.y = uv.y < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\tif ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\tuv.y = Math.ceil( uv.y ) - uv.y;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.flipY ) {\n\n\t\t\tuv.y = 1 - uv.y;\n\n\t\t}\n\n\t\treturn uv;\n\n\t}\n\n} );\n\nObject.defineProperty( Texture.prototype, \"needsUpdate\", {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\n\nexport { Texture };\n","/**\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Vector4( x = 0, y = 0, z = 0, w = 1 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\tthis.z = z;\n\tthis.w = w;\n\n}\n\nObject.defineProperties( Vector4.prototype, {\n\n\t\"width\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.z = value;\n\n\t\t}\n\n\t},\n\n\t\"height\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.w;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.w = value;\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Vector4.prototype, {\n\n\tisVector4: true,\n\n\tset: function ( x, y, z, w ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t\tthis.w = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\t\tthis.w = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetZ: function ( z ) {\n\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetW: function ( w ) {\n\n\t\tthis.w = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tcase 2: this.z = value; break;\n\t\t\tcase 3: this.w = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tcase 2: return this.z;\n\t\t\tcase 3: return this.w;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y, this.z, this.w );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\t\tthis.w = ( v.w !== undefined ) ? v.w : 1;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\t\tthis.w += v.w;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\t\tthis.w += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\t\tthis.w = a.w + b.w;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\t\tthis.w += v.w * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\t\tthis.w -= v.w;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\t\tthis.w -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\t\tthis.w = a.w - b.w;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\t\tthis.w *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z, w = this.w;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;\n\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;\n\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;\n\t\tthis.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tsetAxisAngleFromQuaternion: function ( q ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm\n\n\t\t// q is assumed to be normalized\n\n\t\tthis.w = 2 * Math.acos( q.w );\n\n\t\tconst s = Math.sqrt( 1 - q.w * q.w );\n\n\t\tif ( s < 0.0001 ) {\n\n\t\t\tthis.x = 1;\n\t\t\tthis.y = 0;\n\t\t\tthis.z = 0;\n\n\t\t} else {\n\n\t\t\tthis.x = q.x / s;\n\t\t\tthis.y = q.y / s;\n\t\t\tthis.z = q.z / s;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetAxisAngleFromRotationMatrix: function ( m ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tlet angle, x, y, z; // variables for result\n\t\tconst epsilon = 0.01,\t\t// margin to allow for rounding errors\n\t\t\tepsilon2 = 0.1,\t\t// margin to distinguish between 0 and 180 degrees\n\n\t\t\tte = m.elements,\n\n\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\tif ( ( Math.abs( m12 - m21 ) < epsilon ) &&\n\t\t ( Math.abs( m13 - m31 ) < epsilon ) &&\n\t\t ( Math.abs( m23 - m32 ) < epsilon ) ) {\n\n\t\t\t// singularity found\n\t\t\t// first check for identity matrix which must have +1 for all terms\n\t\t\t// in leading diagonal and zero in other terms\n\n\t\t\tif ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m13 + m31 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m23 + m32 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {\n\n\t\t\t\t// this singularity is identity matrix so angle = 0\n\n\t\t\t\tthis.set( 1, 0, 0, 0 );\n\n\t\t\t\treturn this; // zero angle, arbitrary axis\n\n\t\t\t}\n\n\t\t\t// otherwise this singularity is angle = 180\n\n\t\t\tangle = Math.PI;\n\n\t\t\tconst xx = ( m11 + 1 ) / 2;\n\t\t\tconst yy = ( m22 + 1 ) / 2;\n\t\t\tconst zz = ( m33 + 1 ) / 2;\n\t\t\tconst xy = ( m12 + m21 ) / 4;\n\t\t\tconst xz = ( m13 + m31 ) / 4;\n\t\t\tconst yz = ( m23 + m32 ) / 4;\n\n\t\t\tif ( ( xx > yy ) && ( xx > zz ) ) {\n\n\t\t\t\t// m11 is the largest diagonal term\n\n\t\t\t\tif ( xx < epsilon ) {\n\n\t\t\t\t\tx = 0;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tx = Math.sqrt( xx );\n\t\t\t\t\ty = xy / x;\n\t\t\t\t\tz = xz / x;\n\n\t\t\t\t}\n\n\t\t\t} else if ( yy > zz ) {\n\n\t\t\t\t// m22 is the largest diagonal term\n\n\t\t\t\tif ( yy < epsilon ) {\n\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0;\n\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t} else {\n\n\t\t\t\t\ty = Math.sqrt( yy );\n\t\t\t\t\tx = xy / y;\n\t\t\t\t\tz = yz / y;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// m33 is the largest diagonal term so base result on this\n\n\t\t\t\tif ( zz < epsilon ) {\n\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tz = Math.sqrt( zz );\n\t\t\t\t\tx = xz / z;\n\t\t\t\t\ty = yz / z;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.set( x, y, z, angle );\n\n\t\t\treturn this; // return 180 deg rotation\n\n\t\t}\n\n\t\t// as we have reached here there are no singularities so we can handle normally\n\n\t\tlet s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +\n\t\t\t( m13 - m31 ) * ( m13 - m31 ) +\n\t\t\t( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize\n\n\t\tif ( Math.abs( s ) < 0.001 ) s = 1;\n\n\t\t// prevent divide by zero, should not happen if matrix is orthogonal and should be\n\t\t// caught by singularity test above, but I've left it in just in case\n\n\t\tthis.x = ( m32 - m23 ) / s;\n\t\tthis.y = ( m13 - m31 ) / s;\n\t\tthis.z = ( m21 - m12 ) / s;\n\t\tthis.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );\n\n\t\treturn this;\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\t\tthis.z = Math.min( this.z, v.z );\n\t\tthis.w = Math.min( this.w, v.w );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\t\tthis.z = Math.max( this.z, v.z );\n\t\tthis.w = Math.max( this.w, v.w );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\t\tthis.w = Math.max( min.w, Math.min( max.w, this.w ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\t\tthis.z = Math.max( minVal, Math.min( maxVal, this.z ) );\n\t\tthis.w = Math.max( minVal, Math.min( maxVal, this.w ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\t\tthis.z = Math.floor( this.z );\n\t\tthis.w = Math.floor( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\t\tthis.z = Math.ceil( this.z );\n\t\tthis.w = Math.ceil( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\t\tthis.z = Math.round( this.z );\n\t\tthis.w = Math.round( this.w );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\t\tthis.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\t\tthis.z = - this.z;\n\t\tthis.w = - this.w;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\tthis.z += ( v.z - this.z ) * alpha;\n\t\tthis.w += ( v.w - this.w ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\t\tthis.w = v1.w + ( v2.w - v1.w ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\t\tthis.z = array[ offset + 2 ];\n\t\tthis.w = array[ offset + 3 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\t\tarray[ offset + 2 ] = this.z;\n\t\tarray[ offset + 3 ] = this.w;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\t\tthis.z = attribute.getZ( index );\n\t\tthis.w = attribute.getW( index );\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\t\tthis.w = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector4 };\n","import { EventDispatcher } from '../core/EventDispatcher.js';\nimport { Texture } from '../textures/Texture.js';\nimport { LinearFilter } from '../constants.js';\nimport { Vector4 } from '../math/Vector4.js';\n\n/**\n * @author szimek / https://github.com/szimek/\n * @author alteredq / http://alteredqualia.com/\n * @author Marius Kintel / https://github.com/kintel\n */\n\n/*\n In options, we can specify:\n * Texture parameters for an auto-generated target texture\n * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers\n*/\nfunction WebGLRenderTarget( width, height, options ) {\n\n\tthis.width = width;\n\tthis.height = height;\n\n\tthis.scissor = new Vector4( 0, 0, width, height );\n\tthis.scissorTest = false;\n\n\tthis.viewport = new Vector4( 0, 0, width, height );\n\n\toptions = options || {};\n\n\tthis.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );\n\n\tthis.texture.image = {};\n\tthis.texture.image.width = width;\n\tthis.texture.image.height = height;\n\n\tthis.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;\n\tthis.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;\n\n\tthis.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;\n\tthis.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;\n\tthis.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;\n\n}\n\nWebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: WebGLRenderTarget,\n\n\tisWebGLRenderTarget: true,\n\n\tsetSize: function ( width, height ) {\n\n\t\tif ( this.width !== width || this.height !== height ) {\n\n\t\t\tthis.width = width;\n\t\t\tthis.height = height;\n\n\t\t\tthis.texture.image.width = width;\n\t\t\tthis.texture.image.height = height;\n\n\t\t\tthis.dispose();\n\n\t\t}\n\n\t\tthis.viewport.set( 0, 0, width, height );\n\t\tthis.scissor.set( 0, 0, width, height );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.width = source.width;\n\t\tthis.height = source.height;\n\n\t\tthis.viewport.copy( source.viewport );\n\n\t\tthis.texture = source.texture.clone();\n\n\t\tthis.depthBuffer = source.depthBuffer;\n\t\tthis.stencilBuffer = source.stencilBuffer;\n\t\tthis.depthTexture = source.depthTexture;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { WebGLRenderTarget };\n","/**\n * @author mikael emtinger / http://gomo.se/\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n */\n\nimport { MathUtils } from './MathUtils.js';\n\nfunction Quaternion( x = 0, y = 0, z = 0, w = 1 ) {\n\n\tthis._x = x;\n\tthis._y = y;\n\tthis._z = z;\n\tthis._w = w;\n\n}\n\nObject.assign( Quaternion, {\n\n\tslerp: function ( qa, qb, qm, t ) {\n\n\t\treturn qm.copy( qa ).slerp( qb, t );\n\n\t},\n\n\tslerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {\n\n\t\t// fuzz-free, array-based Quaternion SLERP operation\n\n\t\tlet x0 = src0[ srcOffset0 + 0 ],\n\t\t\ty0 = src0[ srcOffset0 + 1 ],\n\t\t\tz0 = src0[ srcOffset0 + 2 ],\n\t\t\tw0 = src0[ srcOffset0 + 3 ];\n\n\t\tconst x1 = src1[ srcOffset1 + 0 ],\n\t\t\ty1 = src1[ srcOffset1 + 1 ],\n\t\t\tz1 = src1[ srcOffset1 + 2 ],\n\t\t\tw1 = src1[ srcOffset1 + 3 ];\n\n\t\tif ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {\n\n\t\t\tlet s = 1 - t,\n\n\t\t\t\tcos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,\n\n\t\t\t\tdir = ( cos >= 0 ? 1 : - 1 ),\n\t\t\t\tsqrSin = 1 - cos * cos;\n\n\t\t\t// Skip the Slerp for tiny steps to avoid numeric problems:\n\t\t\tif ( sqrSin > Number.EPSILON ) {\n\n\t\t\t\tconst sin = Math.sqrt( sqrSin ),\n\t\t\t\t\tlen = Math.atan2( sin, cos * dir );\n\n\t\t\t\ts = Math.sin( s * len ) / sin;\n\t\t\t\tt = Math.sin( t * len ) / sin;\n\n\t\t\t}\n\n\t\t\tconst tDir = t * dir;\n\n\t\t\tx0 = x0 * s + x1 * tDir;\n\t\t\ty0 = y0 * s + y1 * tDir;\n\t\t\tz0 = z0 * s + z1 * tDir;\n\t\t\tw0 = w0 * s + w1 * tDir;\n\n\t\t\t// Normalize in case we just did a lerp:\n\t\t\tif ( s === 1 - t ) {\n\n\t\t\t\tconst f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );\n\n\t\t\t\tx0 *= f;\n\t\t\t\ty0 *= f;\n\t\t\t\tz0 *= f;\n\t\t\t\tw0 *= f;\n\n\t\t\t}\n\n\t\t}\n\n\t\tdst[ dstOffset ] = x0;\n\t\tdst[ dstOffset + 1 ] = y0;\n\t\tdst[ dstOffset + 2 ] = z0;\n\t\tdst[ dstOffset + 3 ] = w0;\n\n\t},\n\n\tmultiplyQuaternionsFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {\n\n\t\tconst x0 = src0[ srcOffset0 ];\n\t\tconst y0 = src0[ srcOffset0 + 1 ];\n\t\tconst z0 = src0[ srcOffset0 + 2 ];\n\t\tconst w0 = src0[ srcOffset0 + 3 ];\n\n\t\tconst x1 = src1[ srcOffset1 ];\n\t\tconst y1 = src1[ srcOffset1 + 1 ];\n\t\tconst z1 = src1[ srcOffset1 + 2 ];\n\t\tconst w1 = src1[ srcOffset1 + 3 ];\n\n\t\tdst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;\n\t\tdst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;\n\t\tdst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;\n\t\tdst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;\n\n\t\treturn dst;\n\n\t}\n\n} );\n\nObject.defineProperties( Quaternion.prototype, {\n\n\tx: {\n\n\t\tget: function () {\n\n\t\t\treturn this._x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._x = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\ty: {\n\n\t\tget: function () {\n\n\t\t\treturn this._y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._y = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tz: {\n\n\t\tget: function () {\n\n\t\t\treturn this._z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._z = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tw: {\n\n\t\tget: function () {\n\n\t\t\treturn this._w;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._w = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Quaternion.prototype, {\n\n\tisQuaternion: true,\n\n\tset: function ( x, y, z, w ) {\n\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._w = w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this._x, this._y, this._z, this._w );\n\n\t},\n\n\tcopy: function ( quaternion ) {\n\n\t\tthis._x = quaternion.x;\n\t\tthis._y = quaternion.y;\n\t\tthis._z = quaternion.z;\n\t\tthis._w = quaternion.w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromEuler: function ( euler, update ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tthrow new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\tconst x = euler._x, y = euler._y, z = euler._z, order = euler.order;\n\n\t\t// http://www.mathworks.com/matlabcentral/fileexchange/\n\t\t// \t20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\n\t\t//\tcontent/SpinCalc.m\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\n\t\tconst c1 = cos( x / 2 );\n\t\tconst c2 = cos( y / 2 );\n\t\tconst c3 = cos( z / 2 );\n\n\t\tconst s1 = sin( x / 2 );\n\t\tconst s2 = sin( y / 2 );\n\t\tconst s3 = sin( z / 2 );\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t\tif ( update !== false ) this._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromAxisAngle: function ( axis, angle ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm\n\n\t\t// assumes axis is normalized\n\n\t\tconst halfAngle = angle / 2, s = Math.sin( halfAngle );\n\n\t\tthis._x = axis.x * s;\n\t\tthis._y = axis.y * s;\n\t\tthis._z = axis.z * s;\n\t\tthis._w = Math.cos( halfAngle );\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromRotationMatrix: function ( m ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tconst te = m.elements,\n\n\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],\n\n\t\t\ttrace = m11 + m22 + m33;\n\n\t\tif ( trace > 0 ) {\n\n\t\t\tconst s = 0.5 / Math.sqrt( trace + 1.0 );\n\n\t\t\tthis._w = 0.25 / s;\n\t\t\tthis._x = ( m32 - m23 ) * s;\n\t\t\tthis._y = ( m13 - m31 ) * s;\n\t\t\tthis._z = ( m21 - m12 ) * s;\n\n\t\t} else if ( m11 > m22 && m11 > m33 ) {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );\n\n\t\t\tthis._w = ( m32 - m23 ) / s;\n\t\t\tthis._x = 0.25 * s;\n\t\t\tthis._y = ( m12 + m21 ) / s;\n\t\t\tthis._z = ( m13 + m31 ) / s;\n\n\t\t} else if ( m22 > m33 ) {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );\n\n\t\t\tthis._w = ( m13 - m31 ) / s;\n\t\t\tthis._x = ( m12 + m21 ) / s;\n\t\t\tthis._y = 0.25 * s;\n\t\t\tthis._z = ( m23 + m32 ) / s;\n\n\t\t} else {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );\n\n\t\t\tthis._w = ( m21 - m12 ) / s;\n\t\t\tthis._x = ( m13 + m31 ) / s;\n\t\t\tthis._y = ( m23 + m32 ) / s;\n\t\t\tthis._z = 0.25 * s;\n\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromUnitVectors: function ( vFrom, vTo ) {\n\n\t\t// assumes direction vectors vFrom and vTo are normalized\n\n\t\tconst EPS = 0.000001;\n\n\t\tlet r = vFrom.dot( vTo ) + 1;\n\n\t\tif ( r < EPS ) {\n\n\t\t\tr = 0;\n\n\t\t\tif ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {\n\n\t\t\t\tthis._x = - vFrom.y;\n\t\t\t\tthis._y = vFrom.x;\n\t\t\t\tthis._z = 0;\n\t\t\t\tthis._w = r;\n\n\t\t\t} else {\n\n\t\t\t\tthis._x = 0;\n\t\t\t\tthis._y = - vFrom.z;\n\t\t\t\tthis._z = vFrom.y;\n\t\t\t\tthis._w = r;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3\n\n\t\t\tthis._x = vFrom.y * vTo.z - vFrom.z * vTo.y;\n\t\t\tthis._y = vFrom.z * vTo.x - vFrom.x * vTo.z;\n\t\t\tthis._z = vFrom.x * vTo.y - vFrom.y * vTo.x;\n\t\t\tthis._w = r;\n\n\t\t}\n\n\t\treturn this.normalize();\n\n\t},\n\n\tangleTo: function ( q ) {\n\n\t\treturn 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) );\n\n\t},\n\n\trotateTowards: function ( q, step ) {\n\n\t\tconst angle = this.angleTo( q );\n\n\t\tif ( angle === 0 ) return this;\n\n\t\tconst t = Math.min( 1, step / angle );\n\n\t\tthis.slerp( q, t );\n\n\t\treturn this;\n\n\t},\n\n\tinverse: function () {\n\n\t\t// quaternion is assumed to have unit length\n\n\t\treturn this.conjugate();\n\n\t},\n\n\tconjugate: function () {\n\n\t\tthis._x *= - 1;\n\t\tthis._y *= - 1;\n\t\tthis._z *= - 1;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );\n\n\t},\n\n\tnormalize: function () {\n\n\t\tlet l = this.length();\n\n\t\tif ( l === 0 ) {\n\n\t\t\tthis._x = 0;\n\t\t\tthis._y = 0;\n\t\t\tthis._z = 0;\n\t\t\tthis._w = 1;\n\n\t\t} else {\n\n\t\t\tl = 1 / l;\n\n\t\t\tthis._x = this._x * l;\n\t\t\tthis._y = this._y * l;\n\t\t\tthis._z = this._z * l;\n\t\t\tthis._w = this._w * l;\n\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( q, p ) {\n\n\t\tif ( p !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );\n\t\t\treturn this.multiplyQuaternions( q, p );\n\n\t\t}\n\n\t\treturn this.multiplyQuaternions( this, q );\n\n\t},\n\n\tpremultiply: function ( q ) {\n\n\t\treturn this.multiplyQuaternions( q, this );\n\n\t},\n\n\tmultiplyQuaternions: function ( a, b ) {\n\n\t\t// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\n\t\tconst qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;\n\t\tconst qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;\n\n\t\tthis._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;\n\t\tthis._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;\n\t\tthis._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;\n\t\tthis._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tslerp: function ( qb, t ) {\n\n\t\tif ( t === 0 ) return this;\n\t\tif ( t === 1 ) return this.copy( qb );\n\n\t\tconst x = this._x, y = this._y, z = this._z, w = this._w;\n\n\t\t// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/\n\n\t\tlet cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;\n\n\t\tif ( cosHalfTheta < 0 ) {\n\n\t\t\tthis._w = - qb._w;\n\t\t\tthis._x = - qb._x;\n\t\t\tthis._y = - qb._y;\n\t\t\tthis._z = - qb._z;\n\n\t\t\tcosHalfTheta = - cosHalfTheta;\n\n\t\t} else {\n\n\t\t\tthis.copy( qb );\n\n\t\t}\n\n\t\tif ( cosHalfTheta >= 1.0 ) {\n\n\t\t\tthis._w = w;\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;\n\n\t\tif ( sqrSinHalfTheta <= Number.EPSILON ) {\n\n\t\t\tconst s = 1 - t;\n\t\t\tthis._w = s * w + t * this._w;\n\t\t\tthis._x = s * x + t * this._x;\n\t\t\tthis._y = s * y + t * this._y;\n\t\t\tthis._z = s * z + t * this._z;\n\n\t\t\tthis.normalize();\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst sinHalfTheta = Math.sqrt( sqrSinHalfTheta );\n\t\tconst halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );\n\t\tconst ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,\n\t\t\tratioB = Math.sin( t * halfTheta ) / sinHalfTheta;\n\n\t\tthis._w = ( w * ratioA + this._w * ratioB );\n\t\tthis._x = ( x * ratioA + this._x * ratioB );\n\t\tthis._y = ( y * ratioA + this._y * ratioB );\n\t\tthis._z = ( z * ratioA + this._z * ratioB );\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( quaternion ) {\n\n\t\treturn ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis._x = array[ offset ];\n\t\tthis._y = array[ offset + 1 ];\n\t\tthis._z = array[ offset + 2 ];\n\t\tthis._w = array[ offset + 3 ];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this._x;\n\t\tarray[ offset + 1 ] = this._y;\n\t\tarray[ offset + 2 ] = this._z;\n\t\tarray[ offset + 3 ] = this._w;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index ) {\n\n\t\tthis._x = attribute.getX( index );\n\t\tthis._y = attribute.getY( index );\n\t\tthis._z = attribute.getZ( index );\n\t\tthis._w = attribute.getW( index );\n\n\t\treturn this;\n\n\t},\n\n\t_onChange: function ( callback ) {\n\n\t\tthis._onChangeCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\t_onChangeCallback: function () {}\n\n} );\n\n\nexport { Quaternion };\n","import { MathUtils } from './MathUtils.js';\nimport { Quaternion } from './Quaternion.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author kile / http://kile.stravaganza.org/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n\nconst _vector = new Vector3();\nconst _quaternion = new Quaternion();\n\nfunction Vector3( x = 0, y = 0, z = 0 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\tthis.z = z;\n\n}\n\nObject.assign( Vector3.prototype, {\n\n\tisVector3: true,\n\n\tset: function ( x, y, z ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetZ: function ( z ) {\n\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tcase 2: this.z = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tcase 2: return this.z;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y, this.z );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );\n\t\t\treturn this.multiplyVectors( v, w );\n\n\t\t}\n\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\t\tthis.z *= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyVectors: function ( a, b ) {\n\n\t\tthis.x = a.x * b.x;\n\t\tthis.y = a.y * b.y;\n\t\tthis.z = a.z * b.z;\n\n\t\treturn this;\n\n\t},\n\n\tapplyEuler: function ( euler ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tconsole.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\treturn this.applyQuaternion( _quaternion.setFromEuler( euler ) );\n\n\t},\n\n\tapplyAxisAngle: function ( axis, angle ) {\n\n\t\treturn this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;\n\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;\n\t\tthis.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;\n\n\t\treturn this;\n\n\t},\n\n\tapplyNormalMatrix: function ( m ) {\n\n\t\treturn this.applyMatrix3( m ).normalize();\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tconst w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );\n\n\t\tthis.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;\n\t\tthis.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;\n\t\tthis.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;\n\n\t\treturn this;\n\n\t},\n\n\tapplyQuaternion: function ( q ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst qx = q.x, qy = q.y, qz = q.z, qw = q.w;\n\n\t\t// calculate quat * vector\n\n\t\tconst ix = qw * x + qy * z - qz * y;\n\t\tconst iy = qw * y + qz * x - qx * z;\n\t\tconst iz = qw * z + qx * y - qy * x;\n\t\tconst iw = - qx * x - qy * y - qz * z;\n\n\t\t// calculate result * inverse quat\n\n\t\tthis.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;\n\t\tthis.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;\n\t\tthis.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;\n\n\t\treturn this;\n\n\t},\n\n\tproject: function ( camera ) {\n\n\t\treturn this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );\n\n\t},\n\n\tunproject: function ( camera ) {\n\n\t\treturn this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );\n\n\t},\n\n\ttransformDirection: function ( m ) {\n\n\t\t// input: THREE.Matrix4 affine matrix\n\t\t// vector interpreted as a direction\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;\n\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;\n\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;\n\n\t\treturn this.normalize();\n\n\t},\n\n\tdivide: function ( v ) {\n\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\t\tthis.z /= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\t\tthis.z = Math.min( this.z, v.z );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\t\tthis.z = Math.max( this.z, v.z );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\t\tthis.z = Math.max( minVal, Math.min( maxVal, this.z ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\t\tthis.z = Math.floor( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\t\tthis.z = Math.ceil( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\t\tthis.z = Math.round( this.z );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\t\tthis.z = - this.z;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\n\t},\n\n\t// TODO lengthSquared?\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\tthis.z += ( v.z - this.z ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tcross: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );\n\t\t\treturn this.crossVectors( v, w );\n\n\t\t}\n\n\t\treturn this.crossVectors( this, v );\n\n\t},\n\n\tcrossVectors: function ( a, b ) {\n\n\t\tconst ax = a.x, ay = a.y, az = a.z;\n\t\tconst bx = b.x, by = b.y, bz = b.z;\n\n\t\tthis.x = ay * bz - az * by;\n\t\tthis.y = az * bx - ax * bz;\n\t\tthis.z = ax * by - ay * bx;\n\n\t\treturn this;\n\n\t},\n\n\tprojectOnVector: function ( v ) {\n\n\t\tconst denominator = v.lengthSq();\n\n\t\tif ( denominator === 0 ) return this.set( 0, 0, 0 );\n\n\t\tconst scalar = v.dot( this ) / denominator;\n\n\t\treturn this.copy( v ).multiplyScalar( scalar );\n\n\t},\n\n\tprojectOnPlane: function ( planeNormal ) {\n\n\t\t_vector.copy( this ).projectOnVector( planeNormal );\n\n\t\treturn this.sub( _vector );\n\n\t},\n\n\treflect: function ( normal ) {\n\n\t\t// reflect incident vector off plane orthogonal to normal\n\t\t// normal is assumed to have unit length\n\n\t\treturn this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );\n\n\t},\n\n\tangleTo: function ( v ) {\n\n\t\tconst denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );\n\n\t\tif ( denominator === 0 ) return Math.PI / 2;\n\n\t\tconst theta = this.dot( v ) / denominator;\n\n\t\t// clamp, to handle numerical problems\n\n\t\treturn Math.acos( MathUtils.clamp( theta, - 1, 1 ) );\n\n\t},\n\n\tdistanceTo: function ( v ) {\n\n\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t},\n\n\tdistanceToSquared: function ( v ) {\n\n\t\tconst dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;\n\n\t\treturn dx * dx + dy * dy + dz * dz;\n\n\t},\n\n\tmanhattanDistanceTo: function ( v ) {\n\n\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );\n\n\t},\n\n\tsetFromSpherical: function ( s ) {\n\n\t\treturn this.setFromSphericalCoords( s.radius, s.phi, s.theta );\n\n\t},\n\n\tsetFromSphericalCoords: function ( radius, phi, theta ) {\n\n\t\tconst sinPhiRadius = Math.sin( phi ) * radius;\n\n\t\tthis.x = sinPhiRadius * Math.sin( theta );\n\t\tthis.y = Math.cos( phi ) * radius;\n\t\tthis.z = sinPhiRadius * Math.cos( theta );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCylindrical: function ( c ) {\n\n\t\treturn this.setFromCylindricalCoords( c.radius, c.theta, c.y );\n\n\t},\n\n\tsetFromCylindricalCoords: function ( radius, theta, y ) {\n\n\t\tthis.x = radius * Math.sin( theta );\n\t\tthis.y = y;\n\t\tthis.z = radius * Math.cos( theta );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixPosition: function ( m ) {\n\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 12 ];\n\t\tthis.y = e[ 13 ];\n\t\tthis.z = e[ 14 ];\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixScale: function ( m ) {\n\n\t\tconst sx = this.setFromMatrixColumn( m, 0 ).length();\n\t\tconst sy = this.setFromMatrixColumn( m, 1 ).length();\n\t\tconst sz = this.setFromMatrixColumn( m, 2 ).length();\n\n\t\tthis.x = sx;\n\t\tthis.y = sy;\n\t\tthis.z = sz;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixColumn: function ( m, index ) {\n\n\t\treturn this.fromArray( m.elements, index * 4 );\n\n\t},\n\n\tsetFromMatrix3Column: function ( m, index ) {\n\n\t\treturn this.fromArray( m.elements, index * 3 );\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\t\tthis.z = array[ offset + 2 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\t\tarray[ offset + 2 ] = this.z;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\t\tthis.z = attribute.getZ( index );\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector3 };\n","import { Vector3 } from './Vector3.js';\n\nconst _v1 = new Vector3();\nconst _m1 = new Matrix4();\nconst _zero = new Vector3( 0, 0, 0 );\nconst _one = new Vector3( 1, 1, 1 );\nconst _x = new Vector3();\nconst _y = new Vector3();\nconst _z = new Vector3();\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author jordi_ros / http://plattsoft.com\n * @author D1plo1d / http://github.com/D1plo1d\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author timknip / http://www.floorplanner.com/\n * @author bhouston / http://clara.io\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Matrix4() {\n\n\tthis.elements = [\n\n\t\t1, 0, 0, 0,\n\t\t0, 1, 0, 0,\n\t\t0, 0, 1, 0,\n\t\t0, 0, 0, 1\n\n\t];\n\n\tif ( arguments.length > 0 ) {\n\n\t\tconsole.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );\n\n\t}\n\n}\n\nObject.assign( Matrix4.prototype, {\n\n\tisMatrix4: true,\n\n\tset: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;\n\t\tte[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;\n\t\tte[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;\n\t\tte[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;\n\n\t\treturn this;\n\n\t},\n\n\tidentity: function () {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, 1, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new Matrix4().fromArray( this.elements );\n\n\t},\n\n\tcopy: function ( m ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];\n\t\tte[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];\n\t\tte[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];\n\t\tte[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];\n\n\t\treturn this;\n\n\t},\n\n\tcopyPosition: function ( m ) {\n\n\t\tconst te = this.elements, me = m.elements;\n\n\t\tte[ 12 ] = me[ 12 ];\n\t\tte[ 13 ] = me[ 13 ];\n\t\tte[ 14 ] = me[ 14 ];\n\n\t\treturn this;\n\n\t},\n\n\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\txAxis.setFromMatrixColumn( this, 0 );\n\t\tyAxis.setFromMatrixColumn( this, 1 );\n\t\tzAxis.setFromMatrixColumn( this, 2 );\n\n\t\treturn this;\n\n\t},\n\n\tmakeBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\tthis.set(\n\t\t\txAxis.x, yAxis.x, zAxis.x, 0,\n\t\t\txAxis.y, yAxis.y, zAxis.y, 0,\n\t\t\txAxis.z, yAxis.z, zAxis.z, 0,\n\t\t\t0, 0, 0, 1\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\textractRotation: function ( m ) {\n\n\t\t// this method does not support reflection matrices\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tconst scaleX = 1 / _v1.setFromMatrixColumn( m, 0 ).length();\n\t\tconst scaleY = 1 / _v1.setFromMatrixColumn( m, 1 ).length();\n\t\tconst scaleZ = 1 / _v1.setFromMatrixColumn( m, 2 ).length();\n\n\t\tte[ 0 ] = me[ 0 ] * scaleX;\n\t\tte[ 1 ] = me[ 1 ] * scaleX;\n\t\tte[ 2 ] = me[ 2 ] * scaleX;\n\t\tte[ 3 ] = 0;\n\n\t\tte[ 4 ] = me[ 4 ] * scaleY;\n\t\tte[ 5 ] = me[ 5 ] * scaleY;\n\t\tte[ 6 ] = me[ 6 ] * scaleY;\n\t\tte[ 7 ] = 0;\n\n\t\tte[ 8 ] = me[ 8 ] * scaleZ;\n\t\tte[ 9 ] = me[ 9 ] * scaleZ;\n\t\tte[ 10 ] = me[ 10 ] * scaleZ;\n\t\tte[ 11 ] = 0;\n\n\t\tte[ 12 ] = 0;\n\t\tte[ 13 ] = 0;\n\t\tte[ 14 ] = 0;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationFromEuler: function ( euler ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\tconst te = this.elements;\n\n\t\tconst x = euler.x, y = euler.y, z = euler.z;\n\t\tconst a = Math.cos( x ), b = Math.sin( x );\n\t\tconst c = Math.cos( y ), d = Math.sin( y );\n\t\tconst e = Math.cos( z ), f = Math.sin( z );\n\n\t\tif ( euler.order === 'XYZ' ) {\n\n\t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = - c * f;\n\t\t\tte[ 8 ] = d;\n\n\t\t\tte[ 1 ] = af + be * d;\n\t\t\tte[ 5 ] = ae - bf * d;\n\t\t\tte[ 9 ] = - b * c;\n\n\t\t\tte[ 2 ] = bf - ae * d;\n\t\t\tte[ 6 ] = be + af * d;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'YXZ' ) {\n\n\t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\tte[ 0 ] = ce + df * b;\n\t\t\tte[ 4 ] = de * b - cf;\n\t\t\tte[ 8 ] = a * d;\n\n\t\t\tte[ 1 ] = a * f;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = - b;\n\n\t\t\tte[ 2 ] = cf * b - de;\n\t\t\tte[ 6 ] = df + ce * b;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'ZXY' ) {\n\n\t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\tte[ 0 ] = ce - df * b;\n\t\t\tte[ 4 ] = - a * f;\n\t\t\tte[ 8 ] = de + cf * b;\n\n\t\t\tte[ 1 ] = cf + de * b;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = df - ce * b;\n\n\t\t\tte[ 2 ] = - a * d;\n\t\t\tte[ 6 ] = b;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'ZYX' ) {\n\n\t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = be * d - af;\n\t\t\tte[ 8 ] = ae * d + bf;\n\n\t\t\tte[ 1 ] = c * f;\n\t\t\tte[ 5 ] = bf * d + ae;\n\t\t\tte[ 9 ] = af * d - be;\n\n\t\t\tte[ 2 ] = - d;\n\t\t\tte[ 6 ] = b * c;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'YZX' ) {\n\n\t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = bd - ac * f;\n\t\t\tte[ 8 ] = bc * f + ad;\n\n\t\t\tte[ 1 ] = f;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = - b * e;\n\n\t\t\tte[ 2 ] = - d * e;\n\t\t\tte[ 6 ] = ad * f + bc;\n\t\t\tte[ 10 ] = ac - bd * f;\n\n\t\t} else if ( euler.order === 'XZY' ) {\n\n\t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = - f;\n\t\t\tte[ 8 ] = d * e;\n\n\t\t\tte[ 1 ] = ac * f + bd;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = ad * f - bc;\n\n\t\t\tte[ 2 ] = bc * f - ad;\n\t\t\tte[ 6 ] = b * e;\n\t\t\tte[ 10 ] = bd * f + ac;\n\n\t\t}\n\n\t\t// bottom row\n\t\tte[ 3 ] = 0;\n\t\tte[ 7 ] = 0;\n\t\tte[ 11 ] = 0;\n\n\t\t// last column\n\t\tte[ 12 ] = 0;\n\t\tte[ 13 ] = 0;\n\t\tte[ 14 ] = 0;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationFromQuaternion: function ( q ) {\n\n\t\treturn this.compose( _zero, q, _one );\n\n\t},\n\n\tlookAt: function ( eye, target, up ) {\n\n\t\tconst te = this.elements;\n\n\t\t_z.subVectors( eye, target );\n\n\t\tif ( _z.lengthSq() === 0 ) {\n\n\t\t\t// eye and target are in the same position\n\n\t\t\t_z.z = 1;\n\n\t\t}\n\n\t\t_z.normalize();\n\t\t_x.crossVectors( up, _z );\n\n\t\tif ( _x.lengthSq() === 0 ) {\n\n\t\t\t// up and z are parallel\n\n\t\t\tif ( Math.abs( up.z ) === 1 ) {\n\n\t\t\t\t_z.x += 0.0001;\n\n\t\t\t} else {\n\n\t\t\t\t_z.z += 0.0001;\n\n\t\t\t}\n\n\t\t\t_z.normalize();\n\t\t\t_x.crossVectors( up, _z );\n\n\t\t}\n\n\t\t_x.normalize();\n\t\t_y.crossVectors( _z, _x );\n\n\t\tte[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x;\n\t\tte[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y;\n\t\tte[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( m, n ) {\n\n\t\tif ( n !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );\n\t\t\treturn this.multiplyMatrices( m, n );\n\n\t\t}\n\n\t\treturn this.multiplyMatrices( this, m );\n\n\t},\n\n\tpremultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( m, this );\n\n\t},\n\n\tmultiplyMatrices: function ( a, b ) {\n\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\n\t\tconst a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];\n\t\tconst a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];\n\t\tconst a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];\n\t\tconst a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];\n\n\t\tconst b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];\n\t\tconst b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];\n\t\tconst b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];\n\t\tconst b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];\n\n\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n\t\tte[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n\t\tte[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n\t\tte[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n\t\tte[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n\t\tte[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n\t\tte[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n\t\tte[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n\t\tte[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n\t\tte[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n\t\tte[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n\t\tte[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n\t\tte[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n\t\tte[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;\n\t\tte[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;\n\t\tte[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;\n\t\tte[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;\n\n\t\treturn this;\n\n\t},\n\n\tdeterminant: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];\n\t\tconst n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];\n\t\tconst n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];\n\t\tconst n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];\n\n\t\t//TODO: make this more efficient\n\t\t//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )\n\n\t\treturn (\n\t\t\tn41 * (\n\t\t\t\t+ n14 * n23 * n32\n\t\t\t\t - n13 * n24 * n32\n\t\t\t\t - n14 * n22 * n33\n\t\t\t\t + n12 * n24 * n33\n\t\t\t\t + n13 * n22 * n34\n\t\t\t\t - n12 * n23 * n34\n\t\t\t) +\n\t\t\tn42 * (\n\t\t\t\t+ n11 * n23 * n34\n\t\t\t\t - n11 * n24 * n33\n\t\t\t\t + n14 * n21 * n33\n\t\t\t\t - n13 * n21 * n34\n\t\t\t\t + n13 * n24 * n31\n\t\t\t\t - n14 * n23 * n31\n\t\t\t) +\n\t\t\tn43 * (\n\t\t\t\t+ n11 * n24 * n32\n\t\t\t\t - n11 * n22 * n34\n\t\t\t\t - n14 * n21 * n32\n\t\t\t\t + n12 * n21 * n34\n\t\t\t\t + n14 * n22 * n31\n\t\t\t\t - n12 * n24 * n31\n\t\t\t) +\n\t\t\tn44 * (\n\t\t\t\t- n13 * n22 * n31\n\t\t\t\t - n11 * n23 * n32\n\t\t\t\t + n11 * n22 * n33\n\t\t\t\t + n13 * n21 * n32\n\t\t\t\t - n12 * n21 * n33\n\t\t\t\t + n12 * n23 * n31\n\t\t\t)\n\n\t\t);\n\n\t},\n\n\ttranspose: function () {\n\n\t\tconst te = this.elements;\n\t\tlet tmp;\n\n\t\ttmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;\n\t\ttmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;\n\t\ttmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;\n\n\t\ttmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;\n\t\ttmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;\n\t\ttmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;\n\n\t\treturn this;\n\n\t},\n\n\tsetPosition: function ( x, y, z ) {\n\n\t\tconst te = this.elements;\n\n\t\tif ( x.isVector3 ) {\n\n\t\t\tte[ 12 ] = x.x;\n\t\t\tte[ 13 ] = x.y;\n\t\t\tte[ 14 ] = x.z;\n\n\t\t} else {\n\n\t\t\tte[ 12 ] = x;\n\t\t\tte[ 13 ] = y;\n\t\t\tte[ 14 ] = z;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetInverse: function ( m, throwOnDegenerate ) {\n\n\t\tif ( throwOnDegenerate !== undefined ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.\" );\n\n\t\t}\n\n\t\t// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm\n\t\tconst te = this.elements,\n\t\t\tme = m.elements,\n\n\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],\n\t\t\tn12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],\n\t\t\tn13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],\n\t\t\tn14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],\n\n\t\t\tt11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,\n\t\t\tt12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,\n\t\t\tt13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,\n\t\t\tt14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;\n\n\t\tconst det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;\n\n\t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n\t\tconst detInv = 1 / det;\n\n\t\tte[ 0 ] = t11 * detInv;\n\t\tte[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;\n\t\tte[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;\n\t\tte[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;\n\n\t\tte[ 4 ] = t12 * detInv;\n\t\tte[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;\n\t\tte[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;\n\t\tte[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;\n\n\t\tte[ 8 ] = t13 * detInv;\n\t\tte[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;\n\t\tte[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;\n\t\tte[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;\n\n\t\tte[ 12 ] = t14 * detInv;\n\t\tte[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;\n\t\tte[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;\n\t\tte[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( v ) {\n\n\t\tconst te = this.elements;\n\t\tconst x = v.x, y = v.y, z = v.z;\n\n\t\tte[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;\n\t\tte[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;\n\t\tte[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;\n\t\tte[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;\n\n\t\treturn this;\n\n\t},\n\n\tgetMaxScaleOnAxis: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];\n\t\tconst scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];\n\t\tconst scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];\n\n\t\treturn Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );\n\n\t},\n\n\tmakeTranslation: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, x,\n\t\t\t0, 1, 0, y,\n\t\t\t0, 0, 1, z,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationX: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, c, - s, 0,\n\t\t\t0, s, c, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationY: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\t c, 0, s, 0,\n\t\t\t 0, 1, 0, 0,\n\t\t\t- s, 0, c, 0,\n\t\t\t 0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationZ: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\tc, - s, 0, 0,\n\t\t\ts, c, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationAxis: function ( axis, angle ) {\n\n\t\t// Based on http://www.gamedev.net/reference/articles/article1199.asp\n\n\t\tconst c = Math.cos( angle );\n\t\tconst s = Math.sin( angle );\n\t\tconst t = 1 - c;\n\t\tconst x = axis.x, y = axis.y, z = axis.z;\n\t\tconst tx = t * x, ty = t * y;\n\n\t\tthis.set(\n\n\t\t\ttx * x + c, tx * y - s * z, tx * z + s * y, 0,\n\t\t\ttx * y + s * z, ty * y + c, ty * z - s * x, 0,\n\t\t\ttx * z - s * y, ty * z + s * x, t * z * z + c, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\t return this;\n\n\t},\n\n\tmakeScale: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\tx, 0, 0, 0,\n\t\t\t0, y, 0, 0,\n\t\t\t0, 0, z, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeShear: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\t1, y, z, 0,\n\t\t\tx, 1, z, 0,\n\t\t\tx, y, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tcompose: function ( position, quaternion, scale ) {\n\n\t\tconst te = this.elements;\n\n\t\tconst x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;\n\t\tconst x2 = x + x,\ty2 = y + y, z2 = z + z;\n\t\tconst xx = x * x2, xy = x * y2, xz = x * z2;\n\t\tconst yy = y * y2, yz = y * z2, zz = z * z2;\n\t\tconst wx = w * x2, wy = w * y2, wz = w * z2;\n\n\t\tconst sx = scale.x, sy = scale.y, sz = scale.z;\n\n\t\tte[ 0 ] = ( 1 - ( yy + zz ) ) * sx;\n\t\tte[ 1 ] = ( xy + wz ) * sx;\n\t\tte[ 2 ] = ( xz - wy ) * sx;\n\t\tte[ 3 ] = 0;\n\n\t\tte[ 4 ] = ( xy - wz ) * sy;\n\t\tte[ 5 ] = ( 1 - ( xx + zz ) ) * sy;\n\t\tte[ 6 ] = ( yz + wx ) * sy;\n\t\tte[ 7 ] = 0;\n\n\t\tte[ 8 ] = ( xz + wy ) * sz;\n\t\tte[ 9 ] = ( yz - wx ) * sz;\n\t\tte[ 10 ] = ( 1 - ( xx + yy ) ) * sz;\n\t\tte[ 11 ] = 0;\n\n\t\tte[ 12 ] = position.x;\n\t\tte[ 13 ] = position.y;\n\t\tte[ 14 ] = position.z;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tdecompose: function ( position, quaternion, scale ) {\n\n\t\tconst te = this.elements;\n\n\t\tlet sx = _v1.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();\n\t\tlet sy = _v1.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();\n\t\tlet sz = _v1.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();\n\n\t\t// if determine is negative, we need to invert one scale\n\t\tconst det = this.determinant();\n\t\tif ( det < 0 ) sx = - sx;\n\n\t\tposition.x = te[ 12 ];\n\t\tposition.y = te[ 13 ];\n\t\tposition.z = te[ 14 ];\n\n\t\t// scale the rotation part\n\t\t_m1.copy( this );\n\n\t\tconst invSX = 1 / sx;\n\t\tconst invSY = 1 / sy;\n\t\tconst invSZ = 1 / sz;\n\n\t\t_m1.elements[ 0 ] *= invSX;\n\t\t_m1.elements[ 1 ] *= invSX;\n\t\t_m1.elements[ 2 ] *= invSX;\n\n\t\t_m1.elements[ 4 ] *= invSY;\n\t\t_m1.elements[ 5 ] *= invSY;\n\t\t_m1.elements[ 6 ] *= invSY;\n\n\t\t_m1.elements[ 8 ] *= invSZ;\n\t\t_m1.elements[ 9 ] *= invSZ;\n\t\t_m1.elements[ 10 ] *= invSZ;\n\n\t\tquaternion.setFromRotationMatrix( _m1 );\n\n\t\tscale.x = sx;\n\t\tscale.y = sy;\n\t\tscale.z = sz;\n\n\t\treturn this;\n\n\t},\n\n\tmakePerspective: function ( left, right, top, bottom, near, far ) {\n\n\t\tif ( far === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );\n\n\t\t}\n\n\t\tconst te = this.elements;\n\t\tconst x = 2 * near / ( right - left );\n\t\tconst y = 2 * near / ( top - bottom );\n\n\t\tconst a = ( right + left ) / ( right - left );\n\t\tconst b = ( top + bottom ) / ( top - bottom );\n\t\tconst c = - ( far + near ) / ( far - near );\n\t\tconst d = - 2 * far * near / ( far - near );\n\n\t\tte[ 0 ] = x;\tte[ 4 ] = 0;\tte[ 8 ] = a;\tte[ 12 ] = 0;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = y;\tte[ 9 ] = b;\tte[ 13 ] = 0;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = c;\tte[ 14 ] = d;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = - 1;\tte[ 15 ] = 0;\n\n\t\treturn this;\n\n\t},\n\n\tmakeOrthographic: function ( left, right, top, bottom, near, far ) {\n\n\t\tconst te = this.elements;\n\t\tconst w = 1.0 / ( right - left );\n\t\tconst h = 1.0 / ( top - bottom );\n\t\tconst p = 1.0 / ( far - near );\n\n\t\tconst x = ( right + left ) * w;\n\t\tconst y = ( top + bottom ) * h;\n\t\tconst z = ( far + near ) * p;\n\n\t\tte[ 0 ] = 2 * w;\tte[ 4 ] = 0;\tte[ 8 ] = 0;\tte[ 12 ] = - x;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = 2 * h;\tte[ 9 ] = 0;\tte[ 13 ] = - y;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = - 2 * p;\tte[ 14 ] = - z;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = 0;\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( matrix ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor ( let i = 0; i < 16; i ++ ) {\n\n\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tfor ( let i = 0; i < 16; i ++ ) {\n\n\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tconst te = this.elements;\n\n\t\tarray[ offset ] = te[ 0 ];\n\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\tarray[ offset + 2 ] = te[ 2 ];\n\t\tarray[ offset + 3 ] = te[ 3 ];\n\n\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\tarray[ offset + 5 ] = te[ 5 ];\n\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\tarray[ offset + 7 ] = te[ 7 ];\n\n\t\tarray[ offset + 8 ] = te[ 8 ];\n\t\tarray[ offset + 9 ] = te[ 9 ];\n\t\tarray[ offset + 10 ] = te[ 10 ];\n\t\tarray[ offset + 11 ] = te[ 11 ];\n\n\t\tarray[ offset + 12 ] = te[ 12 ];\n\t\tarray[ offset + 13 ] = te[ 13 ];\n\t\tarray[ offset + 14 ] = te[ 14 ];\n\t\tarray[ offset + 15 ] = te[ 15 ];\n\n\t\treturn array;\n\n\t}\n\n} );\n\n\nexport { Matrix4 };\n","import { Quaternion } from './Quaternion.js';\nimport { Vector3 } from './Vector3.js';\nimport { Matrix4 } from './Matrix4.js';\nimport { MathUtils } from './MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n */\n\nconst _matrix = new Matrix4();\nconst _quaternion = new Quaternion();\n\nfunction Euler( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {\n\n\tthis._x = x;\n\tthis._y = y;\n\tthis._z = z;\n\tthis._order = order;\n\n}\n\nEuler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];\n\nEuler.DefaultOrder = 'XYZ';\n\nObject.defineProperties( Euler.prototype, {\n\n\tx: {\n\n\t\tget: function () {\n\n\t\t\treturn this._x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._x = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\ty: {\n\n\t\tget: function () {\n\n\t\t\treturn this._y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._y = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tz: {\n\n\t\tget: function () {\n\n\t\t\treturn this._z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._z = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\torder: {\n\n\t\tget: function () {\n\n\t\t\treturn this._order;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._order = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Euler.prototype, {\n\n\tisEuler: true,\n\n\tset: function ( x, y, z, order ) {\n\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._order = order || this._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this._x, this._y, this._z, this._order );\n\n\t},\n\n\tcopy: function ( euler ) {\n\n\t\tthis._x = euler._x;\n\t\tthis._y = euler._y;\n\t\tthis._z = euler._z;\n\t\tthis._order = euler._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromRotationMatrix: function ( m, order, update ) {\n\n\t\tconst clamp = MathUtils.clamp;\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tconst te = m.elements;\n\t\tconst m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];\n\t\tconst m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];\n\t\tconst m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\torder = order || this._order;\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYZ':\n\n\t\t\t\tthis._y = Math.asin( clamp( m13, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m13 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\n\t\t\t\tthis._x = Math.asin( - clamp( m23, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m23 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\n\t\t\t\tthis._x = Math.asin( clamp( m32, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m32 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = 0;\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\n\t\t\t\tthis._y = Math.asin( - clamp( m31, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m31 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\n\t\t\t\tthis._z = Math.asin( clamp( m21, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m21 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m22 );\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\n\t\t\t\tthis._z = Math.asin( - clamp( m12, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m12 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._y = Math.atan2( m13, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._y = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\n\t\t\t\tconsole.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t\tthis._order = order;\n\n\t\tif ( update !== false ) this._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromQuaternion: function ( q, order, update ) {\n\n\t\t_matrix.makeRotationFromQuaternion( q );\n\n\t\treturn this.setFromRotationMatrix( _matrix, order, update );\n\n\t},\n\n\tsetFromVector3: function ( v, order ) {\n\n\t\treturn this.set( v.x, v.y, v.z, order || this._order );\n\n\t},\n\n\treorder: function ( newOrder ) {\n\n\t\t// WARNING: this discards revolution information -bhouston\n\n\t\t_quaternion.setFromEuler( this );\n\n\t\treturn this.setFromQuaternion( _quaternion, newOrder );\n\n\t},\n\n\tequals: function ( euler ) {\n\n\t\treturn ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );\n\n\t},\n\n\tfromArray: function ( array ) {\n\n\t\tthis._x = array[ 0 ];\n\t\tthis._y = array[ 1 ];\n\t\tthis._z = array[ 2 ];\n\t\tif ( array[ 3 ] !== undefined ) this._order = array[ 3 ];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this._x;\n\t\tarray[ offset + 1 ] = this._y;\n\t\tarray[ offset + 2 ] = this._z;\n\t\tarray[ offset + 3 ] = this._order;\n\n\t\treturn array;\n\n\t},\n\n\ttoVector3: function ( optionalResult ) {\n\n\t\tif ( optionalResult ) {\n\n\t\t\treturn optionalResult.set( this._x, this._y, this._z );\n\n\t\t} else {\n\n\t\t\treturn new Vector3( this._x, this._y, this._z );\n\n\t\t}\n\n\t},\n\n\t_onChange: function ( callback ) {\n\n\t\tthis._onChangeCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\t_onChangeCallback: function () {}\n\n} );\n\n\nexport { Euler };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Layers() {\n\n\tthis.mask = 1 | 0;\n\n}\n\nObject.assign( Layers.prototype, {\n\n\tset: function ( channel ) {\n\n\t\tthis.mask = 1 << channel | 0;\n\n\t},\n\n\tenable: function ( channel ) {\n\n\t\tthis.mask |= 1 << channel | 0;\n\n\t},\n\n\tenableAll: function () {\n\n\t\tthis.mask = 0xffffffff | 0;\n\n\t},\n\n\ttoggle: function ( channel ) {\n\n\t\tthis.mask ^= 1 << channel | 0;\n\n\t},\n\n\tdisable: function ( channel ) {\n\n\t\tthis.mask &= ~ ( 1 << channel | 0 );\n\n\t},\n\n\tdisableAll: function () {\n\n\t\tthis.mask = 0;\n\n\t},\n\n\ttest: function ( layers ) {\n\n\t\treturn ( this.mask & layers.mask ) !== 0;\n\n\t}\n\n} );\n\n\nexport { Layers };\n","import { Quaternion } from '../math/Quaternion.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { EventDispatcher } from './EventDispatcher.js';\nimport { Euler } from '../math/Euler.js';\nimport { Layers } from './Layers.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\nlet _object3DId = 0;\n\nconst _v1 = new Vector3();\nconst _q1 = new Quaternion();\nconst _m1 = new Matrix4();\nconst _target = new Vector3();\n\nconst _position = new Vector3();\nconst _scale = new Vector3();\nconst _quaternion = new Quaternion();\n\nconst _xAxis = new Vector3( 1, 0, 0 );\nconst _yAxis = new Vector3( 0, 1, 0 );\nconst _zAxis = new Vector3( 0, 0, 1 );\n\nconst _addedEvent = { type: 'added' };\nconst _removedEvent = { type: 'removed' };\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author elephantatwork / www.elephantatwork.ch\n */\n\nfunction Object3D() {\n\n\tObject.defineProperty( this, 'id', { value: _object3DId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Object3D';\n\n\tthis.parent = null;\n\tthis.children = [];\n\n\tthis.up = Object3D.DefaultUp.clone();\n\n\tconst position = new Vector3();\n\tconst rotation = new Euler();\n\tconst quaternion = new Quaternion();\n\tconst scale = new Vector3( 1, 1, 1 );\n\n\tfunction onRotationChange() {\n\n\t\tquaternion.setFromEuler( rotation, false );\n\n\t}\n\n\tfunction onQuaternionChange() {\n\n\t\trotation.setFromQuaternion( quaternion, undefined, false );\n\n\t}\n\n\trotation._onChange( onRotationChange );\n\tquaternion._onChange( onQuaternionChange );\n\n\tObject.defineProperties( this, {\n\t\tposition: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: position\n\t\t},\n\t\trotation: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: rotation\n\t\t},\n\t\tquaternion: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: quaternion\n\t\t},\n\t\tscale: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: scale\n\t\t},\n\t\tmodelViewMatrix: {\n\t\t\tvalue: new Matrix4()\n\t\t},\n\t\tnormalMatrix: {\n\t\t\tvalue: new Matrix3()\n\t\t}\n\t} );\n\n\tthis.matrix = new Matrix4();\n\tthis.matrixWorld = new Matrix4();\n\n\tthis.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;\n\tthis.matrixWorldNeedsUpdate = false;\n\n\tthis.layers = new Layers();\n\tthis.visible = true;\n\n\tthis.castShadow = false;\n\tthis.receiveShadow = false;\n\n\tthis.frustumCulled = true;\n\tthis.renderOrder = 0;\n\n\tthis.userData = {};\n\n}\n\nObject3D.DefaultUp = new Vector3( 0, 1, 0 );\nObject3D.DefaultMatrixAutoUpdate = true;\n\nObject3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Object3D,\n\n\tisObject3D: true,\n\n\tonBeforeRender: function () {},\n\tonAfterRender: function () {},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tthis.matrix.premultiply( matrix );\n\n\t\tthis.matrix.decompose( this.position, this.quaternion, this.scale );\n\n\t},\n\n\tapplyQuaternion: function ( q ) {\n\n\t\tthis.quaternion.premultiply( q );\n\n\t\treturn this;\n\n\t},\n\n\tsetRotationFromAxisAngle: function ( axis, angle ) {\n\n\t\t// assumes axis is normalized\n\n\t\tthis.quaternion.setFromAxisAngle( axis, angle );\n\n\t},\n\n\tsetRotationFromEuler: function ( euler ) {\n\n\t\tthis.quaternion.setFromEuler( euler, true );\n\n\t},\n\n\tsetRotationFromMatrix: function ( m ) {\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tthis.quaternion.setFromRotationMatrix( m );\n\n\t},\n\n\tsetRotationFromQuaternion: function ( q ) {\n\n\t\t// assumes q is normalized\n\n\t\tthis.quaternion.copy( q );\n\n\t},\n\n\trotateOnAxis: function ( axis, angle ) {\n\n\t\t// rotate object on axis in object space\n\t\t// axis is assumed to be normalized\n\n\t\t_q1.setFromAxisAngle( axis, angle );\n\n\t\tthis.quaternion.multiply( _q1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateOnWorldAxis: function ( axis, angle ) {\n\n\t\t// rotate object on axis in world space\n\t\t// axis is assumed to be normalized\n\t\t// method assumes no rotated parent\n\n\t\t_q1.setFromAxisAngle( axis, angle );\n\n\t\tthis.quaternion.premultiply( _q1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _xAxis, angle );\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _yAxis, angle );\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _zAxis, angle );\n\n\t},\n\n\ttranslateOnAxis: function ( axis, distance ) {\n\n\t\t// translate object by distance along axis in object space\n\t\t// axis is assumed to be normalized\n\n\t\t_v1.copy( axis ).applyQuaternion( this.quaternion );\n\n\t\tthis.position.add( _v1.multiplyScalar( distance ) );\n\n\t\treturn this;\n\n\t},\n\n\ttranslateX: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _xAxis, distance );\n\n\t},\n\n\ttranslateY: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _yAxis, distance );\n\n\t},\n\n\ttranslateZ: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _zAxis, distance );\n\n\t},\n\n\tlocalToWorld: function ( vector ) {\n\n\t\treturn vector.applyMatrix4( this.matrixWorld );\n\n\t},\n\n\tworldToLocal: function ( vector ) {\n\n\t\treturn vector.applyMatrix4( _m1.getInverse( this.matrixWorld ) );\n\n\t},\n\n\tlookAt: function ( x, y, z ) {\n\n\t\t// This method does not support objects having non-uniformly-scaled parent(s)\n\n\t\tif ( x.isVector3 ) {\n\n\t\t\t_target.copy( x );\n\n\t\t} else {\n\n\t\t\t_target.set( x, y, z );\n\n\t\t}\n\n\t\tconst parent = this.parent;\n\n\t\tthis.updateWorldMatrix( true, false );\n\n\t\t_position.setFromMatrixPosition( this.matrixWorld );\n\n\t\tif ( this.isCamera || this.isLight ) {\n\n\t\t\t_m1.lookAt( _position, _target, this.up );\n\n\t\t} else {\n\n\t\t\t_m1.lookAt( _target, _position, this.up );\n\n\t\t}\n\n\t\tthis.quaternion.setFromRotationMatrix( _m1 );\n\n\t\tif ( parent ) {\n\n\t\t\t_m1.extractRotation( parent.matrixWorld );\n\t\t\t_q1.setFromRotationMatrix( _m1 );\n\t\t\tthis.quaternion.premultiply( _q1.inverse() );\n\n\t\t}\n\n\t},\n\n\tadd: function ( object ) {\n\n\t\tif ( arguments.length > 1 ) {\n\n\t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\tthis.add( arguments[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tif ( object === this ) {\n\n\t\t\tconsole.error( \"THREE.Object3D.add: object can't be added as a child of itself.\", object );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tif ( ( object && object.isObject3D ) ) {\n\n\t\t\tif ( object.parent !== null ) {\n\n\t\t\t\tobject.parent.remove( object );\n\n\t\t\t}\n\n\t\t\tobject.parent = this;\n\t\t\tthis.children.push( object );\n\n\t\t\tobject.dispatchEvent( _addedEvent );\n\n\t\t} else {\n\n\t\t\tconsole.error( \"THREE.Object3D.add: object not an instance of THREE.Object3D.\", object );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tremove: function ( object ) {\n\n\t\tif ( arguments.length > 1 ) {\n\n\t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\tthis.remove( arguments[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst index = this.children.indexOf( object );\n\n\t\tif ( index !== - 1 ) {\n\n\t\t\tobject.parent = null;\n\t\t\tthis.children.splice( index, 1 );\n\n\t\t\tobject.dispatchEvent( _removedEvent );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tattach: function ( object ) {\n\n\t\t// adds object as a child of this, while maintaining the object's world transform\n\n\t\tthis.updateWorldMatrix( true, false );\n\n\t\t_m1.getInverse( this.matrixWorld );\n\n\t\tif ( object.parent !== null ) {\n\n\t\t\tobject.parent.updateWorldMatrix( true, false );\n\n\t\t\t_m1.multiply( object.parent.matrixWorld );\n\n\t\t}\n\n\t\tobject.applyMatrix4( _m1 );\n\n\t\tobject.updateWorldMatrix( false, false );\n\n\t\tthis.add( object );\n\n\t\treturn this;\n\n\t},\n\n\tgetObjectById: function ( id ) {\n\n\t\treturn this.getObjectByProperty( 'id', id );\n\n\t},\n\n\tgetObjectByName: function ( name ) {\n\n\t\treturn this.getObjectByProperty( 'name', name );\n\n\t},\n\n\tgetObjectByProperty: function ( name, value ) {\n\n\t\tif ( this[ name ] === value ) return this;\n\n\t\tfor ( let i = 0, l = this.children.length; i < l; i ++ ) {\n\n\t\t\tconst child = this.children[ i ];\n\t\t\tconst object = child.getObjectByProperty( name, value );\n\n\t\t\tif ( object !== undefined ) {\n\n\t\t\t\treturn object;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn undefined;\n\n\t},\n\n\tgetWorldPosition: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldPosition() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\treturn target.setFromMatrixPosition( this.matrixWorld );\n\n\t},\n\n\tgetWorldQuaternion: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );\n\t\t\ttarget = new Quaternion();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tthis.matrixWorld.decompose( _position, target, _scale );\n\n\t\treturn target;\n\n\t},\n\n\tgetWorldScale: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldScale() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tthis.matrixWorld.decompose( _position, _quaternion, target );\n\n\t\treturn target;\n\n\t},\n\n\tgetWorldDirection: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldDirection() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tconst e = this.matrixWorld.elements;\n\n\t\treturn target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize();\n\n\t},\n\n\traycast: function () {},\n\n\ttraverse: function ( callback ) {\n\n\t\tcallback( this );\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].traverse( callback );\n\n\t\t}\n\n\t},\n\n\ttraverseVisible: function ( callback ) {\n\n\t\tif ( this.visible === false ) return;\n\n\t\tcallback( this );\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].traverseVisible( callback );\n\n\t\t}\n\n\t},\n\n\ttraverseAncestors: function ( callback ) {\n\n\t\tconst parent = this.parent;\n\n\t\tif ( parent !== null ) {\n\n\t\t\tcallback( parent );\n\n\t\t\tparent.traverseAncestors( callback );\n\n\t\t}\n\n\t},\n\n\tupdateMatrix: function () {\n\n\t\tthis.matrix.compose( this.position, this.quaternion, this.scale );\n\n\t\tthis.matrixWorldNeedsUpdate = true;\n\n\t},\n\n\tupdateMatrixWorld: function ( force ) {\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tif ( this.matrixWorldNeedsUpdate || force ) {\n\n\t\t\tif ( this.parent === null ) {\n\n\t\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t\t} else {\n\n\t\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t\t}\n\n\t\t\tthis.matrixWorldNeedsUpdate = false;\n\n\t\t\tforce = true;\n\n\t\t}\n\n\t\t// update children\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].updateMatrixWorld( force );\n\n\t\t}\n\n\t},\n\n\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\tconst parent = this.parent;\n\n\t\tif ( updateParents === true && parent !== null ) {\n\n\t\t\tparent.updateWorldMatrix( true, false );\n\n\t\t}\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tif ( this.parent === null ) {\n\n\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t} else {\n\n\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t}\n\n\t\t// update children\n\n\t\tif ( updateChildren === true ) {\n\n\t\t\tconst children = this.children;\n\n\t\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tchildren[ i ].updateWorldMatrix( false, true );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\t// meta is a string when called from JSON.stringify\n\t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\tconst output = {};\n\n\t\t// meta is a hash used to collect geometries, materials.\n\t\t// not providing it implies that this is the root object\n\t\t// being serialized.\n\t\tif ( isRootObject ) {\n\n\t\t\t// initialize meta obj\n\t\t\tmeta = {\n\t\t\t\tgeometries: {},\n\t\t\t\tmaterials: {},\n\t\t\t\ttextures: {},\n\t\t\t\timages: {},\n\t\t\t\tshapes: {}\n\t\t\t};\n\n\t\t\toutput.metadata = {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Object',\n\t\t\t\tgenerator: 'Object3D.toJSON'\n\t\t\t};\n\n\t\t}\n\n\t\t// standard Object3D serialization\n\n\t\tconst object = {};\n\n\t\tobject.uuid = this.uuid;\n\t\tobject.type = this.type;\n\n\t\tif ( this.name !== '' ) object.name = this.name;\n\t\tif ( this.castShadow === true ) object.castShadow = true;\n\t\tif ( this.receiveShadow === true ) object.receiveShadow = true;\n\t\tif ( this.visible === false ) object.visible = false;\n\t\tif ( this.frustumCulled === false ) object.frustumCulled = false;\n\t\tif ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder;\n\t\tif ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData;\n\n\t\tobject.layers = this.layers.mask;\n\t\tobject.matrix = this.matrix.toArray();\n\n\t\tif ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;\n\n\t\t// object specific properties\n\n\t\tif ( this.isInstancedMesh ) {\n\n\t\t\tobject.type = 'InstancedMesh';\n\t\t\tobject.count = this.count;\n\t\t\tobject.instanceMatrix = this.instanceMatrix.toJSON();\n\n\t\t}\n\n\t\t//\n\n\t\tfunction serialize( library, element ) {\n\n\t\t\tif ( library[ element.uuid ] === undefined ) {\n\n\t\t\t\tlibrary[ element.uuid ] = element.toJSON( meta );\n\n\t\t\t}\n\n\t\t\treturn element.uuid;\n\n\t\t}\n\n\t\tif ( this.isMesh || this.isLine || this.isPoints ) {\n\n\t\t\tobject.geometry = serialize( meta.geometries, this.geometry );\n\n\t\t\tconst parameters = this.geometry.parameters;\n\n\t\t\tif ( parameters !== undefined && parameters.shapes !== undefined ) {\n\n\t\t\t\tconst shapes = parameters.shapes;\n\n\t\t\t\tif ( Array.isArray( shapes ) ) {\n\n\t\t\t\t\tfor ( let i = 0, l = shapes.length; i < l; i ++ ) {\n\n\t\t\t\t\t\tconst shape = shapes[ i ];\n\n\t\t\t\t\t\tserialize( meta.shapes, shape );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tserialize( meta.shapes, shapes );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.material !== undefined ) {\n\n\t\t\tif ( Array.isArray( this.material ) ) {\n\n\t\t\t\tconst uuids = [];\n\n\t\t\t\tfor ( let i = 0, l = this.material.length; i < l; i ++ ) {\n\n\t\t\t\t\tuuids.push( serialize( meta.materials, this.material[ i ] ) );\n\n\t\t\t\t}\n\n\t\t\t\tobject.material = uuids;\n\n\t\t\t} else {\n\n\t\t\t\tobject.material = serialize( meta.materials, this.material );\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tif ( this.children.length > 0 ) {\n\n\t\t\tobject.children = [];\n\n\t\t\tfor ( let i = 0; i < this.children.length; i ++ ) {\n\n\t\t\t\tobject.children.push( this.children[ i ].toJSON( meta ).object );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( isRootObject ) {\n\n\t\t\tconst geometries = extractFromCache( meta.geometries );\n\t\t\tconst materials = extractFromCache( meta.materials );\n\t\t\tconst textures = extractFromCache( meta.textures );\n\t\t\tconst images = extractFromCache( meta.images );\n\t\t\tconst shapes = extractFromCache( meta.shapes );\n\n\t\t\tif ( geometries.length > 0 ) output.geometries = geometries;\n\t\t\tif ( materials.length > 0 ) output.materials = materials;\n\t\t\tif ( textures.length > 0 ) output.textures = textures;\n\t\t\tif ( images.length > 0 ) output.images = images;\n\t\t\tif ( shapes.length > 0 ) output.shapes = shapes;\n\n\t\t}\n\n\t\toutput.object = object;\n\n\t\treturn output;\n\n\t\t// extract data from the cache hash\n\t\t// remove metadata on each item\n\t\t// and return as array\n\t\tfunction extractFromCache( cache ) {\n\n\t\t\tconst values = [];\n\t\t\tfor ( const key in cache ) {\n\n\t\t\t\tconst data = cache[ key ];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push( data );\n\n\t\t\t}\n\n\t\t\treturn values;\n\n\t\t}\n\n\t},\n\n\tclone: function ( recursive ) {\n\n\t\treturn new this.constructor().copy( this, recursive );\n\n\t},\n\n\tcopy: function ( source, recursive ) {\n\n\t\tif ( recursive === undefined ) recursive = true;\n\n\t\tthis.name = source.name;\n\n\t\tthis.up.copy( source.up );\n\n\t\tthis.position.copy( source.position );\n\t\tthis.quaternion.copy( source.quaternion );\n\t\tthis.scale.copy( source.scale );\n\n\t\tthis.matrix.copy( source.matrix );\n\t\tthis.matrixWorld.copy( source.matrixWorld );\n\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;\n\n\t\tthis.layers.mask = source.layers.mask;\n\t\tthis.visible = source.visible;\n\n\t\tthis.castShadow = source.castShadow;\n\t\tthis.receiveShadow = source.receiveShadow;\n\n\t\tthis.frustumCulled = source.frustumCulled;\n\t\tthis.renderOrder = source.renderOrder;\n\n\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\tif ( recursive === true ) {\n\n\t\t\tfor ( let i = 0; i < source.children.length; i ++ ) {\n\n\t\t\t\tconst child = source.children[ i ];\n\t\t\t\tthis.add( child.clone() );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Object3D };\n","import { Object3D } from '../core/Object3D.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Scene() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Scene';\n\n\tthis.background = null;\n\tthis.environment = null;\n\tthis.fog = null;\n\n\tthis.overrideMaterial = null;\n\n\tthis.autoUpdate = true; // checked by the renderer\n\n\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef\n\n\t}\n\n}\n\nScene.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Scene,\n\n\tisScene: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\tif ( source.background !== null ) this.background = source.background.clone();\n\t\tif ( source.environment !== null ) this.environment = source.environment.clone();\n\t\tif ( source.fog !== null ) this.fog = source.fog.clone();\n\n\t\tif ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();\n\n\t\tthis.autoUpdate = source.autoUpdate;\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tif ( this.background !== null ) data.object.background = this.background.toJSON( meta );\n\t\tif ( this.environment !== null ) data.object.environment = this.environment.toJSON( meta );\n\t\tif ( this.fog !== null ) data.object.fog = this.fog.toJSON();\n\n\t\treturn data;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\n\nexport { Scene };\n","import { Vector3 } from './Vector3.js';\n\nconst _points = [\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3()\n];\n\nconst _vector = new Vector3();\n\nconst _box = new Box3();\n\n// triangle centered vertices\n\nconst _v0 = new Vector3();\nconst _v1 = new Vector3();\nconst _v2 = new Vector3();\n\n// triangle edge vectors\n\nconst _f0 = new Vector3();\nconst _f1 = new Vector3();\nconst _f2 = new Vector3();\n\nconst _center = new Vector3();\nconst _extents = new Vector3();\nconst _triangleNormal = new Vector3();\nconst _testAxis = new Vector3();\n\n/**\n * @author bhouston / http://clara.io\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Box3( min, max ) {\n\n\tthis.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );\n\tthis.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );\n\n}\n\n\nObject.assign( Box3.prototype, {\n\n\tisBox3: true,\n\n\tset: function ( min, max ) {\n\n\t\tthis.min.copy( min );\n\t\tthis.max.copy( max );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromArray: function ( array ) {\n\n\t\tlet minX = + Infinity;\n\t\tlet minY = + Infinity;\n\t\tlet minZ = + Infinity;\n\n\t\tlet maxX = - Infinity;\n\t\tlet maxY = - Infinity;\n\t\tlet maxZ = - Infinity;\n\n\t\tfor ( let i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\tconst x = array[ i ];\n\t\t\tconst y = array[ i + 1 ];\n\t\t\tconst z = array[ i + 2 ];\n\n\t\t\tif ( x < minX ) minX = x;\n\t\t\tif ( y < minY ) minY = y;\n\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\tif ( x > maxX ) maxX = x;\n\t\t\tif ( y > maxY ) maxY = y;\n\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t}\n\n\t\tthis.min.set( minX, minY, minZ );\n\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromBufferAttribute: function ( attribute ) {\n\n\t\tlet minX = + Infinity;\n\t\tlet minY = + Infinity;\n\t\tlet minZ = + Infinity;\n\n\t\tlet maxX = - Infinity;\n\t\tlet maxY = - Infinity;\n\t\tlet maxZ = - Infinity;\n\n\t\tfor ( let i = 0, l = attribute.count; i < l; i ++ ) {\n\n\t\t\tconst x = attribute.getX( i );\n\t\t\tconst y = attribute.getY( i );\n\t\t\tconst z = attribute.getZ( i );\n\n\t\t\tif ( x < minX ) minX = x;\n\t\t\tif ( y < minY ) minY = y;\n\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\tif ( x > maxX ) maxX = x;\n\t\t\tif ( y > maxY ) maxY = y;\n\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t}\n\n\t\tthis.min.set( minX, minY, minZ );\n\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tthis.makeEmpty();\n\n\t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\tthis.expandByPoint( points[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCenterAndSize: function ( center, size ) {\n\n\t\tconst halfSize = _vector.copy( size ).multiplyScalar( 0.5 );\n\n\t\tthis.min.copy( center ).sub( halfSize );\n\t\tthis.max.copy( center ).add( halfSize );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromObject: function ( object ) {\n\n\t\tthis.makeEmpty();\n\n\t\treturn this.expandByObject( object );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( box ) {\n\n\t\tthis.min.copy( box.min );\n\t\tthis.max.copy( box.max );\n\n\t\treturn this;\n\n\t},\n\n\tmakeEmpty: function () {\n\n\t\tthis.min.x = this.min.y = this.min.z = + Infinity;\n\t\tthis.max.x = this.max.y = this.max.z = - Infinity;\n\n\t\treturn this;\n\n\t},\n\n\tisEmpty: function () {\n\n\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\n\t\treturn ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );\n\n\t},\n\n\tgetCenter: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getCenter() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );\n\n\t},\n\n\tgetSize: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getSize() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );\n\n\t},\n\n\texpandByPoint: function ( point ) {\n\n\t\tthis.min.min( point );\n\t\tthis.max.max( point );\n\n\t\treturn this;\n\n\t},\n\n\texpandByVector: function ( vector ) {\n\n\t\tthis.min.sub( vector );\n\t\tthis.max.add( vector );\n\n\t\treturn this;\n\n\t},\n\n\texpandByScalar: function ( scalar ) {\n\n\t\tthis.min.addScalar( - scalar );\n\t\tthis.max.addScalar( scalar );\n\n\t\treturn this;\n\n\t},\n\n\texpandByObject: function ( object ) {\n\n\t\t// Computes the world-axis-aligned bounding box of an object (including its children),\n\t\t// accounting for both the object's, and children's, world transforms\n\n\t\tobject.updateWorldMatrix( false, false );\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( geometry !== undefined ) {\n\n\t\t\tif ( geometry.boundingBox === null ) {\n\n\t\t\t\tgeometry.computeBoundingBox();\n\n\t\t\t}\n\n\t\t\t_box.copy( geometry.boundingBox );\n\t\t\t_box.applyMatrix4( object.matrixWorld );\n\n\t\t\tthis.union( _box );\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tthis.expandByObject( children[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn point.x < this.min.x || point.x > this.max.x ||\n\t\t\tpoint.y < this.min.y || point.y > this.max.y ||\n\t\t\tpoint.z < this.min.z || point.z > this.max.z ? false : true;\n\n\t},\n\n\tcontainsBox: function ( box ) {\n\n\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x &&\n\t\t\tthis.min.y <= box.min.y && box.max.y <= this.max.y &&\n\t\t\tthis.min.z <= box.min.z && box.max.z <= this.max.z;\n\n\t},\n\n\tgetParameter: function ( point, target ) {\n\n\t\t// This can potentially have a divide by zero if the box\n\t\t// has a size dimension of 0.\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getParameter() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.set(\n\t\t\t( point.x - this.min.x ) / ( this.max.x - this.min.x ),\n\t\t\t( point.y - this.min.y ) / ( this.max.y - this.min.y ),\n\t\t\t( point.z - this.min.z ) / ( this.max.z - this.min.z )\n\t\t);\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\t// using 6 splitting planes to rule out intersections.\n\t\treturn box.max.x < this.min.x || box.min.x > this.max.x ||\n\t\t\tbox.max.y < this.min.y || box.min.y > this.max.y ||\n\t\t\tbox.max.z < this.min.z || box.min.z > this.max.z ? false : true;\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\t// Find the point on the AABB closest to the sphere center.\n\t\tthis.clampPoint( sphere.center, _vector );\n\n\t\t// If that point is inside the sphere, the AABB and sphere intersect.\n\t\treturn _vector.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\t// We compute the minimum and maximum dot product values. If those values\n\t\t// are on the same side (back or front) of the plane, then there is no intersection.\n\n\t\tlet min, max;\n\n\t\tif ( plane.normal.x > 0 ) {\n\n\t\t\tmin = plane.normal.x * this.min.x;\n\t\t\tmax = plane.normal.x * this.max.x;\n\n\t\t} else {\n\n\t\t\tmin = plane.normal.x * this.max.x;\n\t\t\tmax = plane.normal.x * this.min.x;\n\n\t\t}\n\n\t\tif ( plane.normal.y > 0 ) {\n\n\t\t\tmin += plane.normal.y * this.min.y;\n\t\t\tmax += plane.normal.y * this.max.y;\n\n\t\t} else {\n\n\t\t\tmin += plane.normal.y * this.max.y;\n\t\t\tmax += plane.normal.y * this.min.y;\n\n\t\t}\n\n\t\tif ( plane.normal.z > 0 ) {\n\n\t\t\tmin += plane.normal.z * this.min.z;\n\t\t\tmax += plane.normal.z * this.max.z;\n\n\t\t} else {\n\n\t\t\tmin += plane.normal.z * this.max.z;\n\t\t\tmax += plane.normal.z * this.min.z;\n\n\t\t}\n\n\t\treturn ( min <= - plane.constant && max >= - plane.constant );\n\n\t},\n\n\tintersectsTriangle: function ( triangle ) {\n\n\t\tif ( this.isEmpty() ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// compute box center and extents\n\t\tthis.getCenter( _center );\n\t\t_extents.subVectors( this.max, _center );\n\n\t\t// translate triangle to aabb origin\n\t\t_v0.subVectors( triangle.a, _center );\n\t\t_v1.subVectors( triangle.b, _center );\n\t\t_v2.subVectors( triangle.c, _center );\n\n\t\t// compute edge vectors for triangle\n\t\t_f0.subVectors( _v1, _v0 );\n\t\t_f1.subVectors( _v2, _v1 );\n\t\t_f2.subVectors( _v0, _v2 );\n\n\t\t// test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb\n\t\t// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation\n\t\t// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)\n\t\tlet axes = [\n\t\t\t0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y,\n\t\t\t_f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,\n\t\t\t- _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0\n\t\t];\n\t\tif ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// test 3 face normals from the aabb\n\t\taxes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];\n\t\tif ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// finally testing the face normal of the triangle\n\t\t// use already existing triangle edge vectors here\n\t\t_triangleNormal.crossVectors( _f0, _f1 );\n\t\taxes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];\n\n\t\treturn satForAxes( axes, _v0, _v1, _v2, _extents );\n\n\t},\n\n\tclampPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .clampPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( point ).clamp( this.min, this.max );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\tconst clampedPoint = _vector.copy( point ).clamp( this.min, this.max );\n\n\t\treturn clampedPoint.sub( point ).length();\n\n\t},\n\n\tgetBoundingSphere: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.error( 'THREE.Box3: .getBoundingSphere() target is now required' );\n\t\t\t//target = new Sphere(); // removed to avoid cyclic dependency\n\n\t\t}\n\n\t\tthis.getCenter( target.center );\n\n\t\ttarget.radius = this.getSize( _vector ).length() * 0.5;\n\n\t\treturn target;\n\n\t},\n\n\tintersect: function ( box ) {\n\n\t\tthis.min.max( box.min );\n\t\tthis.max.min( box.max );\n\n\t\t// ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.\n\t\tif ( this.isEmpty() ) this.makeEmpty();\n\n\t\treturn this;\n\n\t},\n\n\tunion: function ( box ) {\n\n\t\tthis.min.min( box.min );\n\t\tthis.max.max( box.max );\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\t// transform of empty box is an empty box.\n\t\tif ( this.isEmpty() ) return this;\n\n\t\t// NOTE: I am using a binary pattern to specify all 2^3 combinations below\n\t\t_points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000\n\t\t_points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001\n\t\t_points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010\n\t\t_points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011\n\t\t_points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100\n\t\t_points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101\n\t\t_points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110\n\t\t_points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111\n\n\t\tthis.setFromPoints( _points );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.min.add( offset );\n\t\tthis.max.add( offset );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( box ) {\n\n\t\treturn box.min.equals( this.min ) && box.max.equals( this.max );\n\n\t}\n\n} );\n\nfunction satForAxes( axes, v0, v1, v2, extents ) {\n\n\tfor ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {\n\n\t\t_testAxis.fromArray( axes, i );\n\t\t// project the aabb onto the seperating axis\n\t\tconst r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );\n\t\t// project all 3 vertices of the triangle onto the seperating axis\n\t\tconst p0 = v0.dot( _testAxis );\n\t\tconst p1 = v1.dot( _testAxis );\n\t\tconst p2 = v2.dot( _testAxis );\n\t\t// actual test, basically see if either of the most extreme of the triangle points intersects r\n\t\tif ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {\n\n\t\t\t// points of the projected triangle are outside the projected half-length of the aabb\n\t\t\t// the axis is seperating and we can exit\n\t\t\treturn false;\n\n\t\t}\n\n\t}\n\n\treturn true;\n\n}\n\nexport { Box3 };\n","import { Box3 } from './Box3.js';\nimport { Vector3 } from './Vector3.js';\n\nconst _box = new Box3();\n\n/**\n * @author bhouston / http://clara.io\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Sphere( center, radius ) {\n\n\tthis.center = ( center !== undefined ) ? center : new Vector3();\n\tthis.radius = ( radius !== undefined ) ? radius : - 1;\n\n}\n\nObject.assign( Sphere.prototype, {\n\n\tset: function ( center, radius ) {\n\n\t\tthis.center.copy( center );\n\t\tthis.radius = radius;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points, optionalCenter ) {\n\n\t\tconst center = this.center;\n\n\t\tif ( optionalCenter !== undefined ) {\n\n\t\t\tcenter.copy( optionalCenter );\n\n\t\t} else {\n\n\t\t\t_box.setFromPoints( points ).getCenter( center );\n\n\t\t}\n\n\t\tlet maxRadiusSq = 0;\n\n\t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );\n\n\t\t}\n\n\t\tthis.radius = Math.sqrt( maxRadiusSq );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( sphere ) {\n\n\t\tthis.center.copy( sphere.center );\n\t\tthis.radius = sphere.radius;\n\n\t\treturn this;\n\n\t},\n\n\tisEmpty: function () {\n\n\t\treturn ( this.radius < 0 );\n\n\t},\n\n\tmakeEmpty: function () {\n\n\t\tthis.center.set( 0, 0, 0 );\n\t\tthis.radius = - 1;\n\n\t\treturn this;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn ( point.distanceTo( this.center ) - this.radius );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\tconst radiusSum = this.radius + sphere.radius;\n\n\t\treturn sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsSphere( this );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\treturn Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;\n\n\t},\n\n\tclampPoint: function ( point, target ) {\n\n\t\tconst deltaLengthSq = this.center.distanceToSquared( point );\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Sphere: .clampPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.copy( point );\n\n\t\tif ( deltaLengthSq > ( this.radius * this.radius ) ) {\n\n\t\t\ttarget.sub( this.center ).normalize();\n\t\t\ttarget.multiplyScalar( this.radius ).add( this.center );\n\n\t\t}\n\n\t\treturn target;\n\n\t},\n\n\tgetBoundingBox: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );\n\t\t\ttarget = new Box3();\n\n\t\t}\n\n\t\tif ( this.isEmpty() ) {\n\n\t\t\t// Empty sphere produces empty bounding box\n\t\t\ttarget.makeEmpty();\n\t\t\treturn target;\n\n\t\t}\n\n\t\ttarget.set( this.center, this.center );\n\t\ttarget.expandByScalar( this.radius );\n\n\t\treturn target;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tthis.center.applyMatrix4( matrix );\n\t\tthis.radius = this.radius * matrix.getMaxScaleOnAxis();\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.center.add( offset );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( sphere ) {\n\n\t\treturn sphere.center.equals( this.center ) && ( sphere.radius === this.radius );\n\n\t}\n\n} );\n\n\nexport { Sphere };\n","import { Vector3 } from './Vector3.js';\n\nconst _vector = new Vector3();\nconst _segCenter = new Vector3();\nconst _segDir = new Vector3();\nconst _diff = new Vector3();\n\nconst _edge1 = new Vector3();\nconst _edge2 = new Vector3();\nconst _normal = new Vector3();\n\n/**\n * @author bhouston / http://clara.io\n */\n\nfunction Ray( origin, direction ) {\n\n\tthis.origin = ( origin !== undefined ) ? origin : new Vector3();\n\tthis.direction = ( direction !== undefined ) ? direction : new Vector3( 0, 0, - 1 );\n\n}\n\nObject.assign( Ray.prototype, {\n\n\tset: function ( origin, direction ) {\n\n\t\tthis.origin.copy( origin );\n\t\tthis.direction.copy( direction );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( ray ) {\n\n\t\tthis.origin.copy( ray.origin );\n\t\tthis.direction.copy( ray.direction );\n\n\t\treturn this;\n\n\t},\n\n\tat: function ( t, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .at() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.direction ).multiplyScalar( t ).add( this.origin );\n\n\t},\n\n\tlookAt: function ( v ) {\n\n\t\tthis.direction.copy( v ).sub( this.origin ).normalize();\n\n\t\treturn this;\n\n\t},\n\n\trecast: function ( t ) {\n\n\t\tthis.origin.copy( this.at( t, _vector ) );\n\n\t\treturn this;\n\n\t},\n\n\tclosestPointToPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .closestPointToPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.subVectors( point, this.origin );\n\n\t\tconst directionDistance = target.dot( this.direction );\n\n\t\tif ( directionDistance < 0 ) {\n\n\t\t\treturn target.copy( this.origin );\n\n\t\t}\n\n\t\treturn target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn Math.sqrt( this.distanceSqToPoint( point ) );\n\n\t},\n\n\tdistanceSqToPoint: function ( point ) {\n\n\t\tconst directionDistance = _vector.subVectors( point, this.origin ).dot( this.direction );\n\n\t\t// point behind the ray\n\n\t\tif ( directionDistance < 0 ) {\n\n\t\t\treturn this.origin.distanceToSquared( point );\n\n\t\t}\n\n\t\t_vector.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t\treturn _vector.distanceToSquared( point );\n\n\t},\n\n\tdistanceSqToSegment: function ( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {\n\n\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h\n\t\t// It returns the min distance between the ray and the segment\n\t\t// defined by v0 and v1\n\t\t// It can also set two optional targets :\n\t\t// - The closest point on the ray\n\t\t// - The closest point on the segment\n\n\t\t_segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );\n\t\t_segDir.copy( v1 ).sub( v0 ).normalize();\n\t\t_diff.copy( this.origin ).sub( _segCenter );\n\n\t\tconst segExtent = v0.distanceTo( v1 ) * 0.5;\n\t\tconst a01 = - this.direction.dot( _segDir );\n\t\tconst b0 = _diff.dot( this.direction );\n\t\tconst b1 = - _diff.dot( _segDir );\n\t\tconst c = _diff.lengthSq();\n\t\tconst det = Math.abs( 1 - a01 * a01 );\n\t\tlet s0, s1, sqrDist, extDet;\n\n\t\tif ( det > 0 ) {\n\n\t\t\t// The ray and segment are not parallel.\n\n\t\t\ts0 = a01 * b1 - b0;\n\t\t\ts1 = a01 * b0 - b1;\n\t\t\textDet = segExtent * det;\n\n\t\t\tif ( s0 >= 0 ) {\n\n\t\t\t\tif ( s1 >= - extDet ) {\n\n\t\t\t\t\tif ( s1 <= extDet ) {\n\n\t\t\t\t\t\t// region 0\n\t\t\t\t\t\t// Minimum at interior points of ray and segment.\n\n\t\t\t\t\t\tconst invDet = 1 / det;\n\t\t\t\t\t\ts0 *= invDet;\n\t\t\t\t\t\ts1 *= invDet;\n\t\t\t\t\t\tsqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// region 1\n\n\t\t\t\t\t\ts1 = segExtent;\n\t\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// region 5\n\n\t\t\t\t\ts1 = - segExtent;\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( s1 <= - extDet ) {\n\n\t\t\t\t\t// region 4\n\n\t\t\t\t\ts0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );\n\t\t\t\t\ts1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t} else if ( s1 <= extDet ) {\n\n\t\t\t\t\t// region 3\n\n\t\t\t\t\ts0 = 0;\n\t\t\t\t\ts1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// region 2\n\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * segExtent + b0 ) );\n\t\t\t\t\ts1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// Ray and segment are parallel.\n\n\t\t\ts1 = ( a01 > 0 ) ? - segExtent : segExtent;\n\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t}\n\n\t\tif ( optionalPointOnRay ) {\n\n\t\t\toptionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin );\n\n\t\t}\n\n\t\tif ( optionalPointOnSegment ) {\n\n\t\t\toptionalPointOnSegment.copy( _segDir ).multiplyScalar( s1 ).add( _segCenter );\n\n\t\t}\n\n\t\treturn sqrDist;\n\n\t},\n\n\tintersectSphere: function ( sphere, target ) {\n\n\t\t_vector.subVectors( sphere.center, this.origin );\n\t\tconst tca = _vector.dot( this.direction );\n\t\tconst d2 = _vector.dot( _vector ) - tca * tca;\n\t\tconst radius2 = sphere.radius * sphere.radius;\n\n\t\tif ( d2 > radius2 ) return null;\n\n\t\tconst thc = Math.sqrt( radius2 - d2 );\n\n\t\t// t0 = first intersect point - entrance on front of sphere\n\t\tconst t0 = tca - thc;\n\n\t\t// t1 = second intersect point - exit point on back of sphere\n\t\tconst t1 = tca + thc;\n\n\t\t// test to see if both t0 and t1 are behind the ray - if so, return null\n\t\tif ( t0 < 0 && t1 < 0 ) return null;\n\n\t\t// test to see if t0 is behind the ray:\n\t\t// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,\n\t\t// in order to always return an intersect point that is in front of the ray.\n\t\tif ( t0 < 0 ) return this.at( t1, target );\n\n\t\t// else t0 is in front of the ray, so return the first collision point scaled by t0\n\t\treturn this.at( t0, target );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\treturn this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t},\n\n\tdistanceToPlane: function ( plane ) {\n\n\t\tconst denominator = plane.normal.dot( this.direction );\n\n\t\tif ( denominator === 0 ) {\n\n\t\t\t// line is coplanar, return origin\n\t\t\tif ( plane.distanceToPoint( this.origin ) === 0 ) {\n\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\t// Null is preferable to undefined since undefined means.... it is undefined\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\tconst t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;\n\n\t\t// Return if the ray never intersects the plane\n\n\t\treturn t >= 0 ? t : null;\n\n\t},\n\n\tintersectPlane: function ( plane, target ) {\n\n\t\tconst t = this.distanceToPlane( plane );\n\n\t\tif ( t === null ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\treturn this.at( t, target );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\t// check if the ray lies on the plane first\n\n\t\tconst distToPoint = plane.distanceToPoint( this.origin );\n\n\t\tif ( distToPoint === 0 ) {\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\tconst denominator = plane.normal.dot( this.direction );\n\n\t\tif ( denominator * distToPoint < 0 ) {\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\t// ray origin is behind the plane (and is pointing behind it)\n\n\t\treturn false;\n\n\t},\n\n\tintersectBox: function ( box, target ) {\n\n\t\tlet tmin, tmax, tymin, tymax, tzmin, tzmax;\n\n\t\tconst invdirx = 1 / this.direction.x,\n\t\t\tinvdiry = 1 / this.direction.y,\n\t\t\tinvdirz = 1 / this.direction.z;\n\n\t\tconst origin = this.origin;\n\n\t\tif ( invdirx >= 0 ) {\n\n\t\t\ttmin = ( box.min.x - origin.x ) * invdirx;\n\t\t\ttmax = ( box.max.x - origin.x ) * invdirx;\n\n\t\t} else {\n\n\t\t\ttmin = ( box.max.x - origin.x ) * invdirx;\n\t\t\ttmax = ( box.min.x - origin.x ) * invdirx;\n\n\t\t}\n\n\t\tif ( invdiry >= 0 ) {\n\n\t\t\ttymin = ( box.min.y - origin.y ) * invdiry;\n\t\t\ttymax = ( box.max.y - origin.y ) * invdiry;\n\n\t\t} else {\n\n\t\t\ttymin = ( box.max.y - origin.y ) * invdiry;\n\t\t\ttymax = ( box.min.y - origin.y ) * invdiry;\n\n\t\t}\n\n\t\tif ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;\n\n\t\t// These lines also handle the case where tmin or tmax is NaN\n\t\t// (result of 0 * Infinity). x !== x returns true if x is NaN\n\n\t\tif ( tymin > tmin || tmin !== tmin ) tmin = tymin;\n\n\t\tif ( tymax < tmax || tmax !== tmax ) tmax = tymax;\n\n\t\tif ( invdirz >= 0 ) {\n\n\t\t\ttzmin = ( box.min.z - origin.z ) * invdirz;\n\t\t\ttzmax = ( box.max.z - origin.z ) * invdirz;\n\n\t\t} else {\n\n\t\t\ttzmin = ( box.max.z - origin.z ) * invdirz;\n\t\t\ttzmax = ( box.min.z - origin.z ) * invdirz;\n\n\t\t}\n\n\t\tif ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null;\n\n\t\tif ( tzmin > tmin || tmin !== tmin ) tmin = tzmin;\n\n\t\tif ( tzmax < tmax || tmax !== tmax ) tmax = tzmax;\n\n\t\t//return point closest to the ray (positive side)\n\n\t\tif ( tmax < 0 ) return null;\n\n\t\treturn this.at( tmin >= 0 ? tmin : tmax, target );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn this.intersectBox( box, _vector ) !== null;\n\n\t},\n\n\tintersectTriangle: function ( a, b, c, backfaceCulling, target ) {\n\n\t\t// Compute the offset origin, edges, and normal.\n\n\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h\n\n\t\t_edge1.subVectors( b, a );\n\t\t_edge2.subVectors( c, a );\n\t\t_normal.crossVectors( _edge1, _edge2 );\n\n\t\t// Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,\n\t\t// E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by\n\t\t// |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))\n\t\t// |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))\n\t\t// |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)\n\t\tlet DdN = this.direction.dot( _normal );\n\t\tlet sign;\n\n\t\tif ( DdN > 0 ) {\n\n\t\t\tif ( backfaceCulling ) return null;\n\t\t\tsign = 1;\n\n\t\t} else if ( DdN < 0 ) {\n\n\t\t\tsign = - 1;\n\t\t\tDdN = - DdN;\n\n\t\t} else {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t_diff.subVectors( this.origin, a );\n\t\tconst DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) );\n\n\t\t// b1 < 0, no intersection\n\t\tif ( DdQxE2 < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\tconst DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) );\n\n\t\t// b2 < 0, no intersection\n\t\tif ( DdE1xQ < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// b1+b2 > 1, no intersection\n\t\tif ( DdQxE2 + DdE1xQ > DdN ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// Line intersects triangle, check if ray does.\n\t\tconst QdN = - sign * _diff.dot( _normal );\n\n\t\t// t < 0, no intersection\n\t\tif ( QdN < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// Ray intersects triangle.\n\t\treturn this.at( QdN / DdN, target );\n\n\t},\n\n\tapplyMatrix4: function ( matrix4 ) {\n\n\t\tthis.origin.applyMatrix4( matrix4 );\n\t\tthis.direction.transformDirection( matrix4 );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( ray ) {\n\n\t\treturn ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );\n\n\t}\n\n} );\n\n\nexport { Ray };\n","import { Matrix3 } from './Matrix3.js';\nimport { Vector3 } from './Vector3.js';\n\n/**\n * @author bhouston / http://clara.io\n */\n\nconst _vector1 = new Vector3();\nconst _vector2 = new Vector3();\nconst _normalMatrix = new Matrix3();\n\nfunction Plane( normal, constant ) {\n\n\t// normal is assumed to be normalized\n\n\tthis.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );\n\tthis.constant = ( constant !== undefined ) ? constant : 0;\n\n}\n\nObject.assign( Plane.prototype, {\n\n\tisPlane: true,\n\n\tset: function ( normal, constant ) {\n\n\t\tthis.normal.copy( normal );\n\t\tthis.constant = constant;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponents: function ( x, y, z, w ) {\n\n\t\tthis.normal.set( x, y, z );\n\t\tthis.constant = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromNormalAndCoplanarPoint: function ( normal, point ) {\n\n\t\tthis.normal.copy( normal );\n\t\tthis.constant = - point.dot( this.normal );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCoplanarPoints: function ( a, b, c ) {\n\n\t\tconst normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();\n\n\t\t// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?\n\n\t\tthis.setFromNormalAndCoplanarPoint( normal, a );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( plane ) {\n\n\t\tthis.normal.copy( plane.normal );\n\t\tthis.constant = plane.constant;\n\n\t\treturn this;\n\n\t},\n\n\tnormalize: function () {\n\n\t\t// Note: will lead to a divide by zero if the plane is invalid.\n\n\t\tconst inverseNormalLength = 1.0 / this.normal.length();\n\t\tthis.normal.multiplyScalar( inverseNormalLength );\n\t\tthis.constant *= inverseNormalLength;\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.constant *= - 1;\n\t\tthis.normal.negate();\n\n\t\treturn this;\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn this.normal.dot( point ) + this.constant;\n\n\t},\n\n\tdistanceToSphere: function ( sphere ) {\n\n\t\treturn this.distanceToPoint( sphere.center ) - sphere.radius;\n\n\t},\n\n\tprojectPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .projectPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );\n\n\t},\n\n\tintersectLine: function ( line, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .intersectLine() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tconst direction = line.delta( _vector1 );\n\n\t\tconst denominator = this.normal.dot( direction );\n\n\t\tif ( denominator === 0 ) {\n\n\t\t\t// line is coplanar, return origin\n\t\t\tif ( this.distanceToPoint( line.start ) === 0 ) {\n\n\t\t\t\treturn target.copy( line.start );\n\n\t\t\t}\n\n\t\t\t// Unsure if this is the correct method to handle this case.\n\t\t\treturn undefined;\n\n\t\t}\n\n\t\tconst t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;\n\n\t\tif ( t < 0 || t > 1 ) {\n\n\t\t\treturn undefined;\n\n\t\t}\n\n\t\treturn target.copy( direction ).multiplyScalar( t ).add( line.start );\n\n\t},\n\n\tintersectsLine: function ( line ) {\n\n\t\t// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.\n\n\t\tconst startSign = this.distanceToPoint( line.start );\n\t\tconst endSign = this.distanceToPoint( line.end );\n\n\t\treturn ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsPlane( this );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\treturn sphere.intersectsPlane( this );\n\n\t},\n\n\tcoplanarPoint: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .coplanarPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.normal ).multiplyScalar( - this.constant );\n\n\t},\n\n\tapplyMatrix4: function ( matrix, optionalNormalMatrix ) {\n\n\t\tconst normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );\n\n\t\tconst referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );\n\n\t\tconst normal = this.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\tthis.constant = - referencePoint.dot( normal );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.constant -= offset.dot( this.normal );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( plane ) {\n\n\t\treturn plane.normal.equals( this.normal ) && ( plane.constant === this.constant );\n\n\t}\n\n} );\n\n\nexport { Plane };\n","import { Vector3 } from './Vector3.js';\nimport { Plane } from './Plane.js';\n\n/**\n * @author bhouston / http://clara.io\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _v0 = new Vector3();\nconst _v1 = new Vector3();\nconst _v2 = new Vector3();\nconst _v3 = new Vector3();\n\nconst _vab = new Vector3();\nconst _vac = new Vector3();\nconst _vbc = new Vector3();\nconst _vap = new Vector3();\nconst _vbp = new Vector3();\nconst _vcp = new Vector3();\n\nfunction Triangle( a, b, c ) {\n\n\tthis.a = ( a !== undefined ) ? a : new Vector3();\n\tthis.b = ( b !== undefined ) ? b : new Vector3();\n\tthis.c = ( c !== undefined ) ? c : new Vector3();\n\n}\n\nObject.assign( Triangle, {\n\n\tgetNormal: function ( a, b, c, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getNormal() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.subVectors( c, b );\n\t\t_v0.subVectors( a, b );\n\t\ttarget.cross( _v0 );\n\n\t\tconst targetLengthSq = target.lengthSq();\n\t\tif ( targetLengthSq > 0 ) {\n\n\t\t\treturn target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );\n\n\t\t}\n\n\t\treturn target.set( 0, 0, 0 );\n\n\t},\n\n\t// static/instance method to calculate barycentric coordinates\n\t// based on: http://www.blackpawn.com/texts/pointinpoly/default.html\n\tgetBarycoord: function ( point, a, b, c, target ) {\n\n\t\t_v0.subVectors( c, a );\n\t\t_v1.subVectors( b, a );\n\t\t_v2.subVectors( point, a );\n\n\t\tconst dot00 = _v0.dot( _v0 );\n\t\tconst dot01 = _v0.dot( _v1 );\n\t\tconst dot02 = _v0.dot( _v2 );\n\t\tconst dot11 = _v1.dot( _v1 );\n\t\tconst dot12 = _v1.dot( _v2 );\n\n\t\tconst denom = ( dot00 * dot11 - dot01 * dot01 );\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getBarycoord() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\t// collinear or singular triangle\n\t\tif ( denom === 0 ) {\n\n\t\t\t// arbitrary location outside of triangle?\n\t\t\t// not sure if this is the best idea, maybe should be returning undefined\n\t\t\treturn target.set( - 2, - 1, - 1 );\n\n\t\t}\n\n\t\tconst invDenom = 1 / denom;\n\t\tconst u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;\n\t\tconst v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;\n\n\t\t// barycentric coordinates must always sum to 1\n\t\treturn target.set( 1 - u - v, v, u );\n\n\t},\n\n\tcontainsPoint: function ( point, a, b, c ) {\n\n\t\tTriangle.getBarycoord( point, a, b, c, _v3 );\n\n\t\treturn ( _v3.x >= 0 ) && ( _v3.y >= 0 ) && ( ( _v3.x + _v3.y ) <= 1 );\n\n\t},\n\n\tgetUV: function ( point, p1, p2, p3, uv1, uv2, uv3, target ) {\n\n\t\tthis.getBarycoord( point, p1, p2, p3, _v3 );\n\n\t\ttarget.set( 0, 0 );\n\t\ttarget.addScaledVector( uv1, _v3.x );\n\t\ttarget.addScaledVector( uv2, _v3.y );\n\t\ttarget.addScaledVector( uv3, _v3.z );\n\n\t\treturn target;\n\n\t},\n\n\tisFrontFacing: function ( a, b, c, direction ) {\n\n\t\t_v0.subVectors( c, b );\n\t\t_v1.subVectors( a, b );\n\n\t\t// strictly front facing\n\t\treturn ( _v0.cross( _v1 ).dot( direction ) < 0 ) ? true : false;\n\n\t}\n\n} );\n\nObject.assign( Triangle.prototype, {\n\n\tset: function ( a, b, c ) {\n\n\t\tthis.a.copy( a );\n\t\tthis.b.copy( b );\n\t\tthis.c.copy( c );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPointsAndIndices: function ( points, i0, i1, i2 ) {\n\n\t\tthis.a.copy( points[ i0 ] );\n\t\tthis.b.copy( points[ i1 ] );\n\t\tthis.c.copy( points[ i2 ] );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( triangle ) {\n\n\t\tthis.a.copy( triangle.a );\n\t\tthis.b.copy( triangle.b );\n\t\tthis.c.copy( triangle.c );\n\n\t\treturn this;\n\n\t},\n\n\tgetArea: function () {\n\n\t\t_v0.subVectors( this.c, this.b );\n\t\t_v1.subVectors( this.a, this.b );\n\n\t\treturn _v0.cross( _v1 ).length() * 0.5;\n\n\t},\n\n\tgetMidpoint: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getMidpoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 );\n\n\t},\n\n\tgetNormal: function ( target ) {\n\n\t\treturn Triangle.getNormal( this.a, this.b, this.c, target );\n\n\t},\n\n\tgetPlane: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getPlane() target is now required' );\n\t\t\ttarget = new Plane();\n\n\t\t}\n\n\t\treturn target.setFromCoplanarPoints( this.a, this.b, this.c );\n\n\t},\n\n\tgetBarycoord: function ( point, target ) {\n\n\t\treturn Triangle.getBarycoord( point, this.a, this.b, this.c, target );\n\n\t},\n\n\tgetUV: function ( point, uv1, uv2, uv3, target ) {\n\n\t\treturn Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, target );\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn Triangle.containsPoint( point, this.a, this.b, this.c );\n\n\t},\n\n\tisFrontFacing: function ( direction ) {\n\n\t\treturn Triangle.isFrontFacing( this.a, this.b, this.c, direction );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsTriangle( this );\n\n\t},\n\n\tclosestPointToPoint: function ( p, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tconst a = this.a, b = this.b, c = this.c;\n\t\tlet v, w;\n\n\t\t// algorithm thanks to Real-Time Collision Detection by Christer Ericson,\n\t\t// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,\n\t\t// under the accompanying license; see chapter 5.1.5 for detailed explanation.\n\t\t// basically, we're distinguishing which of the voronoi regions of the triangle\n\t\t// the point lies in with the minimum amount of redundant computation.\n\n\t\t_vab.subVectors( b, a );\n\t\t_vac.subVectors( c, a );\n\t\t_vap.subVectors( p, a );\n\t\tconst d1 = _vab.dot( _vap );\n\t\tconst d2 = _vac.dot( _vap );\n\t\tif ( d1 <= 0 && d2 <= 0 ) {\n\n\t\t\t// vertex region of A; barycentric coords (1, 0, 0)\n\t\t\treturn target.copy( a );\n\n\t\t}\n\n\t\t_vbp.subVectors( p, b );\n\t\tconst d3 = _vab.dot( _vbp );\n\t\tconst d4 = _vac.dot( _vbp );\n\t\tif ( d3 >= 0 && d4 <= d3 ) {\n\n\t\t\t// vertex region of B; barycentric coords (0, 1, 0)\n\t\t\treturn target.copy( b );\n\n\t\t}\n\n\t\tconst vc = d1 * d4 - d3 * d2;\n\t\tif ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {\n\n\t\t\tv = d1 / ( d1 - d3 );\n\t\t\t// edge region of AB; barycentric coords (1-v, v, 0)\n\t\t\treturn target.copy( a ).addScaledVector( _vab, v );\n\n\t\t}\n\n\t\t_vcp.subVectors( p, c );\n\t\tconst d5 = _vab.dot( _vcp );\n\t\tconst d6 = _vac.dot( _vcp );\n\t\tif ( d6 >= 0 && d5 <= d6 ) {\n\n\t\t\t// vertex region of C; barycentric coords (0, 0, 1)\n\t\t\treturn target.copy( c );\n\n\t\t}\n\n\t\tconst vb = d5 * d2 - d1 * d6;\n\t\tif ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {\n\n\t\t\tw = d2 / ( d2 - d6 );\n\t\t\t// edge region of AC; barycentric coords (1-w, 0, w)\n\t\t\treturn target.copy( a ).addScaledVector( _vac, w );\n\n\t\t}\n\n\t\tconst va = d3 * d6 - d5 * d4;\n\t\tif ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {\n\n\t\t\t_vbc.subVectors( c, b );\n\t\t\tw = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );\n\t\t\t// edge region of BC; barycentric coords (0, 1-w, w)\n\t\t\treturn target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC\n\n\t\t}\n\n\t\t// face region\n\t\tconst denom = 1 / ( va + vb + vc );\n\t\t// u = va * denom\n\t\tv = vb * denom;\n\t\tw = vc * denom;\n\n\t\treturn target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w );\n\n\t},\n\n\tequals: function ( triangle ) {\n\n\t\treturn triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c );\n\n\t}\n\n} );\n\n\nexport { Triangle };\n","import { MathUtils } from './MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,\n\t'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,\n\t'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,\n\t'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,\n\t'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B,\n\t'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F,\n\t'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3,\n\t'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222,\n\t'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700,\n\t'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4,\n\t'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00,\n\t'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3,\n\t'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA,\n\t'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32,\n\t'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3,\n\t'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC,\n\t'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD,\n\t'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6,\n\t'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9,\n\t'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F,\n\t'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE,\n\t'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA,\n\t'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,\n\t'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };\n\nconst _hslA = { h: 0, s: 0, l: 0 };\nconst _hslB = { h: 0, s: 0, l: 0 };\n\nfunction Color( r, g, b ) {\n\n\tif ( g === undefined && b === undefined ) {\n\n\t\t// r is THREE.Color, hex or string\n\t\treturn this.set( r );\n\n\t}\n\n\treturn this.setRGB( r, g, b );\n\n}\n\nfunction hue2rgb( p, q, t ) {\n\n\tif ( t < 0 ) t += 1;\n\tif ( t > 1 ) t -= 1;\n\tif ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;\n\tif ( t < 1 / 2 ) return q;\n\tif ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );\n\treturn p;\n\n}\n\nfunction SRGBToLinear( c ) {\n\n\treturn ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n}\n\nfunction LinearToSRGB( c ) {\n\n\treturn ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;\n\n}\n\nObject.assign( Color.prototype, {\n\n\tisColor: true,\n\n\tr: 1, g: 1, b: 1,\n\n\tset: function ( value ) {\n\n\t\tif ( value && value.isColor ) {\n\n\t\t\tthis.copy( value );\n\n\t\t} else if ( typeof value === 'number' ) {\n\n\t\t\tthis.setHex( value );\n\n\t\t} else if ( typeof value === 'string' ) {\n\n\t\t\tthis.setStyle( value );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.r = scalar;\n\t\tthis.g = scalar;\n\t\tthis.b = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetHex: function ( hex ) {\n\n\t\thex = Math.floor( hex );\n\n\t\tthis.r = ( hex >> 16 & 255 ) / 255;\n\t\tthis.g = ( hex >> 8 & 255 ) / 255;\n\t\tthis.b = ( hex & 255 ) / 255;\n\n\t\treturn this;\n\n\t},\n\n\tsetRGB: function ( r, g, b ) {\n\n\t\tthis.r = r;\n\t\tthis.g = g;\n\t\tthis.b = b;\n\n\t\treturn this;\n\n\t},\n\n\tsetHSL: function ( h, s, l ) {\n\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\th = MathUtils.euclideanModulo( h, 1 );\n\t\ts = MathUtils.clamp( s, 0, 1 );\n\t\tl = MathUtils.clamp( l, 0, 1 );\n\n\t\tif ( s === 0 ) {\n\n\t\t\tthis.r = this.g = this.b = l;\n\n\t\t} else {\n\n\t\t\tconst p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );\n\t\t\tconst q = ( 2 * l ) - p;\n\n\t\t\tthis.r = hue2rgb( q, p, h + 1 / 3 );\n\t\t\tthis.g = hue2rgb( q, p, h );\n\t\t\tthis.b = hue2rgb( q, p, h - 1 / 3 );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetStyle: function ( style ) {\n\n\t\tfunction handleAlpha( string ) {\n\n\t\t\tif ( string === undefined ) return;\n\n\t\t\tif ( parseFloat( string ) < 1 ) {\n\n\t\t\t\tconsole.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );\n\n\t\t\t}\n\n\t\t}\n\n\n\t\tlet m;\n\n\t\tif ( m = /^((?:rgb|hsl)a?)\\(\\s*([^\\)]*)\\)/.exec( style ) ) {\n\n\t\t\t// rgb / hsl\n\n\t\t\tlet color;\n\t\t\tconst name = m[ 1 ];\n\t\t\tconst components = m[ 2 ];\n\n\t\t\tswitch ( name ) {\n\n\t\t\t\tcase 'rgb':\n\t\t\t\tcase 'rgba':\n\n\t\t\t\t\tif ( color = /^(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// rgb(255,0,0) rgba(255,0,0,0.5)\n\t\t\t\t\t\tthis.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;\n\t\t\t\t\t\tthis.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;\n\t\t\t\t\t\tthis.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( color = /^(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)\n\t\t\t\t\t\tthis.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;\n\t\t\t\t\t\tthis.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;\n\t\t\t\t\t\tthis.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'hsl':\n\t\t\t\tcase 'hsla':\n\n\t\t\t\t\tif ( color = /^([0-9]*\\.?[0-9]+)\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// hsl(120,50%,50%) hsla(120,50%,50%,0.5)\n\t\t\t\t\t\tconst h = parseFloat( color[ 1 ] ) / 360;\n\t\t\t\t\t\tconst s = parseInt( color[ 2 ], 10 ) / 100;\n\t\t\t\t\t\tconst l = parseInt( color[ 3 ], 10 ) / 100;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this.setHSL( h, s, l );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t} else if ( m = /^\\#([A-Fa-f0-9]+)$/.exec( style ) ) {\n\n\t\t\t// hex color\n\n\t\t\tconst hex = m[ 1 ];\n\t\t\tconst size = hex.length;\n\n\t\t\tif ( size === 3 ) {\n\n\t\t\t\t// #ff0\n\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;\n\t\t\t\tthis.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\tthis.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;\n\n\t\t\t\treturn this;\n\n\t\t\t} else if ( size === 6 ) {\n\n\t\t\t\t// #ff0000\n\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\tthis.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;\n\t\t\t\tthis.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;\n\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( style && style.length > 0 ) {\n\n\t\t\treturn this.setColorName( style );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetColorName: function ( style ) {\n\n\t\t// color keywords\n\t\tconst hex = _colorKeywords[ style ];\n\n\t\tif ( hex !== undefined ) {\n\n\t\t\t// red\n\t\t\tthis.setHex( hex );\n\n\t\t} else {\n\n\t\t\t// unknown color\n\t\t\tconsole.warn( 'THREE.Color: Unknown color ' + style );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.r, this.g, this.b );\n\n\t},\n\n\tcopy: function ( color ) {\n\n\t\tthis.r = color.r;\n\t\tthis.g = color.g;\n\t\tthis.b = color.b;\n\n\t\treturn this;\n\n\t},\n\n\tcopyGammaToLinear: function ( color, gammaFactor ) {\n\n\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\tthis.r = Math.pow( color.r, gammaFactor );\n\t\tthis.g = Math.pow( color.g, gammaFactor );\n\t\tthis.b = Math.pow( color.b, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tcopyLinearToGamma: function ( color, gammaFactor ) {\n\n\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\tconst safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;\n\n\t\tthis.r = Math.pow( color.r, safeInverse );\n\t\tthis.g = Math.pow( color.g, safeInverse );\n\t\tthis.b = Math.pow( color.b, safeInverse );\n\n\t\treturn this;\n\n\t},\n\n\tconvertGammaToLinear: function ( gammaFactor ) {\n\n\t\tthis.copyGammaToLinear( this, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tconvertLinearToGamma: function ( gammaFactor ) {\n\n\t\tthis.copyLinearToGamma( this, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tcopySRGBToLinear: function ( color ) {\n\n\t\tthis.r = SRGBToLinear( color.r );\n\t\tthis.g = SRGBToLinear( color.g );\n\t\tthis.b = SRGBToLinear( color.b );\n\n\t\treturn this;\n\n\t},\n\n\tcopyLinearToSRGB: function ( color ) {\n\n\t\tthis.r = LinearToSRGB( color.r );\n\t\tthis.g = LinearToSRGB( color.g );\n\t\tthis.b = LinearToSRGB( color.b );\n\n\t\treturn this;\n\n\t},\n\n\tconvertSRGBToLinear: function () {\n\n\t\tthis.copySRGBToLinear( this );\n\n\t\treturn this;\n\n\t},\n\n\tconvertLinearToSRGB: function () {\n\n\t\tthis.copyLinearToSRGB( this );\n\n\t\treturn this;\n\n\t},\n\n\tgetHex: function () {\n\n\t\treturn ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;\n\n\t},\n\n\tgetHexString: function () {\n\n\t\treturn ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );\n\n\t},\n\n\tgetHSL: function ( target ) {\n\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Color: .getHSL() target is now required' );\n\t\t\ttarget = { h: 0, s: 0, l: 0 };\n\n\t\t}\n\n\t\tconst r = this.r, g = this.g, b = this.b;\n\n\t\tconst max = Math.max( r, g, b );\n\t\tconst min = Math.min( r, g, b );\n\n\t\tlet hue, saturation;\n\t\tconst lightness = ( min + max ) / 2.0;\n\n\t\tif ( min === max ) {\n\n\t\t\thue = 0;\n\t\t\tsaturation = 0;\n\n\t\t} else {\n\n\t\t\tconst delta = max - min;\n\n\t\t\tsaturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );\n\n\t\t\tswitch ( max ) {\n\n\t\t\t\tcase r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;\n\t\t\t\tcase g: hue = ( b - r ) / delta + 2; break;\n\t\t\t\tcase b: hue = ( r - g ) / delta + 4; break;\n\n\t\t\t}\n\n\t\t\thue /= 6;\n\n\t\t}\n\n\t\ttarget.h = hue;\n\t\ttarget.s = saturation;\n\t\ttarget.l = lightness;\n\n\t\treturn target;\n\n\t},\n\n\tgetStyle: function () {\n\n\t\treturn 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';\n\n\t},\n\n\toffsetHSL: function ( h, s, l ) {\n\n\t\tthis.getHSL( _hslA );\n\n\t\t_hslA.h += h; _hslA.s += s; _hslA.l += l;\n\n\t\tthis.setHSL( _hslA.h, _hslA.s, _hslA.l );\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( color ) {\n\n\t\tthis.r += color.r;\n\t\tthis.g += color.g;\n\t\tthis.b += color.b;\n\n\t\treturn this;\n\n\t},\n\n\taddColors: function ( color1, color2 ) {\n\n\t\tthis.r = color1.r + color2.r;\n\t\tthis.g = color1.g + color2.g;\n\t\tthis.b = color1.b + color2.b;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.r += s;\n\t\tthis.g += s;\n\t\tthis.b += s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( color ) {\n\n\t\tthis.r = Math.max( 0, this.r - color.r );\n\t\tthis.g = Math.max( 0, this.g - color.g );\n\t\tthis.b = Math.max( 0, this.b - color.b );\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( color ) {\n\n\t\tthis.r *= color.r;\n\t\tthis.g *= color.g;\n\t\tthis.b *= color.b;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tthis.r *= s;\n\t\tthis.g *= s;\n\t\tthis.b *= s;\n\n\t\treturn this;\n\n\t},\n\n\tlerp: function ( color, alpha ) {\n\n\t\tthis.r += ( color.r - this.r ) * alpha;\n\t\tthis.g += ( color.g - this.g ) * alpha;\n\t\tthis.b += ( color.b - this.b ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpHSL: function ( color, alpha ) {\n\n\t\tthis.getHSL( _hslA );\n\t\tcolor.getHSL( _hslB );\n\n\t\tconst h = MathUtils.lerp( _hslA.h, _hslB.h, alpha );\n\t\tconst s = MathUtils.lerp( _hslA.s, _hslB.s, alpha );\n\t\tconst l = MathUtils.lerp( _hslA.l, _hslB.l, alpha );\n\n\t\tthis.setHSL( h, s, l );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( c ) {\n\n\t\treturn ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.r = array[ offset ];\n\t\tthis.g = array[ offset + 1 ];\n\t\tthis.b = array[ offset + 2 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.r;\n\t\tarray[ offset + 1 ] = this.g;\n\t\tarray[ offset + 2 ] = this.b;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index ) {\n\n\t\tthis.r = attribute.getX( index );\n\t\tthis.g = attribute.getY( index );\n\t\tthis.b = attribute.getZ( index );\n\n\t\tif ( attribute.normalized === true ) {\n\n\t\t\t// assuming Uint8Array\n\n\t\t\tthis.r /= 255;\n\t\t\tthis.g /= 255;\n\t\t\tthis.b /= 255;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\treturn this.getHex();\n\n\t}\n\n} );\n\nColor.NAMES = _colorKeywords;\n\nexport { Color };\n","import { Color } from '../math/Color.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction Face3( a, b, c, normal, color, materialIndex ) {\n\n\tthis.a = a;\n\tthis.b = b;\n\tthis.c = c;\n\n\tthis.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();\n\tthis.vertexNormals = Array.isArray( normal ) ? normal : [];\n\n\tthis.color = ( color && color.isColor ) ? color : new Color();\n\tthis.vertexColors = Array.isArray( color ) ? color : [];\n\n\tthis.materialIndex = materialIndex !== undefined ? materialIndex : 0;\n\n}\n\nObject.assign( Face3.prototype, {\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.a = source.a;\n\t\tthis.b = source.b;\n\t\tthis.c = source.c;\n\n\t\tthis.normal.copy( source.normal );\n\t\tthis.color.copy( source.color );\n\n\t\tthis.materialIndex = source.materialIndex;\n\n\t\tfor ( let i = 0, il = source.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\tthis.vertexNormals[ i ] = source.vertexNormals[ i ].clone();\n\n\t\t}\n\n\t\tfor ( let i = 0, il = source.vertexColors.length; i < il; i ++ ) {\n\n\t\t\tthis.vertexColors[ i ] = source.vertexColors[ i ].clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Face3 };\n","import { EventDispatcher } from '../core/EventDispatcher.js';\nimport { FrontSide, FlatShading, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nlet materialId = 0;\n\nfunction Material() {\n\n\tObject.defineProperty( this, 'id', { value: materialId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Material';\n\n\tthis.fog = true;\n\n\tthis.blending = NormalBlending;\n\tthis.side = FrontSide;\n\tthis.flatShading = false;\n\tthis.vertexColors = false;\n\n\tthis.opacity = 1;\n\tthis.transparent = false;\n\n\tthis.blendSrc = SrcAlphaFactor;\n\tthis.blendDst = OneMinusSrcAlphaFactor;\n\tthis.blendEquation = AddEquation;\n\tthis.blendSrcAlpha = null;\n\tthis.blendDstAlpha = null;\n\tthis.blendEquationAlpha = null;\n\n\tthis.depthFunc = LessEqualDepth;\n\tthis.depthTest = true;\n\tthis.depthWrite = true;\n\n\tthis.stencilWriteMask = 0xff;\n\tthis.stencilFunc = AlwaysStencilFunc;\n\tthis.stencilRef = 0;\n\tthis.stencilFuncMask = 0xff;\n\tthis.stencilFail = KeepStencilOp;\n\tthis.stencilZFail = KeepStencilOp;\n\tthis.stencilZPass = KeepStencilOp;\n\tthis.stencilWrite = false;\n\n\tthis.clippingPlanes = null;\n\tthis.clipIntersection = false;\n\tthis.clipShadows = false;\n\n\tthis.shadowSide = null;\n\n\tthis.colorWrite = true;\n\n\tthis.precision = null; // override the renderer's default precision for this material\n\n\tthis.polygonOffset = false;\n\tthis.polygonOffsetFactor = 0;\n\tthis.polygonOffsetUnits = 0;\n\n\tthis.dithering = false;\n\n\tthis.alphaTest = 0;\n\tthis.premultipliedAlpha = false;\n\n\tthis.visible = true;\n\n\tthis.toneMapped = true;\n\n\tthis.userData = {};\n\n\tthis.version = 0;\n\n}\n\nMaterial.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Material,\n\n\tisMaterial: true,\n\n\tonBeforeCompile: function ( /* shaderobject, renderer */ ) {},\n\n\tcustomProgramCacheKey: function () {\n\n\t\treturn this.onBeforeCompile.toString();\n\n\t},\n\n\tsetValues: function ( values ) {\n\n\t\tif ( values === undefined ) return;\n\n\t\tfor ( const key in values ) {\n\n\t\t\tconst newValue = values[ key ];\n\n\t\t\tif ( newValue === undefined ) {\n\n\t\t\t\tconsole.warn( \"THREE.Material: '\" + key + \"' parameter is undefined.\" );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\t// for backward compatability if shading is set in the constructor\n\t\t\tif ( key === 'shading' ) {\n\n\t\t\t\tconsole.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );\n\t\t\t\tthis.flatShading = ( newValue === FlatShading ) ? true : false;\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tconst currentValue = this[ key ];\n\n\t\t\tif ( currentValue === undefined ) {\n\n\t\t\t\tconsole.warn( \"THREE.\" + this.type + \": '\" + key + \"' is not a property of this material.\" );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tif ( currentValue && currentValue.isColor ) {\n\n\t\t\t\tcurrentValue.set( newValue );\n\n\t\t\t} else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {\n\n\t\t\t\tcurrentValue.copy( newValue );\n\n\t\t\t} else {\n\n\t\t\t\tthis[ key ] = newValue;\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst isRoot = ( meta === undefined || typeof meta === 'string' );\n\n\t\tif ( isRoot ) {\n\n\t\t\tmeta = {\n\t\t\t\ttextures: {},\n\t\t\t\timages: {}\n\t\t\t};\n\n\t\t}\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Material',\n\t\t\t\tgenerator: 'Material.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard Material serialization\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\n\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\tif ( this.color && this.color.isColor ) data.color = this.color.getHex();\n\n\t\tif ( this.roughness !== undefined ) data.roughness = this.roughness;\n\t\tif ( this.metalness !== undefined ) data.metalness = this.metalness;\n\n\t\tif ( this.sheen && this.sheen.isColor ) data.sheen = this.sheen.getHex();\n\t\tif ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();\n\t\tif ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;\n\n\t\tif ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();\n\t\tif ( this.shininess !== undefined ) data.shininess = this.shininess;\n\t\tif ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;\n\t\tif ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;\n\n\t\tif ( this.clearcoatMap && this.clearcoatMap.isTexture ) {\n\n\t\t\tdata.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {\n\n\t\t\tdata.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {\n\n\t\t\tdata.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;\n\t\t\tdata.clearcoatNormalScale = this.clearcoatNormalScale.toArray();\n\n\t\t}\n\n\t\tif ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;\n\t\tif ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;\n\t\tif ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;\n\t\tif ( this.lightMap && this.lightMap.isTexture ) data.lightMap = this.lightMap.toJSON( meta ).uuid;\n\n\t\tif ( this.aoMap && this.aoMap.isTexture ) {\n\n\t\t\tdata.aoMap = this.aoMap.toJSON( meta ).uuid;\n\t\t\tdata.aoMapIntensity = this.aoMapIntensity;\n\n\t\t}\n\n\t\tif ( this.bumpMap && this.bumpMap.isTexture ) {\n\n\t\t\tdata.bumpMap = this.bumpMap.toJSON( meta ).uuid;\n\t\t\tdata.bumpScale = this.bumpScale;\n\n\t\t}\n\n\t\tif ( this.normalMap && this.normalMap.isTexture ) {\n\n\t\t\tdata.normalMap = this.normalMap.toJSON( meta ).uuid;\n\t\t\tdata.normalMapType = this.normalMapType;\n\t\t\tdata.normalScale = this.normalScale.toArray();\n\n\t\t}\n\n\t\tif ( this.displacementMap && this.displacementMap.isTexture ) {\n\n\t\t\tdata.displacementMap = this.displacementMap.toJSON( meta ).uuid;\n\t\t\tdata.displacementScale = this.displacementScale;\n\t\t\tdata.displacementBias = this.displacementBias;\n\n\t\t}\n\n\t\tif ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;\n\t\tif ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;\n\n\t\tif ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;\n\t\tif ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;\n\n\t\tif ( this.envMap && this.envMap.isTexture ) {\n\n\t\t\tdata.envMap = this.envMap.toJSON( meta ).uuid;\n\t\t\tdata.reflectivity = this.reflectivity; // Scale behind envMap\n\t\t\tdata.refractionRatio = this.refractionRatio;\n\n\t\t\tif ( this.combine !== undefined ) data.combine = this.combine;\n\t\t\tif ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;\n\n\t\t}\n\n\t\tif ( this.gradientMap && this.gradientMap.isTexture ) {\n\n\t\t\tdata.gradientMap = this.gradientMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.size !== undefined ) data.size = this.size;\n\t\tif ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;\n\n\t\tif ( this.blending !== NormalBlending ) data.blending = this.blending;\n\t\tif ( this.flatShading === true ) data.flatShading = this.flatShading;\n\t\tif ( this.side !== FrontSide ) data.side = this.side;\n\t\tif ( this.vertexColors ) data.vertexColors = true;\n\n\t\tif ( this.opacity < 1 ) data.opacity = this.opacity;\n\t\tif ( this.transparent === true ) data.transparent = this.transparent;\n\n\t\tdata.depthFunc = this.depthFunc;\n\t\tdata.depthTest = this.depthTest;\n\t\tdata.depthWrite = this.depthWrite;\n\n\t\tdata.stencilWrite = this.stencilWrite;\n\t\tdata.stencilWriteMask = this.stencilWriteMask;\n\t\tdata.stencilFunc = this.stencilFunc;\n\t\tdata.stencilRef = this.stencilRef;\n\t\tdata.stencilFuncMask = this.stencilFuncMask;\n\t\tdata.stencilFail = this.stencilFail;\n\t\tdata.stencilZFail = this.stencilZFail;\n\t\tdata.stencilZPass = this.stencilZPass;\n\n\t\t// rotation (SpriteMaterial)\n\t\tif ( this.rotation && this.rotation !== 0 ) data.rotation = this.rotation;\n\n\t\tif ( this.polygonOffset === true ) data.polygonOffset = true;\n\t\tif ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;\n\t\tif ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;\n\n\t\tif ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth;\n\t\tif ( this.dashSize !== undefined ) data.dashSize = this.dashSize;\n\t\tif ( this.gapSize !== undefined ) data.gapSize = this.gapSize;\n\t\tif ( this.scale !== undefined ) data.scale = this.scale;\n\n\t\tif ( this.dithering === true ) data.dithering = true;\n\n\t\tif ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;\n\t\tif ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;\n\n\t\tif ( this.wireframe === true ) data.wireframe = this.wireframe;\n\t\tif ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;\n\t\tif ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;\n\t\tif ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;\n\n\t\tif ( this.morphTargets === true ) data.morphTargets = true;\n\t\tif ( this.morphNormals === true ) data.morphNormals = true;\n\t\tif ( this.skinning === true ) data.skinning = true;\n\n\t\tif ( this.visible === false ) data.visible = false;\n\n\t\tif ( this.toneMapped === false ) data.toneMapped = false;\n\n\t\tif ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;\n\n\t\t// TODO: Copied from Object3D.toJSON\n\n\t\tfunction extractFromCache( cache ) {\n\n\t\t\tconst values = [];\n\n\t\t\tfor ( const key in cache ) {\n\n\t\t\t\tconst data = cache[ key ];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push( data );\n\n\t\t\t}\n\n\t\t\treturn values;\n\n\t\t}\n\n\t\tif ( isRoot ) {\n\n\t\t\tconst textures = extractFromCache( meta.textures );\n\t\t\tconst images = extractFromCache( meta.images );\n\n\t\t\tif ( textures.length > 0 ) data.textures = textures;\n\t\t\tif ( images.length > 0 ) data.images = images;\n\n\t\t}\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\n\t\tthis.fog = source.fog;\n\n\t\tthis.blending = source.blending;\n\t\tthis.side = source.side;\n\t\tthis.flatShading = source.flatShading;\n\t\tthis.vertexColors = source.vertexColors;\n\n\t\tthis.opacity = source.opacity;\n\t\tthis.transparent = source.transparent;\n\n\t\tthis.blendSrc = source.blendSrc;\n\t\tthis.blendDst = source.blendDst;\n\t\tthis.blendEquation = source.blendEquation;\n\t\tthis.blendSrcAlpha = source.blendSrcAlpha;\n\t\tthis.blendDstAlpha = source.blendDstAlpha;\n\t\tthis.blendEquationAlpha = source.blendEquationAlpha;\n\n\t\tthis.depthFunc = source.depthFunc;\n\t\tthis.depthTest = source.depthTest;\n\t\tthis.depthWrite = source.depthWrite;\n\n\t\tthis.stencilWriteMask = source.stencilWriteMask;\n\t\tthis.stencilFunc = source.stencilFunc;\n\t\tthis.stencilRef = source.stencilRef;\n\t\tthis.stencilFuncMask = source.stencilFuncMask;\n\t\tthis.stencilFail = source.stencilFail;\n\t\tthis.stencilZFail = source.stencilZFail;\n\t\tthis.stencilZPass = source.stencilZPass;\n\t\tthis.stencilWrite = source.stencilWrite;\n\n\t\tconst srcPlanes = source.clippingPlanes;\n\t\tlet dstPlanes = null;\n\n\t\tif ( srcPlanes !== null ) {\n\n\t\t\tconst n = srcPlanes.length;\n\t\t\tdstPlanes = new Array( n );\n\n\t\t\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\t\t\tdstPlanes[ i ] = srcPlanes[ i ].clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.clippingPlanes = dstPlanes;\n\t\tthis.clipIntersection = source.clipIntersection;\n\t\tthis.clipShadows = source.clipShadows;\n\n\t\tthis.shadowSide = source.shadowSide;\n\n\t\tthis.colorWrite = source.colorWrite;\n\n\t\tthis.precision = source.precision;\n\n\t\tthis.polygonOffset = source.polygonOffset;\n\t\tthis.polygonOffsetFactor = source.polygonOffsetFactor;\n\t\tthis.polygonOffsetUnits = source.polygonOffsetUnits;\n\n\t\tthis.dithering = source.dithering;\n\n\t\tthis.alphaTest = source.alphaTest;\n\t\tthis.premultipliedAlpha = source.premultipliedAlpha;\n\n\t\tthis.visible = source.visible;\n\n\t\tthis.toneMapped = source.toneMapped;\n\n\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\nObject.defineProperty( Material.prototype, 'needsUpdate', {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\nexport { Material };\n","import { Material } from './Material.js';\nimport { MultiplyOperation } from '../constants.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n * map: new THREE.Texture( ),\n *\n * lightMap: new THREE.Texture( ),\n * lightMapIntensity: \n *\n * aoMap: new THREE.Texture( ),\n * aoMapIntensity: \n *\n * specularMap: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n * combine: THREE.Multiply,\n * reflectivity: ,\n * refractionRatio: ,\n *\n * depthTest: ,\n * depthWrite: ,\n *\n * wireframe: ,\n * wireframeLinewidth: ,\n *\n * skinning: ,\n * morphTargets: \n * }\n */\n\nfunction MeshBasicMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshBasicMaterial';\n\n\tthis.color = new Color( 0xffffff ); // emissive\n\n\tthis.map = null;\n\n\tthis.lightMap = null;\n\tthis.lightMapIntensity = 1.0;\n\n\tthis.aoMap = null;\n\tthis.aoMapIntensity = 1.0;\n\n\tthis.specularMap = null;\n\n\tthis.alphaMap = null;\n\n\tthis.envMap = null;\n\tthis.combine = MultiplyOperation;\n\tthis.reflectivity = 1;\n\tthis.refractionRatio = 0.98;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\tthis.wireframeLinecap = 'round';\n\tthis.wireframeLinejoin = 'round';\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshBasicMaterial.prototype = Object.create( Material.prototype );\nMeshBasicMaterial.prototype.constructor = MeshBasicMaterial;\n\nMeshBasicMaterial.prototype.isMeshBasicMaterial = true;\n\nMeshBasicMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.map = source.map;\n\n\tthis.lightMap = source.lightMap;\n\tthis.lightMapIntensity = source.lightMapIntensity;\n\n\tthis.aoMap = source.aoMap;\n\tthis.aoMapIntensity = source.aoMapIntensity;\n\n\tthis.specularMap = source.specularMap;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.envMap = source.envMap;\n\tthis.combine = source.combine;\n\tthis.reflectivity = source.reflectivity;\n\tthis.refractionRatio = source.refractionRatio;\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\tthis.wireframeLinecap = source.wireframeLinecap;\n\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { MeshBasicMaterial };\n","import { Vector4 } from '../math/Vector4.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Color } from '../math/Color.js';\nimport { StaticDrawUsage } from '../constants.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _vector = new Vector3();\nconst _vector2 = new Vector2();\n\nfunction BufferAttribute( array, itemSize, normalized ) {\n\n\tif ( Array.isArray( array ) ) {\n\n\t\tthrow new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );\n\n\t}\n\n\tthis.name = '';\n\n\tthis.array = array;\n\tthis.itemSize = itemSize;\n\tthis.count = array !== undefined ? array.length / itemSize : 0;\n\tthis.normalized = normalized === true;\n\n\tthis.usage = StaticDrawUsage;\n\tthis.updateRange = { offset: 0, count: - 1 };\n\n\tthis.version = 0;\n\n}\n\nObject.defineProperty( BufferAttribute.prototype, 'needsUpdate', {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\nObject.assign( BufferAttribute.prototype, {\n\n\tisBufferAttribute: true,\n\n\tonUploadCallback: function () {},\n\n\tsetUsage: function ( value ) {\n\n\t\tthis.usage = value;\n\n\t\treturn this;\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\t\tthis.array = new source.array.constructor( source.array );\n\t\tthis.itemSize = source.itemSize;\n\t\tthis.count = source.count;\n\t\tthis.normalized = source.normalized;\n\n\t\tthis.usage = source.usage;\n\n\t\treturn this;\n\n\t},\n\n\tcopyAt: function ( index1, attribute, index2 ) {\n\n\t\tindex1 *= this.itemSize;\n\t\tindex2 *= attribute.itemSize;\n\n\t\tfor ( let i = 0, l = this.itemSize; i < l; i ++ ) {\n\n\t\t\tthis.array[ index1 + i ] = attribute.array[ index2 + i ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyArray: function ( array ) {\n\n\t\tthis.array.set( array );\n\n\t\treturn this;\n\n\t},\n\n\tcopyColorsArray: function ( colors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = colors.length; i < l; i ++ ) {\n\n\t\t\tlet color = colors[ i ];\n\n\t\t\tif ( color === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );\n\t\t\t\tcolor = new Color();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = color.r;\n\t\t\tarray[ offset ++ ] = color.g;\n\t\t\tarray[ offset ++ ] = color.b;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector2sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector2();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector3sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector3();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\tarray[ offset ++ ] = vector.z;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector4sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector4();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\tarray[ offset ++ ] = vector.z;\n\t\t\tarray[ offset ++ ] = vector.w;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tif ( this.itemSize === 2 ) {\n\n\t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t\t_vector2.fromBufferAttribute( this, i );\n\t\t\t\t_vector2.applyMatrix3( m );\n\n\t\t\t\tthis.setXY( i, _vector2.x, _vector2.y, );\n\n\t\t\t}\n\n\t\t} else if ( this.itemSize === 3 ) {\n\n\t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( this, i );\n\t\t\t\t_vector.applyMatrix3( m );\n\n\t\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.applyMatrix4( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyNormalMatrix: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.applyNormalMatrix( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttransformDirection: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.transformDirection( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tset: function ( value, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.array.set( value, offset );\n\n\t\treturn this;\n\n\t},\n\n\tgetX: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize ];\n\n\t},\n\n\tsetX: function ( index, x ) {\n\n\t\tthis.array[ index * this.itemSize ] = x;\n\n\t\treturn this;\n\n\t},\n\n\tgetY: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 1 ];\n\n\t},\n\n\tsetY: function ( index, y ) {\n\n\t\tthis.array[ index * this.itemSize + 1 ] = y;\n\n\t\treturn this;\n\n\t},\n\n\tgetZ: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 2 ];\n\n\t},\n\n\tsetZ: function ( index, z ) {\n\n\t\tthis.array[ index * this.itemSize + 2 ] = z;\n\n\t\treturn this;\n\n\t},\n\n\tgetW: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 3 ];\n\n\t},\n\n\tsetW: function ( index, w ) {\n\n\t\tthis.array[ index * this.itemSize + 3 ] = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetXY: function ( index, x, y ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetXYZ: function ( index, x, y, z ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\t\tthis.array[ index + 2 ] = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetXYZW: function ( index, x, y, z, w ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\t\tthis.array[ index + 2 ] = z;\n\t\tthis.array[ index + 3 ] = w;\n\n\t\treturn this;\n\n\t},\n\n\tonUpload: function ( callback ) {\n\n\t\tthis.onUploadCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.array, this.itemSize ).copy( this );\n\n\t},\n\n\ttoJSON: function () {\n\n\t\treturn {\n\t\t\titemSize: this.itemSize,\n\t\t\ttype: this.array.constructor.name,\n\t\t\tarray: Array.prototype.slice.call( this.array ),\n\t\t\tnormalized: this.normalized\n\t\t};\n\n\t}\n\n} );\n\n//\n\nfunction Int8BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int8Array( array ), itemSize, normalized );\n\n}\n\nInt8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt8BufferAttribute.prototype.constructor = Int8BufferAttribute;\n\n\nfunction Uint8BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint8Array( array ), itemSize, normalized );\n\n}\n\nUint8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;\n\n\nfunction Uint8ClampedBufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint8ClampedArray( array ), itemSize, normalized );\n\n}\n\nUint8ClampedBufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;\n\n\nfunction Int16BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int16Array( array ), itemSize, normalized );\n\n}\n\nInt16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt16BufferAttribute.prototype.constructor = Int16BufferAttribute;\n\n\nfunction Uint16BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint16Array( array ), itemSize, normalized );\n\n}\n\nUint16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;\n\n\nfunction Int32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int32Array( array ), itemSize, normalized );\n\n}\n\nInt32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt32BufferAttribute.prototype.constructor = Int32BufferAttribute;\n\n\nfunction Uint32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint32Array( array ), itemSize, normalized );\n\n}\n\nUint32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;\n\n\nfunction Float32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Float32Array( array ), itemSize, normalized );\n\n}\n\nFloat32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nFloat32BufferAttribute.prototype.constructor = Float32BufferAttribute;\n\n\nfunction Float64BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Float64Array( array ), itemSize, normalized );\n\n}\n\nFloat64BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nFloat64BufferAttribute.prototype.constructor = Float64BufferAttribute;\n\n//\n\nexport {\n\tFloat64BufferAttribute,\n\tFloat32BufferAttribute,\n\tUint32BufferAttribute,\n\tInt32BufferAttribute,\n\tUint16BufferAttribute,\n\tInt16BufferAttribute,\n\tUint8ClampedBufferAttribute,\n\tUint8BufferAttribute,\n\tInt8BufferAttribute,\n\tBufferAttribute\n};\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Vector2 } from '../math/Vector2.js';\n\nfunction DirectGeometry() {\n\n\tthis.vertices = [];\n\tthis.normals = [];\n\tthis.colors = [];\n\tthis.uvs = [];\n\tthis.uvs2 = [];\n\n\tthis.groups = [];\n\n\tthis.morphTargets = {};\n\n\tthis.skinWeights = [];\n\tthis.skinIndices = [];\n\n\t// this.lineDistances = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\t// update flags\n\n\tthis.verticesNeedUpdate = false;\n\tthis.normalsNeedUpdate = false;\n\tthis.colorsNeedUpdate = false;\n\tthis.uvsNeedUpdate = false;\n\tthis.groupsNeedUpdate = false;\n\n}\n\nObject.assign( DirectGeometry.prototype, {\n\n\tcomputeGroups: function ( geometry ) {\n\n\t\tconst groups = [];\n\n\t\tlet group, i;\n\t\tlet materialIndex = undefined;\n\n\t\tconst faces = geometry.faces;\n\n\t\tfor ( i = 0; i < faces.length; i ++ ) {\n\n\t\t\tconst face = faces[ i ];\n\n\t\t\t// materials\n\n\t\t\tif ( face.materialIndex !== materialIndex ) {\n\n\t\t\t\tmaterialIndex = face.materialIndex;\n\n\t\t\t\tif ( group !== undefined ) {\n\n\t\t\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\t\t\tgroups.push( group );\n\n\t\t\t\t}\n\n\t\t\t\tgroup = {\n\t\t\t\t\tstart: i * 3,\n\t\t\t\t\tmaterialIndex: materialIndex\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( group !== undefined ) {\n\n\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\tgroups.push( group );\n\n\t\t}\n\n\t\tthis.groups = groups;\n\n\t},\n\n\tfromGeometry: function ( geometry ) {\n\n\t\tconst faces = geometry.faces;\n\t\tconst vertices = geometry.vertices;\n\t\tconst faceVertexUvs = geometry.faceVertexUvs;\n\n\t\tconst hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;\n\t\tconst hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;\n\n\t\t// morphs\n\n\t\tconst morphTargets = geometry.morphTargets;\n\t\tconst morphTargetsLength = morphTargets.length;\n\n\t\tlet morphTargetsPosition;\n\n\t\tif ( morphTargetsLength > 0 ) {\n\n\t\t\tmorphTargetsPosition = [];\n\n\t\t\tfor ( let i = 0; i < morphTargetsLength; i ++ ) {\n\n\t\t\t\tmorphTargetsPosition[ i ] = {\n\t\t\t\t\tname: morphTargets[ i ].name,\n\t\t\t\t \tdata: []\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.position = morphTargetsPosition;\n\n\t\t}\n\n\t\tconst morphNormals = geometry.morphNormals;\n\t\tconst morphNormalsLength = morphNormals.length;\n\n\t\tlet morphTargetsNormal;\n\n\t\tif ( morphNormalsLength > 0 ) {\n\n\t\t\tmorphTargetsNormal = [];\n\n\t\t\tfor ( let i = 0; i < morphNormalsLength; i ++ ) {\n\n\t\t\t\tmorphTargetsNormal[ i ] = {\n\t\t\t\t\tname: morphNormals[ i ].name,\n\t\t\t\t \tdata: []\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.normal = morphTargetsNormal;\n\n\t\t}\n\n\t\t// skins\n\n\t\tconst skinIndices = geometry.skinIndices;\n\t\tconst skinWeights = geometry.skinWeights;\n\n\t\tconst hasSkinIndices = skinIndices.length === vertices.length;\n\t\tconst hasSkinWeights = skinWeights.length === vertices.length;\n\n\t\t//\n\n\t\tif ( vertices.length > 0 && faces.length === 0 ) {\n\n\t\t\tconsole.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' );\n\n\t\t}\n\n\t\tfor ( let i = 0; i < faces.length; i ++ ) {\n\n\t\t\tconst face = faces[ i ];\n\n\t\t\tthis.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tthis.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] );\n\n\t\t\t} else {\n\n\t\t\t\tconst normal = face.normal;\n\n\t\t\t\tthis.normals.push( normal, normal, normal );\n\n\t\t\t}\n\n\t\t\tconst vertexColors = face.vertexColors;\n\n\t\t\tif ( vertexColors.length === 3 ) {\n\n\t\t\t\tthis.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );\n\n\t\t\t} else {\n\n\t\t\t\tconst color = face.color;\n\n\t\t\t\tthis.colors.push( color, color, color );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexUv === true ) {\n\n\t\t\t\tconst vertexUvs = faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\tthis.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );\n\n\t\t\t\t\tthis.uvs.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexUv2 === true ) {\n\n\t\t\t\tconst vertexUvs = faceVertexUvs[ 1 ][ i ];\n\n\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\tthis.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );\n\n\t\t\t\t\tthis.uvs2.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// morphs\n\n\t\t\tfor ( let j = 0; j < morphTargetsLength; j ++ ) {\n\n\t\t\t\tconst morphTarget = morphTargets[ j ].vertices;\n\n\t\t\t\tmorphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0; j < morphNormalsLength; j ++ ) {\n\n\t\t\t\tconst morphNormal = morphNormals[ j ].vertexNormals[ i ];\n\n\t\t\t\tmorphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );\n\n\t\t\t}\n\n\t\t\t// skins\n\n\t\t\tif ( hasSkinIndices ) {\n\n\t\t\t\tthis.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] );\n\n\t\t\t}\n\n\t\t\tif ( hasSkinWeights ) {\n\n\t\t\t\tthis.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.computeGroups( geometry );\n\n\t\tthis.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\tthis.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\tthis.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\tthis.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\tthis.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { DirectGeometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction arrayMin( array ) {\n\n\tif ( array.length === 0 ) return Infinity;\n\n\tlet min = array[ 0 ];\n\n\tfor ( let i = 1, l = array.length; i < l; ++ i ) {\n\n\t\tif ( array[ i ] < min ) min = array[ i ];\n\n\t}\n\n\treturn min;\n\n}\n\nfunction arrayMax( array ) {\n\n\tif ( array.length === 0 ) return - Infinity;\n\n\tlet max = array[ 0 ];\n\n\tfor ( let i = 1, l = array.length; i < l; ++ i ) {\n\n\t\tif ( array[ i ] > max ) max = array[ i ];\n\n\t}\n\n\treturn max;\n\n}\n\nexport { arrayMin, arrayMax };\n","import { Vector3 } from '../math/Vector3.js';\nimport { Box3 } from '../math/Box3.js';\nimport { EventDispatcher } from './EventDispatcher.js';\nimport { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { DirectGeometry } from './DirectGeometry.js';\nimport { Object3D } from './Object3D.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { arrayMax } from '../utils.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n */\n\nlet _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id\n\nconst _m1 = new Matrix4();\nconst _obj = new Object3D();\nconst _offset = new Vector3();\nconst _box = new Box3();\nconst _boxMorphTargets = new Box3();\nconst _vector = new Vector3();\n\nfunction BufferGeometry() {\n\n\tObject.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'BufferGeometry';\n\n\tthis.index = null;\n\tthis.attributes = {};\n\n\tthis.morphAttributes = {};\n\tthis.morphTargetsRelative = false;\n\n\tthis.groups = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\tthis.drawRange = { start: 0, count: Infinity };\n\n\tthis.userData = {};\n\n}\n\nBufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: BufferGeometry,\n\n\tisBufferGeometry: true,\n\n\tgetIndex: function () {\n\n\t\treturn this.index;\n\n\t},\n\n\tsetIndex: function ( index ) {\n\n\t\tif ( Array.isArray( index ) ) {\n\n\t\t\tthis.index = new ( arrayMax( index ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );\n\n\t\t} else {\n\n\t\t\tthis.index = index;\n\n\t\t}\n\n\t},\n\n\tgetAttribute: function ( name ) {\n\n\t\treturn this.attributes[ name ];\n\n\t},\n\n\tsetAttribute: function ( name, attribute ) {\n\n\t\tthis.attributes[ name ] = attribute;\n\n\t\treturn this;\n\n\t},\n\n\tdeleteAttribute: function ( name ) {\n\n\t\tdelete this.attributes[ name ];\n\n\t\treturn this;\n\n\t},\n\n\taddGroup: function ( start, count, materialIndex ) {\n\n\t\tthis.groups.push( {\n\n\t\t\tstart: start,\n\t\t\tcount: count,\n\t\t\tmaterialIndex: materialIndex !== undefined ? materialIndex : 0\n\n\t\t} );\n\n\t},\n\n\tclearGroups: function () {\n\n\t\tthis.groups = [];\n\n\t},\n\n\tsetDrawRange: function ( start, count ) {\n\n\t\tthis.drawRange.start = start;\n\t\tthis.drawRange.count = count;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tconst position = this.attributes.position;\n\n\t\tif ( position !== undefined ) {\n\n\t\t\tposition.applyMatrix4( matrix );\n\n\t\t\tposition.needsUpdate = true;\n\n\t\t}\n\n\t\tconst normal = this.attributes.normal;\n\n\t\tif ( normal !== undefined ) {\n\n\t\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t\tnormal.applyNormalMatrix( normalMatrix );\n\n\t\t\tnormal.needsUpdate = true;\n\n\t\t}\n\n\t\tconst tangent = this.attributes.tangent;\n\n\t\tif ( tangent !== undefined ) {\n\n\t\t\ttangent.transformDirection( matrix );\n\n\t\t\ttangent.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\t// rotate geometry around world x-axis\n\n\t\t_m1.makeRotationX( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\t// rotate geometry around world y-axis\n\n\t\t_m1.makeRotationY( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\t// rotate geometry around world z-axis\n\n\t\t_m1.makeRotationZ( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( x, y, z ) {\n\n\t\t// translate geometry\n\n\t\t_m1.makeTranslation( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( x, y, z ) {\n\n\t\t// scale geometry\n\n\t\t_m1.makeScale( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tlookAt: function ( vector ) {\n\n\t\t_obj.lookAt( vector );\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4( _obj.matrix );\n\n\t\treturn this;\n\n\t},\n\n\tcenter: function () {\n\n\t\tthis.computeBoundingBox();\n\n\t\tthis.boundingBox.getCenter( _offset ).negate();\n\n\t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromObject: function ( object ) {\n\n\t\t// console.log( 'THREE.BufferGeometry.setFromObject(). Converting', object, this );\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( object.isPoints || object.isLine ) {\n\n\t\t\tconst positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );\n\t\t\tconst colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );\n\n\t\t\tthis.setAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );\n\t\t\tthis.setAttribute( 'color', colors.copyColorsArray( geometry.colors ) );\n\n\t\t\tif ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {\n\n\t\t\t\tconst lineDistances = new Float32BufferAttribute( geometry.lineDistances.length, 1 );\n\n\t\t\t\tthis.setAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t\t}\n\n\t\t} else if ( object.isMesh ) {\n\n\t\t\tif ( geometry && geometry.isGeometry ) {\n\n\t\t\t\tthis.fromGeometry( geometry );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tconst position = [];\n\n\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\tconst point = points[ i ];\n\t\t\tposition.push( point.x, point.y, point.z || 0 );\n\n\t\t}\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );\n\n\t\treturn this;\n\n\t},\n\n\tupdateFromObject: function ( object ) {\n\n\t\tlet geometry = object.geometry;\n\n\t\tif ( object.isMesh ) {\n\n\t\t\tlet direct = geometry.__directGeometry;\n\n\t\t\tif ( geometry.elementsNeedUpdate === true ) {\n\n\t\t\t\tdirect = undefined;\n\t\t\t\tgeometry.elementsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( direct === undefined ) {\n\n\t\t\t\treturn this.fromGeometry( geometry );\n\n\t\t\t}\n\n\t\t\tdirect.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\t\tdirect.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\t\tdirect.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\t\tdirect.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\t\tdirect.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\t\tgeometry.verticesNeedUpdate = false;\n\t\t\tgeometry.normalsNeedUpdate = false;\n\t\t\tgeometry.colorsNeedUpdate = false;\n\t\t\tgeometry.uvsNeedUpdate = false;\n\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t\tgeometry = direct;\n\n\t\t}\n\n\t\tif ( geometry.verticesNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.position;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector3sArray( geometry.vertices );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.verticesNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.normalsNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.normal;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector3sArray( geometry.normals );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.normalsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.colorsNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.color;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyColorsArray( geometry.colors );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.colorsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.uvsNeedUpdate ) {\n\n\t\t\tconst attribute = this.attributes.uv;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector2sArray( geometry.uvs );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.uvsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.lineDistancesNeedUpdate ) {\n\n\t\t\tconst attribute = this.attributes.lineDistance;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyArray( geometry.lineDistances );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.lineDistancesNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.groupsNeedUpdate ) {\n\n\t\t\tgeometry.computeGroups( object.geometry );\n\t\t\tthis.groups = geometry.groups;\n\n\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tfromGeometry: function ( geometry ) {\n\n\t\tgeometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );\n\n\t\treturn this.fromDirectGeometry( geometry.__directGeometry );\n\n\t},\n\n\tfromDirectGeometry: function ( geometry ) {\n\n\t\tconst positions = new Float32Array( geometry.vertices.length * 3 );\n\t\tthis.setAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );\n\n\t\tif ( geometry.normals.length > 0 ) {\n\n\t\t\tconst normals = new Float32Array( geometry.normals.length * 3 );\n\t\t\tthis.setAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );\n\n\t\t}\n\n\t\tif ( geometry.colors.length > 0 ) {\n\n\t\t\tconst colors = new Float32Array( geometry.colors.length * 3 );\n\t\t\tthis.setAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );\n\n\t\t}\n\n\t\tif ( geometry.uvs.length > 0 ) {\n\n\t\t\tconst uvs = new Float32Array( geometry.uvs.length * 2 );\n\t\t\tthis.setAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );\n\n\t\t}\n\n\t\tif ( geometry.uvs2.length > 0 ) {\n\n\t\t\tconst uvs2 = new Float32Array( geometry.uvs2.length * 2 );\n\t\t\tthis.setAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );\n\n\t\t}\n\n\t\t// groups\n\n\t\tthis.groups = geometry.groups;\n\n\t\t// morphs\n\n\t\tfor ( const name in geometry.morphTargets ) {\n\n\t\t\tconst array = [];\n\t\t\tconst morphTargets = geometry.morphTargets[ name ];\n\n\t\t\tfor ( let i = 0, l = morphTargets.length; i < l; i ++ ) {\n\n\t\t\t\tconst morphTarget = morphTargets[ i ];\n\n\t\t\t\tconst attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );\n\t\t\t\tattribute.name = morphTarget.name;\n\n\t\t\t\tarray.push( attribute.copyVector3sArray( morphTarget.data ) );\n\n\t\t\t}\n\n\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t}\n\n\t\t// skinning\n\n\t\tif ( geometry.skinIndices.length > 0 ) {\n\n\t\t\tconst skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );\n\t\t\tthis.setAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );\n\n\t\t}\n\n\t\tif ( geometry.skinWeights.length > 0 ) {\n\n\t\t\tconst skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );\n\t\t\tthis.setAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcomputeBoundingBox: function () {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif ( position !== undefined ) {\n\n\t\t\tthis.boundingBox.setFromBufferAttribute( position );\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\t_box.setFromBufferAttribute( morphAttribute );\n\n\t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n\t\t\t\t\t\t_vector.addVectors( this.boundingBox.min, _box.min );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector );\n\n\t\t\t\t\t\t_vector.addVectors( this.boundingBox.max, _box.max );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _box.min );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _box.max );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.boundingBox.makeEmpty();\n\n\t\t}\n\n\t\tif ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {\n\n\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t}\n\n\t},\n\n\tcomputeBoundingSphere: function () {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif ( position ) {\n\n\t\t\t// first, find the center of the bounding sphere\n\n\t\t\tconst center = this.boundingSphere.center;\n\n\t\t\t_box.setFromBufferAttribute( position );\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\t_boxMorphTargets.setFromBufferAttribute( morphAttribute );\n\n\t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n\t\t\t\t\t\t_vector.addVectors( _box.min, _boxMorphTargets.min );\n\t\t\t\t\t\t_box.expandByPoint( _vector );\n\n\t\t\t\t\t\t_vector.addVectors( _box.max, _boxMorphTargets.max );\n\t\t\t\t\t\t_box.expandByPoint( _vector );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t_box.expandByPoint( _boxMorphTargets.min );\n\t\t\t\t\t\t_box.expandByPoint( _boxMorphTargets.max );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t_box.getCenter( center );\n\n\t\t\t// second, try to find a boundingSphere with a radius smaller than the\n\t\t\t// boundingSphere of the boundingBox: sqrt(3) smaller in the best case\n\n\t\t\tlet maxRadiusSq = 0;\n\n\t\t\tfor ( let i = 0, il = position.count; i < il; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( position, i );\n\n\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t}\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\tconst morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t\t\t\tfor ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {\n\n\t\t\t\t\t\t_vector.fromBufferAttribute( morphAttribute, j );\n\n\t\t\t\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t\t\t\t_offset.fromBufferAttribute( position, j );\n\t\t\t\t\t\t\t_vector.add( _offset );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.boundingSphere.radius = Math.sqrt( maxRadiusSq );\n\n\t\t\tif ( isNaN( this.boundingSphere.radius ) ) {\n\n\t\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tcomputeFaceNormals: function () {\n\n\t\t// backwards compatibility\n\n\t},\n\n\tcomputeVertexNormals: function () {\n\n\t\tconst index = this.index;\n\t\tconst positionAttribute = this.getAttribute( 'position' );\n\n\t\tif ( positionAttribute !== undefined ) {\n\n\t\t\tlet normalAttribute = this.getAttribute( 'normal' );\n\n\t\t\tif ( normalAttribute === undefined ) {\n\n\t\t\t\tnormalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 );\n\t\t\t\tthis.setAttribute( 'normal', normalAttribute );\n\n\t\t\t} else {\n\n\t\t\t\t// reset existing normals to zero\n\n\t\t\t\tfor ( let i = 0, il = normalAttribute.count; i < il; i ++ ) {\n\n\t\t\t\t\tnormalAttribute.setXYZ( i, 0, 0, 0 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst pA = new Vector3(), pB = new Vector3(), pC = new Vector3();\n\t\t\tconst nA = new Vector3(), nB = new Vector3(), nC = new Vector3();\n\t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\t\t// indexed elements\n\n\t\t\tif ( index ) {\n\n\t\t\t\tfor ( let i = 0, il = index.count; i < il; i += 3 ) {\n\n\t\t\t\t\tconst vA = index.getX( i + 0 );\n\t\t\t\t\tconst vB = index.getX( i + 1 );\n\t\t\t\t\tconst vC = index.getX( i + 2 );\n\n\t\t\t\t\tpA.fromBufferAttribute( positionAttribute, vA );\n\t\t\t\t\tpB.fromBufferAttribute( positionAttribute, vB );\n\t\t\t\t\tpC.fromBufferAttribute( positionAttribute, vC );\n\n\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tnA.fromBufferAttribute( normalAttribute, vA );\n\t\t\t\t\tnB.fromBufferAttribute( normalAttribute, vB );\n\t\t\t\t\tnC.fromBufferAttribute( normalAttribute, vC );\n\n\t\t\t\t\tnA.add( cb );\n\t\t\t\t\tnB.add( cb );\n\t\t\t\t\tnC.add( cb );\n\n\t\t\t\t\tnormalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );\n\t\t\t\t\tnormalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );\n\t\t\t\t\tnormalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// non-indexed elements (unconnected triangle soup)\n\n\t\t\t\tfor ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) {\n\n\t\t\t\t\tpA.fromBufferAttribute( positionAttribute, i + 0 );\n\t\t\t\t\tpB.fromBufferAttribute( positionAttribute, i + 1 );\n\t\t\t\t\tpC.fromBufferAttribute( positionAttribute, i + 2 );\n\n\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tnormalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z );\n\t\t\t\t\tnormalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z );\n\t\t\t\t\tnormalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.normalizeNormals();\n\n\t\t\tnormalAttribute.needsUpdate = true;\n\n\t\t}\n\n\t},\n\n\tmerge: function ( geometry, offset ) {\n\n\t\tif ( ! ( geometry && geometry.isBufferGeometry ) ) {\n\n\t\t\tconsole.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( offset === undefined ) {\n\n\t\t\toffset = 0;\n\n\t\t\tconsole.warn(\n\t\t\t\t'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. '\n\t\t\t\t+ 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.'\n\t\t\t);\n\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tif ( geometry.attributes[ key ] === undefined ) continue;\n\n\t\t\tconst attribute1 = attributes[ key ];\n\t\t\tconst attributeArray1 = attribute1.array;\n\n\t\t\tconst attribute2 = geometry.attributes[ key ];\n\t\t\tconst attributeArray2 = attribute2.array;\n\n\t\t\tconst attributeOffset = attribute2.itemSize * offset;\n\t\t\tconst length = Math.min( attributeArray2.length, attributeArray1.length - attributeOffset );\n\n\t\t\tfor ( let i = 0, j = attributeOffset; i < length; i ++, j ++ ) {\n\n\t\t\t\tattributeArray1[ j ] = attributeArray2[ i ];\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tnormalizeNormals: function () {\n\n\t\tconst normals = this.attributes.normal;\n\n\t\tfor ( let i = 0, il = normals.count; i < il; i ++ ) {\n\n\t\t\t_vector.fromBufferAttribute( normals, i );\n\n\t\t\t_vector.normalize();\n\n\t\t\tnormals.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t},\n\n\ttoNonIndexed: function () {\n\n\t\tfunction convertBufferAttribute( attribute, indices ) {\n\n\t\t\tconst array = attribute.array;\n\t\t\tconst itemSize = attribute.itemSize;\n\t\t\tconst normalized = attribute.normalized;\n\n\t\t\tconst array2 = new array.constructor( indices.length * itemSize );\n\n\t\t\tlet index = 0, index2 = 0;\n\n\t\t\tfor ( let i = 0, l = indices.length; i < l; i ++ ) {\n\n\t\t\t\tindex = indices[ i ] * itemSize;\n\n\t\t\t\tfor ( let j = 0; j < itemSize; j ++ ) {\n\n\t\t\t\t\tarray2[ index2 ++ ] = array[ index ++ ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn new BufferAttribute( array2, itemSize, normalized );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( this.index === null ) {\n\n\t\t\tconsole.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst geometry2 = new BufferGeometry();\n\n\t\tconst indices = this.index.array;\n\t\tconst attributes = this.attributes;\n\n\t\t// attributes\n\n\t\tfor ( const name in attributes ) {\n\n\t\t\tconst attribute = attributes[ name ];\n\n\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n\t\t\tgeometry2.setAttribute( name, newAttribute );\n\n\t\t}\n\n\t\t// morph attributes\n\n\t\tconst morphAttributes = this.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst morphArray = [];\n\t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor ( let i = 0, il = morphAttribute.length; i < il; i ++ ) {\n\n\t\t\t\tconst attribute = morphAttribute[ i ];\n\n\t\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n\t\t\t\tmorphArray.push( newAttribute );\n\n\t\t\t}\n\n\t\t\tgeometry2.morphAttributes[ name ] = morphArray;\n\n\t\t}\n\n\t\tgeometry2.morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t// groups\n\n\t\tconst groups = this.groups;\n\n\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\tconst group = groups[ i ];\n\t\t\tgeometry2.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t}\n\n\t\treturn geometry2;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'BufferGeometry',\n\t\t\t\tgenerator: 'BufferGeometry.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard BufferGeometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif ( this.name !== '' ) data.name = this.name;\n\t\tif ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;\n\n\t\tif ( this.parameters !== undefined ) {\n\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor ( const key in parameters ) {\n\n\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t\tdata.data = { attributes: {} };\n\n\t\tconst index = this.index;\n\n\t\tif ( index !== null ) {\n\n\t\t\tdata.data.index = {\n\t\t\t\ttype: index.array.constructor.name,\n\t\t\t\tarray: Array.prototype.slice.call( index.array )\n\t\t\t};\n\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tconst attribute = attributes[ key ];\n\n\t\t\tconst attributeData = attribute.toJSON( data.data );\n\n\t\t\tif ( attribute.name !== '' ) attributeData.name = attribute.name;\n\n\t\t\tdata.data.attributes[ key ] = attributeData;\n\n\t\t}\n\n\t\tconst morphAttributes = {};\n\t\tlet hasMorphAttributes = false;\n\n\t\tfor ( const key in this.morphAttributes ) {\n\n\t\t\tconst attributeArray = this.morphAttributes[ key ];\n\n\t\t\tconst array = [];\n\n\t\t\tfor ( let i = 0, il = attributeArray.length; i < il; i ++ ) {\n\n\t\t\t\tconst attribute = attributeArray[ i ];\n\n\t\t\t\tconst attributeData = attribute.toJSON( data.data );\n\n\t\t\t\tif ( attribute.name !== '' ) attributeData.name = attribute.name;\n\n\t\t\t\tarray.push( attributeData );\n\n\t\t\t}\n\n\t\t\tif ( array.length > 0 ) {\n\n\t\t\t\tmorphAttributes[ key ] = array;\n\n\t\t\t\thasMorphAttributes = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( hasMorphAttributes ) {\n\n\t\t\tdata.data.morphAttributes = morphAttributes;\n\t\t\tdata.data.morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t}\n\n\t\tconst groups = this.groups;\n\n\t\tif ( groups.length > 0 ) {\n\n\t\t\tdata.data.groups = JSON.parse( JSON.stringify( groups ) );\n\n\t\t}\n\n\t\tconst boundingSphere = this.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tdata.data.boundingSphere = {\n\t\t\t\tcenter: boundingSphere.center.toArray(),\n\t\t\t\tradius: boundingSphere.radius\n\t\t\t};\n\n\t\t}\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\t/*\n\t\t // Handle primitives\n\n\t\t const parameters = this.parameters;\n\n\t\t if ( parameters !== undefined ) {\n\n\t\t const values = [];\n\n\t\t for ( const key in parameters ) {\n\n\t\t values.push( parameters[ key ] );\n\n\t\t }\n\n\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t this.constructor.apply( geometry, values );\n\t\t return geometry;\n\n\t\t }\n\n\t\t return new this.constructor().copy( this );\n\t\t */\n\n\t\treturn new BufferGeometry().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\t// reset\n\n\t\tthis.index = null;\n\t\tthis.attributes = {};\n\t\tthis.morphAttributes = {};\n\t\tthis.groups = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// used for storing cloned, shared data\n\n\t\tconst data = {};\n\n\t\t// name\n\n\t\tthis.name = source.name;\n\n\t\t// index\n\n\t\tconst index = source.index;\n\n\t\tif ( index !== null ) {\n\n\t\t\tthis.setIndex( index.clone( data ) );\n\n\t\t}\n\n\t\t// attributes\n\n\t\tconst attributes = source.attributes;\n\n\t\tfor ( const name in attributes ) {\n\n\t\t\tconst attribute = attributes[ name ];\n\t\t\tthis.setAttribute( name, attribute.clone( data ) );\n\n\t\t}\n\n\t\t// morph attributes\n\n\t\tconst morphAttributes = source.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst array = [];\n\t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor ( let i = 0, l = morphAttribute.length; i < l; i ++ ) {\n\n\t\t\t\tarray.push( morphAttribute[ i ].clone( data ) );\n\n\t\t\t}\n\n\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t}\n\n\t\tthis.morphTargetsRelative = source.morphTargetsRelative;\n\n\t\t// groups\n\n\t\tconst groups = source.groups;\n\n\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\tconst group = groups[ i ];\n\t\t\tthis.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t}\n\n\t\t// bounding box\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif ( boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t}\n\n\t\t// bounding sphere\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t}\n\n\t\t// draw range\n\n\t\tthis.drawRange.start = source.drawRange.start;\n\t\tthis.drawRange.count = source.drawRange.count;\n\n\t\t// user data\n\n\t\tthis.userData = source.userData;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { BufferGeometry };\n","import { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Triangle } from '../math/Triangle.js';\nimport { Face3 } from '../core/Face3.js';\nimport { DoubleSide, BackSide } from '../constants.js';\nimport { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author jonobr1 / http://jonobr1.com/\n */\n\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\n\nconst _vA = new Vector3();\nconst _vB = new Vector3();\nconst _vC = new Vector3();\n\nconst _tempA = new Vector3();\nconst _tempB = new Vector3();\nconst _tempC = new Vector3();\n\nconst _morphA = new Vector3();\nconst _morphB = new Vector3();\nconst _morphC = new Vector3();\n\nconst _uvA = new Vector2();\nconst _uvB = new Vector2();\nconst _uvC = new Vector2();\n\nconst _intersectionPoint = new Vector3();\nconst _intersectionPointWorld = new Vector3();\n\nfunction Mesh( geometry, material ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Mesh';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new MeshBasicMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nMesh.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Mesh,\n\n\tisMesh: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tif ( source.morphTargetInfluences !== undefined ) {\n\n\t\t\tthis.morphTargetInfluences = source.morphTargetInfluences.slice();\n\n\t\t}\n\n\t\tif ( source.morphTargetDictionary !== undefined ) {\n\n\t\t\tthis.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );\n\n\t\t}\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst material = this.material;\n\t\tconst matrixWorld = this.matrixWorld;\n\n\t\tif ( material === undefined ) return;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\t// Check boundingBox before continuing\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tif ( _ray.intersectsBox( geometry.boundingBox ) === false ) return;\n\n\t\t}\n\n\t\tlet intersection;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst position = geometry.attributes.position;\n\t\t\tconst morphPosition = geometry.morphAttributes.position;\n\t\t\tconst morphTargetsRelative = geometry.morphTargetsRelative;\n\t\t\tconst uv = geometry.attributes.uv;\n\t\t\tconst uv2 = geometry.attributes.uv2;\n\t\t\tconst groups = geometry.groups;\n\t\t\tconst drawRange = geometry.drawRange;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\t// indexed buffer geometry\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\tconst end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\tconst a = index.getX( j );\n\t\t\t\t\t\t\tconst b = index.getX( j + 1 );\n\t\t\t\t\t\t\tconst c = index.getX( j + 2 );\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst start = Math.max( 0, drawRange.start );\n\t\t\t\t\tconst end = Math.min( index.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\tconst a = index.getX( i );\n\t\t\t\t\t\tconst b = index.getX( i + 1 );\n\t\t\t\t\t\tconst c = index.getX( i + 2 );\n\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( position !== undefined ) {\n\n\t\t\t\t// non-indexed buffer geometry\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\tconst end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\tconst a = j;\n\t\t\t\t\t\t\tconst b = j + 1;\n\t\t\t\t\t\t\tconst c = j + 2;\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst start = Math.max( 0, drawRange.start );\n\t\t\t\t\tconst end = Math.min( position.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\tconst a = i;\n\t\t\t\t\t\tconst b = i + 1;\n\t\t\t\t\t\tconst c = i + 2;\n\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst isMultiMaterial = Array.isArray( material );\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst faces = geometry.faces;\n\t\t\tlet uvs;\n\n\t\t\tconst faceVertexUvs = geometry.faceVertexUvs[ 0 ];\n\t\t\tif ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;\n\n\t\t\tfor ( let f = 0, fl = faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = faces[ f ];\n\t\t\t\tconst faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;\n\n\t\t\t\tif ( faceMaterial === undefined ) continue;\n\n\t\t\t\tconst fvA = vertices[ face.a ];\n\t\t\t\tconst fvB = vertices[ face.b ];\n\t\t\t\tconst fvC = vertices[ face.c ];\n\n\t\t\t\tintersection = checkIntersection( this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint );\n\n\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\tif ( uvs && uvs[ f ] ) {\n\n\t\t\t\t\t\tconst uvs_f = uvs[ f ];\n\t\t\t\t\t\t_uvA.copy( uvs_f[ 0 ] );\n\t\t\t\t\t\t_uvB.copy( uvs_f[ 1 ] );\n\t\t\t\t\t\t_uvC.copy( uvs_f[ 2 ] );\n\n\t\t\t\t\t\tintersection.uv = Triangle.getUV( _intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tintersection.face = face;\n\t\t\t\t\tintersection.faceIndex = f;\n\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\nfunction checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {\n\n\tlet intersect;\n\n\tif ( material.side === BackSide ) {\n\n\t\tintersect = ray.intersectTriangle( pC, pB, pA, true, point );\n\n\t} else {\n\n\t\tintersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );\n\n\t}\n\n\tif ( intersect === null ) return null;\n\n\t_intersectionPointWorld.copy( point );\n\t_intersectionPointWorld.applyMatrix4( object.matrixWorld );\n\n\tconst distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );\n\n\tif ( distance < raycaster.near || distance > raycaster.far ) return null;\n\n\treturn {\n\t\tdistance: distance,\n\t\tpoint: _intersectionPointWorld.clone(),\n\t\tobject: object\n\t};\n\n}\n\nfunction checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) {\n\n\t_vA.fromBufferAttribute( position, a );\n\t_vB.fromBufferAttribute( position, b );\n\t_vC.fromBufferAttribute( position, c );\n\n\tconst morphInfluences = object.morphTargetInfluences;\n\n\tif ( material.morphTargets && morphPosition && morphInfluences ) {\n\n\t\t_morphA.set( 0, 0, 0 );\n\t\t_morphB.set( 0, 0, 0 );\n\t\t_morphC.set( 0, 0, 0 );\n\n\t\tfor ( let i = 0, il = morphPosition.length; i < il; i ++ ) {\n\n\t\t\tconst influence = morphInfluences[ i ];\n\t\t\tconst morphAttribute = morphPosition[ i ];\n\n\t\t\tif ( influence === 0 ) continue;\n\n\t\t\t_tempA.fromBufferAttribute( morphAttribute, a );\n\t\t\t_tempB.fromBufferAttribute( morphAttribute, b );\n\t\t\t_tempC.fromBufferAttribute( morphAttribute, c );\n\n\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t_morphA.addScaledVector( _tempA, influence );\n\t\t\t\t_morphB.addScaledVector( _tempB, influence );\n\t\t\t\t_morphC.addScaledVector( _tempC, influence );\n\n\t\t\t} else {\n\n\t\t\t\t_morphA.addScaledVector( _tempA.sub( _vA ), influence );\n\t\t\t\t_morphB.addScaledVector( _tempB.sub( _vB ), influence );\n\t\t\t\t_morphC.addScaledVector( _tempC.sub( _vC ), influence );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_vA.add( _morphA );\n\t\t_vB.add( _morphB );\n\t\t_vC.add( _morphC );\n\n\t}\n\n\tif ( object.isSkinnedMesh ) {\n\n\t\tobject.boneTransform( a, _vA );\n\t\tobject.boneTransform( b, _vB );\n\t\tobject.boneTransform( c, _vC );\n\n\t}\n\n\tconst intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );\n\n\tif ( intersection ) {\n\n\t\tif ( uv ) {\n\n\t\t\t_uvA.fromBufferAttribute( uv, a );\n\t\t\t_uvB.fromBufferAttribute( uv, b );\n\t\t\t_uvC.fromBufferAttribute( uv, c );\n\n\t\t\tintersection.uv = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t}\n\n\t\tif ( uv2 ) {\n\n\t\t\t_uvA.fromBufferAttribute( uv2, a );\n\t\t\t_uvB.fromBufferAttribute( uv2, b );\n\t\t\t_uvC.fromBufferAttribute( uv2, c );\n\n\t\t\tintersection.uv2 = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t}\n\n\t\tconst face = new Face3( a, b, c );\n\t\tTriangle.getNormal( _vA, _vB, _vC, face.normal );\n\n\t\tintersection.face = face;\n\n\t}\n\n\treturn intersection;\n\n}\n\nexport { Mesh };\n","import { EventDispatcher } from './EventDispatcher.js';\nimport { Face3 } from './Face3.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { Box3 } from '../math/Box3.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Color } from '../math/Color.js';\nimport { Object3D } from './Object3D.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author kile / http://kile.stravaganza.org/\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n * @author bhouston / http://clara.io\n */\n\nlet _geometryId = 0; // Geometry uses even numbers as Id\nconst _m1 = new Matrix4();\nconst _obj = new Object3D();\nconst _offset = new Vector3();\n\nfunction Geometry() {\n\n\tObject.defineProperty( this, 'id', { value: _geometryId += 2 } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Geometry';\n\n\tthis.vertices = [];\n\tthis.colors = [];\n\tthis.faces = [];\n\tthis.faceVertexUvs = [[]];\n\n\tthis.morphTargets = [];\n\tthis.morphNormals = [];\n\n\tthis.skinWeights = [];\n\tthis.skinIndices = [];\n\n\tthis.lineDistances = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\t// update flags\n\n\tthis.elementsNeedUpdate = false;\n\tthis.verticesNeedUpdate = false;\n\tthis.uvsNeedUpdate = false;\n\tthis.normalsNeedUpdate = false;\n\tthis.colorsNeedUpdate = false;\n\tthis.lineDistancesNeedUpdate = false;\n\tthis.groupsNeedUpdate = false;\n\n}\n\nGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Geometry,\n\n\tisGeometry: true,\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\tfor ( let i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\tconst vertex = this.vertices[ i ];\n\t\t\tvertex.applyMatrix4( matrix );\n\n\t\t}\n\n\t\tfor ( let i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\t\t\tface.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\tfor ( let j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\tface.vertexNormals[ j ].applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\tthis.verticesNeedUpdate = true;\n\t\tthis.normalsNeedUpdate = true;\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\t// rotate geometry around world x-axis\n\n\t\t_m1.makeRotationX( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\t// rotate geometry around world y-axis\n\n\t\t_m1.makeRotationY( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\t// rotate geometry around world z-axis\n\n\t\t_m1.makeRotationZ( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( x, y, z ) {\n\n\t\t// translate geometry\n\n\t\t_m1.makeTranslation( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( x, y, z ) {\n\n\t\t// scale geometry\n\n\t\t_m1.makeScale( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tlookAt: function ( vector ) {\n\n\t\t_obj.lookAt( vector );\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4( _obj.matrix );\n\n\t\treturn this;\n\n\t},\n\n\tfromBufferGeometry: function ( geometry ) {\n\n\t\tconst scope = this;\n\n\t\tconst index = geometry.index !== null ? geometry.index : undefined;\n\t\tconst attributes = geometry.attributes;\n\n\t\tif ( attributes.position === undefined ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.' );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst position = attributes.position;\n\t\tconst normal = attributes.normal;\n\t\tconst color = attributes.color;\n\t\tconst uv = attributes.uv;\n\t\tconst uv2 = attributes.uv2;\n\n\t\tif ( uv2 !== undefined ) this.faceVertexUvs[ 1 ] = [];\n\n\t\tfor ( let i = 0; i < position.count; i ++ ) {\n\n\t\t\tscope.vertices.push( new Vector3().fromBufferAttribute( position, i ) );\n\n\t\t\tif ( color !== undefined ) {\n\n\t\t\t\tscope.colors.push( new Color().fromBufferAttribute( color, i ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction addFace( a, b, c, materialIndex ) {\n\n\t\t\tconst vertexColors = ( color === undefined ) ? [] : [\n\t\t\t\tscope.colors[ a ].clone(),\n\t\t\t\tscope.colors[ b ].clone(),\n\t\t\t\tscope.colors[ c ].clone()\n\t\t\t];\n\n\t\t\tconst vertexNormals = ( normal === undefined ) ? [] : [\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, a ),\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, b ),\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, c )\n\t\t\t];\n\n\t\t\tconst face = new Face3( a, b, c, vertexNormals, vertexColors, materialIndex );\n\n\t\t\tscope.faces.push( face );\n\n\t\t\tif ( uv !== undefined ) {\n\n\t\t\t\tscope.faceVertexUvs[ 0 ].push( [\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, a ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, b ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, c )\n\t\t\t\t] );\n\n\t\t\t}\n\n\t\t\tif ( uv2 !== undefined ) {\n\n\t\t\t\tscope.faceVertexUvs[ 1 ].push( [\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, a ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, b ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, c )\n\t\t\t\t] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst groups = geometry.groups;\n\n\t\tif ( groups.length > 0 ) {\n\n\t\t\tfor ( let i = 0; i < groups.length; i ++ ) {\n\n\t\t\t\tconst group = groups[ i ];\n\n\t\t\t\tconst start = group.start;\n\t\t\t\tconst count = group.count;\n\n\t\t\t\tfor ( let j = start, jl = start + count; j < jl; j += 3 ) {\n\n\t\t\t\t\tif ( index !== undefined ) {\n\n\t\t\t\t\t\taddFace( index.getX( j ), index.getX( j + 1 ), index.getX( j + 2 ), group.materialIndex );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\taddFace( j, j + 1, j + 2, group.materialIndex );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( index !== undefined ) {\n\n\t\t\t\tfor ( let i = 0; i < index.count; i += 3 ) {\n\n\t\t\t\t\taddFace( index.getX( i ), index.getX( i + 1 ), index.getX( i + 2 ) );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0; i < position.count; i += 3 ) {\n\n\t\t\t\t\taddFace( i, i + 1, i + 2 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.computeFaceNormals();\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcenter: function () {\n\n\t\tthis.computeBoundingBox();\n\n\t\tthis.boundingBox.getCenter( _offset ).negate();\n\n\t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n\t\treturn this;\n\n\t},\n\n\tnormalize: function () {\n\n\t\tthis.computeBoundingSphere();\n\n\t\tconst center = this.boundingSphere.center;\n\t\tconst radius = this.boundingSphere.radius;\n\n\t\tconst s = radius === 0 ? 1 : 1.0 / radius;\n\n\t\tconst matrix = new Matrix4();\n\t\tmatrix.set(\n\t\t\ts, 0, 0, - s * center.x,\n\t\t\t0, s, 0, - s * center.y,\n\t\t\t0, 0, s, - s * center.z,\n\t\t\t0, 0, 0, 1\n\t\t);\n\n\t\tthis.applyMatrix4( matrix );\n\n\t\treturn this;\n\n\t},\n\n\tcomputeFaceNormals: function () {\n\n\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vA = this.vertices[ face.a ];\n\t\t\tconst vB = this.vertices[ face.b ];\n\t\t\tconst vC = this.vertices[ face.c ];\n\n\t\t\tcb.subVectors( vC, vB );\n\t\t\tab.subVectors( vA, vB );\n\t\t\tcb.cross( ab );\n\n\t\t\tcb.normalize();\n\n\t\t\tface.normal.copy( cb );\n\n\t\t}\n\n\t},\n\n\tcomputeVertexNormals: function ( areaWeighted ) {\n\n\t\tif ( areaWeighted === undefined ) areaWeighted = true;\n\n\t\tconst vertices = new Array( this.vertices.length );\n\n\t\tfor ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\tvertices[ v ] = new Vector3();\n\n\t\t}\n\n\t\tif ( areaWeighted ) {\n\n\t\t\t// vertex normals weighted by triangle areas\n\t\t\t// http://www.iquilezles.org/www/articles/normals/normals.htm\n\n\t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tconst vA = this.vertices[ face.a ];\n\t\t\t\tconst vB = this.vertices[ face.b ];\n\t\t\t\tconst vC = this.vertices[ face.c ];\n\n\t\t\t\tcb.subVectors( vC, vB );\n\t\t\t\tab.subVectors( vA, vB );\n\t\t\t\tcb.cross( ab );\n\n\t\t\t\tvertices[ face.a ].add( cb );\n\t\t\t\tvertices[ face.b ].add( cb );\n\t\t\t\tvertices[ face.c ].add( cb );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.computeFaceNormals();\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tvertices[ face.a ].add( face.normal );\n\t\t\t\tvertices[ face.b ].add( face.normal );\n\t\t\t\tvertices[ face.c ].add( face.normal );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\tvertices[ v ].normalize();\n\n\t\t}\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tvertexNormals[ 0 ].copy( vertices[ face.a ] );\n\t\t\t\tvertexNormals[ 1 ].copy( vertices[ face.b ] );\n\t\t\t\tvertexNormals[ 2 ].copy( vertices[ face.c ] );\n\n\t\t\t} else {\n\n\t\t\t\tvertexNormals[ 0 ] = vertices[ face.a ].clone();\n\t\t\t\tvertexNormals[ 1 ] = vertices[ face.b ].clone();\n\t\t\t\tvertexNormals[ 2 ] = vertices[ face.c ].clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.faces.length > 0 ) {\n\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t}\n\n\t},\n\n\tcomputeFlatVertexNormals: function () {\n\n\t\tthis.computeFaceNormals();\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tvertexNormals[ 0 ].copy( face.normal );\n\t\t\t\tvertexNormals[ 1 ].copy( face.normal );\n\t\t\t\tvertexNormals[ 2 ].copy( face.normal );\n\n\t\t\t} else {\n\n\t\t\t\tvertexNormals[ 0 ] = face.normal.clone();\n\t\t\t\tvertexNormals[ 1 ] = face.normal.clone();\n\t\t\t\tvertexNormals[ 2 ] = face.normal.clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.faces.length > 0 ) {\n\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t}\n\n\t},\n\n\tcomputeMorphNormals: function () {\n\n\t\t// save original normals\n\t\t// - create temp variables on first access\n\t\t// otherwise just copy (for faster repeated calls)\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tif ( ! face.__originalFaceNormal ) {\n\n\t\t\t\tface.__originalFaceNormal = face.normal.clone();\n\n\t\t\t} else {\n\n\t\t\t\tface.__originalFaceNormal.copy( face.normal );\n\n\t\t\t}\n\n\t\t\tif ( ! face.__originalVertexNormals ) face.__originalVertexNormals = [];\n\n\t\t\tfor ( let i = 0, il = face.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\t\tif ( ! face.__originalVertexNormals[ i ] ) {\n\n\t\t\t\t\tface.__originalVertexNormals[ i ] = face.vertexNormals[ i ].clone();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tface.__originalVertexNormals[ i ].copy( face.vertexNormals[ i ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// use temp geometry to compute face and vertex normals for each morph\n\n\t\tconst tmpGeo = new Geometry();\n\t\ttmpGeo.faces = this.faces;\n\n\t\tfor ( let i = 0, il = this.morphTargets.length; i < il; i ++ ) {\n\n\t\t\t// create on first access\n\n\t\t\tif ( ! this.morphNormals[ i ] ) {\n\n\t\t\t\tthis.morphNormals[ i ] = {};\n\t\t\t\tthis.morphNormals[ i ].faceNormals = [];\n\t\t\t\tthis.morphNormals[ i ].vertexNormals = [];\n\n\t\t\t\tconst dstNormalsFace = this.morphNormals[ i ].faceNormals;\n\t\t\t\tconst dstNormalsVertex = this.morphNormals[ i ].vertexNormals;\n\n\t\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\tconst faceNormal = new Vector3();\n\t\t\t\t\tconst vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };\n\n\t\t\t\t\tdstNormalsFace.push( faceNormal );\n\t\t\t\t\tdstNormalsVertex.push( vertexNormals );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst morphNormals = this.morphNormals[ i ];\n\n\t\t\t// set vertices to morph target\n\n\t\t\ttmpGeo.vertices = this.morphTargets[ i ].vertices;\n\n\t\t\t// compute morph normals\n\n\t\t\ttmpGeo.computeFaceNormals();\n\t\t\ttmpGeo.computeVertexNormals();\n\n\t\t\t// store morph normals\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tconst faceNormal = morphNormals.faceNormals[ f ];\n\t\t\t\tconst vertexNormals = morphNormals.vertexNormals[ f ];\n\n\t\t\t\tfaceNormal.copy( face.normal );\n\n\t\t\t\tvertexNormals.a.copy( face.vertexNormals[ 0 ] );\n\t\t\t\tvertexNormals.b.copy( face.vertexNormals[ 1 ] );\n\t\t\t\tvertexNormals.c.copy( face.vertexNormals[ 2 ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// restore original normals\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tface.normal = face.__originalFaceNormal;\n\t\t\tface.vertexNormals = face.__originalVertexNormals;\n\n\t\t}\n\n\t},\n\n\tcomputeBoundingBox: function () {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tthis.boundingBox.setFromPoints( this.vertices );\n\n\t},\n\n\tcomputeBoundingSphere: function () {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tthis.boundingSphere.setFromPoints( this.vertices );\n\n\t},\n\n\tmerge: function ( geometry, matrix, materialIndexOffset ) {\n\n\t\tif ( ! ( geometry && geometry.isGeometry ) ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet normalMatrix,\n\t\t\tvertexOffset = this.vertices.length,\n\t\t\tvertices1 = this.vertices,\n\t\t\tvertices2 = geometry.vertices,\n\t\t\tfaces1 = this.faces,\n\t\t\tfaces2 = geometry.faces,\n\t\t\tcolors1 = this.colors,\n\t\t\tcolors2 = geometry.colors;\n\n\t\tif ( materialIndexOffset === undefined ) materialIndexOffset = 0;\n\n\t\tif ( matrix !== undefined ) {\n\n\t\t\tnormalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t}\n\n\t\t// vertices\n\n\t\tfor ( let i = 0, il = vertices2.length; i < il; i ++ ) {\n\n\t\t\tconst vertex = vertices2[ i ];\n\n\t\t\tconst vertexCopy = vertex.clone();\n\n\t\t\tif ( matrix !== undefined ) vertexCopy.applyMatrix4( matrix );\n\n\t\t\tvertices1.push( vertexCopy );\n\n\t\t}\n\n\t\t// colors\n\n\t\tfor ( let i = 0, il = colors2.length; i < il; i ++ ) {\n\n\t\t\tcolors1.push( colors2[ i ].clone() );\n\n\t\t}\n\n\t\t// faces\n\n\t\tfor ( let i = 0, il = faces2.length; i < il; i ++ ) {\n\n\t\t\tlet face = faces2[ i ], faceCopy, normal, color,\n\t\t\t\tfaceVertexNormals = face.vertexNormals,\n\t\t\t\tfaceVertexColors = face.vertexColors;\n\n\t\t\tfaceCopy = new Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );\n\t\t\tfaceCopy.normal.copy( face.normal );\n\n\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\tfaceCopy.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0, jl = faceVertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\tnormal = faceVertexNormals[ j ].clone();\n\n\t\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\t\tnormal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t}\n\n\t\t\t\tfaceCopy.vertexNormals.push( normal );\n\n\t\t\t}\n\n\t\t\tfaceCopy.color.copy( face.color );\n\n\t\t\tfor ( let j = 0, jl = faceVertexColors.length; j < jl; j ++ ) {\n\n\t\t\t\tcolor = faceVertexColors[ j ];\n\t\t\t\tfaceCopy.vertexColors.push( color.clone() );\n\n\t\t\t}\n\n\t\t\tfaceCopy.materialIndex = face.materialIndex + materialIndexOffset;\n\n\t\t\tfaces1.push( faceCopy );\n\n\t\t}\n\n\t\t// uvs\n\n\t\tfor ( let i = 0, il = geometry.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\tconst faceVertexUvs2 = geometry.faceVertexUvs[ i ];\n\n\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) this.faceVertexUvs[ i ] = [];\n\n\t\t\tfor ( let j = 0, jl = faceVertexUvs2.length; j < jl; j ++ ) {\n\n\t\t\t\tconst uvs2 = faceVertexUvs2[ j ], uvsCopy = [];\n\n\t\t\t\tfor ( let k = 0, kl = uvs2.length; k < kl; k ++ ) {\n\n\t\t\t\t\tuvsCopy.push( uvs2[ k ].clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tmergeMesh: function ( mesh ) {\n\n\t\tif ( ! ( mesh && mesh.isMesh ) ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( mesh.matrixAutoUpdate ) mesh.updateMatrix();\n\n\t\tthis.merge( mesh.geometry, mesh.matrix );\n\n\t},\n\n\t/*\n\t * Checks for duplicate vertices with hashmap.\n\t * Duplicated vertices are removed\n\t * and faces' vertices are updated.\n\t */\n\n\tmergeVertices: function () {\n\n\t\tconst verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)\n\t\tconst unique = [], changes = [];\n\n\t\tconst precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001\n\t\tconst precision = Math.pow( 10, precisionPoints );\n\n\t\tfor ( let i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\tconst v = this.vertices[ i ];\n\t\t\tconst key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision );\n\n\t\t\tif ( verticesMap[ key ] === undefined ) {\n\n\t\t\t\tverticesMap[ key ] = i;\n\t\t\t\tunique.push( this.vertices[ i ] );\n\t\t\t\tchanges[ i ] = unique.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\t//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);\n\t\t\t\tchanges[ i ] = changes[ verticesMap[ key ] ];\n\n\t\t\t}\n\n\t\t}\n\n\n\t\t// if faces are completely degenerate after merging vertices, we\n\t\t// have to remove them from the geometry.\n\t\tconst faceIndicesToRemove = [];\n\n\t\tfor ( let i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\n\t\t\tface.a = changes[ face.a ];\n\t\t\tface.b = changes[ face.b ];\n\t\t\tface.c = changes[ face.c ];\n\n\t\t\tconst indices = [ face.a, face.b, face.c ];\n\n\t\t\t// if any duplicate vertices are found in a Face3\n\t\t\t// we have to remove the face as nothing can be saved\n\t\t\tfor ( let n = 0; n < 3; n ++ ) {\n\n\t\t\t\tif ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) {\n\n\t\t\t\t\tfaceIndicesToRemove.push( i );\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let i = faceIndicesToRemove.length - 1; i >= 0; i -- ) {\n\n\t\t\tconst idx = faceIndicesToRemove[ i ];\n\n\t\t\tthis.faces.splice( idx, 1 );\n\n\t\t\tfor ( let j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\tthis.faceVertexUvs[ j ].splice( idx, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Use unique set of vertices\n\n\t\tconst diff = this.vertices.length - unique.length;\n\t\tthis.vertices = unique;\n\t\treturn diff;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tthis.vertices = [];\n\n\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\tconst point = points[ i ];\n\t\t\tthis.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsortFacesByMaterialIndex: function () {\n\n\t\tconst faces = this.faces;\n\t\tconst length = faces.length;\n\n\t\t// tag faces\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tfaces[ i ]._id = i;\n\n\t\t}\n\n\t\t// sort faces\n\n\t\tfunction materialIndexSort( a, b ) {\n\n\t\t\treturn a.materialIndex - b.materialIndex;\n\n\t\t}\n\n\t\tfaces.sort( materialIndexSort );\n\n\t\t// sort uvs\n\n\t\tconst uvs1 = this.faceVertexUvs[ 0 ];\n\t\tconst uvs2 = this.faceVertexUvs[ 1 ];\n\n\t\tlet newUvs1, newUvs2;\n\n\t\tif ( uvs1 && uvs1.length === length ) newUvs1 = [];\n\t\tif ( uvs2 && uvs2.length === length ) newUvs2 = [];\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tconst id = faces[ i ]._id;\n\n\t\t\tif ( newUvs1 ) newUvs1.push( uvs1[ id ] );\n\t\t\tif ( newUvs2 ) newUvs2.push( uvs2[ id ] );\n\n\t\t}\n\n\t\tif ( newUvs1 ) this.faceVertexUvs[ 0 ] = newUvs1;\n\t\tif ( newUvs2 ) this.faceVertexUvs[ 1 ] = newUvs2;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Geometry',\n\t\t\t\tgenerator: 'Geometry.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard Geometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\tif ( this.parameters !== undefined ) {\n\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor ( const key in parameters ) {\n\n\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t\tconst vertices = [];\n\n\t\tfor ( let i = 0; i < this.vertices.length; i ++ ) {\n\n\t\t\tconst vertex = this.vertices[ i ];\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t}\n\n\t\tconst faces = [];\n\t\tconst normals = [];\n\t\tconst normalsHash = {};\n\t\tconst colors = [];\n\t\tconst colorsHash = {};\n\t\tconst uvs = [];\n\t\tconst uvsHash = {};\n\n\t\tfor ( let i = 0; i < this.faces.length; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\n\t\t\tconst hasMaterial = true;\n\t\t\tconst hasFaceUv = false; // deprecated\n\t\t\tconst hasFaceVertexUv = this.faceVertexUvs[ 0 ][ i ] !== undefined;\n\t\t\tconst hasFaceNormal = face.normal.length() > 0;\n\t\t\tconst hasFaceVertexNormal = face.vertexNormals.length > 0;\n\t\t\tconst hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;\n\t\t\tconst hasFaceVertexColor = face.vertexColors.length > 0;\n\n\t\t\tlet faceType = 0;\n\n\t\t\tfaceType = setBit( faceType, 0, 0 ); // isQuad\n\t\t\tfaceType = setBit( faceType, 1, hasMaterial );\n\t\t\tfaceType = setBit( faceType, 2, hasFaceUv );\n\t\t\tfaceType = setBit( faceType, 3, hasFaceVertexUv );\n\t\t\tfaceType = setBit( faceType, 4, hasFaceNormal );\n\t\t\tfaceType = setBit( faceType, 5, hasFaceVertexNormal );\n\t\t\tfaceType = setBit( faceType, 6, hasFaceColor );\n\t\t\tfaceType = setBit( faceType, 7, hasFaceVertexColor );\n\n\t\t\tfaces.push( faceType );\n\t\t\tfaces.push( face.a, face.b, face.c );\n\t\t\tfaces.push( face.materialIndex );\n\n\t\t\tif ( hasFaceVertexUv ) {\n\n\t\t\t\tconst faceVertexUvs = this.faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 0 ] ),\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 1 ] ),\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tif ( hasFaceNormal ) {\n\n\t\t\t\tfaces.push( getNormalIndex( face.normal ) );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexNormal ) {\n\n\t\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 0 ] ),\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 1 ] ),\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tif ( hasFaceColor ) {\n\n\t\t\t\tfaces.push( getColorIndex( face.color ) );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexColor ) {\n\n\t\t\t\tconst vertexColors = face.vertexColors;\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetColorIndex( vertexColors[ 0 ] ),\n\t\t\t\t\tgetColorIndex( vertexColors[ 1 ] ),\n\t\t\t\t\tgetColorIndex( vertexColors[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setBit( value, position, enabled ) {\n\n\t\t\treturn enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position ) );\n\n\t\t}\n\n\t\tfunction getNormalIndex( normal ) {\n\n\t\t\tconst hash = normal.x.toString() + normal.y.toString() + normal.z.toString();\n\n\t\t\tif ( normalsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn normalsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tnormalsHash[ hash ] = normals.length / 3;\n\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\treturn normalsHash[ hash ];\n\n\t\t}\n\n\t\tfunction getColorIndex( color ) {\n\n\t\t\tconst hash = color.r.toString() + color.g.toString() + color.b.toString();\n\n\t\t\tif ( colorsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn colorsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tcolorsHash[ hash ] = colors.length;\n\t\t\tcolors.push( color.getHex() );\n\n\t\t\treturn colorsHash[ hash ];\n\n\t\t}\n\n\t\tfunction getUvIndex( uv ) {\n\n\t\t\tconst hash = uv.x.toString() + uv.y.toString();\n\n\t\t\tif ( uvsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn uvsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tuvsHash[ hash ] = uvs.length / 2;\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\treturn uvsHash[ hash ];\n\n\t\t}\n\n\t\tdata.data = {};\n\n\t\tdata.data.vertices = vertices;\n\t\tdata.data.normals = normals;\n\t\tif ( colors.length > 0 ) data.data.colors = colors;\n\t\tif ( uvs.length > 0 ) data.data.uvs = [ uvs ]; // temporal backward compatibility\n\t\tdata.data.faces = faces;\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\t/*\n\t\t // Handle primitives\n\n\t\t const parameters = this.parameters;\n\n\t\t if ( parameters !== undefined ) {\n\n\t\t const values = [];\n\n\t\t for ( const key in parameters ) {\n\n\t\t values.push( parameters[ key ] );\n\n\t\t }\n\n\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t this.constructor.apply( geometry, values );\n\t\t return geometry;\n\n\t\t }\n\n\t\t return new this.constructor().copy( this );\n\t\t */\n\n\t\treturn new Geometry().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\t// reset\n\n\t\tthis.vertices = [];\n\t\tthis.colors = [];\n\t\tthis.faces = [];\n\t\tthis.faceVertexUvs = [[]];\n\t\tthis.morphTargets = [];\n\t\tthis.morphNormals = [];\n\t\tthis.skinWeights = [];\n\t\tthis.skinIndices = [];\n\t\tthis.lineDistances = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// name\n\n\t\tthis.name = source.name;\n\n\t\t// vertices\n\n\t\tconst vertices = source.vertices;\n\n\t\tfor ( let i = 0, il = vertices.length; i < il; i ++ ) {\n\n\t\t\tthis.vertices.push( vertices[ i ].clone() );\n\n\t\t}\n\n\t\t// colors\n\n\t\tconst colors = source.colors;\n\n\t\tfor ( let i = 0, il = colors.length; i < il; i ++ ) {\n\n\t\t\tthis.colors.push( colors[ i ].clone() );\n\n\t\t}\n\n\t\t// faces\n\n\t\tconst faces = source.faces;\n\n\t\tfor ( let i = 0, il = faces.length; i < il; i ++ ) {\n\n\t\t\tthis.faces.push( faces[ i ].clone() );\n\n\t\t}\n\n\t\t// face vertex uvs\n\n\t\tfor ( let i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\tconst faceVertexUvs = source.faceVertexUvs[ i ];\n\n\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) {\n\n\t\t\t\tthis.faceVertexUvs[ i ] = [];\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0, jl = faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\tconst uvs = faceVertexUvs[ j ], uvsCopy = [];\n\n\t\t\t\tfor ( let k = 0, kl = uvs.length; k < kl; k ++ ) {\n\n\t\t\t\t\tconst uv = uvs[ k ];\n\n\t\t\t\t\tuvsCopy.push( uv.clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// morph targets\n\n\t\tconst morphTargets = source.morphTargets;\n\n\t\tfor ( let i = 0, il = morphTargets.length; i < il; i ++ ) {\n\n\t\t\tconst morphTarget = {};\n\t\t\tmorphTarget.name = morphTargets[ i ].name;\n\n\t\t\t// vertices\n\n\t\t\tif ( morphTargets[ i ].vertices !== undefined ) {\n\n\t\t\t\tmorphTarget.vertices = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphTargets[ i ].vertices.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphTarget.vertices.push( morphTargets[ i ].vertices[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// normals\n\n\t\t\tif ( morphTargets[ i ].normals !== undefined ) {\n\n\t\t\t\tmorphTarget.normals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphTargets[ i ].normals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphTarget.normals.push( morphTargets[ i ].normals[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.push( morphTarget );\n\n\t\t}\n\n\t\t// morph normals\n\n\t\tconst morphNormals = source.morphNormals;\n\n\t\tfor ( let i = 0, il = morphNormals.length; i < il; i ++ ) {\n\n\t\t\tconst morphNormal = {};\n\n\t\t\t// vertex normals\n\n\t\t\tif ( morphNormals[ i ].vertexNormals !== undefined ) {\n\n\t\t\t\tmorphNormal.vertexNormals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphNormals[ i ].vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tconst srcVertexNormal = morphNormals[ i ].vertexNormals[ j ];\n\t\t\t\t\tconst destVertexNormal = {};\n\n\t\t\t\t\tdestVertexNormal.a = srcVertexNormal.a.clone();\n\t\t\t\t\tdestVertexNormal.b = srcVertexNormal.b.clone();\n\t\t\t\t\tdestVertexNormal.c = srcVertexNormal.c.clone();\n\n\t\t\t\t\tmorphNormal.vertexNormals.push( destVertexNormal );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// face normals\n\n\t\t\tif ( morphNormals[ i ].faceNormals !== undefined ) {\n\n\t\t\t\tmorphNormal.faceNormals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphNormals[ i ].faceNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphNormal.faceNormals.push( morphNormals[ i ].faceNormals[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.morphNormals.push( morphNormal );\n\n\t\t}\n\n\t\t// skin weights\n\n\t\tconst skinWeights = source.skinWeights;\n\n\t\tfor ( let i = 0, il = skinWeights.length; i < il; i ++ ) {\n\n\t\t\tthis.skinWeights.push( skinWeights[ i ].clone() );\n\n\t\t}\n\n\t\t// skin indices\n\n\t\tconst skinIndices = source.skinIndices;\n\n\t\tfor ( let i = 0, il = skinIndices.length; i < il; i ++ ) {\n\n\t\t\tthis.skinIndices.push( skinIndices[ i ].clone() );\n\n\t\t}\n\n\t\t// line distances\n\n\t\tconst lineDistances = source.lineDistances;\n\n\t\tfor ( let i = 0, il = lineDistances.length; i < il; i ++ ) {\n\n\t\t\tthis.lineDistances.push( lineDistances[ i ] );\n\n\t\t}\n\n\t\t// bounding box\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif ( boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t}\n\n\t\t// bounding sphere\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t}\n\n\t\t// update flags\n\n\t\tthis.elementsNeedUpdate = source.elementsNeedUpdate;\n\t\tthis.verticesNeedUpdate = source.verticesNeedUpdate;\n\t\tthis.uvsNeedUpdate = source.uvsNeedUpdate;\n\t\tthis.normalsNeedUpdate = source.normalsNeedUpdate;\n\t\tthis.colorsNeedUpdate = source.colorsNeedUpdate;\n\t\tthis.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;\n\t\tthis.groupsNeedUpdate = source.groupsNeedUpdate;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { Geometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n// BoxGeometry\n\nclass BoxGeometry extends Geometry {\n\n\tconstructor( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tsuper();\n\n\t\tthis.type = 'BoxGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tthis.fromBufferGeometry( new BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n}\n\n// BoxBufferGeometry\n\nclass BoxBufferGeometry extends BufferGeometry {\n\n\tconstructor( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tsuper();\n\n\t\tthis.type = 'BoxBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tconst scope = this;\n\n\t\twidth = width || 1;\n\t\theight = height || 1;\n\t\tdepth = depth || 1;\n\n\t\t// segments\n\n\t\twidthSegments = Math.floor( widthSegments ) || 1;\n\t\theightSegments = Math.floor( heightSegments ) || 1;\n\t\tdepthSegments = Math.floor( depthSegments ) || 1;\n\n\t\t// buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = [];\n\n\t\t// helper variables\n\n\t\tlet numberOfVertices = 0;\n\t\tlet groupStart = 0;\n\n\t\t// build each side of the box geometry\n\n\t\tbuildPlane( 'z', 'y', 'x', - 1, - 1, depth, height, width, depthSegments, heightSegments, 0 ); // px\n\t\tbuildPlane( 'z', 'y', 'x', 1, - 1, depth, height, - width, depthSegments, heightSegments, 1 ); // nx\n\t\tbuildPlane( 'x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2 ); // py\n\t\tbuildPlane( 'x', 'z', 'y', 1, - 1, width, depth, - height, widthSegments, depthSegments, 3 ); // ny\n\t\tbuildPlane( 'x', 'y', 'z', 1, - 1, width, height, depth, widthSegments, heightSegments, 4 ); // pz\n\t\tbuildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth, widthSegments, heightSegments, 5 ); // nz\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\tfunction buildPlane( u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex ) {\n\n\t\t\tconst segmentWidth = width / gridX;\n\t\t\tconst segmentHeight = height / gridY;\n\n\t\t\tconst widthHalf = width / 2;\n\t\t\tconst heightHalf = height / 2;\n\t\t\tconst depthHalf = depth / 2;\n\n\t\t\tconst gridX1 = gridX + 1;\n\t\t\tconst gridY1 = gridY + 1;\n\n\t\t\tlet vertexCounter = 0;\n\t\t\tlet groupCount = 0;\n\n\t\t\tconst vector = new Vector3();\n\n\t\t\t// generate vertices, normals and uvs\n\n\t\t\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n\t\t\t\tconst y = iy * segmentHeight - heightHalf;\n\n\t\t\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\t\t\tconst x = ix * segmentWidth - widthHalf;\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = x * udir;\n\t\t\t\t\tvector[ v ] = y * vdir;\n\t\t\t\t\tvector[ w ] = depthHalf;\n\n\t\t\t\t\t// now apply vector to vertex buffer\n\n\t\t\t\t\tvertices.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = 0;\n\t\t\t\t\tvector[ v ] = 0;\n\t\t\t\t\tvector[ w ] = depth > 0 ? 1 : - 1;\n\n\t\t\t\t\t// now apply vector to normal buffer\n\n\t\t\t\t\tnormals.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// uvs\n\n\t\t\t\t\tuvs.push( ix / gridX );\n\t\t\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t\t\t\t// counters\n\n\t\t\t\t\tvertexCounter += 1;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// indices\n\n\t\t\t// 1. you need three indices to draw a single face\n\t\t\t// 2. a single segment consists of two faces\n\t\t\t// 3. so we need to generate six (2*3) indices per segment\n\n\t\t\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n\t\t\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\t\t\tconst a = numberOfVertices + ix + gridX1 * iy;\n\t\t\t\t\tconst b = numberOfVertices + ix + gridX1 * ( iy + 1 );\n\t\t\t\t\tconst c = numberOfVertices + ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\t\t\tconst d = numberOfVertices + ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t\t\t// faces\n\n\t\t\t\t\tindices.push( a, b, d );\n\t\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t\t// increase counter\n\n\t\t\t\t\tgroupCount += 6;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\t\tscope.addGroup( groupStart, groupCount, materialIndex );\n\n\t\t\t// calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\n\t\t\t// update total number of vertices\n\n\t\t\tnumberOfVertices += vertexCounter;\n\n\t\t}\n\n\t}\n\n}\n\nexport { BoxGeometry, BoxBufferGeometry };\n","/**\n * Uniform Utilities\n */\n\nexport function cloneUniforms( src ) {\n\n\tconst dst = {};\n\n\tfor ( const u in src ) {\n\n\t\tdst[ u ] = {};\n\n\t\tfor ( const p in src[ u ] ) {\n\n\t\t\tconst property = src[ u ][ p ];\n\n\t\t\tif ( property && ( property.isColor ||\n\t\t\t\tproperty.isMatrix3 || property.isMatrix4 ||\n\t\t\t\tproperty.isVector2 || property.isVector3 || property.isVector4 ||\n\t\t\t\tproperty.isTexture ) ) {\n\n\t\t\t\tdst[ u ][ p ] = property.clone();\n\n\t\t\t} else if ( Array.isArray( property ) ) {\n\n\t\t\t\tdst[ u ][ p ] = property.slice();\n\n\t\t\t} else {\n\n\t\t\t\tdst[ u ][ p ] = property;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn dst;\n\n}\n\nexport function mergeUniforms( uniforms ) {\n\n\tconst merged = {};\n\n\tfor ( let u = 0; u < uniforms.length; u ++ ) {\n\n\t\tconst tmp = cloneUniforms( uniforms[ u ] );\n\n\t\tfor ( const p in tmp ) {\n\n\t\t\tmerged[ p ] = tmp[ p ];\n\n\t\t}\n\n\t}\n\n\treturn merged;\n\n}\n\n// Legacy\n\nconst UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };\n\nexport { UniformsUtils };\n","export default /* glsl */`\nvoid main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n`;\n","export default /* glsl */`\nvoid main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}\n`;\n","/**\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * defines: { \"label\" : \"value\" },\n * uniforms: { \"parameter1\": { value: 1.0 }, \"parameter2\": { value2: 2 } },\n *\n * fragmentShader: ,\n * vertexShader: ,\n *\n * wireframe: ,\n * wireframeLinewidth: ,\n *\n * lights: ,\n *\n * skinning: ,\n * morphTargets: ,\n * morphNormals: \n * }\n */\n\nimport { Material } from './Material.js';\nimport { cloneUniforms } from '../renderers/shaders/UniformsUtils.js';\n\nimport default_vertex from '../renderers/shaders/ShaderChunk/default_vertex.glsl.js';\nimport default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.glsl.js';\n\nfunction ShaderMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'ShaderMaterial';\n\n\tthis.defines = {};\n\tthis.uniforms = {};\n\n\tthis.vertexShader = default_vertex;\n\tthis.fragmentShader = default_fragment;\n\n\tthis.linewidth = 1;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\n\tthis.fog = false; // set to use scene fog\n\tthis.lights = false; // set to use scene lights\n\tthis.clipping = false; // set to use user-defined clipping planes\n\n\tthis.skinning = false; // set to use skinning attribute streams\n\tthis.morphTargets = false; // set to use morph targets\n\tthis.morphNormals = false; // set to use morph normals\n\n\tthis.extensions = {\n\t\tderivatives: false, // set to use derivatives\n\t\tfragDepth: false, // set to use fragment depth values\n\t\tdrawBuffers: false, // set to use draw buffers\n\t\tshaderTextureLOD: false // set to use shader texture LOD\n\t};\n\n\t// When rendered geometry doesn't include these attributes but the material does,\n\t// use these default values in WebGL. This avoids errors when buffer data is missing.\n\tthis.defaultAttributeValues = {\n\t\t'color': [ 1, 1, 1 ],\n\t\t'uv': [ 0, 0 ],\n\t\t'uv2': [ 0, 0 ]\n\t};\n\n\tthis.index0AttributeName = undefined;\n\tthis.uniformsNeedUpdate = false;\n\n\tif ( parameters !== undefined ) {\n\n\t\tif ( parameters.attributes !== undefined ) {\n\n\t\t\tconsole.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' );\n\n\t\t}\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n}\n\nShaderMaterial.prototype = Object.create( Material.prototype );\nShaderMaterial.prototype.constructor = ShaderMaterial;\n\nShaderMaterial.prototype.isShaderMaterial = true;\n\nShaderMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.fragmentShader = source.fragmentShader;\n\tthis.vertexShader = source.vertexShader;\n\n\tthis.uniforms = cloneUniforms( source.uniforms );\n\n\tthis.defines = Object.assign( {}, source.defines );\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\tthis.lights = source.lights;\n\tthis.clipping = source.clipping;\n\n\tthis.skinning = source.skinning;\n\n\tthis.morphTargets = source.morphTargets;\n\tthis.morphNormals = source.morphNormals;\n\n\tthis.extensions = Object.assign( {}, source.extensions );\n\n\treturn this;\n\n};\n\nShaderMaterial.prototype.toJSON = function ( meta ) {\n\n\tconst data = Material.prototype.toJSON.call( this, meta );\n\n\tdata.uniforms = {};\n\n\tfor ( const name in this.uniforms ) {\n\n\t\tconst uniform = this.uniforms[ name ];\n\t\tconst value = uniform.value;\n\n\t\tif ( value && value.isTexture ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 't',\n\t\t\t\tvalue: value.toJSON( meta ).uuid\n\t\t\t};\n\n\t\t} else if ( value && value.isColor ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'c',\n\t\t\t\tvalue: value.getHex()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector2 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v2',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector3 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v3',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector4 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v4',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isMatrix3 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'm3',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isMatrix4 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'm4',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\tvalue: value\n\t\t\t};\n\n\t\t\t// note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far\n\n\t\t}\n\n\t}\n\n\tif ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;\n\n\tdata.vertexShader = this.vertexShader;\n\tdata.fragmentShader = this.fragmentShader;\n\n\tconst extensions = {};\n\n\tfor ( const key in this.extensions ) {\n\n\t\tif ( this.extensions[ key ] === true ) extensions[ key ] = true;\n\n\t}\n\n\tif ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;\n\n\treturn data;\n\n};\n\n\nexport { ShaderMaterial };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n * @author WestLangley / http://github.com/WestLangley\n*/\n\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\n\nfunction Camera() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Camera';\n\n\tthis.matrixWorldInverse = new Matrix4();\n\n\tthis.projectionMatrix = new Matrix4();\n\tthis.projectionMatrixInverse = new Matrix4();\n\n}\n\nCamera.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Camera,\n\n\tisCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\tthis.matrixWorldInverse.copy( source.matrixWorldInverse );\n\n\t\tthis.projectionMatrix.copy( source.projectionMatrix );\n\t\tthis.projectionMatrixInverse.copy( source.projectionMatrixInverse );\n\n\t\treturn this;\n\n\t},\n\n\tgetWorldDirection: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Camera: .getWorldDirection() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tconst e = this.matrixWorld.elements;\n\n\t\treturn target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();\n\n\t},\n\n\tupdateMatrixWorld: function ( force ) {\n\n\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t},\n\n\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\tObject3D.prototype.updateWorldMatrix.call( this, updateParents, updateChildren );\n\n\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t}\n\n} );\n\nexport { Camera };\n","import { Camera } from './Camera.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author greggman / http://games.greggman.com/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n * @author tschw\n */\n\nfunction PerspectiveCamera( fov, aspect, near, far ) {\n\n\tCamera.call( this );\n\n\tthis.type = 'PerspectiveCamera';\n\n\tthis.fov = fov !== undefined ? fov : 50;\n\tthis.zoom = 1;\n\n\tthis.near = near !== undefined ? near : 0.1;\n\tthis.far = far !== undefined ? far : 2000;\n\tthis.focus = 10;\n\n\tthis.aspect = aspect !== undefined ? aspect : 1;\n\tthis.view = null;\n\n\tthis.filmGauge = 35;\t// width of the film (default in millimeters)\n\tthis.filmOffset = 0;\t// horizontal film offset (same unit as gauge)\n\n\tthis.updateProjectionMatrix();\n\n}\n\nPerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\tconstructor: PerspectiveCamera,\n\n\tisPerspectiveCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\tthis.fov = source.fov;\n\t\tthis.zoom = source.zoom;\n\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\t\tthis.focus = source.focus;\n\n\t\tthis.aspect = source.aspect;\n\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\tthis.filmGauge = source.filmGauge;\n\t\tthis.filmOffset = source.filmOffset;\n\n\t\treturn this;\n\n\t},\n\n\t/**\n\t * Sets the FOV by focal length in respect to the current .filmGauge.\n\t *\n\t * The default film gauge is 35, so that the focal length can be specified for\n\t * a 35mm (full frame) camera.\n\t *\n\t * Values for focal length and film gauge must have the same unit.\n\t */\n\tsetFocalLength: function ( focalLength ) {\n\n\t\t// see http://www.bobatkins.com/photography/technical/field_of_view.html\n\t\tconst vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;\n\n\t\tthis.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope );\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\t/**\n\t * Calculates the focal length from the current .fov and .filmGauge.\n\t */\n\tgetFocalLength: function () {\n\n\t\tconst vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov );\n\n\t\treturn 0.5 * this.getFilmHeight() / vExtentSlope;\n\n\t},\n\n\tgetEffectiveFOV: function () {\n\n\t\treturn MathUtils.RAD2DEG * 2 * Math.atan(\n\t\t\tMath.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom );\n\n\t},\n\n\tgetFilmWidth: function () {\n\n\t\t// film not completely covered in portrait format (aspect < 1)\n\t\treturn this.filmGauge * Math.min( this.aspect, 1 );\n\n\t},\n\n\tgetFilmHeight: function () {\n\n\t\t// film not completely covered in landscape format (aspect > 1)\n\t\treturn this.filmGauge / Math.max( this.aspect, 1 );\n\n\t},\n\n\t/**\n\t * Sets an offset in a larger frustum. This is useful for multi-window or\n\t * multi-monitor/multi-machine setups.\n\t *\n\t * For example, if you have 3x2 monitors and each monitor is 1920x1080 and\n\t * the monitors are in grid like this\n\t *\n\t * +---+---+---+\n\t * | A | B | C |\n\t * +---+---+---+\n\t * | D | E | F |\n\t * +---+---+---+\n\t *\n\t * then for each monitor you would call it like this\n\t *\n\t * const w = 1920;\n\t * const h = 1080;\n\t * const fullWidth = w * 3;\n\t * const fullHeight = h * 2;\n\t *\n\t * --A--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );\n\t * --B--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );\n\t * --C--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );\n\t * --D--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );\n\t * --E--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );\n\t * --F--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );\n\t *\n\t * Note there is no reason monitors have to be the same size or in a grid.\n\t */\n\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\tthis.aspect = fullWidth / fullHeight;\n\n\t\tif ( this.view === null ) {\n\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tclearViewOffset: function () {\n\n\t\tif ( this.view !== null ) {\n\n\t\t\tthis.view.enabled = false;\n\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tupdateProjectionMatrix: function () {\n\n\t\tlet near = this.near,\n\t\t\ttop = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom,\n\t\t\theight = 2 * top,\n\t\t\twidth = this.aspect * height,\n\t\t\tleft = - 0.5 * width,\n\t\t\tview = this.view;\n\n\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\tconst fullWidth = view.fullWidth,\n\t\t\t\tfullHeight = view.fullHeight;\n\n\t\t\tleft += view.offsetX * width / fullWidth;\n\t\t\ttop -= view.offsetY * height / fullHeight;\n\t\t\twidth *= view.width / fullWidth;\n\t\t\theight *= view.height / fullHeight;\n\n\t\t}\n\n\t\tconst skew = this.filmOffset;\n\t\tif ( skew !== 0 ) left += near * skew / this.getFilmWidth();\n\n\t\tthis.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );\n\n\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.fov = this.fov;\n\t\tdata.object.zoom = this.zoom;\n\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\t\tdata.object.focus = this.focus;\n\n\t\tdata.object.aspect = this.aspect;\n\n\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\tdata.object.filmGauge = this.filmGauge;\n\t\tdata.object.filmOffset = this.filmOffset;\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { PerspectiveCamera };\n","/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nimport { Texture } from './Texture.js';\nimport { NearestFilter } from '../constants.js';\n\nfunction DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {\n\n\tTexture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1 };\n\n\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\tthis.unpackAlignment = 1;\n\n\tthis.needsUpdate = true;\n\n}\n\nDataTexture.prototype = Object.create( Texture.prototype );\nDataTexture.prototype.constructor = DataTexture;\n\nDataTexture.prototype.isDataTexture = true;\n\n\nexport { DataTexture };\n","import { Vector3 } from './Vector3.js';\nimport { Sphere } from './Sphere.js';\nimport { Plane } from './Plane.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author bhouston / http://clara.io\n */\n\nconst _sphere = new Sphere();\nconst _vector = new Vector3();\n\nfunction Frustum( p0, p1, p2, p3, p4, p5 ) {\n\n\tthis.planes = [\n\n\t\t( p0 !== undefined ) ? p0 : new Plane(),\n\t\t( p1 !== undefined ) ? p1 : new Plane(),\n\t\t( p2 !== undefined ) ? p2 : new Plane(),\n\t\t( p3 !== undefined ) ? p3 : new Plane(),\n\t\t( p4 !== undefined ) ? p4 : new Plane(),\n\t\t( p5 !== undefined ) ? p5 : new Plane()\n\n\t];\n\n}\n\nObject.assign( Frustum.prototype, {\n\n\tset: function ( p0, p1, p2, p3, p4, p5 ) {\n\n\t\tconst planes = this.planes;\n\n\t\tplanes[ 0 ].copy( p0 );\n\t\tplanes[ 1 ].copy( p1 );\n\t\tplanes[ 2 ].copy( p2 );\n\t\tplanes[ 3 ].copy( p3 );\n\t\tplanes[ 4 ].copy( p4 );\n\t\tplanes[ 5 ].copy( p5 );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( frustum ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tplanes[ i ].copy( frustum.planes[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromProjectionMatrix: function ( m ) {\n\n\t\tconst planes = this.planes;\n\t\tconst me = m.elements;\n\t\tconst me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];\n\t\tconst me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];\n\t\tconst me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];\n\t\tconst me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];\n\n\t\tplanes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();\n\t\tplanes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();\n\t\tplanes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();\n\t\tplanes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();\n\t\tplanes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();\n\t\tplanes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();\n\n\t\treturn this;\n\n\t},\n\n\tintersectsObject: function ( object ) {\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );\n\n\t\treturn this.intersectsSphere( _sphere );\n\n\t},\n\n\tintersectsSprite: function ( sprite ) {\n\n\t\t_sphere.center.set( 0, 0, 0 );\n\t\t_sphere.radius = 0.7071067811865476;\n\t\t_sphere.applyMatrix4( sprite.matrixWorld );\n\n\t\treturn this.intersectsSphere( _sphere );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\tconst planes = this.planes;\n\t\tconst center = sphere.center;\n\t\tconst negRadius = - sphere.radius;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tconst distance = planes[ i ].distanceToPoint( center );\n\n\t\t\tif ( distance < negRadius ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tconst plane = planes[ i ];\n\n\t\t\t// corner at max distance\n\n\t\t\t_vector.x = plane.normal.x > 0 ? box.max.x : box.min.x;\n\t\t\t_vector.y = plane.normal.y > 0 ? box.max.y : box.min.y;\n\t\t\t_vector.z = plane.normal.z > 0 ? box.max.z : box.min.z;\n\n\t\t\tif ( plane.distanceToPoint( _vector ) < 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tif ( planes[ i ].distanceToPoint( point ) < 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n} );\n\n\nexport { Frustum };\n","import { Color } from '../../math/Color.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Matrix3 } from '../../math/Matrix3.js';\n\n/**\n * Uniforms library for shared webgl shaders\n */\n\nconst UniformsLib = {\n\n\tcommon: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\n\t\tmap: { value: null },\n\t\tuvTransform: { value: new Matrix3() },\n\t\tuv2Transform: { value: new Matrix3() },\n\n\t\talphaMap: { value: null },\n\n\t},\n\n\tspecularmap: {\n\n\t\tspecularMap: { value: null },\n\n\t},\n\n\tenvmap: {\n\n\t\tenvMap: { value: null },\n\t\tflipEnvMap: { value: - 1 },\n\t\treflectivity: { value: 1.0 },\n\t\trefractionRatio: { value: 0.98 },\n\t\tmaxMipLevel: { value: 0 }\n\n\t},\n\n\taomap: {\n\n\t\taoMap: { value: null },\n\t\taoMapIntensity: { value: 1 }\n\n\t},\n\n\tlightmap: {\n\n\t\tlightMap: { value: null },\n\t\tlightMapIntensity: { value: 1 }\n\n\t},\n\n\temissivemap: {\n\n\t\temissiveMap: { value: null }\n\n\t},\n\n\tbumpmap: {\n\n\t\tbumpMap: { value: null },\n\t\tbumpScale: { value: 1 }\n\n\t},\n\n\tnormalmap: {\n\n\t\tnormalMap: { value: null },\n\t\tnormalScale: { value: new Vector2( 1, 1 ) }\n\n\t},\n\n\tdisplacementmap: {\n\n\t\tdisplacementMap: { value: null },\n\t\tdisplacementScale: { value: 1 },\n\t\tdisplacementBias: { value: 0 }\n\n\t},\n\n\troughnessmap: {\n\n\t\troughnessMap: { value: null }\n\n\t},\n\n\tmetalnessmap: {\n\n\t\tmetalnessMap: { value: null }\n\n\t},\n\n\tgradientmap: {\n\n\t\tgradientMap: { value: null }\n\n\t},\n\n\tfog: {\n\n\t\tfogDensity: { value: 0.00025 },\n\t\tfogNear: { value: 1 },\n\t\tfogFar: { value: 2000 },\n\t\tfogColor: { value: new Color( 0xffffff ) }\n\n\t},\n\n\tlights: {\n\n\t\tambientLightColor: { value: [] },\n\n\t\tlightProbe: { value: [] },\n\n\t\tdirectionalLights: { value: [], properties: {\n\t\t\tdirection: {},\n\t\t\tcolor: {}\n\t\t} },\n\n\t\tdirectionalLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {}\n\t\t} },\n\n\t\tdirectionalShadowMap: { value: [] },\n\t\tdirectionalShadowMatrix: { value: [] },\n\n\t\tspotLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\tdirection: {},\n\t\t\tdistance: {},\n\t\t\tconeCos: {},\n\t\t\tpenumbraCos: {},\n\t\t\tdecay: {}\n\t\t} },\n\n\t\tspotLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {}\n\t\t} },\n\n\t\tspotShadowMap: { value: [] },\n\t\tspotShadowMatrix: { value: [] },\n\n\t\tpointLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\tdecay: {},\n\t\t\tdistance: {}\n\t\t} },\n\n\t\tpointLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {},\n\t\t\tshadowCameraNear: {},\n\t\t\tshadowCameraFar: {}\n\t\t} },\n\n\t\tpointShadowMap: { value: [] },\n\t\tpointShadowMatrix: { value: [] },\n\n\t\themisphereLights: { value: [], properties: {\n\t\t\tdirection: {},\n\t\t\tskyColor: {},\n\t\t\tgroundColor: {}\n\t\t} },\n\n\t\t// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src\n\t\trectAreaLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\twidth: {},\n\t\t\theight: {}\n\t\t} }\n\n\t},\n\n\tpoints: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\t\tsize: { value: 1.0 },\n\t\tscale: { value: 1.0 },\n\t\tmap: { value: null },\n\t\talphaMap: { value: null },\n\t\tuvTransform: { value: new Matrix3() }\n\n\t},\n\n\tsprite: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\t\tcenter: { value: new Vector2( 0.5, 0.5 ) },\n\t\trotation: { value: 0.0 },\n\t\tmap: { value: null },\n\t\talphaMap: { value: null },\n\t\tuvTransform: { value: new Matrix3() }\n\n\t}\n\n};\n\nexport { UniformsLib };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLAnimation() {\n\n\tlet context = null;\n\tlet isAnimating = false;\n\tlet animationLoop = null;\n\tlet requestId = null;\n\n\tfunction onAnimationFrame( time, frame ) {\n\n\t\tanimationLoop( time, frame );\n\n\t\trequestId = context.requestAnimationFrame( onAnimationFrame );\n\n\t}\n\n\treturn {\n\n\t\tstart: function () {\n\n\t\t\tif ( isAnimating === true ) return;\n\t\t\tif ( animationLoop === null ) return;\n\n\t\t\trequestId = context.requestAnimationFrame( onAnimationFrame );\n\n\t\t\tisAnimating = true;\n\n\t\t},\n\n\t\tstop: function () {\n\n\t\t\tcontext.cancelAnimationFrame( requestId );\n\n\t\t\tisAnimating = false;\n\n\t\t},\n\n\t\tsetAnimationLoop: function ( callback ) {\n\n\t\t\tanimationLoop = callback;\n\n\t\t},\n\n\t\tsetContext: function ( value ) {\n\n\t\t\tcontext = value;\n\n\t\t}\n\n\t};\n\n}\n\nexport { WebGLAnimation };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLAttributes( gl, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tconst buffers = new WeakMap();\n\n\tfunction createBuffer( attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst usage = attribute.usage;\n\n\t\tconst buffer = gl.createBuffer();\n\n\t\tgl.bindBuffer( bufferType, buffer );\n\t\tgl.bufferData( bufferType, array, usage );\n\n\t\tattribute.onUploadCallback();\n\n\t\tlet type = gl.FLOAT;\n\n\t\tif ( array instanceof Float32Array ) {\n\n\t\t\ttype = gl.FLOAT;\n\n\t\t} else if ( array instanceof Float64Array ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' );\n\n\t\t} else if ( array instanceof Uint16Array ) {\n\n\t\t\ttype = gl.UNSIGNED_SHORT;\n\n\t\t} else if ( array instanceof Int16Array ) {\n\n\t\t\ttype = gl.SHORT;\n\n\t\t} else if ( array instanceof Uint32Array ) {\n\n\t\t\ttype = gl.UNSIGNED_INT;\n\n\t\t} else if ( array instanceof Int32Array ) {\n\n\t\t\ttype = gl.INT;\n\n\t\t} else if ( array instanceof Int8Array ) {\n\n\t\t\ttype = gl.BYTE;\n\n\t\t} else if ( array instanceof Uint8Array ) {\n\n\t\t\ttype = gl.UNSIGNED_BYTE;\n\n\t\t}\n\n\t\treturn {\n\t\t\tbuffer: buffer,\n\t\t\ttype: type,\n\t\t\tbytesPerElement: array.BYTES_PER_ELEMENT,\n\t\t\tversion: attribute.version\n\t\t};\n\n\t}\n\n\tfunction updateBuffer( buffer, attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst updateRange = attribute.updateRange;\n\n\t\tgl.bindBuffer( bufferType, buffer );\n\n\t\tif ( updateRange.count === - 1 ) {\n\n\t\t\t// Not using update ranges\n\n\t\t\tgl.bufferSubData( bufferType, 0, array );\n\n\t\t} else {\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray, updateRange.offset, updateRange.count );\n\n\t\t\t} else {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );\n\n\t\t\t}\n\n\t\t\tupdateRange.count = - 1; // reset range\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction get( attribute ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\treturn buffers.get( attribute );\n\n\t}\n\n\tfunction remove( attribute ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\tconst data = buffers.get( attribute );\n\n\t\tif ( data ) {\n\n\t\t\tgl.deleteBuffer( data.buffer );\n\n\t\t\tbuffers.delete( attribute );\n\n\t\t}\n\n\t}\n\n\tfunction update( attribute, bufferType ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\tconst data = buffers.get( attribute );\n\n\t\tif ( data === undefined ) {\n\n\t\t\tbuffers.set( attribute, createBuffer( attribute, bufferType ) );\n\n\t\t} else if ( data.version < attribute.version ) {\n\n\t\t\tupdateBuffer( data.buffer, attribute, bufferType );\n\n\t\t\tdata.version = attribute.version;\n\n\t\t}\n\n\t}\n\n\treturn {\n\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update\n\n\t};\n\n}\n\n\nexport { WebGLAttributes };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n// PlaneGeometry\n\nfunction PlaneGeometry( width, height, widthSegments, heightSegments ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'PlaneGeometry';\n\n\tthis.parameters = {\n\t\twidth: width,\n\t\theight: height,\n\t\twidthSegments: widthSegments,\n\t\theightSegments: heightSegments\n\t};\n\n\tthis.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );\n\tthis.mergeVertices();\n\n}\n\nPlaneGeometry.prototype = Object.create( Geometry.prototype );\nPlaneGeometry.prototype.constructor = PlaneGeometry;\n\n// PlaneBufferGeometry\n\nfunction PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'PlaneBufferGeometry';\n\n\tthis.parameters = {\n\t\twidth: width,\n\t\theight: height,\n\t\twidthSegments: widthSegments,\n\t\theightSegments: heightSegments\n\t};\n\n\twidth = width || 1;\n\theight = height || 1;\n\n\tconst width_half = width / 2;\n\tconst height_half = height / 2;\n\n\tconst gridX = Math.floor( widthSegments ) || 1;\n\tconst gridY = Math.floor( heightSegments ) || 1;\n\n\tconst gridX1 = gridX + 1;\n\tconst gridY1 = gridY + 1;\n\n\tconst segment_width = width / gridX;\n\tconst segment_height = height / gridY;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// generate vertices, normals and uvs\n\n\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n\t\tconst y = iy * segment_height - height_half;\n\n\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\tconst x = ix * segment_width - width_half;\n\n\t\t\tvertices.push( x, - y, 0 );\n\n\t\t\tnormals.push( 0, 0, 1 );\n\n\t\t\tuvs.push( ix / gridX );\n\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t}\n\n\t}\n\n\t// indices\n\n\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\tconst a = ix + gridX1 * iy;\n\t\t\tconst b = ix + gridX1 * ( iy + 1 );\n\t\t\tconst c = ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\tconst d = ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t// faces\n\n\t\t\tindices.push( a, b, d );\n\t\t\tindices.push( b, c, d );\n\n\t\t}\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n}\n\nPlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nPlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;\n\n\nexport { PlaneGeometry, PlaneBufferGeometry };\n","import alphamap_fragment from './ShaderChunk/alphamap_fragment.glsl.js';\nimport alphamap_pars_fragment from './ShaderChunk/alphamap_pars_fragment.glsl.js';\nimport alphatest_fragment from './ShaderChunk/alphatest_fragment.glsl.js';\nimport aomap_fragment from './ShaderChunk/aomap_fragment.glsl.js';\nimport aomap_pars_fragment from './ShaderChunk/aomap_pars_fragment.glsl.js';\nimport begin_vertex from './ShaderChunk/begin_vertex.glsl.js';\nimport beginnormal_vertex from './ShaderChunk/beginnormal_vertex.glsl.js';\nimport bsdfs from './ShaderChunk/bsdfs.glsl.js';\nimport bumpmap_pars_fragment from './ShaderChunk/bumpmap_pars_fragment.glsl.js';\nimport clipping_planes_fragment from './ShaderChunk/clipping_planes_fragment.glsl.js';\nimport clipping_planes_pars_fragment from './ShaderChunk/clipping_planes_pars_fragment.glsl.js';\nimport clipping_planes_pars_vertex from './ShaderChunk/clipping_planes_pars_vertex.glsl.js';\nimport clipping_planes_vertex from './ShaderChunk/clipping_planes_vertex.glsl.js';\nimport color_fragment from './ShaderChunk/color_fragment.glsl.js';\nimport color_pars_fragment from './ShaderChunk/color_pars_fragment.glsl.js';\nimport color_pars_vertex from './ShaderChunk/color_pars_vertex.glsl.js';\nimport color_vertex from './ShaderChunk/color_vertex.glsl.js';\nimport common from './ShaderChunk/common.glsl.js';\nimport cube_uv_reflection_fragment from './ShaderChunk/cube_uv_reflection_fragment.glsl.js';\nimport defaultnormal_vertex from './ShaderChunk/defaultnormal_vertex.glsl.js';\nimport displacementmap_pars_vertex from './ShaderChunk/displacementmap_pars_vertex.glsl.js';\nimport displacementmap_vertex from './ShaderChunk/displacementmap_vertex.glsl.js';\nimport emissivemap_fragment from './ShaderChunk/emissivemap_fragment.glsl.js';\nimport emissivemap_pars_fragment from './ShaderChunk/emissivemap_pars_fragment.glsl.js';\nimport encodings_fragment from './ShaderChunk/encodings_fragment.glsl.js';\nimport encodings_pars_fragment from './ShaderChunk/encodings_pars_fragment.glsl.js';\nimport envmap_fragment from './ShaderChunk/envmap_fragment.glsl.js';\nimport envmap_common_pars_fragment from './ShaderChunk/envmap_common_pars_fragment.glsl.js';\nimport envmap_pars_fragment from './ShaderChunk/envmap_pars_fragment.glsl.js';\nimport envmap_pars_vertex from './ShaderChunk/envmap_pars_vertex.glsl.js';\nimport envmap_vertex from './ShaderChunk/envmap_vertex.glsl.js';\nimport fog_vertex from './ShaderChunk/fog_vertex.glsl.js';\nimport fog_pars_vertex from './ShaderChunk/fog_pars_vertex.glsl.js';\nimport fog_fragment from './ShaderChunk/fog_fragment.glsl.js';\nimport fog_pars_fragment from './ShaderChunk/fog_pars_fragment.glsl.js';\nimport gradientmap_pars_fragment from './ShaderChunk/gradientmap_pars_fragment.glsl.js';\nimport lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl.js';\nimport lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl.js';\nimport lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl.js';\nimport lights_pars_begin from './ShaderChunk/lights_pars_begin.glsl.js';\nimport envmap_physical_pars_fragment from './ShaderChunk/envmap_physical_pars_fragment.glsl.js';\nimport lights_toon_fragment from './ShaderChunk/lights_toon_fragment.glsl.js';\nimport lights_toon_pars_fragment from './ShaderChunk/lights_toon_pars_fragment.glsl.js';\nimport lights_phong_fragment from './ShaderChunk/lights_phong_fragment.glsl.js';\nimport lights_phong_pars_fragment from './ShaderChunk/lights_phong_pars_fragment.glsl.js';\nimport lights_physical_fragment from './ShaderChunk/lights_physical_fragment.glsl.js';\nimport lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fragment.glsl.js';\nimport lights_fragment_begin from './ShaderChunk/lights_fragment_begin.glsl.js';\nimport lights_fragment_maps from './ShaderChunk/lights_fragment_maps.glsl.js';\nimport lights_fragment_end from './ShaderChunk/lights_fragment_end.glsl.js';\nimport logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl.js';\nimport logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl.js';\nimport logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl.js';\nimport logdepthbuf_vertex from './ShaderChunk/logdepthbuf_vertex.glsl.js';\nimport map_fragment from './ShaderChunk/map_fragment.glsl.js';\nimport map_pars_fragment from './ShaderChunk/map_pars_fragment.glsl.js';\nimport map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js';\nimport map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js';\nimport metalnessmap_fragment from './ShaderChunk/metalnessmap_fragment.glsl.js';\nimport metalnessmap_pars_fragment from './ShaderChunk/metalnessmap_pars_fragment.glsl.js';\nimport morphnormal_vertex from './ShaderChunk/morphnormal_vertex.glsl.js';\nimport morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.js';\nimport morphtarget_vertex from './ShaderChunk/morphtarget_vertex.glsl.js';\nimport normal_fragment_begin from './ShaderChunk/normal_fragment_begin.glsl.js';\nimport normal_fragment_maps from './ShaderChunk/normal_fragment_maps.glsl.js';\nimport normalmap_pars_fragment from './ShaderChunk/normalmap_pars_fragment.glsl.js';\nimport clearcoat_normal_fragment_begin from './ShaderChunk/clearcoat_normal_fragment_begin.glsl.js';\nimport clearcoat_normal_fragment_maps from './ShaderChunk/clearcoat_normal_fragment_maps.glsl.js';\nimport clearcoat_pars_fragment from './ShaderChunk/clearcoat_pars_fragment.glsl.js';\nimport packing from './ShaderChunk/packing.glsl.js';\nimport premultiplied_alpha_fragment from './ShaderChunk/premultiplied_alpha_fragment.glsl.js';\nimport project_vertex from './ShaderChunk/project_vertex.glsl.js';\nimport dithering_fragment from './ShaderChunk/dithering_fragment.glsl.js';\nimport dithering_pars_fragment from './ShaderChunk/dithering_pars_fragment.glsl.js';\nimport roughnessmap_fragment from './ShaderChunk/roughnessmap_fragment.glsl.js';\nimport roughnessmap_pars_fragment from './ShaderChunk/roughnessmap_pars_fragment.glsl.js';\nimport shadowmap_pars_fragment from './ShaderChunk/shadowmap_pars_fragment.glsl.js';\nimport shadowmap_pars_vertex from './ShaderChunk/shadowmap_pars_vertex.glsl.js';\nimport shadowmap_vertex from './ShaderChunk/shadowmap_vertex.glsl.js';\nimport shadowmask_pars_fragment from './ShaderChunk/shadowmask_pars_fragment.glsl.js';\nimport skinbase_vertex from './ShaderChunk/skinbase_vertex.glsl.js';\nimport skinning_pars_vertex from './ShaderChunk/skinning_pars_vertex.glsl.js';\nimport skinning_vertex from './ShaderChunk/skinning_vertex.glsl.js';\nimport skinnormal_vertex from './ShaderChunk/skinnormal_vertex.glsl.js';\nimport specularmap_fragment from './ShaderChunk/specularmap_fragment.glsl.js';\nimport specularmap_pars_fragment from './ShaderChunk/specularmap_pars_fragment.glsl.js';\nimport tonemapping_fragment from './ShaderChunk/tonemapping_fragment.glsl.js';\nimport tonemapping_pars_fragment from './ShaderChunk/tonemapping_pars_fragment.glsl.js';\nimport uv_pars_fragment from './ShaderChunk/uv_pars_fragment.glsl.js';\nimport uv_pars_vertex from './ShaderChunk/uv_pars_vertex.glsl.js';\nimport uv_vertex from './ShaderChunk/uv_vertex.glsl.js';\nimport uv2_pars_fragment from './ShaderChunk/uv2_pars_fragment.glsl.js';\nimport uv2_pars_vertex from './ShaderChunk/uv2_pars_vertex.glsl.js';\nimport uv2_vertex from './ShaderChunk/uv2_vertex.glsl.js';\nimport worldpos_vertex from './ShaderChunk/worldpos_vertex.glsl.js';\n\nimport background_frag from './ShaderLib/background_frag.glsl.js';\nimport background_vert from './ShaderLib/background_vert.glsl.js';\nimport cube_frag from './ShaderLib/cube_frag.glsl.js';\nimport cube_vert from './ShaderLib/cube_vert.glsl.js';\nimport depth_frag from './ShaderLib/depth_frag.glsl.js';\nimport depth_vert from './ShaderLib/depth_vert.glsl.js';\nimport distanceRGBA_frag from './ShaderLib/distanceRGBA_frag.glsl.js';\nimport distanceRGBA_vert from './ShaderLib/distanceRGBA_vert.glsl.js';\nimport equirect_frag from './ShaderLib/equirect_frag.glsl.js';\nimport equirect_vert from './ShaderLib/equirect_vert.glsl.js';\nimport linedashed_frag from './ShaderLib/linedashed_frag.glsl.js';\nimport linedashed_vert from './ShaderLib/linedashed_vert.glsl.js';\nimport meshbasic_frag from './ShaderLib/meshbasic_frag.glsl.js';\nimport meshbasic_vert from './ShaderLib/meshbasic_vert.glsl.js';\nimport meshlambert_frag from './ShaderLib/meshlambert_frag.glsl.js';\nimport meshlambert_vert from './ShaderLib/meshlambert_vert.glsl.js';\nimport meshmatcap_frag from './ShaderLib/meshmatcap_frag.glsl.js';\nimport meshmatcap_vert from './ShaderLib/meshmatcap_vert.glsl.js';\nimport meshtoon_frag from './ShaderLib/meshtoon_frag.glsl.js';\nimport meshtoon_vert from './ShaderLib/meshtoon_vert.glsl.js';\nimport meshphong_frag from './ShaderLib/meshphong_frag.glsl.js';\nimport meshphong_vert from './ShaderLib/meshphong_vert.glsl.js';\nimport meshphysical_frag from './ShaderLib/meshphysical_frag.glsl.js';\nimport meshphysical_vert from './ShaderLib/meshphysical_vert.glsl.js';\nimport normal_frag from './ShaderLib/normal_frag.glsl.js';\nimport normal_vert from './ShaderLib/normal_vert.glsl.js';\nimport points_frag from './ShaderLib/points_frag.glsl.js';\nimport points_vert from './ShaderLib/points_vert.glsl.js';\nimport shadow_frag from './ShaderLib/shadow_frag.glsl.js';\nimport shadow_vert from './ShaderLib/shadow_vert.glsl.js';\nimport sprite_frag from './ShaderLib/sprite_frag.glsl.js';\nimport sprite_vert from './ShaderLib/sprite_vert.glsl.js';\n\nexport const ShaderChunk = {\n\talphamap_fragment: alphamap_fragment,\n\talphamap_pars_fragment: alphamap_pars_fragment,\n\talphatest_fragment: alphatest_fragment,\n\taomap_fragment: aomap_fragment,\n\taomap_pars_fragment: aomap_pars_fragment,\n\tbegin_vertex: begin_vertex,\n\tbeginnormal_vertex: beginnormal_vertex,\n\tbsdfs: bsdfs,\n\tbumpmap_pars_fragment: bumpmap_pars_fragment,\n\tclipping_planes_fragment: clipping_planes_fragment,\n\tclipping_planes_pars_fragment: clipping_planes_pars_fragment,\n\tclipping_planes_pars_vertex: clipping_planes_pars_vertex,\n\tclipping_planes_vertex: clipping_planes_vertex,\n\tcolor_fragment: color_fragment,\n\tcolor_pars_fragment: color_pars_fragment,\n\tcolor_pars_vertex: color_pars_vertex,\n\tcolor_vertex: color_vertex,\n\tcommon: common,\n\tcube_uv_reflection_fragment: cube_uv_reflection_fragment,\n\tdefaultnormal_vertex: defaultnormal_vertex,\n\tdisplacementmap_pars_vertex: displacementmap_pars_vertex,\n\tdisplacementmap_vertex: displacementmap_vertex,\n\temissivemap_fragment: emissivemap_fragment,\n\temissivemap_pars_fragment: emissivemap_pars_fragment,\n\tencodings_fragment: encodings_fragment,\n\tencodings_pars_fragment: encodings_pars_fragment,\n\tenvmap_fragment: envmap_fragment,\n\tenvmap_common_pars_fragment: envmap_common_pars_fragment,\n\tenvmap_pars_fragment: envmap_pars_fragment,\n\tenvmap_pars_vertex: envmap_pars_vertex,\n\tenvmap_physical_pars_fragment: envmap_physical_pars_fragment,\n\tenvmap_vertex: envmap_vertex,\n\tfog_vertex: fog_vertex,\n\tfog_pars_vertex: fog_pars_vertex,\n\tfog_fragment: fog_fragment,\n\tfog_pars_fragment: fog_pars_fragment,\n\tgradientmap_pars_fragment: gradientmap_pars_fragment,\n\tlightmap_fragment: lightmap_fragment,\n\tlightmap_pars_fragment: lightmap_pars_fragment,\n\tlights_lambert_vertex: lights_lambert_vertex,\n\tlights_pars_begin: lights_pars_begin,\n\tlights_toon_fragment: lights_toon_fragment,\n\tlights_toon_pars_fragment: lights_toon_pars_fragment,\n\tlights_phong_fragment: lights_phong_fragment,\n\tlights_phong_pars_fragment: lights_phong_pars_fragment,\n\tlights_physical_fragment: lights_physical_fragment,\n\tlights_physical_pars_fragment: lights_physical_pars_fragment,\n\tlights_fragment_begin: lights_fragment_begin,\n\tlights_fragment_maps: lights_fragment_maps,\n\tlights_fragment_end: lights_fragment_end,\n\tlogdepthbuf_fragment: logdepthbuf_fragment,\n\tlogdepthbuf_pars_fragment: logdepthbuf_pars_fragment,\n\tlogdepthbuf_pars_vertex: logdepthbuf_pars_vertex,\n\tlogdepthbuf_vertex: logdepthbuf_vertex,\n\tmap_fragment: map_fragment,\n\tmap_pars_fragment: map_pars_fragment,\n\tmap_particle_fragment: map_particle_fragment,\n\tmap_particle_pars_fragment: map_particle_pars_fragment,\n\tmetalnessmap_fragment: metalnessmap_fragment,\n\tmetalnessmap_pars_fragment: metalnessmap_pars_fragment,\n\tmorphnormal_vertex: morphnormal_vertex,\n\tmorphtarget_pars_vertex: morphtarget_pars_vertex,\n\tmorphtarget_vertex: morphtarget_vertex,\n\tnormal_fragment_begin: normal_fragment_begin,\n\tnormal_fragment_maps: normal_fragment_maps,\n\tnormalmap_pars_fragment: normalmap_pars_fragment,\n\tclearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin,\n\tclearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps,\n\tclearcoat_pars_fragment: clearcoat_pars_fragment,\n\tpacking: packing,\n\tpremultiplied_alpha_fragment: premultiplied_alpha_fragment,\n\tproject_vertex: project_vertex,\n\tdithering_fragment: dithering_fragment,\n\tdithering_pars_fragment: dithering_pars_fragment,\n\troughnessmap_fragment: roughnessmap_fragment,\n\troughnessmap_pars_fragment: roughnessmap_pars_fragment,\n\tshadowmap_pars_fragment: shadowmap_pars_fragment,\n\tshadowmap_pars_vertex: shadowmap_pars_vertex,\n\tshadowmap_vertex: shadowmap_vertex,\n\tshadowmask_pars_fragment: shadowmask_pars_fragment,\n\tskinbase_vertex: skinbase_vertex,\n\tskinning_pars_vertex: skinning_pars_vertex,\n\tskinning_vertex: skinning_vertex,\n\tskinnormal_vertex: skinnormal_vertex,\n\tspecularmap_fragment: specularmap_fragment,\n\tspecularmap_pars_fragment: specularmap_pars_fragment,\n\ttonemapping_fragment: tonemapping_fragment,\n\ttonemapping_pars_fragment: tonemapping_pars_fragment,\n\tuv_pars_fragment: uv_pars_fragment,\n\tuv_pars_vertex: uv_pars_vertex,\n\tuv_vertex: uv_vertex,\n\tuv2_pars_fragment: uv2_pars_fragment,\n\tuv2_pars_vertex: uv2_pars_vertex,\n\tuv2_vertex: uv2_vertex,\n\tworldpos_vertex: worldpos_vertex,\n\n\tbackground_frag: background_frag,\n\tbackground_vert: background_vert,\n\tcube_frag: cube_frag,\n\tcube_vert: cube_vert,\n\tdepth_frag: depth_frag,\n\tdepth_vert: depth_vert,\n\tdistanceRGBA_frag: distanceRGBA_frag,\n\tdistanceRGBA_vert: distanceRGBA_vert,\n\tequirect_frag: equirect_frag,\n\tequirect_vert: equirect_vert,\n\tlinedashed_frag: linedashed_frag,\n\tlinedashed_vert: linedashed_vert,\n\tmeshbasic_frag: meshbasic_frag,\n\tmeshbasic_vert: meshbasic_vert,\n\tmeshlambert_frag: meshlambert_frag,\n\tmeshlambert_vert: meshlambert_vert,\n\tmeshmatcap_frag: meshmatcap_frag,\n\tmeshmatcap_vert: meshmatcap_vert,\n\tmeshtoon_frag: meshtoon_frag,\n\tmeshtoon_vert: meshtoon_vert,\n\tmeshphong_frag: meshphong_frag,\n\tmeshphong_vert: meshphong_vert,\n\tmeshphysical_frag: meshphysical_frag,\n\tmeshphysical_vert: meshphysical_vert,\n\tnormal_frag: normal_frag,\n\tnormal_vert: normal_vert,\n\tpoints_frag: points_frag,\n\tpoints_vert: points_vert,\n\tshadow_frag: shadow_frag,\n\tshadow_vert: shadow_vert,\n\tsprite_frag: sprite_frag,\n\tsprite_vert: sprite_vert\n};\n","export default /* glsl */`\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef ALPHATEST\n\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 transformed = vec3( position );\n`;\n","export default /* glsl */`\nvec3 objectNormal = vec3( normal );\n\n#ifdef USE_TANGENT\n\n\tvec3 objectTangent = vec3( tangent.xyz );\n\n#endif\n`;\n","export default /* glsl */`\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via 'environmentBRDF' from \"Physically Based Shading on Mobile\"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n\tvec4 r = roughness * c0 + c1;\n\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n}\n\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\n\tif( cutoffDistance > 0.0 ) {\n\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\n\t}\n\n\treturn distanceFalloff;\n\n#else\n\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n#endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\n\treturn RECIPROCAL_PI * diffuseColor;\n\n} // validated\n\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\n\t// Original approximation by Christophe Schlick '94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH '13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n} // validated\n\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\n\treturn Fr * fresnel + F0;\n\n}\n\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\t// geometry term (normalized) = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\n\t// also see #12151\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\n\treturn 1.0 / ( gl * gv );\n\n} // validated\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4's roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\tfloat D = D_GGX( alpha, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// Rect Area Light\n\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\n\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\tfloat dotNV = saturate( dot( N, V ) );\n\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\treturn uv;\n\n}\n\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\n\tfloat l = length( f );\n\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n\n}\n\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\n\tfloat x = dot( v1, v2 );\n\n\tfloat y = abs( x );\n\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\n\treturn cross( v1, v2 ) * theta_sintheta;\n\n}\n\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\n\t// transform rect\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\n\t// project rect onto sphere\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\n\t// calculate vector form factor\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\n\tfloat result = len * scale;\n*/\n\n\treturn vec3( result );\n\n}\n\n// End Rect Area Light\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Agüera's \"Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting\"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n\n}\n\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n\n}\n\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n\n}\n\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\n\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n\n#if defined( USE_SHEEN )\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, \"Production Friendly Microfacet Sheen BRDF\"\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, \"Crafting a Next-gen Material Pipeline for The Order: 1886\"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\n\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n\n}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen\n\t// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf\n\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvec4 plane;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\n\t\tbool clipped = true;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t\tif ( clipped ) discard;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvClipPosition = - mvPosition.xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tdiffuseColor.rgb *= vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvColor.xyz = color.xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\n\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\n\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\n\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n}\n\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t// dir can be either a direction vector or a normal vector\n\t// upper-left 3x3 of matrix is assumed to be orthogonal\n\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n\n}\n\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\n\treturn - distance * planeNormal + point;\n\n}\n\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n\n}\n\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n\n}\n\nmat3 transposeMat3( const in mat3 m ) {\n\n\tmat3 tmp;\n\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\n\treturn tmp;\n\n}\n\n// https://en.wikipedia.org/wiki/Relative_luminance\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\n\treturn dot( weights, color.rgb );\n\n}\n\nbool isPerspectiveMatrix( mat4 m ) {\n\n return m[ 2 ][ 3 ] == - 1.0;\n\n}\n\nvec2 equirectUv( in vec3 dir ) {\n\n\t// dir is assumed to be unit length\n\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\treturn vec2( u, v );\n\n}\n`;\n","export default /* glsl */`\n#ifdef ENVMAP_TYPE_CUBE_UV\n\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\n\n// These shader functions convert between the UV coordinates of a single face of\n// a cubemap, the 0-5 integer index of a cube face, and the direction vector for\n// sampling a textureCube (not generally normalized).\n\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\n\n// RH coordinate system; PMREM face-indexing convention\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x\n } else if (face == 1.0) {\n uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y\n } else if (face == 2.0) {\n uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z\n } else if (face == 3.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x\n } else if (face == 4.0) {\n uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y\n } else {\n uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z\n }\n return 0.5 * (uv + 1.0);\n}\n\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n\n// These defines must match with PMREMGenerator\n\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\n\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n }\n return mip;\n}\n\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif\n`;\n","export default /* glsl */`\nvec3 transformedNormal = objectNormal;\n\n#ifdef USE_INSTANCING\n\n\t// this is in lieu of a per-instance normal-matrix\n\t// shear transforms in the instance matrix are not supported\n\n\tmat3 m = mat3( instanceMatrix );\n\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\n\ttransformedNormal = m * transformedNormal;\n\n#endif\n\ntransformedNormal = normalMatrix * transformedNormal;\n\n#ifdef FLIP_SIDED\n\n\ttransformedNormal = - transformedNormal;\n\n#endif\n\n#ifdef USE_TANGENT\n\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#ifdef FLIP_SIDED\n\n\t\ttransformedTangent = - transformedTangent;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_DISPLACEMENTMAP\n\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_EMISSIVEMAP\n\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_EMISSIVEMAP\n\n\tuniform sampler2D emissiveMap;\n\n#endif\n`;\n","export default /* glsl */`\ngl_FragColor = linearToOutputTexel( gl_FragColor );\n`;\n","export default /* glsl */`\n// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\n\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\n\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\n\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\n\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\n\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\n\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\n\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\t// NOTE: The implementation with min causes the shader to not compile on\n\t// a common Alcatel A502DL in Chrome 78/Android 8.1. Some research suggests \n\t// that the chipset is Mediatek MT6739 w/ IMG PowerVR GE8100 GPU.\n\t// D = min( floor( D ) / 255.0, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\n\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\n\n// M matrix, for encoding\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\n\n// Inverse M matrix, for decoding\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\n\t\t}\n\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#else\n\n\t\tvec3 reflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tvec2 sampleUV = equirectUv( reflectVec );\n\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\n\t#else\n\n\t\tvec4 envColor = vec4( 0.0 );\n\n\t#endif\n\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\n\t\tenvColor = envMapTexelToLinear( envColor );\n\n\t#endif\n\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_ENVMAP )\n\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\n\tvec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {\n\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#else\n\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\n\t\t#else\n\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\n\t\t#endif\n\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\n\t}\n\n\t// Trowbridge-Reitz distribution to Mip level, following the logic of http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\n\t\t// clamp to allowable LOD ranges.\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\n\t}\n\n\tvec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\n\t\t // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\n\t\t#else\n\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\n\t\t#endif\n\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\t\tvec2 sampleUV = equirectUv( reflectVec );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#endif\n\n\t\treturn envMapColor.rgb * envMapIntensity;\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvWorldPosition = worldPosition.xyz;\n\n\t#else\n\n\t\tvec3 cameraToVertex;\n\n\t\tif ( isOrthographic ) { \n\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\t\t}\n\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t\t#else\n\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tfogDepth = -mvPosition.z;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tvarying float fogDepth;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\t#ifdef FOG_EXP2\n\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\n\t#endif\n\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n\n#ifdef USE_GRADIENTMAP\n\n\tuniform sampler2D gradientMap;\n\n#endif\n\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\n\t// dotNL will be from -1.0 to 1.0\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\n\t#ifdef USE_GRADIENTMAP\n\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\n\t#else\n\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\n\t#endif\n\n}\n\n`;\n","export default /* glsl */`\n#ifdef USE_LIGHTMAP\n\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LIGHTMAP\n\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 diffuse = vec3( 1.0 );\n\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\n\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\n\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\n\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n\n#ifdef DOUBLE_SIDED\n\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n\n#endif\n\n#if NUM_POINT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n/*\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\t// TODO (abelnation): implement\n\n\t}\n\n#endif\n*/\n\n#if NUM_DIR_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_HEMI_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n`;\n","export default /* glsl */`\nuniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\n\n// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\n\t// normal is assumed to have unit length\n\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\n\t// band 0\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\n\t// band 1\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\n\t// band 2\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\n\treturn result;\n\n}\n\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\n\treturn irradiance;\n\n}\n\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\n\tvec3 irradiance = ambientLightColor;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI;\n\n\t#endif\n\n\treturn irradiance;\n\n}\n\n#if NUM_DIR_LIGHTS > 0\n\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\n\t}\n\n#endif\n\n\n#if NUM_POINT_LIGHTS > 0\n\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\n\t}\n\n#endif\n\n\n#if NUM_SPOT_LIGHTS > 0\n\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\n\t\tif ( angleCos > spotLight.coneCos ) {\n\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\n\t\t} else {\n\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\n\t\t}\n\t}\n\n#endif\n\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\n\t// Pre-computed values of LinearTransformedCosine approximation of BRDF\n\t// BRDF approximation Texture is 64x64\n\tuniform sampler2D ltc_1; // RGBA Float\n\tuniform sampler2D ltc_2; // RGBA Float\n\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n\n#endif\n\n\n#if NUM_HEMI_LIGHTS > 0\n\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tirradiance *= PI;\n\n\t\t#endif\n\n\t\treturn irradiance;\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\nToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\n`;\n","export default /* glsl */`\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct ToonMaterial {\n\n\tvec3\tdiffuseColor;\n\n};\n\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\n#define Material_LightProbeLOD( material )\t(0)\n`;\n","export default /* glsl */`\nBlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n`;\n","export default /* glsl */`\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct BlinnPhongMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n\n#define Material_LightProbeLOD( material )\t(0)\n`;\n","export default /* glsl */`\nPhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\n\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\n\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n\n#ifdef REFLECTIVITY\n\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\n#else\n\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n\n#endif\n\n#ifdef CLEARCOAT\n\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\n\t#ifdef USE_CLEARCOATMAP\n\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\n\t#endif\n\n\tmaterial.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model\n\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n\n#endif\n\n#ifdef USE_SHEEN\n\n\tmaterial.sheenColor = sheen;\n\n#endif\n`;\n","export default /* glsl */`\nstruct PhysicalMaterial {\n\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n\n};\n\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n\n// Clear coat directional hemishperical reflectance (this approximation should be improved)\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n\n}\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction\n\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\n\t\t// LTC Fresnel Approximation by Stephen Hill\n\t\t// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\n\t}\n\n#endif\n\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tccIrradiance *= PI; // punctual light\n\n\t\t#endif\n\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\n\t// Both indirect specular and indirect diffuse light accumulate here\n\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n\n// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n\n}\n`;\n","export default /* glsl */`\n/**\n * This is a template that can be used to light a material, it uses pluggable\n * RenderEquations (RE)for specific lighting scenarios.\n *\n * Instructions for use:\n * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined\n * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???\n * - Create a material parameter that is to be passed as the third parameter to your lighting functions.\n *\n * TODO:\n * - Add area light support.\n * - Add sphere light support.\n * - Add diffuse light probe (irradiance cubemap) support.\n */\n\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( RE_IndirectDiffuse )\n\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\t// Doing a strict comparison with == 1.0 can cause noise artifacts\n\t// on some platforms. See issue #17623.\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\n\t#else\n\n\t\tuniform float logDepthBufFC;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\n\t#else\n\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\n\t\t\tgl_Position.z *= gl_Position.w;\n\n\t\t}\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_MAP\n\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tuniform mat3 uvTransform;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n`;\n","export default /* glsl */`\nfloat metalnessFactor = metalness;\n\n#ifdef USE_METALNESSMAP\n\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\n\t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tmetalnessFactor *= texelMetalness.b;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_METALNESSMAP\n\n\tuniform sampler2D metalnessMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHNORMALS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHTARGETS\n\n\tuniform float morphTargetBaseInfluence;\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHTARGETS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef FLAT_SHADED\n\n\t// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...\n\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n\n#else\n\n\tvec3 normal = normalize( vNormal );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\t#ifdef USE_TANGENT\n\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n\n// non perturbed normal for clearcoat among others\n\nvec3 geometryNormal = normal;\n\n`;\n","export default /* glsl */`\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n\t#ifdef FLIP_SIDED\n\n\t\tnormal = - normal;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\tnormal = normalize( normalMatrix * normal );\n\n#elif defined( TANGENTSPACE_NORMALMAP )\n\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tnormal = normalize( vTBN * mapN );\n\n\t#else\n\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\n\t#endif\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n#endif\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tuniform mat3 normalMatrix;\n\n#endif\n\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\n\t// Per-Pixel Tangent Space Normal Mapping\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tmat3 tsn = mat3( S, T, N );\n\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef CLEARCOAT\n\n\tvec3 clearcoatNormal = geometryNormal;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\n\t#else\n\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n\n#ifdef USE_CLEARCOATMAP\n\n\tuniform sampler2D clearcoatMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform sampler2D clearcoatRoughnessMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\n\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\n\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\n\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\nconst float ShiftRight8 = 1. / 256.;\n\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\n\treturn r * PackUpscale;\n}\n\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\n\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\n\n// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions\n\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\n\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n`;\n","export default /* glsl */`\n#ifdef PREMULTIPLIED_ALPHA\n\n\t// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.\n\tgl_FragColor.rgb *= gl_FragColor.a;\n\n#endif\n`;\n","export default /* glsl */`\nvec4 mvPosition = vec4( transformed, 1.0 );\n\n#ifdef USE_INSTANCING\n\n\tmvPosition = instanceMatrix * mvPosition;\n\n#endif\n\nmvPosition = modelViewMatrix * mvPosition;\n\ngl_Position = projectionMatrix * mvPosition;\n`;\n","export default /* glsl */`\n#ifdef DITHERING\n\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef DITHERING\n\n\t// based on https://www.shadertoy.com/view/MslGR8\n\tvec3 dithering( vec3 color ) {\n\t\t//Calculate grid position\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\n\t\t//modify shift acording to grid position.\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\n\t\t//shift the color by dither_shift\n\t\treturn color + dither_shift_RGB;\n\t}\n\n#endif\n`;\n","export default /* glsl */`\nfloat roughnessFactor = roughness;\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\n\t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\troughnessFactor *= texelRoughness.g;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform sampler2D roughnessMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): create uniforms for area light shadows\n\n\t#endif\n\t*/\n\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\n\t}\n\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n\t}\n\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n\t\tfloat occlusion = 1.0;\n\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\n\t\tfloat hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n\t\tif (hard_shadow != 1.0 ) {\n\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n\t\t}\n\t\treturn occlusion;\n\n\t}\n\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n\t\tfloat shadow = 1.0;\n\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\n\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t// if ( all( something, something ) ) using this instead\n\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#else // no percentage-closer filtering:\n\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#endif\n\n\t\t}\n\n\t\treturn shadow;\n\n\t}\n\n\t// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D\n\t// vector suitable for 2D texture mapping. This code uses the following layout for the\n\t// 2D texture:\n\t//\n\t// xzXZ\n\t// y Y\n\t//\n\t// Y - Positive y direction\n\t// y - Negative y direction\n\t// X - Positive x direction\n\t// x - Negative x direction\n\t// Z - Positive z direction\n\t// z - Negative z direction\n\t//\n\t// Source and test bed:\n\t// https://gist.github.com/tschw/da10c43c467ce8afd0c4\n\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\n\t\t// Number of texels to avoid at the edge of each square\n\n\t\tvec3 absV = abs( v );\n\n\t\t// Intersect unit cube\n\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\n\t\t// Apply scale to avoid seams\n\n\t\t// two texels less per square (one texel will do for NEAREST)\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\n\t\t// Unwrap\n\n\t\t// space: -1 ... 1 range for each square\n\t\t//\n\t\t// #X##\t\tdim := ( 4 , 2 )\n\t\t// # #\t\tcenter := ( 1 , 1 )\n\n\t\tvec2 planar = v.xy;\n\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\n\t\tif ( absV.z >= almostOne ) {\n\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\n\t\t} else if ( absV.x >= almostOne ) {\n\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\n\t\t} else if ( absV.y >= almostOne ) {\n\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\n\t\t}\n\n\t\t// Transform to UV space\n\n\t\t// scale := 0.5 / dim\n\t\t// translate := ( center + 0.5 ) / dim\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\n\t}\n\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n\t\t// for point lights, the uniform @vShadowCoord is re-purposed to hold\n\t\t// the vector from the light to the world-space position of the fragment.\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\n\t\t// dp = normalized distance from light to fragment position\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?\n\t\tdp += shadowBias;\n\n\t\t// bd3D = base direction 3D\n\t\tvec3 bd3D = normalize( lightToPosition );\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#else // no percentage-closer filtering\n\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\n\t\t#endif\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): uniforms for area light shadows\n\n\t#endif\n\t*/\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\t// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\n\t#endif\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update vAreaShadowCoord with area light info\n\n\t#endif\n\t*/\n\n#endif\n`;\n","export default /* glsl */`\nfloat getShadowMask() {\n\n\tfloat shadow = 1.0;\n\n\t#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\tDirectionalLightShadow directionalLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\tSpotLightShadow spotLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\tPointLightShadow pointLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update shadow for Area light\n\n\t#endif\n\t*/\n\n\t#endif\n\n\treturn shadow;\n\n}\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\n\t\t\ty = dy * ( y + 0.5 );\n\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\n\t#ifdef USE_TANGENT\n\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\nfloat specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( TONE_MAPPING )\n\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\n#endif\n`;\n","export default /* glsl */`\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n\nuniform float toneMappingExposure;\n\n// exposure only\nvec3 LinearToneMapping( vec3 color ) {\n\n\treturn toneMappingExposure * color;\n\n}\n\n// source: https://www.cs.utah.edu/~reinhard/cdrom/\nvec3 ReinhardToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n\n}\n\n// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\n\t// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n\n}\n\n// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs\nvec3 RRTAndODTFit( vec3 v ) {\n\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n\n}\n\n// this implementation of ACES is modified to accommodate a brighter viewing environment.\n// the scale factor of 1/0.6 is subjective. see discussion in #19621.\n\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\n\t// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ), // transposed from source\n\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\n\t// ODT_SAT => XYZ => D60_2_D65 => sRGB\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ), // transposed from source\n\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\n\tcolor *= toneMappingExposure / 0.6;\n\n\tcolor = ACESInputMat * color;\n\n\t// Apply RRT and ODT\n\tcolor = RRTAndODTFit( color );\n\n\tcolor = ACESOutputMat * color;\n\n\t// Clamp to [0, 1]\n\treturn saturate( color );\n\n}\n\nvec3 CustomToneMapping( vec3 color ) { return color; }\n`;\n","export default /* glsl */`\n#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\n\tvarying vec2 vUv;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_UV\n\n\t#ifdef UVS_VERTEX_ONLY\n\n\t\tvec2 vUv;\n\n\t#else\n\n\t\tvarying vec2 vUv;\n\n\t#endif\n\n\tuniform mat3 uvTransform;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_UV\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvarying vec2 vUv2;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\n\tuniform mat3 uv2Transform;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t#ifdef USE_INSTANCING\n\n\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t#endif\n\n\tworldPosition = modelMatrix * worldPosition;\n\n#endif\n`;\n","export default /* glsl */`\nuniform sampler2D t2D;\n\nvarying vec2 vUv;\n\nvoid main() {\n\n\tvec4 texColor = texture2D( t2D, vUv );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec2 vUv;\nuniform mat3 uvTransform;\n\nvoid main() {\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n\n}\n`;\n","export default /* glsl */`\n#include \nuniform float opacity;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n}\n`;\n","export default /* glsl */`\n#if DEPTH_PACKING == 3200\n\n\tuniform float opacity;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tdiffuseColor.a = opacity;\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\n\t// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\n\t#elif DEPTH_PACKING == 3201\n\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\n\t#endif\n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvHighPrecisionZW = gl_Position.zw;\n\n}\n`;\n","export default /* glsl */`\n#define DISTANCE\n\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main () {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#include \n\t#include \n\t#include \n\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist ); // clamp to [ 0, 1 ]\n\n\tgl_FragColor = packDepthToRGBA( dist );\n\n}\n`;\n","export default /* glsl */`\n#define DISTANCE\n\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvWorldPosition = worldPosition.xyz;\n\n}\n`;\n","export default /* glsl */`\nuniform sampler2D tEquirect;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 direction = normalize( vWorldDirection );\n\n\tvec2 sampleUV = equirectUv( direction );\n\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform float dashSize;\nuniform float totalSize;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\n\t\tdiscard;\n\n\t}\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb; // simple shader\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float scale;\nattribute float lineDistance;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tvLineDistance = scale * lineDistance;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\n\t#endif\n\n\t// modulation\n\t#include \n\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifdef USE_ENVMAP\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\n\t#endif\n\n\t#include \n\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\n\t#else\n\n\t\treflectedLight.directDiffuse = vLightFront;\n\n\t#endif\n\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\n\t// modulation\n\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n`;\n","export default /* glsl */`\n#define LAMBERT\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n`;\n","export default /* glsl */`\n#define MATCAP\n\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks\n\n\t#ifdef USE_MATCAP\n\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\n\t#else\n\n\t\tvec4 matcapColor = vec4( 1.0 );\n\n\t#endif\n\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define MATCAP\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\t\tvNormal = normalize( transformedNormal );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n}\n`;\n","export default /* glsl */`\n#define TOON\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define TOON\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define PHONG\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t// this is a stub for the transparency model\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define NORMAL\n\nuniform float opacity;\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\n}\n`;\n","export default /* glsl */`\n#define NORMAL\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvViewPosition = - mvPosition.xyz;\n\n#endif\n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float size;\nuniform float scale;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_PointSize = size;\n\n\t#ifdef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 color;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float rotation;\nuniform vec2 center;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n\t#ifndef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\n\t#endif\n\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\n\tmvPosition.xy += rotatedPosition;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","import { ShaderChunk } from './ShaderChunk.js';\nimport { mergeUniforms } from './UniformsUtils.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Vector3 } from '../../math/Vector3.js';\nimport { UniformsLib } from './UniformsLib.js';\nimport { Color } from '../../math/Color.js';\nimport { Matrix3 } from '../../math/Matrix3.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n */\n\nconst ShaderLib = {\n\n\tbasic: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshbasic_vert,\n\t\tfragmentShader: ShaderChunk.meshbasic_frag\n\n\t},\n\n\tlambert: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshlambert_vert,\n\t\tfragmentShader: ShaderChunk.meshlambert_frag\n\n\t},\n\n\tphong: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\tspecular: { value: new Color( 0x111111 ) },\n\t\t\t\tshininess: { value: 30 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphong_vert,\n\t\tfragmentShader: ShaderChunk.meshphong_frag\n\n\t},\n\n\tstandard: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.roughnessmap,\n\t\t\tUniformsLib.metalnessmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\troughness: { value: 1.0 },\n\t\t\t\tmetalness: { value: 0.0 },\n\t\t\t\tenvMapIntensity: { value: 1 } // temporary\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\n\t},\n\n\ttoon: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.gradientmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshtoon_vert,\n\t\tfragmentShader: ShaderChunk.meshtoon_frag\n\n\t},\n\n\tmatcap: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tmatcap: { value: null }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshmatcap_vert,\n\t\tfragmentShader: ShaderChunk.meshmatcap_frag\n\n\t},\n\n\tpoints: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.points,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.points_vert,\n\t\tfragmentShader: ShaderChunk.points_frag\n\n\t},\n\n\tdashed: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tscale: { value: 1 },\n\t\t\t\tdashSize: { value: 1 },\n\t\t\t\ttotalSize: { value: 2 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.linedashed_vert,\n\t\tfragmentShader: ShaderChunk.linedashed_frag\n\n\t},\n\n\tdepth: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.displacementmap\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.depth_vert,\n\t\tfragmentShader: ShaderChunk.depth_frag\n\n\t},\n\n\tnormal: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\t{\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.normal_vert,\n\t\tfragmentShader: ShaderChunk.normal_frag\n\n\t},\n\n\tsprite: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.sprite,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.sprite_vert,\n\t\tfragmentShader: ShaderChunk.sprite_frag\n\n\t},\n\n\tbackground: {\n\n\t\tuniforms: {\n\t\t\tuvTransform: { value: new Matrix3() },\n\t\t\tt2D: { value: null },\n\t\t},\n\n\t\tvertexShader: ShaderChunk.background_vert,\n\t\tfragmentShader: ShaderChunk.background_frag\n\n\t},\n\t/* -------------------------------------------------------------------------\n\t//\tCube map shader\n\t ------------------------------------------------------------------------- */\n\n\tcube: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.envmap,\n\t\t\t{\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.cube_vert,\n\t\tfragmentShader: ShaderChunk.cube_frag\n\n\t},\n\n\tequirect: {\n\n\t\tuniforms: {\n\t\t\ttEquirect: { value: null },\n\t\t},\n\n\t\tvertexShader: ShaderChunk.equirect_vert,\n\t\tfragmentShader: ShaderChunk.equirect_frag\n\n\t},\n\n\tdistanceRGBA: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.displacementmap,\n\t\t\t{\n\t\t\t\treferencePosition: { value: new Vector3() },\n\t\t\t\tnearDistance: { value: 1 },\n\t\t\t\tfarDistance: { value: 1000 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.distanceRGBA_vert,\n\t\tfragmentShader: ShaderChunk.distanceRGBA_frag\n\n\t},\n\n\tshadow: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.lights,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tcolor: { value: new Color( 0x00000 ) },\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t},\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.shadow_vert,\n\t\tfragmentShader: ShaderChunk.shadow_frag\n\n\t}\n\n};\n\nShaderLib.physical = {\n\n\tuniforms: mergeUniforms( [\n\t\tShaderLib.standard.uniforms,\n\t\t{\n\t\t\tclearcoat: { value: 0 },\n\t\t\tclearcoatMap: { value: null },\n\t\t\tclearcoatRoughness: { value: 0 },\n\t\t\tclearcoatRoughnessMap: { value: null },\n\t\t\tclearcoatNormalScale: { value: new Vector2( 1, 1 ) },\n\t\t\tclearcoatNormalMap: { value: null },\n\t\t\tsheen: { value: new Color( 0x000000 ) },\n\t\t\ttransparency: { value: 0 },\n\t\t}\n\t] ),\n\n\tvertexShader: ShaderChunk.meshphysical_vert,\n\tfragmentShader: ShaderChunk.meshphysical_frag\n\n};\n\n\nexport { ShaderLib };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide, FrontSide, CubeUVReflectionMapping } from '../../constants.js';\nimport { BoxBufferGeometry } from '../../geometries/BoxGeometry.js';\nimport { PlaneBufferGeometry } from '../../geometries/PlaneGeometry.js';\nimport { ShaderMaterial } from '../../materials/ShaderMaterial.js';\nimport { Color } from '../../math/Color.js';\nimport { Mesh } from '../../objects/Mesh.js';\nimport { ShaderLib } from '../shaders/ShaderLib.js';\nimport { cloneUniforms } from '../shaders/UniformsUtils.js';\n\nfunction WebGLBackground( renderer, state, objects, premultipliedAlpha ) {\n\n\tconst clearColor = new Color( 0x000000 );\n\tlet clearAlpha = 0;\n\n\tlet planeMesh;\n\tlet boxMesh;\n\n\tlet currentBackground = null;\n\tlet currentBackgroundVersion = 0;\n\tlet currentTonemapping = null;\n\n\tfunction render( renderList, scene, camera, forceClear ) {\n\n\t\tlet background = scene.isScene === true ? scene.background : null;\n\n\t\t// Ignore background in AR\n\t\t// TODO: Reconsider this.\n\n\t\tconst xr = renderer.xr;\n\t\tconst session = xr.getSession && xr.getSession();\n\n\t\tif ( session && session.environmentBlendMode === 'additive' ) {\n\n\t\t\tbackground = null;\n\n\t\t}\n\n\t\tif ( background === null ) {\n\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t} else if ( background && background.isColor ) {\n\n\t\t\tsetClear( background, 1 );\n\t\t\tforceClear = true;\n\n\t\t}\n\n\t\tif ( renderer.autoClear || forceClear ) {\n\n\t\t\trenderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );\n\n\t\t}\n\n\t\tif ( background && ( background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping ) ) {\n\n\t\t\tif ( boxMesh === undefined ) {\n\n\t\t\t\tboxMesh = new Mesh(\n\t\t\t\t\tnew BoxBufferGeometry( 1, 1, 1 ),\n\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\tname: 'BackgroundCubeMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.cube.uniforms ),\n\t\t\t\t\t\tvertexShader: ShaderLib.cube.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.cube.fragmentShader,\n\t\t\t\t\t\tside: BackSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\t\tboxMesh.geometry.deleteAttribute( 'normal' );\n\t\t\t\tboxMesh.geometry.deleteAttribute( 'uv' );\n\n\t\t\t\tboxMesh.onBeforeRender = function ( renderer, scene, camera ) {\n\n\t\t\t\t\tthis.matrixWorld.copyPosition( camera.matrixWorld );\n\n\t\t\t\t};\n\n\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\tObject.defineProperty( boxMesh.material, 'envMap', {\n\n\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\treturn this.uniforms.envMap.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\tobjects.update( boxMesh );\n\n\t\t\t}\n\n\t\t\tconst texture = background.isWebGLCubeRenderTarget ? background.texture : background;\n\n\t\t\tboxMesh.material.uniforms.envMap.value = texture;\n\t\t\tboxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1;\n\n\t\t\tif ( currentBackground !== background ||\n\t\t\t\tcurrentBackgroundVersion !== texture.version ||\n\t\t\t\tcurrentTonemapping !== renderer.toneMapping ) {\n\n\t\t\t\tboxMesh.material.needsUpdate = true;\n\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = texture.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\n\t\t\t}\n\n\t\t\t// push to the pre-sorted opaque render list\n\t\t\trenderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null );\n\n\t\t} else if ( background && background.isTexture ) {\n\n\t\t\tif ( planeMesh === undefined ) {\n\n\t\t\t\tplaneMesh = new Mesh(\n\t\t\t\t\tnew PlaneBufferGeometry( 2, 2 ),\n\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\tname: 'BackgroundMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.background.uniforms ),\n\t\t\t\t\t\tvertexShader: ShaderLib.background.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.background.fragmentShader,\n\t\t\t\t\t\tside: FrontSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\t\tplaneMesh.geometry.deleteAttribute( 'normal' );\n\n\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\tObject.defineProperty( planeMesh.material, 'map', {\n\n\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\treturn this.uniforms.t2D.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\tobjects.update( planeMesh );\n\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.t2D.value = background;\n\n\t\t\tif ( background.matrixAutoUpdate === true ) {\n\n\t\t\t\tbackground.updateMatrix();\n\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.uvTransform.value.copy( background.matrix );\n\n\t\t\tif ( currentBackground !== background ||\n\t\t\t\tcurrentBackgroundVersion !== background.version ||\n\t\t\t\tcurrentTonemapping !== renderer.toneMapping ) {\n\n\t\t\t\tplaneMesh.material.needsUpdate = true;\n\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = background.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\n\t\t\t}\n\n\n\t\t\t// push to the pre-sorted opaque render list\n\t\t\trenderList.unshift( planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null );\n\n\t\t}\n\n\t}\n\n\tfunction setClear( color, alpha ) {\n\n\t\tstate.buffers.color.setClear( color.r, color.g, color.b, alpha, premultipliedAlpha );\n\n\t}\n\n\treturn {\n\n\t\tgetClearColor: function () {\n\n\t\t\treturn clearColor;\n\n\t\t},\n\t\tsetClearColor: function ( color, alpha ) {\n\n\t\t\tclearColor.set( color );\n\t\t\tclearAlpha = alpha !== undefined ? alpha : 1;\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t},\n\t\tgetClearAlpha: function () {\n\n\t\t\treturn clearAlpha;\n\n\t\t},\n\t\tsetClearAlpha: function ( alpha ) {\n\n\t\t\tclearAlpha = alpha;\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t},\n\t\trender: render\n\n\t};\n\n}\n\n\nexport { WebGLBackground };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n * @author Takahiro / https://github.com/takahirox\n */\n\nfunction WebGLBindingStates( gl, extensions, attributes, capabilities ) {\n\n\tconst maxVertexAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );\n\n\tconst extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' );\n\tconst vaoAvailable = capabilities.isWebGL2 || extension !== null;\n\n\tconst bindingStates = {};\n\n\tconst defaultState = createBindingState( null );\n\tlet currentState = defaultState;\n\n\tfunction setup( object, material, program, geometry, index ) {\n\n\t\tlet updateBuffers = false;\n\n\t\tif ( vaoAvailable ) {\n\n\t\t\tconst state = getBindingState( geometry, program, material );\n\n\t\t\tif ( currentState !== state ) {\n\n\t\t\t\tcurrentState = state;\n\t\t\t\tbindVertexArrayObject( currentState.object );\n\n\t\t\t}\n\n\t\t\tupdateBuffers = needsUpdate( geometry );\n\n\t\t\tif ( updateBuffers ) saveCache( geometry );\n\n\t\t} else {\n\n\t\t\tconst wireframe = ( material.wireframe === true );\n\n\t\t\tif ( currentState.geometry !== geometry.id ||\n\t\t\t\tcurrentState.program !== program.id ||\n\t\t\t\tcurrentState.wireframe !== wireframe ) {\n\n\t\t\t\tcurrentState.geometry = geometry.id;\n\t\t\t\tcurrentState.program = program.id;\n\t\t\t\tcurrentState.wireframe = wireframe;\n\n\t\t\t\tupdateBuffers = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh === true ) {\n\n\t\t\tupdateBuffers = true;\n\n\t\t}\n\n\t\tif ( index !== null ) {\n\n\t\t\tattributes.update( index, gl.ELEMENT_ARRAY_BUFFER );\n\n\t\t}\n\n\t\tif ( updateBuffers ) {\n\n\t\t\tsetupVertexAttributes( object, material, program, geometry );\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tgl.bindBuffer( gl.ELEMENT_ARRAY_BUFFER, attributes.get( index ).buffer );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction createVertexArrayObject() {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.createVertexArray();\n\n\t\treturn extension.createVertexArrayOES();\n\n\t}\n\n\tfunction bindVertexArrayObject( vao ) {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.bindVertexArray( vao );\n\n\t\treturn extension.bindVertexArrayOES( vao );\n\n\t}\n\n\tfunction deleteVertexArrayObject( vao ) {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.deleteVertexArray( vao );\n\n\t\treturn extension.deleteVertexArrayOES( vao );\n\n\t}\n\n\tfunction getBindingState( geometry, program, material ) {\n\n\t\tconst wireframe = ( material.wireframe === true );\n\n\t\tlet programMap = bindingStates[ geometry.id ];\n\n\t\tif ( programMap === undefined ) {\n\n\t\t\tprogramMap = {};\n\t\t\tbindingStates[ geometry.id ] = programMap;\n\n\t\t}\n\n\t\tlet stateMap = programMap[ program.id ];\n\n\t\tif ( stateMap === undefined ) {\n\n\t\t\tstateMap = {};\n\t\t\tprogramMap[ program.id ] = stateMap;\n\n\t\t}\n\n\t\tlet state = stateMap[ wireframe ];\n\n\t\tif ( state === undefined ) {\n\n\t\t\tstate = createBindingState( createVertexArrayObject() );\n\t\t\tstateMap[ wireframe ] = state;\n\n\t\t}\n\n\t\treturn state;\n\n\t}\n\n\tfunction createBindingState( vao ) {\n\n\t\tconst newAttributes = [];\n\t\tconst enabledAttributes = [];\n\t\tconst attributeDivisors = [];\n\n\t\tfor ( let i = 0; i < maxVertexAttributes; i ++ ) {\n\n\t\t\tnewAttributes[ i ] = 0;\n\t\t\tenabledAttributes[ i ] = 0;\n\t\t\tattributeDivisors[ i ] = 0;\n\n\t\t}\n\n\t\treturn {\n\n\t\t\t// for backward compatibility on non-VAO support browser\n\t\t\tgeometry: null,\n\t\t\tprogram: null,\n\t\t\twireframe: false,\n\n\t\t\tnewAttributes: newAttributes,\n\t\t\tenabledAttributes: enabledAttributes,\n\t\t\tattributeDivisors: attributeDivisors,\n\t\t\tobject: vao,\n\t\t\tattributes: {}\n\n\t\t};\n\n\t}\n\n\tfunction needsUpdate( geometry ) {\n\n\t\tconst cachedAttributes = currentState.attributes;\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\tif ( Object.keys( cachedAttributes ).length !== Object.keys( geometryAttributes ).length ) return true;\n\n\t\tfor ( const key in geometryAttributes ) {\n\n\t\t\tconst cachedAttribute = cachedAttributes[ key ];\n\t\t\tconst geometryAttribute = geometryAttributes[ key ];\n\n\t\t\tif ( cachedAttribute.attribute !== geometryAttribute ) return true;\n\n\t\t\tif ( cachedAttribute.data !== geometryAttribute.data ) return true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tfunction saveCache( geometry ) {\n\n\t\tconst cache = {};\n\t\tconst attributes = geometry.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tconst attribute = attributes[ key ];\n\n\t\t\tconst data = {};\n\t\t\tdata.attribute = attribute;\n\n\t\t\tif ( attribute.data ) {\n\n\t\t\t\tdata.data = attribute.data;\n\n\t\t\t}\n\n\t\t\tcache[ key ] = data;\n\n\t\t}\n\n\t\tcurrentState.attributes = cache;\n\n\t}\n\n\tfunction initAttributes() {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\n\t\tfor ( let i = 0, il = newAttributes.length; i < il; i ++ ) {\n\n\t\t\tnewAttributes[ i ] = 0;\n\n\t\t}\n\n\t}\n\n\tfunction enableAttribute( attribute ) {\n\n\t\tenableAttributeAndDivisor( attribute, 0 );\n\n\t}\n\n\tfunction enableAttributeAndDivisor( attribute, meshPerAttribute ) {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\t\tconst attributeDivisors = currentState.attributeDivisors;\n\n\t\tnewAttributes[ attribute ] = 1;\n\n\t\tif ( enabledAttributes[ attribute ] === 0 ) {\n\n\t\t\tgl.enableVertexAttribArray( attribute );\n\t\t\tenabledAttributes[ attribute ] = 1;\n\n\t\t}\n\n\t\tif ( attributeDivisors[ attribute ] !== meshPerAttribute ) {\n\n\t\t\tconst extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t\textension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );\n\t\t\tattributeDivisors[ attribute ] = meshPerAttribute;\n\n\t\t}\n\n\t}\n\n\tfunction disableUnusedAttributes() {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\n\t\tfor ( let i = 0, il = enabledAttributes.length; i < il; i ++ ) {\n\n\t\t\tif ( enabledAttributes[ i ] !== newAttributes[ i ] ) {\n\n\t\t\t\tgl.disableVertexAttribArray( i );\n\t\t\t\tenabledAttributes[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction vertexAttribPointer( index, size, type, normalized, stride, offset ) {\n\n\t\tif ( capabilities.isWebGL2 === true && ( type === gl.INT || type === gl.UNSIGNED_INT ) ) {\n\n\t\t\tgl.vertexAttribIPointer( index, size, type, normalized, stride, offset );\n\n\t\t} else {\n\n\t\t\tgl.vertexAttribPointer( index, size, type, normalized, stride, offset );\n\n\t\t}\n\n\t}\n\n\tfunction setupVertexAttributes( object, material, program, geometry ) {\n\n\t\tif ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) {\n\n\t\t\tif ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return;\n\n\t\t}\n\n\t\tinitAttributes();\n\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tconst materialDefaultAttributeValues = material.defaultAttributeValues;\n\n\t\tfor ( const name in programAttributes ) {\n\n\t\t\tconst programAttribute = programAttributes[ name ];\n\n\t\t\tif ( programAttribute >= 0 ) {\n\n\t\t\t\tconst geometryAttribute = geometryAttributes[ name ];\n\n\t\t\t\tif ( geometryAttribute !== undefined ) {\n\n\t\t\t\t\tconst normalized = geometryAttribute.normalized;\n\t\t\t\t\tconst size = geometryAttribute.itemSize;\n\n\t\t\t\t\tconst attribute = attributes.get( geometryAttribute );\n\n\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\t\t\t\t\tconst bytesPerElement = attribute.bytesPerElement;\n\n\t\t\t\t\tif ( geometryAttribute.isInterleavedBufferAttribute ) {\n\n\t\t\t\t\t\tconst data = geometryAttribute.data;\n\t\t\t\t\t\tconst stride = data.stride;\n\t\t\t\t\t\tconst offset = geometryAttribute.offset;\n\n\t\t\t\t\t\tif ( data && data.isInstancedInterleavedBuffer ) {\n\n\t\t\t\t\t\t\tenableAttributeAndDivisor( programAttribute, data.meshPerAttribute );\n\n\t\t\t\t\t\t\tif ( geometry._maxInstanceCount === undefined ) {\n\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = data.meshPerAttribute * data.count;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tenableAttribute( programAttribute );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\t\t\t\t\t\tvertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( geometryAttribute.isInstancedBufferAttribute ) {\n\n\t\t\t\t\t\t\tenableAttributeAndDivisor( programAttribute, geometryAttribute.meshPerAttribute );\n\n\t\t\t\t\t\t\tif ( geometry._maxInstanceCount === undefined ) {\n\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tenableAttribute( programAttribute );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\t\t\t\t\t\tvertexAttribPointer( programAttribute, size, type, normalized, 0, 0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( name === 'instanceMatrix' ) {\n\n\t\t\t\t\tconst attribute = attributes.get( object.instanceMatrix );\n\n\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 0, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 1, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 2, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 3, 1 );\n\n\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 0, 4, type, false, 64, 0 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 1, 4, type, false, 64, 16 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 2, 4, type, false, 64, 32 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 3, 4, type, false, 64, 48 );\n\n\t\t\t\t} else if ( materialDefaultAttributeValues !== undefined ) {\n\n\t\t\t\t\tconst value = materialDefaultAttributeValues[ name ];\n\n\t\t\t\t\tif ( value !== undefined ) {\n\n\t\t\t\t\t\tswitch ( value.length ) {\n\n\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\tgl.vertexAttrib2fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\tgl.vertexAttrib3fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\tgl.vertexAttrib4fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tgl.vertexAttrib1fv( programAttribute, value );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tdisableUnusedAttributes();\n\n\t}\n\n\tfunction dispose() {\n\n\t\treset();\n\n\t\tfor ( const geometryId in bindingStates ) {\n\n\t\t\tconst programMap = bindingStates[ geometryId ];\n\n\t\t\tfor ( const programId in programMap ) {\n\n\t\t\t\tconst stateMap = programMap[ programId ];\n\n\t\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t\t}\n\n\t\t\t\tdelete programMap[ programId ];\n\n\t\t\t}\n\n\t\t\tdelete bindingStates[ geometryId ];\n\n\t\t}\n\n\t}\n\n\tfunction releaseStatesOfGeometry( geometry ) {\n\n\t\tif ( bindingStates[ geometry.id ] === undefined ) return;\n\n\t\tconst programMap = bindingStates[ geometry.id ];\n\n\t\tfor ( const programId in programMap ) {\n\n\t\t\tconst stateMap = programMap[ programId ];\n\n\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t}\n\n\t\t\tdelete programMap[ programId ];\n\n\t\t}\n\n\t\tdelete bindingStates[ geometry.id ];\n\n\t}\n\n\tfunction releaseStatesOfProgram( program ) {\n\n\t\tfor ( const geometryId in bindingStates ) {\n\n\t\t\tconst programMap = bindingStates[ geometryId ];\n\n\t\t\tif ( programMap[ program.id ] === undefined ) continue;\n\n\t\t\tconst stateMap = programMap[ program.id ];\n\n\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t}\n\n\t\t\tdelete programMap[ program.id ];\n\n\t\t}\n\n\t}\n\n\tfunction reset() {\n\n\t\tresetDefaultState();\n\n\t\tif ( currentState === defaultState ) return;\n\n\t\tcurrentState = defaultState;\n\t\tbindVertexArrayObject( currentState.object );\n\n\t}\n\n\t// for backward-compatilibity\n\n\tfunction resetDefaultState() {\n\n\t\tdefaultState.geometry = null;\n\t\tdefaultState.program = null;\n\t\tdefaultState.wireframe = false;\n\n\t}\n\n\treturn {\n\n\t\tsetup: setup,\n\t\treset: reset,\n\t\tresetDefaultState: resetDefaultState,\n\t\tdispose: dispose,\n\t\treleaseStatesOfGeometry: releaseStatesOfGeometry,\n\t\treleaseStatesOfProgram: releaseStatesOfProgram,\n\n\t\tinitAttributes: initAttributes,\n\t\tenableAttribute: enableAttribute,\n\t\tdisableUnusedAttributes: disableUnusedAttributes\n\n\t};\n\n}\n\n\nexport { WebGLBindingStates };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLBufferRenderer( gl, extensions, info, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tlet mode;\n\n\tfunction setMode( value ) {\n\n\t\tmode = value;\n\n\t}\n\n\tfunction render( start, count ) {\n\n\t\tgl.drawArrays( mode, start, count );\n\n\t\tinfo.update( count, mode );\n\n\t}\n\n\tfunction renderInstances( geometry, start, count, primcount ) {\n\n\t\tif ( primcount === 0 ) return;\n\n\t\tlet extension, methodName;\n\n\t\tif ( isWebGL2 ) {\n\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawArraysInstanced';\n\n\t\t} else {\n\n\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\t\t\tmethodName = 'drawArraysInstancedANGLE';\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\textension[ methodName ]( mode, start, count, primcount );\n\n\t\tinfo.update( count, mode, primcount );\n\n\t}\n\n\t//\n\n\tthis.setMode = setMode;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n\n}\n\n\nexport { WebGLBufferRenderer };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLCapabilities( gl, extensions, parameters ) {\n\n\tlet maxAnisotropy;\n\n\tfunction getMaxAnisotropy() {\n\n\t\tif ( maxAnisotropy !== undefined ) return maxAnisotropy;\n\n\t\tconst extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\tif ( extension !== null ) {\n\n\t\t\tmaxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT );\n\n\t\t} else {\n\n\t\t\tmaxAnisotropy = 0;\n\n\t\t}\n\n\t\treturn maxAnisotropy;\n\n\t}\n\n\tfunction getMaxPrecision( precision ) {\n\n\t\tif ( precision === 'highp' ) {\n\n\t\t\tif ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&\n\t\t\t\tgl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0 ) {\n\n\t\t\t\treturn 'highp';\n\n\t\t\t}\n\n\t\t\tprecision = 'mediump';\n\n\t\t}\n\n\t\tif ( precision === 'mediump' ) {\n\n\t\t\tif ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&\n\t\t\t\tgl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0 ) {\n\n\t\t\t\treturn 'mediump';\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn 'lowp';\n\n\t}\n\n\t/* eslint-disable no-undef */\n\tconst isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) ||\n\t\t( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext );\n\t/* eslint-enable no-undef */\n\n\tlet precision = parameters.precision !== undefined ? parameters.precision : 'highp';\n\tconst maxPrecision = getMaxPrecision( precision );\n\n\tif ( maxPrecision !== precision ) {\n\n\t\tconsole.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );\n\t\tprecision = maxPrecision;\n\n\t}\n\n\tconst logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;\n\n\tconst maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );\n\tconst maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );\n\tconst maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );\n\tconst maxCubemapSize = gl.getParameter( gl.MAX_CUBE_MAP_TEXTURE_SIZE );\n\n\tconst maxAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );\n\tconst maxVertexUniforms = gl.getParameter( gl.MAX_VERTEX_UNIFORM_VECTORS );\n\tconst maxVaryings = gl.getParameter( gl.MAX_VARYING_VECTORS );\n\tconst maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );\n\n\tconst vertexTextures = maxVertexTextures > 0;\n\tconst floatFragmentTextures = isWebGL2 || !! extensions.get( 'OES_texture_float' );\n\tconst floatVertexTextures = vertexTextures && floatFragmentTextures;\n\n\tconst maxSamples = isWebGL2 ? gl.getParameter( gl.MAX_SAMPLES ) : 0;\n\n\treturn {\n\n\t\tisWebGL2: isWebGL2,\n\n\t\tgetMaxAnisotropy: getMaxAnisotropy,\n\t\tgetMaxPrecision: getMaxPrecision,\n\n\t\tprecision: precision,\n\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\tmaxTextures: maxTextures,\n\t\tmaxVertexTextures: maxVertexTextures,\n\t\tmaxTextureSize: maxTextureSize,\n\t\tmaxCubemapSize: maxCubemapSize,\n\n\t\tmaxAttributes: maxAttributes,\n\t\tmaxVertexUniforms: maxVertexUniforms,\n\t\tmaxVaryings: maxVaryings,\n\t\tmaxFragmentUniforms: maxFragmentUniforms,\n\n\t\tvertexTextures: vertexTextures,\n\t\tfloatFragmentTextures: floatFragmentTextures,\n\t\tfloatVertexTextures: floatVertexTextures,\n\n\t\tmaxSamples: maxSamples\n\n\t};\n\n}\n\n\nexport { WebGLCapabilities };\n","/**\n * @author tschw\n */\n\nimport { Matrix3 } from '../../math/Matrix3.js';\nimport { Plane } from '../../math/Plane.js';\n\nfunction WebGLClipping() {\n\n\tconst scope = this;\n\n\tlet globalState = null,\n\t\tnumGlobalPlanes = 0,\n\t\tlocalClippingEnabled = false,\n\t\trenderingShadows = false;\n\n\tconst plane = new Plane(),\n\t\tviewNormalMatrix = new Matrix3(),\n\n\t\tuniform = { value: null, needsUpdate: false };\n\n\tthis.uniform = uniform;\n\tthis.numPlanes = 0;\n\tthis.numIntersection = 0;\n\n\tthis.init = function ( planes, enableLocalClipping, camera ) {\n\n\t\tconst enabled =\n\t\t\tplanes.length !== 0 ||\n\t\t\tenableLocalClipping ||\n\t\t\t// enable state of previous frame - the clipping code has to\n\t\t\t// run another frame in order to reset the state:\n\t\t\tnumGlobalPlanes !== 0 ||\n\t\t\tlocalClippingEnabled;\n\n\t\tlocalClippingEnabled = enableLocalClipping;\n\n\t\tglobalState = projectPlanes( planes, camera, 0 );\n\t\tnumGlobalPlanes = planes.length;\n\n\t\treturn enabled;\n\n\t};\n\n\tthis.beginShadows = function () {\n\n\t\trenderingShadows = true;\n\t\tprojectPlanes( null );\n\n\t};\n\n\tthis.endShadows = function () {\n\n\t\trenderingShadows = false;\n\t\tresetGlobalState();\n\n\t};\n\n\tthis.setState = function ( planes, clipIntersection, clipShadows, camera, cache, fromCache ) {\n\n\t\tif ( ! localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && ! clipShadows ) {\n\n\t\t\t// there's no local clipping\n\n\t\t\tif ( renderingShadows ) {\n\n\t\t\t\t// there's no global clipping\n\n\t\t\t\tprojectPlanes( null );\n\n\t\t\t} else {\n\n\t\t\t\tresetGlobalState();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst nGlobal = renderingShadows ? 0 : numGlobalPlanes,\n\t\t\t\tlGlobal = nGlobal * 4;\n\n\t\t\tlet dstArray = cache.clippingState || null;\n\n\t\t\tuniform.value = dstArray; // ensure unique state\n\n\t\t\tdstArray = projectPlanes( planes, camera, lGlobal, fromCache );\n\n\t\t\tfor ( let i = 0; i !== lGlobal; ++ i ) {\n\n\t\t\t\tdstArray[ i ] = globalState[ i ];\n\n\t\t\t}\n\n\t\t\tcache.clippingState = dstArray;\n\t\t\tthis.numIntersection = clipIntersection ? this.numPlanes : 0;\n\t\t\tthis.numPlanes += nGlobal;\n\n\t\t}\n\n\n\t};\n\n\tfunction resetGlobalState() {\n\n\t\tif ( uniform.value !== globalState ) {\n\n\t\t\tuniform.value = globalState;\n\t\t\tuniform.needsUpdate = numGlobalPlanes > 0;\n\n\t\t}\n\n\t\tscope.numPlanes = numGlobalPlanes;\n\t\tscope.numIntersection = 0;\n\n\t}\n\n\tfunction projectPlanes( planes, camera, dstOffset, skipTransform ) {\n\n\t\tlet nPlanes = planes !== null ? planes.length : 0,\n\t\t\tdstArray = null;\n\n\t\tif ( nPlanes !== 0 ) {\n\n\t\t\tdstArray = uniform.value;\n\n\t\t\tif ( skipTransform !== true || dstArray === null ) {\n\n\t\t\t\tconst flatSize = dstOffset + nPlanes * 4,\n\t\t\t\t\tviewMatrix = camera.matrixWorldInverse;\n\n\t\t\t\tviewNormalMatrix.getNormalMatrix( viewMatrix );\n\n\t\t\t\tif ( dstArray === null || dstArray.length < flatSize ) {\n\n\t\t\t\t\tdstArray = new Float32Array( flatSize );\n\n\t\t\t\t}\n\n\t\t\t\tfor ( let i = 0, i4 = dstOffset; i !== nPlanes; ++ i, i4 += 4 ) {\n\n\t\t\t\t\tplane.copy( planes[ i ] ).applyMatrix4( viewMatrix, viewNormalMatrix );\n\n\t\t\t\t\tplane.normal.toArray( dstArray, i4 );\n\t\t\t\t\tdstArray[ i4 + 3 ] = plane.constant;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tuniform.value = dstArray;\n\t\t\tuniform.needsUpdate = true;\n\n\t\t}\n\n\t\tscope.numPlanes = nPlanes;\n\t\tscope.numIntersection = 0;\n\n\t\treturn dstArray;\n\n\t}\n\n}\n\n\nexport { WebGLClipping };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLExtensions( gl ) {\n\n\tconst extensions = {};\n\n\treturn {\n\n\t\tget: function ( name ) {\n\n\t\t\tif ( extensions[ name ] !== undefined ) {\n\n\t\t\t\treturn extensions[ name ];\n\n\t\t\t}\n\n\t\t\tlet extension;\n\n\t\t\tswitch ( name ) {\n\n\t\t\t\tcase 'WEBGL_depth_texture':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'EXT_texture_filter_anisotropic':\n\t\t\t\t\textension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'WEBGL_compressed_texture_s3tc':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'WEBGL_compressed_texture_pvrtc':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\textension = gl.getExtension( name );\n\n\t\t\t}\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );\n\n\t\t\t}\n\n\t\t\textensions[ name ] = extension;\n\n\t\t\treturn extension;\n\n\t\t}\n\n\t};\n\n}\n\n\nexport { WebGLExtensions };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js';\nimport { BufferGeometry } from '../../core/BufferGeometry.js';\nimport { arrayMax } from '../../utils.js';\n\nfunction WebGLGeometries( gl, attributes, info, bindingStates ) {\n\n\tconst geometries = new WeakMap();\n\tconst wireframeAttributes = new WeakMap();\n\n\tfunction onGeometryDispose( event ) {\n\n\t\tconst geometry = event.target;\n\t\tconst buffergeometry = geometries.get( geometry );\n\n\t\tif ( buffergeometry.index !== null ) {\n\n\t\t\tattributes.remove( buffergeometry.index );\n\n\t\t}\n\n\t\tfor ( const name in buffergeometry.attributes ) {\n\n\t\t\tattributes.remove( buffergeometry.attributes[ name ] );\n\n\t\t}\n\n\t\tgeometry.removeEventListener( 'dispose', onGeometryDispose );\n\n\t\tgeometries.delete( geometry );\n\n\t\tconst attribute = wireframeAttributes.get( buffergeometry );\n\n\t\tif ( attribute ) {\n\n\t\t\tattributes.remove( attribute );\n\t\t\twireframeAttributes.delete( buffergeometry );\n\n\t\t}\n\n\t\tbindingStates.releaseStatesOfGeometry( geometry );\n\n\t\tif ( geometry.isInstancedBufferGeometry === true ) {\n\n\t\t\tdelete geometry._maxInstanceCount;\n\n\t\t}\n\n\t\t//\n\n\t\tinfo.memory.geometries --;\n\n\t}\n\n\tfunction get( object, geometry ) {\n\n\t\tlet buffergeometry = geometries.get( geometry );\n\n\t\tif ( buffergeometry ) return buffergeometry;\n\n\t\tgeometry.addEventListener( 'dispose', onGeometryDispose );\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tbuffergeometry = geometry;\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tif ( geometry._bufferGeometry === undefined ) {\n\n\t\t\t\tgeometry._bufferGeometry = new BufferGeometry().setFromObject( object );\n\n\t\t\t}\n\n\t\t\tbuffergeometry = geometry._bufferGeometry;\n\n\t\t}\n\n\t\tgeometries.set( geometry, buffergeometry );\n\n\t\tinfo.memory.geometries ++;\n\n\t\treturn buffergeometry;\n\n\t}\n\n\tfunction update( geometry ) {\n\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\t// Updating index buffer in VAO now. See WebGLBindingStates.\n\n\t\tfor ( const name in geometryAttributes ) {\n\n\t\t\tattributes.update( geometryAttributes[ name ], gl.ARRAY_BUFFER );\n\n\t\t}\n\n\t\t// morph targets\n\n\t\tconst morphAttributes = geometry.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst array = morphAttributes[ name ];\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\tattributes.update( array[ i ], gl.ARRAY_BUFFER );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction updateWireframeAttribute( geometry ) {\n\n\t\tconst indices = [];\n\n\t\tconst geometryIndex = geometry.index;\n\t\tconst geometryPosition = geometry.attributes.position;\n\t\tlet version = 0;\n\n\t\tif ( geometryIndex !== null ) {\n\n\t\t\tconst array = geometryIndex.array;\n\t\t\tversion = geometryIndex.version;\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\t\tconst a = array[ i + 0 ];\n\t\t\t\tconst b = array[ i + 1 ];\n\t\t\t\tconst c = array[ i + 2 ];\n\n\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst array = geometryPosition.array;\n\t\t\tversion = geometryPosition.version;\n\n\t\t\tfor ( let i = 0, l = ( array.length / 3 ) - 1; i < l; i += 3 ) {\n\n\t\t\t\tconst a = i + 0;\n\t\t\t\tconst b = i + 1;\n\t\t\t\tconst c = i + 2;\n\n\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst attribute = new ( arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );\n\t\tattribute.version = version;\n\n\t\t// Updating index buffer in VAO now. See WebGLBindingStates\n\n\t\t//\n\n\t\tconst previousAttribute = wireframeAttributes.get( geometry );\n\n\t\tif ( previousAttribute ) attributes.remove( previousAttribute );\n\n\t\t//\n\n\t\twireframeAttributes.set( geometry, attribute );\n\n\t}\n\n\tfunction getWireframeAttribute( geometry ) {\n\n\t\tconst currentAttribute = wireframeAttributes.get( geometry );\n\n\t\tif ( currentAttribute ) {\n\n\t\t\tconst geometryIndex = geometry.index;\n\n\t\t\tif ( geometryIndex !== null ) {\n\n\t\t\t\t// if the attribute is obsolete, create a new one\n\n\t\t\t\tif ( currentAttribute.version < geometryIndex.version ) {\n\n\t\t\t\t\tupdateWireframeAttribute( geometry );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tupdateWireframeAttribute( geometry );\n\n\t\t}\n\n\t\treturn wireframeAttributes.get( geometry );\n\n\t}\n\n\treturn {\n\n\t\tget: get,\n\t\tupdate: update,\n\n\t\tgetWireframeAttribute: getWireframeAttribute\n\n\t};\n\n}\n\n\nexport { WebGLGeometries };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tlet mode;\n\n\tfunction setMode( value ) {\n\n\t\tmode = value;\n\n\t}\n\n\tlet type, bytesPerElement;\n\n\tfunction setIndex( value ) {\n\n\t\ttype = value.type;\n\t\tbytesPerElement = value.bytesPerElement;\n\n\t}\n\n\tfunction render( start, count ) {\n\n\t\tgl.drawElements( mode, count, type, start * bytesPerElement );\n\n\t\tinfo.update( count, mode );\n\n\t}\n\n\tfunction renderInstances( geometry, start, count, primcount ) {\n\n\t\tif ( primcount === 0 ) return;\n\n\t\tlet extension, methodName;\n\n\t\tif ( isWebGL2 ) {\n\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawElementsInstanced';\n\n\t\t} else {\n\n\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\t\t\tmethodName = 'drawElementsInstancedANGLE';\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\textension[ methodName ]( mode, count, type, start * bytesPerElement, primcount );\n\n\t\tinfo.update( count, mode, primcount );\n\n\t}\n\n\t//\n\n\tthis.setMode = setMode;\n\tthis.setIndex = setIndex;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n\n}\n\n\nexport { WebGLIndexedBufferRenderer };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nfunction WebGLInfo( gl ) {\n\n\tconst memory = {\n\t\tgeometries: 0,\n\t\ttextures: 0\n\t};\n\n\tconst render = {\n\t\tframe: 0,\n\t\tcalls: 0,\n\t\ttriangles: 0,\n\t\tpoints: 0,\n\t\tlines: 0\n\t};\n\n\tfunction update( count, mode, instanceCount ) {\n\n\t\tinstanceCount = instanceCount || 1;\n\n\t\trender.calls ++;\n\n\t\tswitch ( mode ) {\n\n\t\t\tcase gl.TRIANGLES:\n\t\t\t\trender.triangles += instanceCount * ( count / 3 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINES:\n\t\t\t\trender.lines += instanceCount * ( count / 2 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_STRIP:\n\t\t\t\trender.lines += instanceCount * ( count - 1 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_LOOP:\n\t\t\t\trender.lines += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tcase gl.POINTS:\n\t\t\t\trender.points += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.error( 'THREE.WebGLInfo: Unknown draw mode:', mode );\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tfunction reset() {\n\n\t\trender.frame ++;\n\t\trender.calls = 0;\n\t\trender.triangles = 0;\n\t\trender.points = 0;\n\t\trender.lines = 0;\n\n\t}\n\n\treturn {\n\t\tmemory: memory,\n\t\trender: render,\n\t\tprograms: null,\n\t\tautoReset: true,\n\t\treset: reset,\n\t\tupdate: update\n\t};\n\n}\n\n\nexport { WebGLInfo };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction numericalSort( a, b ) {\n\n\treturn a[ 0 ] - b[ 0 ];\n\n}\n\nfunction absNumericalSort( a, b ) {\n\n\treturn Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );\n\n}\n\nfunction WebGLMorphtargets( gl ) {\n\n\tconst influencesList = {};\n\tconst morphInfluences = new Float32Array( 8 );\n\n\tconst workInfluences = [];\n\n\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\tworkInfluences[ i ] = [ i, 0 ];\n\n\t}\n\n\tfunction update( object, geometry, material, program ) {\n\n\t\tconst objectInfluences = object.morphTargetInfluences;\n\n\t\t// When object doesn't have morph target influences defined, we treat it as a 0-length array\n\t\t// This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences\n\n\t\tconst length = objectInfluences === undefined ? 0 : objectInfluences.length;\n\n\t\tlet influences = influencesList[ geometry.id ];\n\n\t\tif ( influences === undefined ) {\n\n\t\t\t// initialise list\n\n\t\t\tinfluences = [];\n\n\t\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\t\tinfluences[ i ] = [ i, 0 ];\n\n\t\t\t}\n\n\t\t\tinfluencesList[ geometry.id ] = influences;\n\n\t\t}\n\n\t\t// Collect influences\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tconst influence = influences[ i ];\n\n\t\t\tinfluence[ 0 ] = i;\n\t\t\tinfluence[ 1 ] = objectInfluences[ i ];\n\n\t\t}\n\n\t\tinfluences.sort( absNumericalSort );\n\n\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\tif ( i < length && influences[ i ][ 1 ] ) {\n\n\t\t\t\tworkInfluences[ i ][ 0 ] = influences[ i ][ 0 ];\n\t\t\t\tworkInfluences[ i ][ 1 ] = influences[ i ][ 1 ];\n\n\t\t\t} else {\n\n\t\t\t\tworkInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER;\n\t\t\t\tworkInfluences[ i ][ 1 ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tworkInfluences.sort( numericalSort );\n\n\t\tconst morphTargets = material.morphTargets && geometry.morphAttributes.position;\n\t\tconst morphNormals = material.morphNormals && geometry.morphAttributes.normal;\n\n\t\tlet morphInfluencesSum = 0;\n\n\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\tconst influence = workInfluences[ i ];\n\t\t\tconst index = influence[ 0 ];\n\t\t\tconst value = influence[ 1 ];\n\n\t\t\tif ( index !== Number.MAX_SAFE_INTEGER && value ) {\n\n\t\t\t\tif ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) {\n\n\t\t\t\t\tgeometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] );\n\n\t\t\t\t}\n\n\t\t\t\tif ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) {\n\n\t\t\t\t\tgeometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] );\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = value;\n\t\t\t\tmorphInfluencesSum += value;\n\n\t\t\t} else {\n\n\t\t\t\tif ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== undefined ) {\n\n\t\t\t\t\tgeometry.deleteAttribute( 'morphTarget' + i );\n\n\t\t\t\t}\n\n\t\t\t\tif ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== undefined ) {\n\n\t\t\t\t\tgeometry.deleteAttribute( 'morphNormal' + i );\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// GLSL shader uses formula baseinfluence * base + sum(target * influence)\n\t\t// This allows us to switch between absolute morphs and relative morphs without changing shader code\n\t\t// When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)\n\t\tconst morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;\n\n\t\tprogram.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );\n\t\tprogram.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences );\n\n\t}\n\n\treturn {\n\n\t\tupdate: update\n\n\t};\n\n}\n\n\nexport { WebGLMorphtargets };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLObjects( gl, geometries, attributes, info ) {\n\n\tlet updateMap = new WeakMap();\n\n\tfunction update( object ) {\n\n\t\tconst frame = info.render.frame;\n\n\t\tconst geometry = object.geometry;\n\t\tconst buffergeometry = geometries.get( object, geometry );\n\n\t\t// Update once per frame\n\n\t\tif ( updateMap.get( buffergeometry ) !== frame ) {\n\n\t\t\tif ( geometry.isGeometry ) {\n\n\t\t\t\tbuffergeometry.updateFromObject( object );\n\n\t\t\t}\n\n\t\t\tgeometries.update( buffergeometry );\n\n\t\t\tupdateMap.set( buffergeometry, frame );\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh ) {\n\n\t\t\tattributes.update( object.instanceMatrix, gl.ARRAY_BUFFER );\n\n\t\t}\n\n\t\treturn buffergeometry;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tupdateMap = new WeakMap();\n\n\t}\n\n\treturn {\n\n\t\tupdate: update,\n\t\tdispose: dispose\n\n\t};\n\n}\n\n\nexport { WebGLObjects };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Texture } from './Texture.js';\nimport { CubeReflectionMapping, RGBFormat } from '../constants.js';\n\nfunction CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\timages = images !== undefined ? images : [];\n\tmapping = mapping !== undefined ? mapping : CubeReflectionMapping;\n\tformat = format !== undefined ? format : RGBFormat;\n\n\tTexture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\tthis.flipY = false;\n\n}\n\nCubeTexture.prototype = Object.create( Texture.prototype );\nCubeTexture.prototype.constructor = CubeTexture;\n\nCubeTexture.prototype.isCubeTexture = true;\n\nObject.defineProperty( CubeTexture.prototype, 'images', {\n\n\tget: function () {\n\n\t\treturn this.image;\n\n\t},\n\n\tset: function ( value ) {\n\n\t\tthis.image = value;\n\n\t}\n\n} );\n\n\nexport { CubeTexture };\n","/**\n * @author Takahiro https://github.com/takahirox\n */\n\nimport { Texture } from './Texture.js';\nimport { ClampToEdgeWrapping, NearestFilter } from '../constants.js';\n\nfunction DataTexture2DArray( data, width, height, depth ) {\n\n\tTexture.call( this, null );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };\n\n\tthis.magFilter = NearestFilter;\n\tthis.minFilter = NearestFilter;\n\n\tthis.wrapR = ClampToEdgeWrapping;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\n\tthis.needsUpdate = true;\n\n}\n\nDataTexture2DArray.prototype = Object.create( Texture.prototype );\nDataTexture2DArray.prototype.constructor = DataTexture2DArray;\nDataTexture2DArray.prototype.isDataTexture2DArray = true;\n\nexport { DataTexture2DArray };\n","/**\n * @author Artur Trzesiok\n */\n\nimport { Texture } from './Texture.js';\nimport { ClampToEdgeWrapping, NearestFilter } from '../constants.js';\n\nfunction DataTexture3D( data, width, height, depth ) {\n\n\t// We're going to add .setXXX() methods for setting properties later.\n\t// Users can still set in DataTexture3D directly.\n\t//\n\t//\tconst texture = new THREE.DataTexture3D( data, width, height, depth );\n\t// \ttexture.anisotropy = 16;\n\t//\n\t// See #14839\n\n\tTexture.call( this, null );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };\n\n\tthis.magFilter = NearestFilter;\n\tthis.minFilter = NearestFilter;\n\n\tthis.wrapR = ClampToEdgeWrapping;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\n\tthis.needsUpdate = true;\n\n\n}\n\nDataTexture3D.prototype = Object.create( Texture.prototype );\nDataTexture3D.prototype.constructor = DataTexture3D;\nDataTexture3D.prototype.isDataTexture3D = true;\n\nexport { DataTexture3D };\n","/**\n * @author tschw\n * @author Mugen87 / https://github.com/Mugen87\n * @author mrdoob / http://mrdoob.com/\n *\n * Uniforms of a program.\n * Those form a tree structure with a special top-level container for the root,\n * which you get by calling 'new WebGLUniforms( gl, program )'.\n *\n *\n * Properties of inner nodes including the top-level container:\n *\n * .seq - array of nested uniforms\n * .map - nested uniforms by name\n *\n *\n * Methods of all nodes except the top-level container:\n *\n * .setValue( gl, value, [textures] )\n *\n * \t\tuploads a uniform value(s)\n * \tthe 'textures' parameter is needed for sampler uniforms\n *\n *\n * Static methods of the top-level container (textures factorizations):\n *\n * .upload( gl, seq, values, textures )\n *\n * \t\tsets uniforms in 'seq' to 'values[id].value'\n *\n * .seqWithValue( seq, values ) : filteredSeq\n *\n * \t\tfilters 'seq' entries with corresponding entry in values\n *\n *\n * Methods of the top-level container (textures factorizations):\n *\n * .setValue( gl, name, value, textures )\n *\n * \t\tsets uniform with name 'name' to 'value'\n *\n * .setOptional( gl, obj, prop )\n *\n * \t\tlike .set for an optional property of the object\n *\n */\n\nimport { CubeTexture } from '../../textures/CubeTexture.js';\nimport { Texture } from '../../textures/Texture.js';\nimport { DataTexture2DArray } from '../../textures/DataTexture2DArray.js';\nimport { DataTexture3D } from '../../textures/DataTexture3D.js';\n\nconst emptyTexture = new Texture();\nconst emptyTexture2dArray = new DataTexture2DArray();\nconst emptyTexture3d = new DataTexture3D();\nconst emptyCubeTexture = new CubeTexture();\n\n// --- Utilities ---\n\n// Array Caches (provide typed arrays for temporary by size)\n\nconst arrayCacheF32 = [];\nconst arrayCacheI32 = [];\n\n// Float32Array caches used for uploading Matrix uniforms\n\nconst mat4array = new Float32Array( 16 );\nconst mat3array = new Float32Array( 9 );\nconst mat2array = new Float32Array( 4 );\n\n// Flattening for arrays of vectors and matrices\n\nfunction flatten( array, nBlocks, blockSize ) {\n\n\tconst firstElem = array[ 0 ];\n\n\tif ( firstElem <= 0 || firstElem > 0 ) return array;\n\t// unoptimized: ! isNaN( firstElem )\n\t// see http://jacksondunstan.com/articles/983\n\n\tlet n = nBlocks * blockSize,\n\t\tr = arrayCacheF32[ n ];\n\n\tif ( r === undefined ) {\n\n\t\tr = new Float32Array( n );\n\t\tarrayCacheF32[ n ] = r;\n\n\t}\n\n\tif ( nBlocks !== 0 ) {\n\n\t\tfirstElem.toArray( r, 0 );\n\n\t\tfor ( let i = 1, offset = 0; i !== nBlocks; ++ i ) {\n\n\t\t\toffset += blockSize;\n\t\t\tarray[ i ].toArray( r, offset );\n\n\t\t}\n\n\t}\n\n\treturn r;\n\n}\n\nfunction arraysEqual( a, b ) {\n\n\tif ( a.length !== b.length ) return false;\n\n\tfor ( let i = 0, l = a.length; i < l; i ++ ) {\n\n\t\tif ( a[ i ] !== b[ i ] ) return false;\n\n\t}\n\n\treturn true;\n\n}\n\nfunction copyArray( a, b ) {\n\n\tfor ( let i = 0, l = b.length; i < l; i ++ ) {\n\n\t\ta[ i ] = b[ i ];\n\n\t}\n\n}\n\n// Texture unit allocation\n\nfunction allocTexUnits( textures, n ) {\n\n\tlet r = arrayCacheI32[ n ];\n\n\tif ( r === undefined ) {\n\n\t\tr = new Int32Array( n );\n\t\tarrayCacheI32[ n ] = r;\n\n\t}\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\tr[ i ] = textures.allocateTextureUnit();\n\n\t}\n\n\treturn r;\n\n}\n\n// --- Setters ---\n\n// Note: Defining these methods externally, because they come in a bunch\n// and this way their names minify.\n\n// Single scalar\n\nfunction setValueV1f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1f( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\n// Single float vector (from flat array or THREE.VectorN)\n\nfunction setValueV2f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {\n\n\t\t\tgl.uniform2f( this.addr, v.x, v.y );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform2fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\nfunction setValueV3f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {\n\n\t\t\tgl.uniform3f( this.addr, v.x, v.y, v.z );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\t\t\tcache[ 2 ] = v.z;\n\n\t\t}\n\n\t} else if ( v.r !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) {\n\n\t\t\tgl.uniform3f( this.addr, v.r, v.g, v.b );\n\n\t\t\tcache[ 0 ] = v.r;\n\t\t\tcache[ 1 ] = v.g;\n\t\t\tcache[ 2 ] = v.b;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform3fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\nfunction setValueV4f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {\n\n\t\t\tgl.uniform4f( this.addr, v.x, v.y, v.z, v.w );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\t\t\tcache[ 2 ] = v.z;\n\t\t\tcache[ 3 ] = v.w;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform4fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\n// Single matrix (from flat array or MatrixN)\n\nfunction setValueM2( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix2fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat2array.set( elements );\n\n\t\tgl.uniformMatrix2fv( this.addr, false, mat2array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\nfunction setValueM3( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix3fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat3array.set( elements );\n\n\t\tgl.uniformMatrix3fv( this.addr, false, mat3array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\nfunction setValueM4( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix4fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat4array.set( elements );\n\n\t\tgl.uniformMatrix4fv( this.addr, false, mat4array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\n// Single texture (2D / Cube)\n\nfunction setValueT1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.safeSetTexture2D( v || emptyTexture, unit );\n\n}\n\nfunction setValueT2DArray1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.setTexture2DArray( v || emptyTexture2dArray, unit );\n\n}\n\nfunction setValueT3D1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.setTexture3D( v || emptyTexture3d, unit );\n\n}\n\nfunction setValueT6( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.safeSetTextureCube( v || emptyCubeTexture, unit );\n\n}\n\n// Integer / Boolean vectors or arrays thereof (always flat arrays)\n\nfunction setValueV1i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1i( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\nfunction setValueV2i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform2iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\nfunction setValueV3i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform3iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\nfunction setValueV4i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform4iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\n// uint\n\nfunction setValueV1ui( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1ui( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\n// Helper to pick the right setter for the singular case\n\nfunction getSingularSetter( type ) {\n\n\tswitch ( type ) {\n\n\t\tcase 0x1406: return setValueV1f; // FLOAT\n\t\tcase 0x8b50: return setValueV2f; // _VEC2\n\t\tcase 0x8b51: return setValueV3f; // _VEC3\n\t\tcase 0x8b52: return setValueV4f; // _VEC4\n\n\t\tcase 0x8b5a: return setValueM2; // _MAT2\n\t\tcase 0x8b5b: return setValueM3; // _MAT3\n\t\tcase 0x8b5c: return setValueM4; // _MAT4\n\n\t\tcase 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL\n\t\tcase 0x8b53: case 0x8b57: return setValueV2i; // _VEC2\n\t\tcase 0x8b54: case 0x8b58: return setValueV3i; // _VEC3\n\t\tcase 0x8b55: case 0x8b59: return setValueV4i; // _VEC4\n\n\t\tcase 0x1405: return setValueV1ui; // UINT\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\t\tcase 0x8b62: // SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1;\n\n\t\tcase 0x8b5f: // SAMPLER_3D\n\t\tcase 0x8dcb: // INT_SAMPLER_3D\n\t\tcase 0x8dd3: // UNSIGNED_INT_SAMPLER_3D\n\t\t\treturn setValueT3D1;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\t\tcase 0x8dc5: // SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6;\n\n\t\tcase 0x8dc1: // SAMPLER_2D_ARRAY\n\t\tcase 0x8dcf: // INT_SAMPLER_2D_ARRAY\n\t\tcase 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY\n\t\tcase 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW\n\t\t\treturn setValueT2DArray1;\n\n\t}\n\n}\n\n// Array of scalars\nfunction setValueV1fArray( gl, v ) {\n\n\tgl.uniform1fv( this.addr, v );\n\n}\n\n// Integer / Boolean vectors or arrays thereof (always flat arrays)\nfunction setValueV1iArray( gl, v ) {\n\n\tgl.uniform1iv( this.addr, v );\n\n}\n\nfunction setValueV2iArray( gl, v ) {\n\n\tgl.uniform2iv( this.addr, v );\n\n}\n\nfunction setValueV3iArray( gl, v ) {\n\n\tgl.uniform3iv( this.addr, v );\n\n}\n\nfunction setValueV4iArray( gl, v ) {\n\n\tgl.uniform4iv( this.addr, v );\n\n}\n\n\n// Array of vectors (flat or from THREE classes)\n\nfunction setValueV2fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 2 );\n\n\tgl.uniform2fv( this.addr, data );\n\n}\n\nfunction setValueV3fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 3 );\n\n\tgl.uniform3fv( this.addr, data );\n\n}\n\nfunction setValueV4fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 4 );\n\n\tgl.uniform4fv( this.addr, data );\n\n}\n\n// Array of matrices (flat or from THREE clases)\n\nfunction setValueM2Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 4 );\n\n\tgl.uniformMatrix2fv( this.addr, false, data );\n\n}\n\nfunction setValueM3Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 9 );\n\n\tgl.uniformMatrix3fv( this.addr, false, data );\n\n}\n\nfunction setValueM4Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 16 );\n\n\tgl.uniformMatrix4fv( this.addr, false, data );\n\n}\n\n// Array of textures (2D / Cube)\n\nfunction setValueT1Array( gl, v, textures ) {\n\n\tconst n = v.length;\n\n\tconst units = allocTexUnits( textures, n );\n\n\tgl.uniform1iv( this.addr, units );\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\ttextures.safeSetTexture2D( v[ i ] || emptyTexture, units[ i ] );\n\n\t}\n\n}\n\nfunction setValueT6Array( gl, v, textures ) {\n\n\tconst n = v.length;\n\n\tconst units = allocTexUnits( textures, n );\n\n\tgl.uniform1iv( this.addr, units );\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\ttextures.safeSetTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );\n\n\t}\n\n}\n\n// Helper to pick the right setter for a pure (bottom-level) array\n\nfunction getPureArraySetter( type ) {\n\n\tswitch ( type ) {\n\n\t\tcase 0x1406: return setValueV1fArray; // FLOAT\n\t\tcase 0x8b50: return setValueV2fArray; // _VEC2\n\t\tcase 0x8b51: return setValueV3fArray; // _VEC3\n\t\tcase 0x8b52: return setValueV4fArray; // _VEC4\n\n\t\tcase 0x8b5a: return setValueM2Array; // _MAT2\n\t\tcase 0x8b5b: return setValueM3Array; // _MAT3\n\t\tcase 0x8b5c: return setValueM4Array; // _MAT4\n\n\t\tcase 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL\n\t\tcase 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2\n\t\tcase 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3\n\t\tcase 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\t\tcase 0x8b62: // SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1Array;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\t\tcase 0x8dc5: // SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6Array;\n\n\t}\n\n}\n\n// --- Uniform Classes ---\n\nfunction SingleUniform( id, activeInfo, addr ) {\n\n\tthis.id = id;\n\tthis.addr = addr;\n\tthis.cache = [];\n\tthis.setValue = getSingularSetter( activeInfo.type );\n\n\t// this.path = activeInfo.name; // DEBUG\n\n}\n\nfunction PureArrayUniform( id, activeInfo, addr ) {\n\n\tthis.id = id;\n\tthis.addr = addr;\n\tthis.cache = [];\n\tthis.size = activeInfo.size;\n\tthis.setValue = getPureArraySetter( activeInfo.type );\n\n\t// this.path = activeInfo.name; // DEBUG\n\n}\n\nPureArrayUniform.prototype.updateCache = function ( data ) {\n\n\tlet cache = this.cache;\n\n\tif ( data instanceof Float32Array && cache.length !== data.length ) {\n\n\t\tthis.cache = new Float32Array( data.length );\n\n\t}\n\n\tcopyArray( cache, data );\n\n};\n\nfunction StructuredUniform( id ) {\n\n\tthis.id = id;\n\n\tthis.seq = [];\n\tthis.map = {};\n\n}\n\nStructuredUniform.prototype.setValue = function ( gl, value, textures ) {\n\n\tconst seq = this.seq;\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ];\n\t\tu.setValue( gl, value[ u.id ], textures );\n\n\t}\n\n};\n\n// --- Top-level ---\n\n// Parser - builds up the property tree from the path strings\n\nconst RePathPart = /([\\w\\d_]+)(\\])?(\\[|\\.)?/g;\n\n// extracts\n// \t- the identifier (member name or array index)\n// - followed by an optional right bracket (found when array index)\n// - followed by an optional left bracket or dot (type of subscript)\n//\n// Note: These portions can be read in a non-overlapping fashion and\n// allow straightforward parsing of the hierarchy that WebGL encodes\n// in the uniform names.\n\nfunction addUniform( container, uniformObject ) {\n\n\tcontainer.seq.push( uniformObject );\n\tcontainer.map[ uniformObject.id ] = uniformObject;\n\n}\n\nfunction parseUniform( activeInfo, addr, container ) {\n\n\tconst path = activeInfo.name,\n\t\tpathLength = path.length;\n\n\t// reset RegExp object, because of the early exit of a previous run\n\tRePathPart.lastIndex = 0;\n\n\twhile ( true ) {\n\n\t\tconst match = RePathPart.exec( path ),\n\t\t\tmatchEnd = RePathPart.lastIndex;\n\n\t\tlet id = match[ 1 ],\n\t\t\tidIsIndex = match[ 2 ] === ']',\n\t\t\tsubscript = match[ 3 ];\n\n\t\tif ( idIsIndex ) id = id | 0; // convert to integer\n\n\t\tif ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) {\n\n\t\t\t// bare name or \"pure\" bottom-level array \"[0]\" suffix\n\n\t\t\taddUniform( container, subscript === undefined ?\n\t\t\t\tnew SingleUniform( id, activeInfo, addr ) :\n\t\t\t\tnew PureArrayUniform( id, activeInfo, addr ) );\n\n\t\t\tbreak;\n\n\t\t} else {\n\n\t\t\t// step into inner node / create it in case it doesn't exist\n\n\t\t\tconst map = container.map;\n\t\t\tlet next = map[ id ];\n\n\t\t\tif ( next === undefined ) {\n\n\t\t\t\tnext = new StructuredUniform( id );\n\t\t\t\taddUniform( container, next );\n\n\t\t\t}\n\n\t\t\tcontainer = next;\n\n\t\t}\n\n\t}\n\n}\n\n// Root Container\n\nfunction WebGLUniforms( gl, program ) {\n\n\tthis.seq = [];\n\tthis.map = {};\n\n\tconst n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );\n\n\tfor ( let i = 0; i < n; ++ i ) {\n\n\t\tconst info = gl.getActiveUniform( program, i ),\n\t\t\taddr = gl.getUniformLocation( program, info.name );\n\n\t\tparseUniform( info, addr, this );\n\n\t}\n\n}\n\nWebGLUniforms.prototype.setValue = function ( gl, name, value, textures ) {\n\n\tconst u = this.map[ name ];\n\n\tif ( u !== undefined ) u.setValue( gl, value, textures );\n\n};\n\nWebGLUniforms.prototype.setOptional = function ( gl, object, name ) {\n\n\tconst v = object[ name ];\n\n\tif ( v !== undefined ) this.setValue( gl, name, v );\n\n};\n\n\n// Static interface\n\nWebGLUniforms.upload = function ( gl, seq, values, textures ) {\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ],\n\t\t\tv = values[ u.id ];\n\n\t\tif ( v.needsUpdate !== false ) {\n\n\t\t\t// note: always updating when .needsUpdate is undefined\n\t\t\tu.setValue( gl, v.value, textures );\n\n\t\t}\n\n\t}\n\n};\n\nWebGLUniforms.seqWithValue = function ( seq, values ) {\n\n\tconst r = [];\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ];\n\t\tif ( u.id in values ) r.push( u );\n\n\t}\n\n\treturn r;\n\n};\n\nexport { WebGLUniforms };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLShader( gl, type, string ) {\n\n\tconst shader = gl.createShader( type );\n\n\tgl.shaderSource( shader, string );\n\tgl.compileShader( shader );\n\n\treturn shader;\n\n}\n\nexport { WebGLShader };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { WebGLUniforms } from './WebGLUniforms.js';\nimport { WebGLShader } from './WebGLShader.js';\nimport { ShaderChunk } from '../shaders/ShaderChunk.js';\nimport { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, EquirectangularRefractionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, CubeUVRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GammaEncoding, RGBDEncoding, RGBM16Encoding, RGBM7Encoding, RGBEEncoding, sRGBEncoding, LinearEncoding, LogLuvEncoding } from '../../constants.js';\n\nlet programIdCount = 0;\n\nfunction addLineNumbers( string ) {\n\n\tconst lines = string.split( '\\n' );\n\n\tfor ( let i = 0; i < lines.length; i ++ ) {\n\n\t\tlines[ i ] = ( i + 1 ) + ': ' + lines[ i ];\n\n\t}\n\n\treturn lines.join( '\\n' );\n\n}\n\nfunction getEncodingComponents( encoding ) {\n\n\tswitch ( encoding ) {\n\n\t\tcase LinearEncoding:\n\t\t\treturn [ 'Linear', '( value )' ];\n\t\tcase sRGBEncoding:\n\t\t\treturn [ 'sRGB', '( value )' ];\n\t\tcase RGBEEncoding:\n\t\t\treturn [ 'RGBE', '( value )' ];\n\t\tcase RGBM7Encoding:\n\t\t\treturn [ 'RGBM', '( value, 7.0 )' ];\n\t\tcase RGBM16Encoding:\n\t\t\treturn [ 'RGBM', '( value, 16.0 )' ];\n\t\tcase RGBDEncoding:\n\t\t\treturn [ 'RGBD', '( value, 256.0 )' ];\n\t\tcase GammaEncoding:\n\t\t\treturn [ 'Gamma', '( value, float( GAMMA_FACTOR ) )' ];\n\t\tcase LogLuvEncoding:\n\t\t\treturn [ 'LogLuv', '( value )' ];\n\t\tdefault:\n\t\t\tconsole.warn( 'THREE.WebGLProgram: Unsupported encoding:', encoding );\n\t\t\treturn [ 'Linear', '( value )' ];\n\n\t}\n\n}\n\nfunction getShaderErrors( gl, shader, type ) {\n\n\tconst status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );\n\tconst log = gl.getShaderInfoLog( shader ).trim();\n\n\tif ( status && log === '' ) return '';\n\n\t// --enable-privileged-webgl-extension\n\t// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );\n\n\tconst source = gl.getShaderSource( shader );\n\n\treturn 'THREE.WebGLShader: gl.getShaderInfoLog() ' + type + '\\n' + log + addLineNumbers( source );\n\n}\n\nfunction getTexelDecodingFunction( functionName, encoding ) {\n\n\tconst components = getEncodingComponents( encoding );\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return ' + components[ 0 ] + 'ToLinear' + components[ 1 ] + '; }';\n\n}\n\nfunction getTexelEncodingFunction( functionName, encoding ) {\n\n\tconst components = getEncodingComponents( encoding );\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }';\n\n}\n\nfunction getToneMappingFunction( functionName, toneMapping ) {\n\n\tlet toneMappingName;\n\n\tswitch ( toneMapping ) {\n\n\t\tcase LinearToneMapping:\n\t\t\ttoneMappingName = 'Linear';\n\t\t\tbreak;\n\n\t\tcase ReinhardToneMapping:\n\t\t\ttoneMappingName = 'Reinhard';\n\t\t\tbreak;\n\n\t\tcase CineonToneMapping:\n\t\t\ttoneMappingName = 'OptimizedCineon';\n\t\t\tbreak;\n\n\t\tcase ACESFilmicToneMapping:\n\t\t\ttoneMappingName = 'ACESFilmic';\n\t\t\tbreak;\n\n\t\tcase CustomToneMapping:\n\t\t\ttoneMappingName = 'Custom';\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tconsole.warn( 'THREE.WebGLProgram: Unsupported toneMapping:', toneMapping );\n\t\t\ttoneMappingName = 'Linear';\n\n\t}\n\n\treturn 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';\n\n}\n\nfunction generateExtensions( parameters ) {\n\n\tconst chunks = [\n\t\t( parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',\n\t\t( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',\n\t\t( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',\n\t\t( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''\n\t];\n\n\treturn chunks.filter( filterEmptyLine ).join( '\\n' );\n\n}\n\nfunction generateDefines( defines ) {\n\n\tconst chunks = [];\n\n\tfor ( const name in defines ) {\n\n\t\tconst value = defines[ name ];\n\n\t\tif ( value === false ) continue;\n\n\t\tchunks.push( '#define ' + name + ' ' + value );\n\n\t}\n\n\treturn chunks.join( '\\n' );\n\n}\n\nfunction fetchAttributeLocations( gl, program ) {\n\n\tconst attributes = {};\n\n\tconst n = gl.getProgramParameter( program, gl.ACTIVE_ATTRIBUTES );\n\n\tfor ( let i = 0; i < n; i ++ ) {\n\n\t\tconst info = gl.getActiveAttrib( program, i );\n\t\tconst name = info.name;\n\n\t\t// console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i );\n\n\t\tattributes[ name ] = gl.getAttribLocation( program, name );\n\n\t}\n\n\treturn attributes;\n\n}\n\nfunction filterEmptyLine( string ) {\n\n\treturn string !== '';\n\n}\n\nfunction replaceLightNums( string, parameters ) {\n\n\treturn string\n\t\t.replace( /NUM_DIR_LIGHTS/g, parameters.numDirLights )\n\t\t.replace( /NUM_SPOT_LIGHTS/g, parameters.numSpotLights )\n\t\t.replace( /NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights )\n\t\t.replace( /NUM_POINT_LIGHTS/g, parameters.numPointLights )\n\t\t.replace( /NUM_HEMI_LIGHTS/g, parameters.numHemiLights )\n\t\t.replace( /NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows )\n\t\t.replace( /NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows )\n\t\t.replace( /NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows );\n\n}\n\nfunction replaceClippingPlaneNums( string, parameters ) {\n\n\treturn string\n\t\t.replace( /NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes )\n\t\t.replace( /UNION_CLIPPING_PLANES/g, ( parameters.numClippingPlanes - parameters.numClipIntersection ) );\n\n}\n\n// Resolve Includes\n\nconst includePattern = /^[ \\t]*#include +<([\\w\\d./]+)>/gm;\n\nfunction resolveIncludes( string ) {\n\n\treturn string.replace( includePattern, includeReplacer );\n\n}\n\nfunction includeReplacer( match, include ) {\n\n\tconst string = ShaderChunk[ include ];\n\n\tif ( string === undefined ) {\n\n\t\tthrow new Error( 'Can not resolve #include <' + include + '>' );\n\n\t}\n\n\treturn resolveIncludes( string );\n\n}\n\n// Unroll Loops\n\nconst deprecatedUnrollLoopPattern = /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g;\nconst unrollLoopPattern = /#pragma unroll_loop_start[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}[\\s]+?#pragma unroll_loop_end/g;\n\nfunction unrollLoops( string ) {\n\n\treturn string\n\t\t.replace( unrollLoopPattern, loopReplacer )\n\t\t.replace( deprecatedUnrollLoopPattern, deprecatedLoopReplacer );\n\n}\n\nfunction deprecatedLoopReplacer( match, start, end, snippet ) {\n\n\tconsole.warn( 'WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.' );\n\treturn loopReplacer( match, start, end, snippet );\n\n}\n\nfunction loopReplacer( match, start, end, snippet ) {\n\n\tlet string = '';\n\n\tfor ( let i = parseInt( start ); i < parseInt( end ); i ++ ) {\n\n\t\tstring += snippet\n\t\t\t.replace( /\\[ i \\]/g, '[ ' + i + ' ]' )\n\t\t\t.replace( /UNROLLED_LOOP_INDEX/g, i );\n\n\t}\n\n\treturn string;\n\n}\n\n//\n\nfunction generatePrecision( parameters ) {\n\n\tlet precisionstring = \"precision \" + parameters.precision + \" float;\\nprecision \" + parameters.precision + \" int;\";\n\n\tif ( parameters.precision === \"highp\" ) {\n\n\t\tprecisionstring += \"\\n#define HIGH_PRECISION\";\n\n\t} else if ( parameters.precision === \"mediump\" ) {\n\n\t\tprecisionstring += \"\\n#define MEDIUM_PRECISION\";\n\n\t} else if ( parameters.precision === \"lowp\" ) {\n\n\t\tprecisionstring += \"\\n#define LOW_PRECISION\";\n\n\t}\n\n\treturn precisionstring;\n\n}\n\nfunction generateShadowMapTypeDefine( parameters ) {\n\n\tlet shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC';\n\n\tif ( parameters.shadowMapType === PCFShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF';\n\n\t} else if ( parameters.shadowMapType === PCFSoftShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT';\n\n\t} else if ( parameters.shadowMapType === VSMShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM';\n\n\t}\n\n\treturn shadowMapTypeDefine;\n\n}\n\nfunction generateEnvMapTypeDefine( parameters ) {\n\n\tlet envMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.envMapMode ) {\n\n\t\t\tcase CubeReflectionMapping:\n\t\t\tcase CubeRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\t\t\t\tbreak;\n\n\t\t\tcase CubeUVReflectionMapping:\n\t\t\tcase CubeUVRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV';\n\t\t\t\tbreak;\n\n\t\t\tcase EquirectangularReflectionMapping:\n\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_EQUIREC';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapTypeDefine;\n\n}\n\nfunction generateEnvMapModeDefine( parameters ) {\n\n\tlet envMapModeDefine = 'ENVMAP_MODE_REFLECTION';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.envMapMode ) {\n\n\t\t\tcase CubeRefractionMapping:\n\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\tenvMapModeDefine = 'ENVMAP_MODE_REFRACTION';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapModeDefine;\n\n}\n\nfunction generateEnvMapBlendingDefine( parameters ) {\n\n\tlet envMapBlendingDefine = 'ENVMAP_BLENDING_NONE';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.combine ) {\n\n\t\t\tcase MultiplyOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';\n\t\t\t\tbreak;\n\n\t\t\tcase MixOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MIX';\n\t\t\t\tbreak;\n\n\t\t\tcase AddOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_ADD';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapBlendingDefine;\n\n}\n\nfunction WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {\n\n\tconst gl = renderer.getContext();\n\n\tconst defines = parameters.defines;\n\n\tlet vertexShader = parameters.vertexShader;\n\tlet fragmentShader = parameters.fragmentShader;\n\n\tconst shadowMapTypeDefine = generateShadowMapTypeDefine( parameters );\n\tconst envMapTypeDefine = generateEnvMapTypeDefine( parameters );\n\tconst envMapModeDefine = generateEnvMapModeDefine( parameters );\n\tconst envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );\n\n\n\tconst gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0;\n\n\tconst customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );\n\n\tconst customDefines = generateDefines( defines );\n\n\tconst program = gl.createProgram();\n\n\tlet prefixVertex, prefixFragment;\n\n\tif ( parameters.isRawShaderMaterial ) {\n\n\t\tprefixVertex = [\n\n\t\t\tcustomDefines\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tif ( prefixVertex.length > 0 ) {\n\n\t\t\tprefixVertex += '\\n';\n\n\t\t}\n\n\t\tprefixFragment = [\n\n\t\t\tcustomExtensions,\n\t\t\tcustomDefines\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tif ( prefixFragment.length > 0 ) {\n\n\t\t\tprefixFragment += '\\n';\n\n\t\t}\n\n\t} else {\n\n\t\tprefixVertex = [\n\n\t\t\tgeneratePrecision( parameters ),\n\n\t\t\t'#define SHADER_NAME ' + parameters.shaderName,\n\n\t\t\tcustomDefines,\n\n\t\t\tparameters.instancing ? '#define USE_INSTANCING' : '',\n\t\t\tparameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',\n\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t'#define MAX_BONES ' + parameters.maxBones,\n\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',\n\n\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '',\n\n\t\t\tparameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',\n\t\t\tparameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',\n\t\t\tparameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',\n\t\t\tparameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '',\n\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\n\t\t\tparameters.vertexTangents ? '#define USE_TANGENT' : '',\n\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\t\t\tparameters.vertexUvs ? '#define USE_UV' : '',\n\t\t\tparameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',\n\n\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\tparameters.skinning ? '#define USE_SKINNING' : '',\n\t\t\tparameters.useVertexTexture ? '#define BONE_TEXTURE' : '',\n\n\t\t\tparameters.morphTargets ? '#define USE_MORPHTARGETS' : '',\n\t\t\tparameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',\n\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\tparameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',\n\n\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t'uniform mat4 modelMatrix;',\n\t\t\t'uniform mat4 modelViewMatrix;',\n\t\t\t'uniform mat4 projectionMatrix;',\n\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t'uniform mat3 normalMatrix;',\n\t\t\t'uniform vec3 cameraPosition;',\n\t\t\t'uniform bool isOrthographic;',\n\n\t\t\t'#ifdef USE_INSTANCING',\n\n\t\t\t' attribute mat4 instanceMatrix;',\n\n\t\t\t'#endif',\n\n\t\t\t'attribute vec3 position;',\n\t\t\t'attribute vec3 normal;',\n\t\t\t'attribute vec2 uv;',\n\n\t\t\t'#ifdef USE_TANGENT',\n\n\t\t\t'\tattribute vec4 tangent;',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_COLOR',\n\n\t\t\t'\tattribute vec3 color;',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_MORPHTARGETS',\n\n\t\t\t'\tattribute vec3 morphTarget0;',\n\t\t\t'\tattribute vec3 morphTarget1;',\n\t\t\t'\tattribute vec3 morphTarget2;',\n\t\t\t'\tattribute vec3 morphTarget3;',\n\n\t\t\t'\t#ifdef USE_MORPHNORMALS',\n\n\t\t\t'\t\tattribute vec3 morphNormal0;',\n\t\t\t'\t\tattribute vec3 morphNormal1;',\n\t\t\t'\t\tattribute vec3 morphNormal2;',\n\t\t\t'\t\tattribute vec3 morphNormal3;',\n\n\t\t\t'\t#else',\n\n\t\t\t'\t\tattribute vec3 morphTarget4;',\n\t\t\t'\t\tattribute vec3 morphTarget5;',\n\t\t\t'\t\tattribute vec3 morphTarget6;',\n\t\t\t'\t\tattribute vec3 morphTarget7;',\n\n\t\t\t'\t#endif',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_SKINNING',\n\n\t\t\t'\tattribute vec4 skinIndex;',\n\t\t\t'\tattribute vec4 skinWeight;',\n\n\t\t\t'#endif',\n\n\t\t\t'\\n'\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tprefixFragment = [\n\n\t\t\tcustomExtensions,\n\n\t\t\tgeneratePrecision( parameters ),\n\n\t\t\t'#define SHADER_NAME ' + parameters.shaderName,\n\n\t\t\tcustomDefines,\n\n\t\t\tparameters.alphaTest ? '#define ALPHATEST ' + parameters.alphaTest + ( parameters.alphaTest % 1 ? '' : '.0' ) : '', // add '.0' if integer\n\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',\n\n\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\tparameters.matcap ? '#define USE_MATCAP' : '',\n\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\tparameters.envMap ? '#define ' + envMapTypeDefine : '',\n\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\tparameters.envMap ? '#define ' + envMapBlendingDefine : '',\n\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '',\n\t\t\tparameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',\n\t\t\tparameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',\n\t\t\tparameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',\n\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\n\t\t\tparameters.sheen ? '#define USE_SHEEN' : '',\n\n\t\t\tparameters.vertexTangents ? '#define USE_TANGENT' : '',\n\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\t\t\tparameters.vertexUvs ? '#define USE_UV' : '',\n\t\t\tparameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',\n\n\t\t\tparameters.gradientMap ? '#define USE_GRADIENTMAP' : '',\n\n\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\tparameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',\n\n\t\t\tparameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',\n\n\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '',\n\n\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t'uniform vec3 cameraPosition;',\n\t\t\t'uniform bool isOrthographic;',\n\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '',\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '',\n\n\t\t\tparameters.dithering ? '#define DITHERING' : '',\n\n\t\t\tShaderChunk[ 'encodings_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below\n\t\t\tparameters.map ? getTexelDecodingFunction( 'mapTexelToLinear', parameters.mapEncoding ) : '',\n\t\t\tparameters.matcap ? getTexelDecodingFunction( 'matcapTexelToLinear', parameters.matcapEncoding ) : '',\n\t\t\tparameters.envMap ? getTexelDecodingFunction( 'envMapTexelToLinear', parameters.envMapEncoding ) : '',\n\t\t\tparameters.emissiveMap ? getTexelDecodingFunction( 'emissiveMapTexelToLinear', parameters.emissiveMapEncoding ) : '',\n\t\t\tparameters.lightMap ? getTexelDecodingFunction( 'lightMapTexelToLinear', parameters.lightMapEncoding ) : '',\n\t\t\tgetTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ),\n\n\t\t\tparameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',\n\n\t\t\t'\\n'\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t}\n\n\tvertexShader = resolveIncludes( vertexShader );\n\tvertexShader = replaceLightNums( vertexShader, parameters );\n\tvertexShader = replaceClippingPlaneNums( vertexShader, parameters );\n\n\tfragmentShader = resolveIncludes( fragmentShader );\n\tfragmentShader = replaceLightNums( fragmentShader, parameters );\n\tfragmentShader = replaceClippingPlaneNums( fragmentShader, parameters );\n\n\tvertexShader = unrollLoops( vertexShader );\n\tfragmentShader = unrollLoops( fragmentShader );\n\n\tif ( parameters.isWebGL2 && ! parameters.isRawShaderMaterial ) {\n\n\t\tlet isGLSL3ShaderMaterial = false;\n\n\t\tconst versionRegex = /^\\s*#version\\s+300\\s+es\\s*\\n/;\n\n\t\tif ( parameters.isShaderMaterial &&\n\t\t\tvertexShader.match( versionRegex ) !== null &&\n\t\t\tfragmentShader.match( versionRegex ) !== null ) {\n\n\t\t\tisGLSL3ShaderMaterial = true;\n\n\t\t\tvertexShader = vertexShader.replace( versionRegex, '' );\n\t\t\tfragmentShader = fragmentShader.replace( versionRegex, '' );\n\n\t\t}\n\n\t\t// GLSL 3.0 conversion\n\n\t\tprefixVertex = [\n\t\t\t'#version 300 es\\n',\n\t\t\t'#define attribute in',\n\t\t\t'#define varying out',\n\t\t\t'#define texture2D texture'\n\t\t].join( '\\n' ) + '\\n' + prefixVertex;\n\n\t\tprefixFragment = [\n\t\t\t'#version 300 es\\n',\n\t\t\t'#define varying in',\n\t\t\tisGLSL3ShaderMaterial ? '' : 'out highp vec4 pc_fragColor;',\n\t\t\tisGLSL3ShaderMaterial ? '' : '#define gl_FragColor pc_fragColor',\n\t\t\t'#define gl_FragDepthEXT gl_FragDepth',\n\t\t\t'#define texture2D texture',\n\t\t\t'#define textureCube texture',\n\t\t\t'#define texture2DProj textureProj',\n\t\t\t'#define texture2DLodEXT textureLod',\n\t\t\t'#define texture2DProjLodEXT textureProjLod',\n\t\t\t'#define textureCubeLodEXT textureLod',\n\t\t\t'#define texture2DGradEXT textureGrad',\n\t\t\t'#define texture2DProjGradEXT textureProjGrad',\n\t\t\t'#define textureCubeGradEXT textureGrad'\n\t\t].join( '\\n' ) + '\\n' + prefixFragment;\n\n\t}\n\n\tconst vertexGlsl = prefixVertex + vertexShader;\n\tconst fragmentGlsl = prefixFragment + fragmentShader;\n\n\t// console.log( '*VERTEX*', vertexGlsl );\n\t// console.log( '*FRAGMENT*', fragmentGlsl );\n\n\tconst glVertexShader = WebGLShader( gl, gl.VERTEX_SHADER, vertexGlsl );\n\tconst glFragmentShader = WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentGlsl );\n\n\tgl.attachShader( program, glVertexShader );\n\tgl.attachShader( program, glFragmentShader );\n\n\t// Force a particular attribute to index 0.\n\n\tif ( parameters.index0AttributeName !== undefined ) {\n\n\t\tgl.bindAttribLocation( program, 0, parameters.index0AttributeName );\n\n\t} else if ( parameters.morphTargets === true ) {\n\n\t\t// programs with morphTargets displace position out of attribute 0\n\t\tgl.bindAttribLocation( program, 0, 'position' );\n\n\t}\n\n\tgl.linkProgram( program );\n\n\t// check for link errors\n\tif ( renderer.debug.checkShaderErrors ) {\n\n\t\tconst programLog = gl.getProgramInfoLog( program ).trim();\n\t\tconst vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();\n\t\tconst fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();\n\n\t\tlet runnable = true;\n\t\tlet haveDiagnostics = true;\n\n\t\tif ( gl.getProgramParameter( program, gl.LINK_STATUS ) === false ) {\n\n\t\t\trunnable = false;\n\n\t\t\tconst vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );\n\t\t\tconst fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );\n\n\t\t\tconsole.error( 'THREE.WebGLProgram: shader error: ', gl.getError(), 'gl.VALIDATE_STATUS', gl.getProgramParameter( program, gl.VALIDATE_STATUS ), 'gl.getProgramInfoLog', programLog, vertexErrors, fragmentErrors );\n\n\t\t} else if ( programLog !== '' ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLProgram: gl.getProgramInfoLog()', programLog );\n\n\t\t} else if ( vertexLog === '' || fragmentLog === '' ) {\n\n\t\t\thaveDiagnostics = false;\n\n\t\t}\n\n\t\tif ( haveDiagnostics ) {\n\n\t\t\tthis.diagnostics = {\n\n\t\t\t\trunnable: runnable,\n\n\t\t\t\tprogramLog: programLog,\n\n\t\t\t\tvertexShader: {\n\n\t\t\t\t\tlog: vertexLog,\n\t\t\t\t\tprefix: prefixVertex\n\n\t\t\t\t},\n\n\t\t\t\tfragmentShader: {\n\n\t\t\t\t\tlog: fragmentLog,\n\t\t\t\t\tprefix: prefixFragment\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}\n\n\t}\n\n\t// Clean up\n\n\t// Crashes in iOS9 and iOS10. #18402\n\t// gl.detachShader( program, glVertexShader );\n\t// gl.detachShader( program, glFragmentShader );\n\n\tgl.deleteShader( glVertexShader );\n\tgl.deleteShader( glFragmentShader );\n\n\t// set up caching for uniform locations\n\n\tlet cachedUniforms;\n\n\tthis.getUniforms = function () {\n\n\t\tif ( cachedUniforms === undefined ) {\n\n\t\t\tcachedUniforms = new WebGLUniforms( gl, program );\n\n\t\t}\n\n\t\treturn cachedUniforms;\n\n\t};\n\n\t// set up caching for attribute locations\n\n\tlet cachedAttributes;\n\n\tthis.getAttributes = function () {\n\n\t\tif ( cachedAttributes === undefined ) {\n\n\t\t\tcachedAttributes = fetchAttributeLocations( gl, program );\n\n\t\t}\n\n\t\treturn cachedAttributes;\n\n\t};\n\n\t// free resource\n\n\tthis.destroy = function () {\n\n\t\tbindingStates.releaseStatesOfProgram( this );\n\n\t\tgl.deleteProgram( program );\n\t\tthis.program = undefined;\n\n\t};\n\n\t//\n\n\tthis.name = parameters.shaderName;\n\tthis.id = programIdCount ++;\n\tthis.cacheKey = cacheKey;\n\tthis.usedTimes = 1;\n\tthis.program = program;\n\tthis.vertexShader = glVertexShader;\n\tthis.fragmentShader = glFragmentShader;\n\n\treturn this;\n\n}\n\nexport { WebGLProgram };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide, DoubleSide, CubeUVRefractionMapping, CubeUVReflectionMapping, LinearEncoding, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping } from '../../constants.js';\nimport { WebGLProgram } from './WebGLProgram.js';\nimport { ShaderLib } from '../shaders/ShaderLib.js';\nimport { UniformsUtils } from '../shaders/UniformsUtils.js';\n\nfunction WebGLPrograms( renderer, extensions, capabilities, bindingStates ) {\n\n\tconst programs = [];\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;\n\tconst floatVertexTextures = capabilities.floatVertexTextures;\n\tconst maxVertexUniforms = capabilities.maxVertexUniforms;\n\tconst vertexTextures = capabilities.vertexTextures;\n\n\tlet precision = capabilities.precision;\n\n\tconst shaderIDs = {\n\t\tMeshDepthMaterial: 'depth',\n\t\tMeshDistanceMaterial: 'distanceRGBA',\n\t\tMeshNormalMaterial: 'normal',\n\t\tMeshBasicMaterial: 'basic',\n\t\tMeshLambertMaterial: 'lambert',\n\t\tMeshPhongMaterial: 'phong',\n\t\tMeshToonMaterial: 'toon',\n\t\tMeshStandardMaterial: 'physical',\n\t\tMeshPhysicalMaterial: 'physical',\n\t\tMeshMatcapMaterial: 'matcap',\n\t\tLineBasicMaterial: 'basic',\n\t\tLineDashedMaterial: 'dashed',\n\t\tPointsMaterial: 'points',\n\t\tShadowMaterial: 'shadow',\n\t\tSpriteMaterial: 'sprite'\n\t};\n\n\tconst parameterNames = [\n\t\t\"precision\", \"isWebGL2\", \"supportsVertexTextures\", \"outputEncoding\", \"instancing\",\n\t\t\"map\", \"mapEncoding\", \"matcap\", \"matcapEncoding\", \"envMap\", \"envMapMode\", \"envMapEncoding\", \"envMapCubeUV\",\n\t\t\"lightMap\", \"lightMapEncoding\", \"aoMap\", \"emissiveMap\", \"emissiveMapEncoding\", \"bumpMap\", \"normalMap\", \"objectSpaceNormalMap\", \"tangentSpaceNormalMap\", \"clearcoatMap\", \"clearcoatRoughnessMap\", \"clearcoatNormalMap\", \"displacementMap\", \"specularMap\",\n\t\t\"roughnessMap\", \"metalnessMap\", \"gradientMap\",\n\t\t\"alphaMap\", \"combine\", \"vertexColors\", \"vertexTangents\", \"vertexUvs\", \"uvsVertexOnly\", \"fog\", \"useFog\", \"fogExp2\",\n\t\t\"flatShading\", \"sizeAttenuation\", \"logarithmicDepthBuffer\", \"skinning\",\n\t\t\"maxBones\", \"useVertexTexture\", \"morphTargets\", \"morphNormals\",\n\t\t\"maxMorphTargets\", \"maxMorphNormals\", \"premultipliedAlpha\",\n\t\t\"numDirLights\", \"numPointLights\", \"numSpotLights\", \"numHemiLights\", \"numRectAreaLights\",\n\t\t\"numDirLightShadows\", \"numPointLightShadows\", \"numSpotLightShadows\",\n\t\t\"shadowMapEnabled\", \"shadowMapType\", \"toneMapping\", 'physicallyCorrectLights',\n\t\t\"alphaTest\", \"doubleSided\", \"flipSided\", \"numClippingPlanes\", \"numClipIntersection\", \"depthPacking\", \"dithering\",\n\t\t\"sheen\"\n\t];\n\n\tfunction getShaderObject( material, shaderID ) {\n\n\t\tlet shaderobject;\n\n\t\tif ( shaderID ) {\n\n\t\t\tconst shader = ShaderLib[ shaderID ];\n\n\t\t\tshaderobject = {\n\t\t\t\tname: material.name || material.type,\n\t\t\t\tuniforms: UniformsUtils.clone( shader.uniforms ),\n\t\t\t\tvertexShader: shader.vertexShader,\n\t\t\t\tfragmentShader: shader.fragmentShader\n\t\t\t};\n\n\t\t} else {\n\n\t\t\tshaderobject = {\n\t\t\t\tname: material.name || material.type,\n\t\t\t\tuniforms: material.uniforms,\n\t\t\t\tvertexShader: material.vertexShader,\n\t\t\t\tfragmentShader: material.fragmentShader\n\t\t\t};\n\n\t\t}\n\n\t\treturn shaderobject;\n\n\t}\n\n\tfunction allocateBones( object ) {\n\n\t\tconst skeleton = object.skeleton;\n\t\tconst bones = skeleton.bones;\n\n\t\tif ( floatVertexTextures ) {\n\n\t\t\treturn 1024;\n\n\t\t} else {\n\n\t\t\t// default for when object is not specified\n\t\t\t// ( for example when prebuilding shader to be used with multiple objects )\n\t\t\t//\n\t\t\t// - leave some extra space for other uniforms\n\t\t\t// - limit here is ANGLE's 254 max uniform vectors\n\t\t\t// (up to 54 should be safe)\n\n\t\t\tconst nVertexUniforms = maxVertexUniforms;\n\t\t\tconst nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );\n\n\t\t\tconst maxBones = Math.min( nVertexMatrices, bones.length );\n\n\t\t\tif ( maxBones < bones.length ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' );\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\treturn maxBones;\n\n\t\t}\n\n\t}\n\n\tfunction getTextureEncodingFromMap( map ) {\n\n\t\tlet encoding;\n\n\t\tif ( ! map ) {\n\n\t\t\tencoding = LinearEncoding;\n\n\t\t} else if ( map.isTexture ) {\n\n\t\t\tencoding = map.encoding;\n\n\t\t} else if ( map.isWebGLRenderTarget ) {\n\n\t\t\tconsole.warn( \"THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\tencoding = map.texture.encoding;\n\n\t\t}\n\n\t\treturn encoding;\n\n\t}\n\n\tfunction getParameters( material, lights, shadows, scene, nClipPlanes, nClipIntersection, object ) {\n\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\n\t\tconst envMap = material.envMap || environment;\n\n\t\tconst shaderID = shaderIDs[ material.type ];\n\n\t\t// heuristics to create shader parameters according to lights in the scene\n\t\t// (not to blow over maxLights budget)\n\n\t\tconst maxBones = object.isSkinnedMesh ? allocateBones( object ) : 0;\n\n\t\tif ( material.precision !== null ) {\n\n\t\t\tprecision = capabilities.getMaxPrecision( material.precision );\n\n\t\t\tif ( precision !== material.precision ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst shaderobject = getShaderObject( material, shaderID );\n\t\tmaterial.onBeforeCompile( shaderobject, renderer );\n\n\t\tconst currentRenderTarget = renderer.getRenderTarget();\n\n\t\tconst parameters = {\n\n\t\t\tisWebGL2: isWebGL2,\n\n\t\t\tshaderID: shaderID,\n\t\t\tshaderName: shaderobject.name,\n\n\t\t\tuniforms: shaderobject.uniforms,\n\t\t\tvertexShader: shaderobject.vertexShader,\n\t\t\tfragmentShader: shaderobject.fragmentShader,\n\t\t\tdefines: material.defines,\n\n\t\t\tisRawShaderMaterial: material.isRawShaderMaterial,\n\t\t\tisShaderMaterial: material.isShaderMaterial,\n\n\t\t\tprecision: precision,\n\n\t\t\tinstancing: object.isInstancedMesh === true,\n\n\t\t\tsupportsVertexTextures: vertexTextures,\n\t\t\toutputEncoding: ( currentRenderTarget !== null ) ? getTextureEncodingFromMap( currentRenderTarget.texture ) : renderer.outputEncoding,\n\t\t\tmap: !! material.map,\n\t\t\tmapEncoding: getTextureEncodingFromMap( material.map ),\n\t\t\tmatcap: !! material.matcap,\n\t\t\tmatcapEncoding: getTextureEncodingFromMap( material.matcap ),\n\t\t\tenvMap: !! envMap,\n\t\t\tenvMapMode: envMap && envMap.mapping,\n\t\t\tenvMapEncoding: getTextureEncodingFromMap( envMap ),\n\t\t\tenvMapCubeUV: ( !! envMap ) && ( ( envMap.mapping === CubeUVReflectionMapping ) || ( envMap.mapping === CubeUVRefractionMapping ) ),\n\t\t\tlightMap: !! material.lightMap,\n\t\t\tlightMapEncoding: getTextureEncodingFromMap( material.lightMap ),\n\t\t\taoMap: !! material.aoMap,\n\t\t\temissiveMap: !! material.emissiveMap,\n\t\t\temissiveMapEncoding: getTextureEncodingFromMap( material.emissiveMap ),\n\t\t\tbumpMap: !! material.bumpMap,\n\t\t\tnormalMap: !! material.normalMap,\n\t\t\tobjectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,\n\t\t\ttangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap,\n\t\t\tclearcoatMap: !! material.clearcoatMap,\n\t\t\tclearcoatRoughnessMap: !! material.clearcoatRoughnessMap,\n\t\t\tclearcoatNormalMap: !! material.clearcoatNormalMap,\n\t\t\tdisplacementMap: !! material.displacementMap,\n\t\t\troughnessMap: !! material.roughnessMap,\n\t\t\tmetalnessMap: !! material.metalnessMap,\n\t\t\tspecularMap: !! material.specularMap,\n\t\t\talphaMap: !! material.alphaMap,\n\n\t\t\tgradientMap: !! material.gradientMap,\n\n\t\t\tsheen: !! material.sheen,\n\n\t\t\tcombine: material.combine,\n\n\t\t\tvertexTangents: ( material.normalMap && material.vertexTangents ),\n\t\t\tvertexColors: material.vertexColors,\n\t\t\tvertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap,\n\t\t\tuvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap ) && !! material.displacementMap,\n\n\t\t\tfog: !! fog,\n\t\t\tuseFog: material.fog,\n\t\t\tfogExp2: ( fog && fog.isFogExp2 ),\n\n\t\t\tflatShading: material.flatShading,\n\n\t\t\tsizeAttenuation: material.sizeAttenuation,\n\t\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\t\tskinning: material.skinning && maxBones > 0,\n\t\t\tmaxBones: maxBones,\n\t\t\tuseVertexTexture: floatVertexTextures,\n\n\t\t\tmorphTargets: material.morphTargets,\n\t\t\tmorphNormals: material.morphNormals,\n\t\t\tmaxMorphTargets: renderer.maxMorphTargets,\n\t\t\tmaxMorphNormals: renderer.maxMorphNormals,\n\n\t\t\tnumDirLights: lights.directional.length,\n\t\t\tnumPointLights: lights.point.length,\n\t\t\tnumSpotLights: lights.spot.length,\n\t\t\tnumRectAreaLights: lights.rectArea.length,\n\t\t\tnumHemiLights: lights.hemi.length,\n\n\t\t\tnumDirLightShadows: lights.directionalShadowMap.length,\n\t\t\tnumPointLightShadows: lights.pointShadowMap.length,\n\t\t\tnumSpotLightShadows: lights.spotShadowMap.length,\n\n\t\t\tnumClippingPlanes: nClipPlanes,\n\t\t\tnumClipIntersection: nClipIntersection,\n\n\t\t\tdithering: material.dithering,\n\n\t\t\tshadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,\n\t\t\tshadowMapType: renderer.shadowMap.type,\n\n\t\t\ttoneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,\n\t\t\tphysicallyCorrectLights: renderer.physicallyCorrectLights,\n\n\t\t\tpremultipliedAlpha: material.premultipliedAlpha,\n\n\t\t\talphaTest: material.alphaTest,\n\t\t\tdoubleSided: material.side === DoubleSide,\n\t\t\tflipSided: material.side === BackSide,\n\n\t\t\tdepthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false,\n\n\t\t\tindex0AttributeName: material.index0AttributeName,\n\n\t\t\textensionDerivatives: material.extensions && material.extensions.derivatives,\n\t\t\textensionFragDepth: material.extensions && material.extensions.fragDepth,\n\t\t\textensionDrawBuffers: material.extensions && material.extensions.drawBuffers,\n\t\t\textensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD,\n\n\t\t\trendererExtensionFragDepth: isWebGL2 || extensions.get( 'EXT_frag_depth' ) !== null,\n\t\t\trendererExtensionDrawBuffers: isWebGL2 || extensions.get( 'WEBGL_draw_buffers' ) !== null,\n\t\t\trendererExtensionShaderTextureLod: isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) !== null,\n\n\t\t\tcustomProgramCacheKey: material.customProgramCacheKey()\n\n\t\t};\n\n\t\treturn parameters;\n\n\t}\n\n\tfunction getProgramCacheKey( parameters ) {\n\n\t\tconst array = [];\n\n\t\tif ( parameters.shaderID ) {\n\n\t\t\tarray.push( parameters.shaderID );\n\n\t\t} else {\n\n\t\t\tarray.push( parameters.fragmentShader );\n\t\t\tarray.push( parameters.vertexShader );\n\n\t\t}\n\n\t\tif ( parameters.defines !== undefined ) {\n\n\t\t\tfor ( const name in parameters.defines ) {\n\n\t\t\t\tarray.push( name );\n\t\t\t\tarray.push( parameters.defines[ name ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( parameters.isRawShaderMaterial === undefined ) {\n\n\t\t\tfor ( let i = 0; i < parameterNames.length; i ++ ) {\n\n\t\t\t\tarray.push( parameters[ parameterNames[ i ] ] );\n\n\t\t\t}\n\n\t\t\tarray.push( renderer.outputEncoding );\n\t\t\tarray.push( renderer.gammaFactor );\n\n\t\t}\n\n\t\tarray.push( parameters.customProgramCacheKey );\n\n\t\treturn array.join();\n\n\t}\n\n\tfunction acquireProgram( parameters, cacheKey ) {\n\n\t\tlet program;\n\n\t\t// Check if code has been already compiled\n\t\tfor ( let p = 0, pl = programs.length; p < pl; p ++ ) {\n\n\t\t\tconst preexistingProgram = programs[ p ];\n\n\t\t\tif ( preexistingProgram.cacheKey === cacheKey ) {\n\n\t\t\t\tprogram = preexistingProgram;\n\t\t\t\t++ program.usedTimes;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( program === undefined ) {\n\n\t\t\tprogram = new WebGLProgram( renderer, cacheKey, parameters, bindingStates );\n\t\t\tprograms.push( program );\n\n\t\t}\n\n\t\treturn program;\n\n\t}\n\n\tfunction releaseProgram( program ) {\n\n\t\tif ( -- program.usedTimes === 0 ) {\n\n\t\t\t// Remove from unordered set\n\t\t\tconst i = programs.indexOf( program );\n\t\t\tprograms[ i ] = programs[ programs.length - 1 ];\n\t\t\tprograms.pop();\n\n\t\t\t// Free WebGL resources\n\t\t\tprogram.destroy();\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\tgetParameters: getParameters,\n\t\tgetProgramCacheKey: getProgramCacheKey,\n\t\tacquireProgram: acquireProgram,\n\t\treleaseProgram: releaseProgram,\n\t\t// Exposed for resource monitoring & error feedback via renderer.info:\n\t\tprograms: programs\n\t};\n\n}\n\n\nexport { WebGLPrograms };\n","/**\n * @author fordacious / fordacious.github.io\n */\n\nfunction WebGLProperties() {\n\n\tlet properties = new WeakMap();\n\n\tfunction get( object ) {\n\n\t\tlet map = properties.get( object );\n\n\t\tif ( map === undefined ) {\n\n\t\t\tmap = {};\n\t\t\tproperties.set( object, map );\n\n\t\t}\n\n\t\treturn map;\n\n\t}\n\n\tfunction remove( object ) {\n\n\t\tproperties.delete( object );\n\n\t}\n\n\tfunction update( object, key, value ) {\n\n\t\tproperties.get( object )[ key ] = value;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tproperties = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLProperties };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction painterSortStable( a, b ) {\n\n\tif ( a.groupOrder !== b.groupOrder ) {\n\n\t\treturn a.groupOrder - b.groupOrder;\n\n\t} else if ( a.renderOrder !== b.renderOrder ) {\n\n\t\treturn a.renderOrder - b.renderOrder;\n\n\t} else if ( a.program !== b.program ) {\n\n\t\treturn a.program.id - b.program.id;\n\n\t} else if ( a.material.id !== b.material.id ) {\n\n\t\treturn a.material.id - b.material.id;\n\n\t} else if ( a.z !== b.z ) {\n\n\t\treturn a.z - b.z;\n\n\t} else {\n\n\t\treturn a.id - b.id;\n\n\t}\n\n}\n\nfunction reversePainterSortStable( a, b ) {\n\n\tif ( a.groupOrder !== b.groupOrder ) {\n\n\t\treturn a.groupOrder - b.groupOrder;\n\n\t} else if ( a.renderOrder !== b.renderOrder ) {\n\n\t\treturn a.renderOrder - b.renderOrder;\n\n\t} else if ( a.z !== b.z ) {\n\n\t\treturn b.z - a.z;\n\n\t} else {\n\n\t\treturn a.id - b.id;\n\n\t}\n\n}\n\n\nfunction WebGLRenderList() {\n\n\tconst renderItems = [];\n\tlet renderItemsIndex = 0;\n\n\tconst opaque = [];\n\tconst transparent = [];\n\n\tconst defaultProgram = { id: - 1 };\n\n\tfunction init() {\n\n\t\trenderItemsIndex = 0;\n\n\t\topaque.length = 0;\n\t\ttransparent.length = 0;\n\n\t}\n\n\tfunction getNextRenderItem( object, geometry, material, groupOrder, z, group ) {\n\n\t\tlet renderItem = renderItems[ renderItemsIndex ];\n\n\t\tif ( renderItem === undefined ) {\n\n\t\t\trenderItem = {\n\t\t\t\tid: object.id,\n\t\t\t\tobject: object,\n\t\t\t\tgeometry: geometry,\n\t\t\t\tmaterial: material,\n\t\t\t\tprogram: material.program || defaultProgram,\n\t\t\t\tgroupOrder: groupOrder,\n\t\t\t\trenderOrder: object.renderOrder,\n\t\t\t\tz: z,\n\t\t\t\tgroup: group\n\t\t\t};\n\n\t\t\trenderItems[ renderItemsIndex ] = renderItem;\n\n\t\t} else {\n\n\t\t\trenderItem.id = object.id;\n\t\t\trenderItem.object = object;\n\t\t\trenderItem.geometry = geometry;\n\t\t\trenderItem.material = material;\n\t\t\trenderItem.program = material.program || defaultProgram;\n\t\t\trenderItem.groupOrder = groupOrder;\n\t\t\trenderItem.renderOrder = object.renderOrder;\n\t\t\trenderItem.z = z;\n\t\t\trenderItem.group = group;\n\n\t\t}\n\n\t\trenderItemsIndex ++;\n\n\t\treturn renderItem;\n\n\t}\n\n\tfunction push( object, geometry, material, groupOrder, z, group ) {\n\n\t\tconst renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );\n\n\t\t( material.transparent === true ? transparent : opaque ).push( renderItem );\n\n\t}\n\n\tfunction unshift( object, geometry, material, groupOrder, z, group ) {\n\n\t\tconst renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );\n\n\t\t( material.transparent === true ? transparent : opaque ).unshift( renderItem );\n\n\t}\n\n\tfunction sort( customOpaqueSort, customTransparentSort ) {\n\n\t\tif ( opaque.length > 1 ) opaque.sort( customOpaqueSort || painterSortStable );\n\t\tif ( transparent.length > 1 ) transparent.sort( customTransparentSort || reversePainterSortStable );\n\n\t}\n\n\tfunction finish() {\n\n\t\t// Clear references from inactive renderItems in the list\n\n\t\tfor ( let i = renderItemsIndex, il = renderItems.length; i < il; i ++ ) {\n\n\t\t\tconst renderItem = renderItems[ i ];\n\n\t\t\tif ( renderItem.id === null ) break;\n\n\t\t\trenderItem.id = null;\n\t\t\trenderItem.object = null;\n\t\t\trenderItem.geometry = null;\n\t\t\trenderItem.material = null;\n\t\t\trenderItem.program = null;\n\t\t\trenderItem.group = null;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\topaque: opaque,\n\t\ttransparent: transparent,\n\n\t\tinit: init,\n\t\tpush: push,\n\t\tunshift: unshift,\n\t\tfinish: finish,\n\n\t\tsort: sort\n\t};\n\n}\n\nfunction WebGLRenderLists() {\n\n\tlet lists = new WeakMap();\n\n\tfunction onSceneDispose( event ) {\n\n\t\tconst scene = event.target;\n\n\t\tscene.removeEventListener( 'dispose', onSceneDispose );\n\n\t\tlists.delete( scene );\n\n\t}\n\n\tfunction get( scene, camera ) {\n\n\t\tconst cameras = lists.get( scene );\n\t\tlet list;\n\n\t\tif ( cameras === undefined ) {\n\n\t\t\tlist = new WebGLRenderList();\n\t\t\tlists.set( scene, new WeakMap() );\n\t\t\tlists.get( scene ).set( camera, list );\n\n\t\t\tscene.addEventListener( 'dispose', onSceneDispose );\n\n\t\t} else {\n\n\t\t\tlist = cameras.get( camera );\n\t\t\tif ( list === undefined ) {\n\n\t\t\t\tlist = new WebGLRenderList();\n\t\t\t\tcameras.set( camera, list );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn list;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tlists = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLRenderLists };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Color } from '../../math/Color.js';\nimport { Matrix4 } from '../../math/Matrix4.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Vector3 } from '../../math/Vector3.js';\n\nfunction UniformsCache() {\n\n\tconst lights = {};\n\n\treturn {\n\n\t\tget: function ( light ) {\n\n\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\treturn lights[ light.id ];\n\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch ( light.type ) {\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tconeCos: 0,\n\t\t\t\t\t\tpenumbraCos: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'HemisphereLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tskyColor: new Color(),\n\t\t\t\t\t\tgroundColor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RectAreaLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\thalfWidth: new Vector3(),\n\t\t\t\t\t\thalfHeight: new Vector3()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\treturn uniforms;\n\n\t\t}\n\n\t};\n\n}\n\nfunction ShadowUniformsCache() {\n\n\tconst lights = {};\n\n\treturn {\n\n\t\tget: function ( light ) {\n\n\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\treturn lights[ light.id ];\n\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch ( light.type ) {\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2(),\n\t\t\t\t\t\tshadowCameraNear: 1,\n\t\t\t\t\t\tshadowCameraFar: 1000\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\t// TODO (abelnation): set RectAreaLight shadow uniforms\n\n\t\t\t}\n\n\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\treturn uniforms;\n\n\t\t}\n\n\t};\n\n}\n\n\n\nlet nextVersion = 0;\n\nfunction shadowCastingLightsFirst( lightA, lightB ) {\n\n\treturn ( lightB.castShadow ? 1 : 0 ) - ( lightA.castShadow ? 1 : 0 );\n\n}\n\nfunction WebGLLights() {\n\n\tconst cache = new UniformsCache();\n\n\tconst shadowCache = ShadowUniformsCache();\n\n\tconst state = {\n\n\t\tversion: 0,\n\n\t\thash: {\n\t\t\tdirectionalLength: - 1,\n\t\t\tpointLength: - 1,\n\t\t\tspotLength: - 1,\n\t\t\trectAreaLength: - 1,\n\t\t\themiLength: - 1,\n\n\t\t\tnumDirectionalShadows: - 1,\n\t\t\tnumPointShadows: - 1,\n\t\t\tnumSpotShadows: - 1\n\t\t},\n\n\t\tambient: [ 0, 0, 0 ],\n\t\tprobe: [],\n\t\tdirectional: [],\n\t\tdirectionalShadow: [],\n\t\tdirectionalShadowMap: [],\n\t\tdirectionalShadowMatrix: [],\n\t\tspot: [],\n\t\tspotShadow: [],\n\t\tspotShadowMap: [],\n\t\tspotShadowMatrix: [],\n\t\trectArea: [],\n\t\tpoint: [],\n\t\tpointShadow: [],\n\t\tpointShadowMap: [],\n\t\tpointShadowMatrix: [],\n\t\themi: []\n\n\t};\n\n\tfor ( let i = 0; i < 9; i ++ ) state.probe.push( new Vector3() );\n\n\tconst vector3 = new Vector3();\n\tconst matrix4 = new Matrix4();\n\tconst matrix42 = new Matrix4();\n\n\tfunction setup( lights, shadows, camera ) {\n\n\t\tlet r = 0, g = 0, b = 0;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) state.probe[ i ].set( 0, 0, 0 );\n\n\t\tlet directionalLength = 0;\n\t\tlet pointLength = 0;\n\t\tlet spotLength = 0;\n\t\tlet rectAreaLength = 0;\n\t\tlet hemiLength = 0;\n\n\t\tlet numDirectionalShadows = 0;\n\t\tlet numPointShadows = 0;\n\t\tlet numSpotShadows = 0;\n\n\t\tconst viewMatrix = camera.matrixWorldInverse;\n\n\t\tlights.sort( shadowCastingLightsFirst );\n\n\t\tfor ( let i = 0, l = lights.length; i < l; i ++ ) {\n\n\t\t\tconst light = lights[ i ];\n\n\t\t\tconst color = light.color;\n\t\t\tconst intensity = light.intensity;\n\t\t\tconst distance = light.distance;\n\n\t\t\tconst shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null;\n\n\t\t\tif ( light.isAmbientLight ) {\n\n\t\t\t\tr += color.r * intensity;\n\t\t\t\tg += color.g * intensity;\n\t\t\t\tb += color.b * intensity;\n\n\t\t\t} else if ( light.isLightProbe ) {\n\n\t\t\t\tfor ( let j = 0; j < 9; j ++ ) {\n\n\t\t\t\t\tstate.probe[ j ].addScaledVector( light.sh.coefficients[ j ], intensity );\n\n\t\t\t\t}\n\n\t\t\t} else if ( light.isDirectionalLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\tstate.directionalShadow[ directionalLength ] = shadowUniforms;\n\t\t\t\t\tstate.directionalShadowMap[ directionalLength ] = shadowMap;\n\t\t\t\t\tstate.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumDirectionalShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.directional[ directionalLength ] = uniforms;\n\n\t\t\t\tdirectionalLength ++;\n\n\t\t\t} else if ( light.isSpotLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\t\t\t\tuniforms.distance = distance;\n\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\tuniforms.coneCos = Math.cos( light.angle );\n\t\t\t\tuniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) );\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\tstate.spotShadow[ spotLength ] = shadowUniforms;\n\t\t\t\t\tstate.spotShadowMap[ spotLength ] = shadowMap;\n\t\t\t\t\tstate.spotShadowMatrix[ spotLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumSpotShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.spot[ spotLength ] = uniforms;\n\n\t\t\t\tspotLength ++;\n\n\t\t\t} else if ( light.isRectAreaLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\t// (a) intensity is the total visible light emitted\n\t\t\t\t//uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );\n\n\t\t\t\t// (b) intensity is the brightness of the light\n\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\t// extract local rotation of light to derive width/height half vectors\n\t\t\t\tmatrix42.identity();\n\t\t\t\tmatrix4.copy( light.matrixWorld );\n\t\t\t\tmatrix4.premultiply( viewMatrix );\n\t\t\t\tmatrix42.extractRotation( matrix4 );\n\n\t\t\t\tuniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 );\n\t\t\t\tuniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 );\n\n\t\t\t\tuniforms.halfWidth.applyMatrix4( matrix42 );\n\t\t\t\tuniforms.halfHeight.applyMatrix4( matrix42 );\n\n\t\t\t\t// TODO (abelnation): RectAreaLight distance?\n\t\t\t\t// uniforms.distance = distance;\n\n\t\t\t\tstate.rectArea[ rectAreaLength ] = uniforms;\n\n\t\t\t\trectAreaLength ++;\n\n\t\t\t} else if ( light.isPointLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\tuniforms.distance = light.distance;\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\tshadowUniforms.shadowCameraNear = shadow.camera.near;\n\t\t\t\t\tshadowUniforms.shadowCameraFar = shadow.camera.far;\n\n\t\t\t\t\tstate.pointShadow[ pointLength ] = shadowUniforms;\n\t\t\t\t\tstate.pointShadowMap[ pointLength ] = shadowMap;\n\t\t\t\t\tstate.pointShadowMatrix[ pointLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumPointShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.point[ pointLength ] = uniforms;\n\n\t\t\t\tpointLength ++;\n\n\t\t\t} else if ( light.isHemisphereLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\t\t\t\tuniforms.direction.normalize();\n\n\t\t\t\tuniforms.skyColor.copy( light.color ).multiplyScalar( intensity );\n\t\t\t\tuniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );\n\n\t\t\t\tstate.hemi[ hemiLength ] = uniforms;\n\n\t\t\t\themiLength ++;\n\n\t\t\t}\n\n\t\t}\n\n\t\tstate.ambient[ 0 ] = r;\n\t\tstate.ambient[ 1 ] = g;\n\t\tstate.ambient[ 2 ] = b;\n\n\t\tconst hash = state.hash;\n\n\t\tif ( hash.directionalLength !== directionalLength ||\n\t\t\thash.pointLength !== pointLength ||\n\t\t\thash.spotLength !== spotLength ||\n\t\t\thash.rectAreaLength !== rectAreaLength ||\n\t\t\thash.hemiLength !== hemiLength ||\n\t\t\thash.numDirectionalShadows !== numDirectionalShadows ||\n\t\t\thash.numPointShadows !== numPointShadows ||\n\t\t\thash.numSpotShadows !== numSpotShadows ) {\n\n\t\t\tstate.directional.length = directionalLength;\n\t\t\tstate.spot.length = spotLength;\n\t\t\tstate.rectArea.length = rectAreaLength;\n\t\t\tstate.point.length = pointLength;\n\t\t\tstate.hemi.length = hemiLength;\n\n\t\t\tstate.directionalShadow.length = numDirectionalShadows;\n\t\t\tstate.directionalShadowMap.length = numDirectionalShadows;\n\t\t\tstate.pointShadow.length = numPointShadows;\n\t\t\tstate.pointShadowMap.length = numPointShadows;\n\t\t\tstate.spotShadow.length = numSpotShadows;\n\t\t\tstate.spotShadowMap.length = numSpotShadows;\n\t\t\tstate.directionalShadowMatrix.length = numDirectionalShadows;\n\t\t\tstate.pointShadowMatrix.length = numPointShadows;\n\t\t\tstate.spotShadowMatrix.length = numSpotShadows;\n\n\t\t\thash.directionalLength = directionalLength;\n\t\t\thash.pointLength = pointLength;\n\t\t\thash.spotLength = spotLength;\n\t\t\thash.rectAreaLength = rectAreaLength;\n\t\t\thash.hemiLength = hemiLength;\n\n\t\t\thash.numDirectionalShadows = numDirectionalShadows;\n\t\t\thash.numPointShadows = numPointShadows;\n\t\t\thash.numSpotShadows = numSpotShadows;\n\n\t\t\tstate.version = nextVersion ++;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\tsetup: setup,\n\t\tstate: state\n\t};\n\n}\n\n\nexport { WebGLLights };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { WebGLLights } from './WebGLLights.js';\n\nfunction WebGLRenderState() {\n\n\tconst lights = new WebGLLights();\n\n\tconst lightsArray = [];\n\tconst shadowsArray = [];\n\n\tfunction init() {\n\n\t\tlightsArray.length = 0;\n\t\tshadowsArray.length = 0;\n\n\t}\n\n\tfunction pushLight( light ) {\n\n\t\tlightsArray.push( light );\n\n\t}\n\n\tfunction pushShadow( shadowLight ) {\n\n\t\tshadowsArray.push( shadowLight );\n\n\t}\n\n\tfunction setupLights( camera ) {\n\n\t\tlights.setup( lightsArray, shadowsArray, camera );\n\n\t}\n\n\tconst state = {\n\t\tlightsArray: lightsArray,\n\t\tshadowsArray: shadowsArray,\n\n\t\tlights: lights\n\t};\n\n\treturn {\n\t\tinit: init,\n\t\tstate: state,\n\t\tsetupLights: setupLights,\n\n\t\tpushLight: pushLight,\n\t\tpushShadow: pushShadow\n\t};\n\n}\n\nfunction WebGLRenderStates() {\n\n\tlet renderStates = new WeakMap();\n\n\tfunction onSceneDispose( event ) {\n\n\t\tconst scene = event.target;\n\n\t\tscene.removeEventListener( 'dispose', onSceneDispose );\n\n\t\trenderStates.delete( scene );\n\n\t}\n\n\tfunction get( scene, camera ) {\n\n\t\tlet renderState;\n\n\t\tif ( renderStates.has( scene ) === false ) {\n\n\t\t\trenderState = new WebGLRenderState();\n\t\t\trenderStates.set( scene, new WeakMap() );\n\t\t\trenderStates.get( scene ).set( camera, renderState );\n\n\t\t\tscene.addEventListener( 'dispose', onSceneDispose );\n\n\t\t} else {\n\n\t\t\tif ( renderStates.get( scene ).has( camera ) === false ) {\n\n\t\t\t\trenderState = new WebGLRenderState();\n\t\t\t\trenderStates.get( scene ).set( camera, renderState );\n\n\t\t\t} else {\n\n\t\t\t\trenderState = renderStates.get( scene ).get( camera );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn renderState;\n\n\t}\n\n\tfunction dispose() {\n\n\t\trenderStates = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLRenderStates };\n","import { Material } from './Material.js';\nimport { BasicDepthPacking } from '../constants.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author bhouston / https://clara.io\n * @author WestLangley / http://github.com/WestLangley\n *\n * parameters = {\n *\n * opacity: ,\n *\n * map: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * displacementMap: new THREE.Texture( ),\n * displacementScale: ,\n * displacementBias: ,\n *\n * wireframe: ,\n * wireframeLinewidth: \n * }\n */\n\nfunction MeshDepthMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshDepthMaterial';\n\n\tthis.depthPacking = BasicDepthPacking;\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.displacementMap = null;\n\tthis.displacementScale = 1;\n\tthis.displacementBias = 0;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\n\tthis.fog = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshDepthMaterial.prototype = Object.create( Material.prototype );\nMeshDepthMaterial.prototype.constructor = MeshDepthMaterial;\n\nMeshDepthMaterial.prototype.isMeshDepthMaterial = true;\n\nMeshDepthMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.depthPacking = source.depthPacking;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.displacementMap = source.displacementMap;\n\tthis.displacementScale = source.displacementScale;\n\tthis.displacementBias = source.displacementBias;\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\treturn this;\n\n};\n\n\nexport { MeshDepthMaterial };\n","import { Material } from './Material.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n/**\n * @author WestLangley / http://github.com/WestLangley\n *\n * parameters = {\n *\n * referencePosition: ,\n * nearDistance: ,\n * farDistance: ,\n *\n * skinning: ,\n * morphTargets: ,\n *\n * map: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * displacementMap: new THREE.Texture( ),\n * displacementScale: ,\n * displacementBias: \n *\n * }\n */\n\nfunction MeshDistanceMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshDistanceMaterial';\n\n\tthis.referencePosition = new Vector3();\n\tthis.nearDistance = 1;\n\tthis.farDistance = 1000;\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.displacementMap = null;\n\tthis.displacementScale = 1;\n\tthis.displacementBias = 0;\n\n\tthis.fog = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshDistanceMaterial.prototype = Object.create( Material.prototype );\nMeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;\n\nMeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;\n\nMeshDistanceMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.referencePosition.copy( source.referencePosition );\n\tthis.nearDistance = source.nearDistance;\n\tthis.farDistance = source.farDistance;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.displacementMap = source.displacementMap;\n\tthis.displacementScale = source.displacementScale;\n\tthis.displacementBias = source.displacementBias;\n\n\treturn this;\n\n};\n\n\nexport { MeshDistanceMaterial };\n","export default /* glsl */`\nuniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n\n#include \n\nvoid main() {\n\n float mean = 0.0;\n float squared_mean = 0.0;\n\n\t// This seems totally useless but it's a crazy work around for a Adreno compiler bug\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\n #ifdef HORIZONAL_PASS\n\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\n #else\n\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n\n #endif\n\n }\n\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n\n float std_dev = sqrt( squared_mean - mean * mean );\n\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n\n}\n`;\n","export default /* glsl */`\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n`;\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { FrontSide, BackSide, DoubleSide, RGBAFormat, NearestFilter, LinearFilter, PCFShadowMap, VSMShadowMap, RGBADepthPacking, NoBlending } from '../../constants.js';\nimport { WebGLRenderTarget } from '../WebGLRenderTarget.js';\nimport { MeshDepthMaterial } from '../../materials/MeshDepthMaterial.js';\nimport { MeshDistanceMaterial } from '../../materials/MeshDistanceMaterial.js';\nimport { ShaderMaterial } from '../../materials/ShaderMaterial.js';\nimport { BufferAttribute } from '../../core/BufferAttribute.js';\nimport { BufferGeometry } from '../../core/BufferGeometry.js';\nimport { Mesh } from '../../objects/Mesh.js';\nimport { Vector4 } from '../../math/Vector4.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Frustum } from '../../math/Frustum.js';\n\nimport vsm_frag from '../shaders/ShaderLib/vsm_frag.glsl.js';\nimport vsm_vert from '../shaders/ShaderLib/vsm_vert.glsl.js';\n\nfunction WebGLShadowMap( _renderer, _objects, maxTextureSize ) {\n\n\tlet _frustum = new Frustum();\n\n\tconst _shadowMapSize = new Vector2(),\n\t\t_viewportSize = new Vector2(),\n\n\t\t_viewport = new Vector4(),\n\n\t\t_depthMaterials = [],\n\t\t_distanceMaterials = [],\n\n\t\t_materialCache = {};\n\n\tconst shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };\n\n\tconst shadowMaterialVertical = new ShaderMaterial( {\n\n\t\tdefines: {\n\t\t\tSAMPLE_RATE: 2.0 / 8.0,\n\t\t\tHALF_SAMPLE_RATE: 1.0 / 8.0\n\t\t},\n\n\t\tuniforms: {\n\t\t\tshadow_pass: { value: null },\n\t\t\tresolution: { value: new Vector2() },\n\t\t\tradius: { value: 4.0 }\n\t\t},\n\n\t\tvertexShader: vsm_vert,\n\n\t\tfragmentShader: vsm_frag\n\n\t} );\n\n\tconst shadowMaterialHorizonal = shadowMaterialVertical.clone();\n\tshadowMaterialHorizonal.defines.HORIZONAL_PASS = 1;\n\n\tconst fullScreenTri = new BufferGeometry();\n\tfullScreenTri.setAttribute(\n\t\t\"position\",\n\t\tnew BufferAttribute(\n\t\t\tnew Float32Array( [ - 1, - 1, 0.5, 3, - 1, 0.5, - 1, 3, 0.5 ] ),\n\t\t\t3\n\t\t)\n\t);\n\n\tconst fullScreenMesh = new Mesh( fullScreenTri, shadowMaterialVertical );\n\n\tconst scope = this;\n\n\tthis.enabled = false;\n\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\n\tthis.type = PCFShadowMap;\n\n\tthis.render = function ( lights, scene, camera ) {\n\n\t\tif ( scope.enabled === false ) return;\n\t\tif ( scope.autoUpdate === false && scope.needsUpdate === false ) return;\n\n\t\tif ( lights.length === 0 ) return;\n\n\t\tconst currentRenderTarget = _renderer.getRenderTarget();\n\t\tconst activeCubeFace = _renderer.getActiveCubeFace();\n\t\tconst activeMipmapLevel = _renderer.getActiveMipmapLevel();\n\n\t\tconst _state = _renderer.state;\n\n\t\t// Set GL state for depth map.\n\t\t_state.setBlending( NoBlending );\n\t\t_state.buffers.color.setClear( 1, 1, 1, 1 );\n\t\t_state.buffers.depth.setTest( true );\n\t\t_state.setScissorTest( false );\n\n\t\t// render depth map\n\n\t\tfor ( let i = 0, il = lights.length; i < il; i ++ ) {\n\n\t\t\tconst light = lights[ i ];\n\t\t\tconst shadow = light.shadow;\n\n\t\t\tif ( shadow.autoUpdate === false && shadow.needsUpdate === false ) continue;\n\n\t\t\tif ( shadow === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\t_shadowMapSize.copy( shadow.mapSize );\n\n\t\t\tconst shadowFrameExtents = shadow.getFrameExtents();\n\n\t\t\t_shadowMapSize.multiply( shadowFrameExtents );\n\n\t\t\t_viewportSize.copy( shadow.mapSize );\n\n\t\t\tif ( _shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize ) {\n\n\t\t\t\tif ( _shadowMapSize.x > maxTextureSize ) {\n\n\t\t\t\t\t_viewportSize.x = Math.floor( maxTextureSize / shadowFrameExtents.x );\n\t\t\t\t\t_shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x;\n\t\t\t\t\tshadow.mapSize.x = _viewportSize.x;\n\n\t\t\t\t}\n\n\t\t\t\tif ( _shadowMapSize.y > maxTextureSize ) {\n\n\t\t\t\t\t_viewportSize.y = Math.floor( maxTextureSize / shadowFrameExtents.y );\n\t\t\t\t\t_shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y;\n\t\t\t\t\tshadow.mapSize.y = _viewportSize.y;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( shadow.map === null && ! shadow.isPointLightShadow && this.type === VSMShadowMap ) {\n\n\t\t\t\tconst pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };\n\n\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\tshadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t\tif ( shadow.map === null ) {\n\n\t\t\t\tconst pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat };\n\n\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t\t_renderer.setRenderTarget( shadow.map );\n\t\t\t_renderer.clear();\n\n\t\t\tconst viewportCount = shadow.getViewportCount();\n\n\t\t\tfor ( let vp = 0; vp < viewportCount; vp ++ ) {\n\n\t\t\t\tconst viewport = shadow.getViewport( vp );\n\n\t\t\t\t_viewport.set(\n\t\t\t\t\t_viewportSize.x * viewport.x,\n\t\t\t\t\t_viewportSize.y * viewport.y,\n\t\t\t\t\t_viewportSize.x * viewport.z,\n\t\t\t\t\t_viewportSize.y * viewport.w\n\t\t\t\t);\n\n\t\t\t\t_state.viewport( _viewport );\n\n\t\t\t\tshadow.updateMatrices( light, vp );\n\n\t\t\t\t_frustum = shadow.getFrustum();\n\n\t\t\t\trenderObject( scene, camera, shadow.camera, light, this.type );\n\n\t\t\t}\n\n\t\t\t// do blur pass for VSM\n\n\t\t\tif ( ! shadow.isPointLightShadow && this.type === VSMShadowMap ) {\n\n\t\t\t\tVSMPass( shadow, camera );\n\n\t\t\t}\n\n\t\t\tshadow.needsUpdate = false;\n\n\t\t}\n\n\t\tscope.needsUpdate = false;\n\n\t\t_renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );\n\n\t};\n\n\tfunction VSMPass( shadow, camera ) {\n\n\t\tconst geometry = _objects.update( fullScreenMesh );\n\n\t\t// vertical pass\n\n\t\tshadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;\n\t\tshadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialVertical.uniforms.radius.value = shadow.radius;\n\t\t_renderer.setRenderTarget( shadow.mapPass );\n\t\t_renderer.clear();\n\t\t_renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );\n\n\t\t// horizonal pass\n\n\t\tshadowMaterialHorizonal.uniforms.shadow_pass.value = shadow.mapPass.texture;\n\t\tshadowMaterialHorizonal.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialHorizonal.uniforms.radius.value = shadow.radius;\n\t\t_renderer.setRenderTarget( shadow.map );\n\t\t_renderer.clear();\n\t\t_renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizonal, fullScreenMesh, null );\n\n\t}\n\n\tfunction getDepthMaterialVariant( useMorphing, useSkinning, useInstancing ) {\n\n\t\tconst index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\n\t\tlet material = _depthMaterials[ index ];\n\n\t\tif ( material === undefined ) {\n\n\t\t\tmaterial = new MeshDepthMaterial( {\n\n\t\t\t\tdepthPacking: RGBADepthPacking,\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_depthMaterials[ index ] = material;\n\n\t\t}\n\n\t\treturn material;\n\n\t}\n\n\tfunction getDistanceMaterialVariant( useMorphing, useSkinning, useInstancing ) {\n\n\t\tconst index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\n\t\tlet material = _distanceMaterials[ index ];\n\n\t\tif ( material === undefined ) {\n\n\t\t\tmaterial = new MeshDistanceMaterial( {\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_distanceMaterials[ index ] = material;\n\n\t\t}\n\n\t\treturn material;\n\n\t}\n\n\tfunction getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) {\n\n\t\tlet result = null;\n\n\t\tlet getMaterialVariant = getDepthMaterialVariant;\n\t\tlet customMaterial = object.customDepthMaterial;\n\n\t\tif ( light.isPointLight === true ) {\n\n\t\t\tgetMaterialVariant = getDistanceMaterialVariant;\n\t\t\tcustomMaterial = object.customDistanceMaterial;\n\n\t\t}\n\n\t\tif ( customMaterial === undefined ) {\n\n\t\t\tlet useMorphing = false;\n\n\t\t\tif ( material.morphTargets === true ) {\n\n\t\t\t\tuseMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;\n\n\t\t\t}\n\n\t\t\tlet useSkinning = false;\n\n\t\t\tif ( object.isSkinnedMesh === true ) {\n\n\t\t\t\tif ( material.skinning === true ) {\n\n\t\t\t\t\tuseSkinning = true;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:', object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst useInstancing = object.isInstancedMesh === true;\n\n\t\t\tresult = getMaterialVariant( useMorphing, useSkinning, useInstancing );\n\n\t\t} else {\n\n\t\t\tresult = customMaterial;\n\n\t\t}\n\n\t\tif ( _renderer.localClippingEnabled &&\n\t\t\t\tmaterial.clipShadows === true &&\n\t\t\t\tmaterial.clippingPlanes.length !== 0 ) {\n\n\t\t\t// in this case we need a unique material instance reflecting the\n\t\t\t// appropriate state\n\n\t\t\tconst keyA = result.uuid, keyB = material.uuid;\n\n\t\t\tlet materialsForVariant = _materialCache[ keyA ];\n\n\t\t\tif ( materialsForVariant === undefined ) {\n\n\t\t\t\tmaterialsForVariant = {};\n\t\t\t\t_materialCache[ keyA ] = materialsForVariant;\n\n\t\t\t}\n\n\t\t\tlet cachedMaterial = materialsForVariant[ keyB ];\n\n\t\t\tif ( cachedMaterial === undefined ) {\n\n\t\t\t\tcachedMaterial = result.clone();\n\t\t\t\tmaterialsForVariant[ keyB ] = cachedMaterial;\n\n\t\t\t}\n\n\t\t\tresult = cachedMaterial;\n\n\t\t}\n\n\t\tresult.visible = material.visible;\n\t\tresult.wireframe = material.wireframe;\n\n\t\tif ( type === VSMShadowMap ) {\n\n\t\t\tresult.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side;\n\n\t\t} else {\n\n\t\t\tresult.side = ( material.shadowSide !== null ) ? material.shadowSide : shadowSide[ material.side ];\n\n\t\t}\n\n\t\tresult.clipShadows = material.clipShadows;\n\t\tresult.clippingPlanes = material.clippingPlanes;\n\t\tresult.clipIntersection = material.clipIntersection;\n\n\t\tresult.wireframeLinewidth = material.wireframeLinewidth;\n\t\tresult.linewidth = material.linewidth;\n\n\t\tif ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {\n\n\t\t\tresult.referencePosition.setFromMatrixPosition( light.matrixWorld );\n\t\t\tresult.nearDistance = shadowCameraNear;\n\t\t\tresult.farDistance = shadowCameraFar;\n\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\tfunction renderObject( object, camera, shadowCamera, light, type ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tconst visible = object.layers.test( camera.layers );\n\n\t\tif ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) {\n\n\t\t\tif ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) {\n\n\t\t\t\tobject.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );\n\n\t\t\t\tconst geometry = _objects.update( object );\n\t\t\t\tconst material = object.material;\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\tfor ( let k = 0, kl = groups.length; k < kl; k ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ k ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\tconst depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type );\n\n\t\t\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\tconst depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type );\n\n\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\trenderObject( children[ i ], camera, shadowCamera, light, type );\n\n\t\t}\n\n\t}\n\n}\n\n\nexport { WebGLShadowMap };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js';\nimport { Vector4 } from '../../math/Vector4.js';\n\nfunction WebGLState( gl, extensions, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction ColorBuffer() {\n\n\t\tlet locked = false;\n\n\t\tconst color = new Vector4();\n\t\tlet currentColorMask = null;\n\t\tconst currentColorClear = new Vector4( 0, 0, 0, 0 );\n\n\t\treturn {\n\n\t\t\tsetMask: function ( colorMask ) {\n\n\t\t\t\tif ( currentColorMask !== colorMask && ! locked ) {\n\n\t\t\t\t\tgl.colorMask( colorMask, colorMask, colorMask, colorMask );\n\t\t\t\t\tcurrentColorMask = colorMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( r, g, b, a, premultipliedAlpha ) {\n\n\t\t\t\tif ( premultipliedAlpha === true ) {\n\n\t\t\t\t\tr *= a; g *= a; b *= a;\n\n\t\t\t\t}\n\n\t\t\t\tcolor.set( r, g, b, a );\n\n\t\t\t\tif ( currentColorClear.equals( color ) === false ) {\n\n\t\t\t\t\tgl.clearColor( r, g, b, a );\n\t\t\t\t\tcurrentColorClear.copy( color );\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentColorMask = null;\n\t\t\t\tcurrentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tfunction DepthBuffer() {\n\n\t\tlet locked = false;\n\n\t\tlet currentDepthMask = null;\n\t\tlet currentDepthFunc = null;\n\t\tlet currentDepthClear = null;\n\n\t\treturn {\n\n\t\t\tsetTest: function ( depthTest ) {\n\n\t\t\t\tif ( depthTest ) {\n\n\t\t\t\t\tenable( gl.DEPTH_TEST );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdisable( gl.DEPTH_TEST );\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetMask: function ( depthMask ) {\n\n\t\t\t\tif ( currentDepthMask !== depthMask && ! locked ) {\n\n\t\t\t\t\tgl.depthMask( depthMask );\n\t\t\t\t\tcurrentDepthMask = depthMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetFunc: function ( depthFunc ) {\n\n\t\t\t\tif ( currentDepthFunc !== depthFunc ) {\n\n\t\t\t\t\tif ( depthFunc ) {\n\n\t\t\t\t\t\tswitch ( depthFunc ) {\n\n\t\t\t\t\t\t\tcase NeverDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.NEVER );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase AlwaysDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.ALWAYS );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase LessDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LESS );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase LessEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase EqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.EQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase GreaterEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.GEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase GreaterDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.GREATER );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase NotEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.NOTEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentDepthFunc = depthFunc;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( depth ) {\n\n\t\t\t\tif ( currentDepthClear !== depth ) {\n\n\t\t\t\t\tgl.clearDepth( depth );\n\t\t\t\t\tcurrentDepthClear = depth;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentDepthMask = null;\n\t\t\t\tcurrentDepthFunc = null;\n\t\t\t\tcurrentDepthClear = null;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tfunction StencilBuffer() {\n\n\t\tlet locked = false;\n\n\t\tlet currentStencilMask = null;\n\t\tlet currentStencilFunc = null;\n\t\tlet currentStencilRef = null;\n\t\tlet currentStencilFuncMask = null;\n\t\tlet currentStencilFail = null;\n\t\tlet currentStencilZFail = null;\n\t\tlet currentStencilZPass = null;\n\t\tlet currentStencilClear = null;\n\n\t\treturn {\n\n\t\t\tsetTest: function ( stencilTest ) {\n\n\t\t\t\tif ( ! locked ) {\n\n\t\t\t\t\tif ( stencilTest ) {\n\n\t\t\t\t\t\tenable( gl.STENCIL_TEST );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tdisable( gl.STENCIL_TEST );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetMask: function ( stencilMask ) {\n\n\t\t\t\tif ( currentStencilMask !== stencilMask && ! locked ) {\n\n\t\t\t\t\tgl.stencilMask( stencilMask );\n\t\t\t\t\tcurrentStencilMask = stencilMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetFunc: function ( stencilFunc, stencilRef, stencilMask ) {\n\n\t\t\t\tif ( currentStencilFunc !== stencilFunc ||\n\t\t\t\t currentStencilRef \t!== stencilRef \t||\n\t\t\t\t currentStencilFuncMask !== stencilMask ) {\n\n\t\t\t\t\tgl.stencilFunc( stencilFunc, stencilRef, stencilMask );\n\n\t\t\t\t\tcurrentStencilFunc = stencilFunc;\n\t\t\t\t\tcurrentStencilRef = stencilRef;\n\t\t\t\t\tcurrentStencilFuncMask = stencilMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetOp: function ( stencilFail, stencilZFail, stencilZPass ) {\n\n\t\t\t\tif ( currentStencilFail\t !== stencilFail \t||\n\t\t\t\t currentStencilZFail !== stencilZFail ||\n\t\t\t\t currentStencilZPass !== stencilZPass ) {\n\n\t\t\t\t\tgl.stencilOp( stencilFail, stencilZFail, stencilZPass );\n\n\t\t\t\t\tcurrentStencilFail = stencilFail;\n\t\t\t\t\tcurrentStencilZFail = stencilZFail;\n\t\t\t\t\tcurrentStencilZPass = stencilZPass;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( stencil ) {\n\n\t\t\t\tif ( currentStencilClear !== stencil ) {\n\n\t\t\t\t\tgl.clearStencil( stencil );\n\t\t\t\t\tcurrentStencilClear = stencil;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentStencilMask = null;\n\t\t\t\tcurrentStencilFunc = null;\n\t\t\t\tcurrentStencilRef = null;\n\t\t\t\tcurrentStencilFuncMask = null;\n\t\t\t\tcurrentStencilFail = null;\n\t\t\t\tcurrentStencilZFail = null;\n\t\t\t\tcurrentStencilZPass = null;\n\t\t\t\tcurrentStencilClear = null;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t//\n\n\tconst colorBuffer = new ColorBuffer();\n\tconst depthBuffer = new DepthBuffer();\n\tconst stencilBuffer = new StencilBuffer();\n\n\tlet enabledCapabilities = {};\n\n\tlet currentProgram = null;\n\n\tlet currentBlendingEnabled = null;\n\tlet currentBlending = null;\n\tlet currentBlendEquation = null;\n\tlet currentBlendSrc = null;\n\tlet currentBlendDst = null;\n\tlet currentBlendEquationAlpha = null;\n\tlet currentBlendSrcAlpha = null;\n\tlet currentBlendDstAlpha = null;\n\tlet currentPremultipledAlpha = false;\n\n\tlet currentFlipSided = null;\n\tlet currentCullFace = null;\n\n\tlet currentLineWidth = null;\n\n\tlet currentPolygonOffsetFactor = null;\n\tlet currentPolygonOffsetUnits = null;\n\n\tconst maxTextures = gl.getParameter( gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS );\n\n\tlet lineWidthAvailable = false;\n\tlet version = 0;\n\tconst glVersion = gl.getParameter( gl.VERSION );\n\n\tif ( glVersion.indexOf( 'WebGL' ) !== - 1 ) {\n\n\t\tversion = parseFloat( /^WebGL\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\tlineWidthAvailable = ( version >= 1.0 );\n\n\t} else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) {\n\n\t\tversion = parseFloat( /^OpenGL\\ ES\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\tlineWidthAvailable = ( version >= 2.0 );\n\n\t}\n\n\tlet currentTextureSlot = null;\n\tlet currentBoundTextures = {};\n\n\tconst currentScissor = new Vector4();\n\tconst currentViewport = new Vector4();\n\n\tfunction createTexture( type, target, count ) {\n\n\t\tconst data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.\n\t\tconst texture = gl.createTexture();\n\n\t\tgl.bindTexture( type, texture );\n\t\tgl.texParameteri( type, gl.TEXTURE_MIN_FILTER, gl.NEAREST );\n\t\tgl.texParameteri( type, gl.TEXTURE_MAG_FILTER, gl.NEAREST );\n\n\t\tfor ( let i = 0; i < count; i ++ ) {\n\n\t\t\tgl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );\n\n\t\t}\n\n\t\treturn texture;\n\n\t}\n\n\tconst emptyTextures = {};\n\temptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );\n\temptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );\n\n\t// init\n\n\tcolorBuffer.setClear( 0, 0, 0, 1 );\n\tdepthBuffer.setClear( 1 );\n\tstencilBuffer.setClear( 0 );\n\n\tenable( gl.DEPTH_TEST );\n\tdepthBuffer.setFunc( LessEqualDepth );\n\n\tsetFlipSided( false );\n\tsetCullFace( CullFaceBack );\n\tenable( gl.CULL_FACE );\n\n\tsetBlending( NoBlending );\n\n\t//\n\n\tfunction enable( id ) {\n\n\t\tif ( enabledCapabilities[ id ] !== true ) {\n\n\t\t\tgl.enable( id );\n\t\t\tenabledCapabilities[ id ] = true;\n\n\t\t}\n\n\t}\n\n\tfunction disable( id ) {\n\n\t\tif ( enabledCapabilities[ id ] !== false ) {\n\n\t\t\tgl.disable( id );\n\t\t\tenabledCapabilities[ id ] = false;\n\n\t\t}\n\n\t}\n\n\tfunction useProgram( program ) {\n\n\t\tif ( currentProgram !== program ) {\n\n\t\t\tgl.useProgram( program );\n\n\t\t\tcurrentProgram = program;\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tconst equationToGL = {\n\t\t[ AddEquation ]: gl.FUNC_ADD,\n\t\t[ SubtractEquation ]: gl.FUNC_SUBTRACT,\n\t\t[ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT\n\t};\n\n\tif ( isWebGL2 ) {\n\n\t\tequationToGL[ MinEquation ] = gl.MIN;\n\t\tequationToGL[ MaxEquation ] = gl.MAX;\n\n\t} else {\n\n\t\tconst extension = extensions.get( 'EXT_blend_minmax' );\n\n\t\tif ( extension !== null ) {\n\n\t\t\tequationToGL[ MinEquation ] = extension.MIN_EXT;\n\t\t\tequationToGL[ MaxEquation ] = extension.MAX_EXT;\n\n\t\t}\n\n\t}\n\n\tconst factorToGL = {\n\t\t[ ZeroFactor ]: gl.ZERO,\n\t\t[ OneFactor ]: gl.ONE,\n\t\t[ SrcColorFactor ]: gl.SRC_COLOR,\n\t\t[ SrcAlphaFactor ]: gl.SRC_ALPHA,\n\t\t[ SrcAlphaSaturateFactor ]: gl.SRC_ALPHA_SATURATE,\n\t\t[ DstColorFactor ]: gl.DST_COLOR,\n\t\t[ DstAlphaFactor ]: gl.DST_ALPHA,\n\t\t[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,\n\t\t[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,\n\t\t[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,\n\t\t[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA\n\t};\n\n\tfunction setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {\n\n\t\tif ( blending === NoBlending ) {\n\n\t\t\tif ( currentBlendingEnabled ) {\n\n\t\t\t\tdisable( gl.BLEND );\n\t\t\t\tcurrentBlendingEnabled = false;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( ! currentBlendingEnabled ) {\n\n\t\t\tenable( gl.BLEND );\n\t\t\tcurrentBlendingEnabled = true;\n\n\t\t}\n\n\t\tif ( blending !== CustomBlending ) {\n\n\t\t\tif ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) {\n\n\t\t\t\tif ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) {\n\n\t\t\t\t\tgl.blendEquation( gl.FUNC_ADD );\n\n\t\t\t\t\tcurrentBlendEquation = AddEquation;\n\t\t\t\t\tcurrentBlendEquationAlpha = AddEquation;\n\n\t\t\t\t}\n\n\t\t\t\tif ( premultipliedAlpha ) {\n\n\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ONE, gl.ONE );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ZERO, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.SRC_ALPHA, gl.ONE );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ZERO, gl.ONE_MINUS_SRC_COLOR );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ZERO, gl.SRC_COLOR );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tcurrentBlendSrc = null;\n\t\t\t\tcurrentBlendDst = null;\n\t\t\t\tcurrentBlendSrcAlpha = null;\n\t\t\t\tcurrentBlendDstAlpha = null;\n\n\t\t\t\tcurrentBlending = blending;\n\t\t\t\tcurrentPremultipledAlpha = premultipliedAlpha;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t// custom blending\n\n\t\tblendEquationAlpha = blendEquationAlpha || blendEquation;\n\t\tblendSrcAlpha = blendSrcAlpha || blendSrc;\n\t\tblendDstAlpha = blendDstAlpha || blendDst;\n\n\t\tif ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) {\n\n\t\t\tgl.blendEquationSeparate( equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] );\n\n\t\t\tcurrentBlendEquation = blendEquation;\n\t\t\tcurrentBlendEquationAlpha = blendEquationAlpha;\n\n\t\t}\n\n\t\tif ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) {\n\n\t\t\tgl.blendFuncSeparate( factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] );\n\n\t\t\tcurrentBlendSrc = blendSrc;\n\t\t\tcurrentBlendDst = blendDst;\n\t\t\tcurrentBlendSrcAlpha = blendSrcAlpha;\n\t\t\tcurrentBlendDstAlpha = blendDstAlpha;\n\n\t\t}\n\n\t\tcurrentBlending = blending;\n\t\tcurrentPremultipledAlpha = null;\n\n\t}\n\n\tfunction setMaterial( material, frontFaceCW ) {\n\n\t\tmaterial.side === DoubleSide\n\t\t\t? disable( gl.CULL_FACE )\n\t\t\t: enable( gl.CULL_FACE );\n\n\t\tlet flipSided = ( material.side === BackSide );\n\t\tif ( frontFaceCW ) flipSided = ! flipSided;\n\n\t\tsetFlipSided( flipSided );\n\n\t\t( material.blending === NormalBlending && material.transparent === false )\n\t\t\t? setBlending( NoBlending )\n\t\t\t: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );\n\n\t\tdepthBuffer.setFunc( material.depthFunc );\n\t\tdepthBuffer.setTest( material.depthTest );\n\t\tdepthBuffer.setMask( material.depthWrite );\n\t\tcolorBuffer.setMask( material.colorWrite );\n\n\t\tconst stencilWrite = material.stencilWrite;\n\t\tstencilBuffer.setTest( stencilWrite );\n\t\tif ( stencilWrite ) {\n\n\t\t\tstencilBuffer.setMask( material.stencilWriteMask );\n\t\t\tstencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask );\n\t\t\tstencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass );\n\n\t\t}\n\n\t\tsetPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );\n\n\t}\n\n\t//\n\n\tfunction setFlipSided( flipSided ) {\n\n\t\tif ( currentFlipSided !== flipSided ) {\n\n\t\t\tif ( flipSided ) {\n\n\t\t\t\tgl.frontFace( gl.CW );\n\n\t\t\t} else {\n\n\t\t\t\tgl.frontFace( gl.CCW );\n\n\t\t\t}\n\n\t\t\tcurrentFlipSided = flipSided;\n\n\t\t}\n\n\t}\n\n\tfunction setCullFace( cullFace ) {\n\n\t\tif ( cullFace !== CullFaceNone ) {\n\n\t\t\tenable( gl.CULL_FACE );\n\n\t\t\tif ( cullFace !== currentCullFace ) {\n\n\t\t\t\tif ( cullFace === CullFaceBack ) {\n\n\t\t\t\t\tgl.cullFace( gl.BACK );\n\n\t\t\t\t} else if ( cullFace === CullFaceFront ) {\n\n\t\t\t\t\tgl.cullFace( gl.FRONT );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tgl.cullFace( gl.FRONT_AND_BACK );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdisable( gl.CULL_FACE );\n\n\t\t}\n\n\t\tcurrentCullFace = cullFace;\n\n\t}\n\n\tfunction setLineWidth( width ) {\n\n\t\tif ( width !== currentLineWidth ) {\n\n\t\t\tif ( lineWidthAvailable ) gl.lineWidth( width );\n\n\t\t\tcurrentLineWidth = width;\n\n\t\t}\n\n\t}\n\n\tfunction setPolygonOffset( polygonOffset, factor, units ) {\n\n\t\tif ( polygonOffset ) {\n\n\t\t\tenable( gl.POLYGON_OFFSET_FILL );\n\n\t\t\tif ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {\n\n\t\t\t\tgl.polygonOffset( factor, units );\n\n\t\t\t\tcurrentPolygonOffsetFactor = factor;\n\t\t\t\tcurrentPolygonOffsetUnits = units;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdisable( gl.POLYGON_OFFSET_FILL );\n\n\t\t}\n\n\t}\n\n\tfunction setScissorTest( scissorTest ) {\n\n\t\tif ( scissorTest ) {\n\n\t\t\tenable( gl.SCISSOR_TEST );\n\n\t\t} else {\n\n\t\t\tdisable( gl.SCISSOR_TEST );\n\n\t\t}\n\n\t}\n\n\t// texture\n\n\tfunction activeTexture( webglSlot ) {\n\n\t\tif ( webglSlot === undefined ) webglSlot = gl.TEXTURE0 + maxTextures - 1;\n\n\t\tif ( currentTextureSlot !== webglSlot ) {\n\n\t\t\tgl.activeTexture( webglSlot );\n\t\t\tcurrentTextureSlot = webglSlot;\n\n\t\t}\n\n\t}\n\n\tfunction bindTexture( webglType, webglTexture ) {\n\n\t\tif ( currentTextureSlot === null ) {\n\n\t\t\tactiveTexture();\n\n\t\t}\n\n\t\tlet boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\tif ( boundTexture === undefined ) {\n\n\t\t\tboundTexture = { type: undefined, texture: undefined };\n\t\t\tcurrentBoundTextures[ currentTextureSlot ] = boundTexture;\n\n\t\t}\n\n\t\tif ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) {\n\n\t\t\tgl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] );\n\n\t\t\tboundTexture.type = webglType;\n\t\t\tboundTexture.texture = webglTexture;\n\n\t\t}\n\n\t}\n\n\tfunction unbindTexture() {\n\n\t\tconst boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\tif ( boundTexture !== undefined && boundTexture.type !== undefined ) {\n\n\t\t\tgl.bindTexture( boundTexture.type, null );\n\n\t\t\tboundTexture.type = undefined;\n\t\t\tboundTexture.texture = undefined;\n\n\t\t}\n\n\t}\n\n\tfunction compressedTexImage2D() {\n\n\t\ttry {\n\n\t\t\tgl.compressedTexImage2D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\tfunction texImage2D() {\n\n\t\ttry {\n\n\t\t\tgl.texImage2D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\tfunction texImage3D() {\n\n\t\ttry {\n\n\t\t\tgl.texImage3D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction scissor( scissor ) {\n\n\t\tif ( currentScissor.equals( scissor ) === false ) {\n\n\t\t\tgl.scissor( scissor.x, scissor.y, scissor.z, scissor.w );\n\t\t\tcurrentScissor.copy( scissor );\n\n\t\t}\n\n\t}\n\n\tfunction viewport( viewport ) {\n\n\t\tif ( currentViewport.equals( viewport ) === false ) {\n\n\t\t\tgl.viewport( viewport.x, viewport.y, viewport.z, viewport.w );\n\t\t\tcurrentViewport.copy( viewport );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction reset() {\n\n\t\tenabledCapabilities = {};\n\n\t\tcurrentTextureSlot = null;\n\t\tcurrentBoundTextures = {};\n\n\t\tcurrentProgram = null;\n\n\t\tcurrentBlending = null;\n\n\t\tcurrentFlipSided = null;\n\t\tcurrentCullFace = null;\n\n\t\tcolorBuffer.reset();\n\t\tdepthBuffer.reset();\n\t\tstencilBuffer.reset();\n\n\t}\n\n\treturn {\n\n\t\tbuffers: {\n\t\t\tcolor: colorBuffer,\n\t\t\tdepth: depthBuffer,\n\t\t\tstencil: stencilBuffer\n\t\t},\n\n\t\tenable: enable,\n\t\tdisable: disable,\n\n\t\tuseProgram: useProgram,\n\n\t\tsetBlending: setBlending,\n\t\tsetMaterial: setMaterial,\n\n\t\tsetFlipSided: setFlipSided,\n\t\tsetCullFace: setCullFace,\n\n\t\tsetLineWidth: setLineWidth,\n\t\tsetPolygonOffset: setPolygonOffset,\n\n\t\tsetScissorTest: setScissorTest,\n\n\t\tactiveTexture: activeTexture,\n\t\tbindTexture: bindTexture,\n\t\tunbindTexture: unbindTexture,\n\t\tcompressedTexImage2D: compressedTexImage2D,\n\t\ttexImage2D: texImage2D,\n\t\ttexImage3D: texImage3D,\n\n\t\tscissor: scissor,\n\t\tviewport: viewport,\n\n\t\treset: reset\n\n\t};\n\n}\n\nexport { WebGLState };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping } from '../../constants.js';\nimport { MathUtils } from '../../math/MathUtils.js';\n\nfunction WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst maxTextures = capabilities.maxTextures;\n\tconst maxCubemapSize = capabilities.maxCubemapSize;\n\tconst maxTextureSize = capabilities.maxTextureSize;\n\tconst maxSamples = capabilities.maxSamples;\n\n\tconst _videoTextures = new WeakMap();\n\tlet _canvas;\n\n\t// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,\n\t// also OffscreenCanvas.getContext(\"webgl\"), but not OffscreenCanvas.getContext(\"2d\")!\n\t// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).\n\n\tlet useOffscreenCanvas = false;\n\n\ttry {\n\n\t\tuseOffscreenCanvas = typeof OffscreenCanvas !== 'undefined'\n\t\t\t&& ( new OffscreenCanvas( 1, 1 ).getContext( \"2d\" ) ) !== null;\n\n\t} catch ( err ) {\n\n\t\t// Ignore any errors\n\n\t}\n\n\tfunction createCanvas( width, height ) {\n\n\t\t// Use OffscreenCanvas when available. Specially needed in web workers\n\n\t\treturn useOffscreenCanvas ?\n\t\t\tnew OffscreenCanvas( width, height ) :\n\t\t\tdocument.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t}\n\n\tfunction resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {\n\n\t\tlet scale = 1;\n\n\t\t// handle case if texture exceeds max size\n\n\t\tif ( image.width > maxSize || image.height > maxSize ) {\n\n\t\t\tscale = maxSize / Math.max( image.width, image.height );\n\n\t\t}\n\n\t\t// only perform resize if necessary\n\n\t\tif ( scale < 1 || needsPowerOfTwo === true ) {\n\n\t\t\t// only perform resize for certain image types\n\n\t\t\tif ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||\n\t\t\t\t( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||\n\t\t\t\t( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {\n\n\t\t\t\tconst floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;\n\n\t\t\t\tconst width = floor( scale * image.width );\n\t\t\t\tconst height = floor( scale * image.height );\n\n\t\t\t\tif ( _canvas === undefined ) _canvas = createCanvas( width, height );\n\n\t\t\t\t// cube textures can't reuse the same canvas\n\n\t\t\t\tconst canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas;\n\n\t\t\t\tcanvas.width = width;\n\t\t\t\tcanvas.height = height;\n\n\t\t\t\tconst context = canvas.getContext( '2d' );\n\t\t\t\tcontext.drawImage( image, 0, 0, width, height );\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );\n\n\t\t\t\treturn canvas;\n\n\t\t\t} else {\n\n\t\t\t\tif ( 'data' in image ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').' );\n\n\t\t\t\t}\n\n\t\t\t\treturn image;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn image;\n\n\t}\n\n\tfunction isPowerOfTwo( image ) {\n\n\t\treturn MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height );\n\n\t}\n\n\tfunction textureNeedsPowerOfTwo( texture ) {\n\n\t\tif ( isWebGL2 ) return false;\n\n\t\treturn ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||\n\t\t\t( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );\n\n\t}\n\n\tfunction textureNeedsGenerateMipmaps( texture, supportsMips ) {\n\n\t\treturn texture.generateMipmaps && supportsMips &&\n\t\t\ttexture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\n\t}\n\n\tfunction generateMipmap( target, texture, width, height ) {\n\n\t\t_gl.generateMipmap( target );\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\t// Note: Math.log( x ) * Math.LOG2E used instead of Math.log2( x ) which is not supported by IE11\n\t\ttextureProperties.__maxMipLevel = Math.log( Math.max( width, height ) ) * Math.LOG2E;\n\n\t}\n\n\tfunction getInternalFormat( internalFormatName, glFormat, glType ) {\n\n\t\tif ( isWebGL2 === false ) return glFormat;\n\n\t\tif ( internalFormatName !== null ) {\n\n\t\t\tif ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \\'' + internalFormatName + '\\'' );\n\n\t\t}\n\n\t\tlet internalFormat = glFormat;\n\n\t\tif ( glFormat === _gl.RED ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.R32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.R16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8;\n\n\t\t}\n\n\t\tif ( glFormat === _gl.RGB ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.RGB32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGB16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8;\n\n\t\t}\n\n\t\tif ( glFormat === _gl.RGBA ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8;\n\n\t\t}\n\n\t\tif ( internalFormat === _gl.R16F || internalFormat === _gl.R32F ||\n\t\t\tinternalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F ) {\n\n\t\t\textensions.get( 'EXT_color_buffer_float' );\n\n\t\t}\n\n\t\treturn internalFormat;\n\n\t}\n\n\t// Fallback filters for non-power-of-2 textures\n\n\tfunction filterFallback( f ) {\n\n\t\tif ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {\n\n\t\t\treturn _gl.NEAREST;\n\n\t\t}\n\n\t\treturn _gl.LINEAR;\n\n\t}\n\n\t//\n\n\tfunction onTextureDispose( event ) {\n\n\t\tconst texture = event.target;\n\n\t\ttexture.removeEventListener( 'dispose', onTextureDispose );\n\n\t\tdeallocateTexture( texture );\n\n\t\tif ( texture.isVideoTexture ) {\n\n\t\t\t_videoTextures.delete( texture );\n\n\t\t}\n\n\t\tinfo.memory.textures --;\n\n\t}\n\n\tfunction onRenderTargetDispose( event ) {\n\n\t\tconst renderTarget = event.target;\n\n\t\trenderTarget.removeEventListener( 'dispose', onRenderTargetDispose );\n\n\t\tdeallocateRenderTarget( renderTarget );\n\n\t\tinfo.memory.textures --;\n\n\t}\n\n\t//\n\n\tfunction deallocateTexture( texture ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( textureProperties.__webglInit === undefined ) return;\n\n\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\tproperties.remove( texture );\n\n\t}\n\n\tfunction deallocateRenderTarget( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst textureProperties = properties.get( renderTarget.texture );\n\n\t\tif ( ! renderTarget ) return;\n\n\t\tif ( textureProperties.__webglTexture !== undefined ) {\n\n\t\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\t}\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\trenderTarget.depthTexture.dispose();\n\n\t\t}\n\n\t\tif ( renderTarget.isWebGLCubeRenderTarget ) {\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer );\n\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer );\n\t\t\tif ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\tif ( renderTargetProperties.__webglColorRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer );\n\t\t\tif ( renderTargetProperties.__webglDepthRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer );\n\n\t\t}\n\n\t\tproperties.remove( renderTarget.texture );\n\t\tproperties.remove( renderTarget );\n\n\t}\n\n\t//\n\n\tlet textureUnits = 0;\n\n\tfunction resetTextureUnits() {\n\n\t\ttextureUnits = 0;\n\n\t}\n\n\tfunction allocateTextureUnit() {\n\n\t\tconst textureUnit = textureUnits;\n\n\t\tif ( textureUnit >= maxTextures ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );\n\n\t\t}\n\n\t\ttextureUnits += 1;\n\n\t\treturn textureUnit;\n\n\t}\n\n\t//\n\n\tfunction setTexture2D( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.isVideoTexture ) updateVideoTexture( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tconst image = texture.image;\n\n\t\t\tif ( image === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is undefined' );\n\n\t\t\t} else if ( image.complete === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' );\n\n\t\t\t} else {\n\n\t\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTexture2DArray( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\treturn;\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTexture3D( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\treturn;\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTextureCube( texture, slot ) {\n\n\t\tif ( texture.image.length !== 6 ) return;\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tinitTexture( textureProperties, texture );\n\n\t\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\n\t\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );\n\n\t\t\tconst isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) );\n\t\t\tconst isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );\n\n\t\t\tconst cubeImage = [];\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\tif ( ! isCompressed && ! isDataTexture ) {\n\n\t\t\t\t\tcubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst image = cubeImage[ 0 ],\n\t\t\t\tsupportsMips = isPowerOfTwo( image ) || isWebGL2,\n\t\t\t\tglFormat = utils.convert( texture.format ),\n\t\t\t\tglType = utils.convert( texture.type ),\n\t\t\t\tglInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );\n\n\t\t\tsetTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );\n\n\t\t\tlet mipmaps;\n\n\t\t\tif ( isCompressed ) {\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tmipmaps = cubeImage[ i ].mipmaps;\n\n\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\n\t\t\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\t\t\tif ( glFormat !== null ) {\n\n\t\t\t\t\t\t\t\tstate.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tmipmaps = texture.mipmaps;\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tif ( isDataTexture ) {\n\n\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );\n\n\t\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\t\t\t\t\t\t\tconst mipmapImage = mipmap.image[ i ].image;\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );\n\n\t\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length;\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\t\t// We assume images for cube map have the same size.\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_CUBE_MAP, texture, image.width, image.height );\n\n\t\t\t}\n\n\t\t\ttextureProperties.__version = texture.version;\n\n\t\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t\t} else {\n\n\t\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\n\t\t}\n\n\t}\n\n\tfunction setTextureCubeDynamic( texture, slot ) {\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, properties.get( texture ).__webglTexture );\n\n\t}\n\n\tconst wrappingToGL = {\n\t\t[ RepeatWrapping ]: _gl.REPEAT,\n\t\t[ ClampToEdgeWrapping ]: _gl.CLAMP_TO_EDGE,\n\t\t[ MirroredRepeatWrapping ]: _gl.MIRRORED_REPEAT\n\t};\n\n\tconst filterToGL = {\n\t\t[ NearestFilter ]: _gl.NEAREST,\n\t\t[ NearestMipmapNearestFilter ]: _gl.NEAREST_MIPMAP_NEAREST,\n\t\t[ NearestMipmapLinearFilter ]: _gl.NEAREST_MIPMAP_LINEAR,\n\n\t\t[ LinearFilter ]: _gl.LINEAR,\n\t\t[ LinearMipmapNearestFilter ]: _gl.LINEAR_MIPMAP_NEAREST,\n\t\t[ LinearMipmapLinearFilter ]: _gl.LINEAR_MIPMAP_LINEAR\n\t};\n\n\tfunction setTextureParameters( textureType, texture, supportsMips ) {\n\n\t\tif ( supportsMips ) {\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );\n\n\t\t\tif ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {\n\n\t\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );\n\n\t\t\t}\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );\n\n\t\t} else {\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );\n\n\t\t\tif ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {\n\n\t\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );\n\n\t\t\t}\n\n\t\t\tif ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );\n\n\t\t\t}\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );\n\n\t\t\tif ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\tif ( extension ) {\n\n\t\t\tif ( texture.type === FloatType && extensions.get( 'OES_texture_float_linear' ) === null ) return;\n\t\t\tif ( texture.type === HalfFloatType && ( isWebGL2 || extensions.get( 'OES_texture_half_float_linear' ) ) === null ) return;\n\n\t\t\tif ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {\n\n\t\t\t\t_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );\n\t\t\t\tproperties.get( texture ).__currentAnisotropy = texture.anisotropy;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction initTexture( textureProperties, texture ) {\n\n\t\tif ( textureProperties.__webglInit === undefined ) {\n\n\t\t\ttextureProperties.__webglInit = true;\n\n\t\t\ttexture.addEventListener( 'dispose', onTextureDispose );\n\n\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\t\tinfo.memory.textures ++;\n\n\t\t}\n\n\t}\n\n\tfunction uploadTexture( textureProperties, texture, slot ) {\n\n\t\tlet textureType = _gl.TEXTURE_2D;\n\n\t\tif ( texture.isDataTexture2DArray ) textureType = _gl.TEXTURE_2D_ARRAY;\n\t\tif ( texture.isDataTexture3D ) textureType = _gl.TEXTURE_3D;\n\n\t\tinitTexture( textureProperties, texture );\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( textureType, textureProperties.__webglTexture );\n\n\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );\n\t\t_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );\n\t\t_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );\n\n\t\tconst needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;\n\t\tconst image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );\n\n\t\tconst supportsMips = isPowerOfTwo( image ) || isWebGL2,\n\t\t\tglFormat = utils.convert( texture.format );\n\n\t\tlet glType = utils.convert( texture.type ),\n\t\t\tglInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );\n\n\t\tsetTextureParameters( textureType, texture, supportsMips );\n\n\t\tlet mipmap;\n\t\tconst mipmaps = texture.mipmaps;\n\n\t\tif ( texture.isDepthTexture ) {\n\n\t\t\t// populate depth texture with dummy data\n\n\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT;\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\n\t\t\t\t} else if ( texture.type === UnsignedIntType ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\n\t\t\t\t} else if ( texture.type === UnsignedInt248Type ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH24_STENCIL8;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tconsole.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// validation checks for WebGL 1\n\n\t\t\tif ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {\n\n\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );\n\n\t\t\t\t\ttexture.type = UnsignedShortType;\n\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {\n\n\t\t\t\t// Depth stencil textures need the DEPTH_STENCIL internal format\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tglInternalFormat = _gl.DEPTH_STENCIL;\n\n\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.type !== UnsignedInt248Type ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );\n\n\t\t\t\t\ttexture.type = UnsignedInt248Type;\n\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );\n\n\t\t} else if ( texture.isDataTexture ) {\n\n\t\t\t// use manually created mipmaps if available\n\t\t\t// if there are no manual mipmaps\n\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\tif ( mipmaps.length > 0 && supportsMips ) {\n\n\t\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t}\n\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t}\n\n\t\t} else if ( texture.isCompressedTexture ) {\n\n\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\tmipmap = mipmaps[ i ];\n\n\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\tif ( glFormat !== null ) {\n\n\t\t\t\t\t\tstate.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t} else if ( texture.isDataTexture2DArray ) {\n\n\t\t\tstate.texImage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t} else if ( texture.isDataTexture3D ) {\n\n\t\t\tstate.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t} else {\n\n\t\t\t// regular Texture (image, video, canvas)\n\n\t\t\t// use manually created mipmaps if available\n\t\t\t// if there are no manual mipmaps\n\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\tif ( mipmaps.length > 0 && supportsMips ) {\n\n\t\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap );\n\n\t\t\t\t}\n\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\tgenerateMipmap( textureType, texture, image.width, image.height );\n\n\t\t}\n\n\t\ttextureProperties.__version = texture.version;\n\n\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t}\n\n\t// Render targets\n\n\t// Setup storage for target texture and bind it to correct framebuffer\n\tfunction setupFrameBufferTexture( framebuffer, renderTarget, attachment, textureTarget ) {\n\n\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\t\tstate.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\t}\n\n\t// Setup storage for internal depth/stencil buffers and bind to correct framebuffer\n\tfunction setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {\n\n\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );\n\n\t\tif ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {\n\n\t\t\tlet glInternalFormat = _gl.DEPTH_COMPONENT16;\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst depthTexture = renderTarget.depthTexture;\n\n\t\t\t\tif ( depthTexture && depthTexture.isDepthTexture ) {\n\n\t\t\t\t\tif ( depthTexture.type === FloatType ) {\n\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\n\t\t\t\t\t} else if ( depthTexture.type === UnsignedIntType ) {\n\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );\n\n\t\t} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\n\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );\n\n\t\t} else {\n\n\t\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );\n\n\t}\n\n\t// Setup resources for a Depth Texture for a FBO (needs an extension)\n\tfunction setupDepthTexture( framebuffer, renderTarget ) {\n\n\t\tconst isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget );\n\t\tif ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );\n\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\n\t\tif ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) {\n\n\t\t\tthrow new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' );\n\n\t\t}\n\n\t\t// upload an empty depth texture with framebuffer size\n\t\tif ( ! properties.get( renderTarget.depthTexture ).__webglTexture ||\n\t\t\t\trenderTarget.depthTexture.image.width !== renderTarget.width ||\n\t\t\t\trenderTarget.depthTexture.image.height !== renderTarget.height ) {\n\n\t\t\trenderTarget.depthTexture.image.width = renderTarget.width;\n\t\t\trenderTarget.depthTexture.image.height = renderTarget.height;\n\t\t\trenderTarget.depthTexture.needsUpdate = true;\n\n\t\t}\n\n\t\tsetTexture2D( renderTarget.depthTexture, 0 );\n\n\t\tconst webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;\n\n\t\tif ( renderTarget.depthTexture.format === DepthFormat ) {\n\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );\n\n\t\t} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {\n\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );\n\n\t\t} else {\n\n\t\t\tthrow new Error( 'Unknown depthTexture format' );\n\n\t\t}\n\n\t}\n\n\t// Setup GL resources for a non-texture depth buffer\n\tfunction setupDepthRenderbuffer( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\tif ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );\n\n\t\t\tsetupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );\n\n\t\t} else {\n\n\t\t\tif ( isCube ) {\n\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = [];\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();\n\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();\n\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\t}\n\n\t// Set up GL resources for the render target\n\tfunction setupRenderTarget( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst textureProperties = properties.get( renderTarget.texture );\n\n\t\trenderTarget.addEventListener( 'dispose', onRenderTargetDispose );\n\n\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\tinfo.memory.textures ++;\n\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\t\tconst isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );\n\t\tconst supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;\n\n\t\t// Handles WebGL2 RGBFormat fallback - #18858\n\n\t\tif ( isWebGL2 && renderTarget.texture.format === RGBFormat && ( renderTarget.texture.type === FloatType || renderTarget.texture.type === HalfFloatType ) ) {\n\n\t\t\trenderTarget.texture.format = RGBAFormat;\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.' );\n\n\t\t}\n\n\t\t// Setup framebuffer\n\n\t\tif ( isCube ) {\n\n\t\t\trenderTargetProperties.__webglFramebuffer = [];\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\trenderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\trenderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\t\trenderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();\n\t\t\t\t\trenderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();\n\n\t\t\t\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );\n\n\t\t\t\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\t\t\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\t\t\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\t\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\t\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );\n\t\t\t\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );\n\n\t\t\t\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\t\t\t\trenderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();\n\t\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Setup color buffer\n\n\t\tif ( isCube ) {\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\t\t\tsetTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, supportsMips );\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i );\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) {\n\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, null );\n\n\t\t} else {\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );\n\t\t\tsetTextureParameters( _gl.TEXTURE_2D, renderTarget.texture, supportsMips );\n\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D );\n\n\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) {\n\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_2D, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_2D, null );\n\n\t\t}\n\n\t\t// Setup depth and stencil buffers\n\n\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\tsetupDepthRenderbuffer( renderTarget );\n\n\t\t}\n\n\t}\n\n\tfunction updateRenderTargetMipmap( renderTarget ) {\n\n\t\tconst texture = renderTarget.texture;\n\t\tconst supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;\n\n\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\tconst target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;\n\t\t\tconst webglTexture = properties.get( texture ).__webglTexture;\n\n\t\t\tstate.bindTexture( target, webglTexture );\n\t\t\tgenerateMipmap( target, texture, renderTarget.width, renderTarget.height );\n\t\t\tstate.bindTexture( target, null );\n\n\t\t}\n\n\t}\n\n\tfunction updateMultisampleRenderTarget( renderTarget ) {\n\n\t\tif ( renderTarget.isWebGLMultisampleRenderTarget ) {\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tconst renderTargetProperties = properties.get( renderTarget );\n\n\t\t\t\t_gl.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\t\t_gl.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );\n\n\t\t\t\tconst width = renderTarget.width;\n\t\t\t\tconst height = renderTarget.height;\n\t\t\t\tlet mask = _gl.COLOR_BUFFER_BIT;\n\n\t\t\t\tif ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;\n\t\t\t\tif ( renderTarget.stencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t\t\t_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer ); // see #18905\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction getRenderTargetSamples( renderTarget ) {\n\n\t\treturn ( isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ) ?\n\t\t\tMath.min( maxSamples, renderTarget.samples ) : 0;\n\n\t}\n\n\tfunction updateVideoTexture( texture ) {\n\n\t\tconst frame = info.render.frame;\n\n\t\t// Check the last frame we updated the VideoTexture\n\n\t\tif ( _videoTextures.get( texture ) !== frame ) {\n\n\t\t\t_videoTextures.set( texture, frame );\n\t\t\ttexture.update();\n\n\t\t}\n\n\t}\n\n\t// backwards compatibility\n\n\tlet warnedTexture2D = false;\n\tlet warnedTextureCube = false;\n\n\tfunction safeSetTexture2D( texture, slot ) {\n\n\t\tif ( texture && texture.isWebGLRenderTarget ) {\n\n\t\t\tif ( warnedTexture2D === false ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\t\twarnedTexture2D = true;\n\n\t\t\t}\n\n\t\t\ttexture = texture.texture;\n\n\t\t}\n\n\t\tsetTexture2D( texture, slot );\n\n\t}\n\n\tfunction safeSetTextureCube( texture, slot ) {\n\n\t\tif ( texture && texture.isWebGLCubeRenderTarget ) {\n\n\t\t\tif ( warnedTextureCube === false ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead.\" );\n\t\t\t\twarnedTextureCube = true;\n\n\t\t\t}\n\n\t\t\ttexture = texture.texture;\n\n\t\t}\n\n\t\t// currently relying on the fact that WebGLCubeRenderTarget.texture is a Texture and NOT a CubeTexture\n\t\t// TODO: unify these code paths\n\t\tif ( ( texture && texture.isCubeTexture ) ||\n\t\t\t( Array.isArray( texture.image ) && texture.image.length === 6 ) ) {\n\n\t\t\t// CompressedTexture can have Array in image :/\n\n\t\t\t// this function alone should take care of cube textures\n\t\t\tsetTextureCube( texture, slot );\n\n\t\t} else {\n\n\t\t\t// assumed: texture property of THREE.WebGLCubeRenderTarget\n\t\t\tsetTextureCubeDynamic( texture, slot );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tthis.allocateTextureUnit = allocateTextureUnit;\n\tthis.resetTextureUnits = resetTextureUnits;\n\n\tthis.setTexture2D = setTexture2D;\n\tthis.setTexture2DArray = setTexture2DArray;\n\tthis.setTexture3D = setTexture3D;\n\tthis.setTextureCube = setTextureCube;\n\tthis.setTextureCubeDynamic = setTextureCubeDynamic;\n\tthis.setupRenderTarget = setupRenderTarget;\n\tthis.updateRenderTargetMipmap = updateRenderTargetMipmap;\n\tthis.updateMultisampleRenderTarget = updateMultisampleRenderTarget;\n\n\tthis.safeSetTexture2D = safeSetTexture2D;\n\tthis.safeSetTextureCube = safeSetTextureCube;\n\n}\n\nexport { WebGLTextures };\n","/**\n * @author thespite / http://www.twitter.com/thespite\n */\n\nimport { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, RGBFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, SRGB8_ALPHA8_ASTC_4x4_Format, SRGB8_ALPHA8_ASTC_5x4_Format, SRGB8_ALPHA8_ASTC_5x5_Format, SRGB8_ALPHA8_ASTC_6x5_Format, SRGB8_ALPHA8_ASTC_6x6_Format, SRGB8_ALPHA8_ASTC_8x5_Format, SRGB8_ALPHA8_ASTC_8x6_Format, SRGB8_ALPHA8_ASTC_8x8_Format, SRGB8_ALPHA8_ASTC_10x5_Format, SRGB8_ALPHA8_ASTC_10x6_Format, SRGB8_ALPHA8_ASTC_10x8_Format, SRGB8_ALPHA8_ASTC_10x10_Format, SRGB8_ALPHA8_ASTC_12x10_Format, SRGB8_ALPHA8_ASTC_12x12_Format, RGBA_BPTC_Format } from '../../constants.js';\n\nfunction WebGLUtils( gl, extensions, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction convert( p ) {\n\n\t\tlet extension;\n\n\t\tif ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;\n\t\tif ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;\n\t\tif ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;\n\t\tif ( p === UnsignedShort565Type ) return gl.UNSIGNED_SHORT_5_6_5;\n\n\t\tif ( p === ByteType ) return gl.BYTE;\n\t\tif ( p === ShortType ) return gl.SHORT;\n\t\tif ( p === UnsignedShortType ) return gl.UNSIGNED_SHORT;\n\t\tif ( p === IntType ) return gl.INT;\n\t\tif ( p === UnsignedIntType ) return gl.UNSIGNED_INT;\n\t\tif ( p === FloatType ) return gl.FLOAT;\n\n\t\tif ( p === HalfFloatType ) {\n\n\t\t\tif ( isWebGL2 ) return gl.HALF_FLOAT;\n\n\t\t\textension = extensions.get( 'OES_texture_half_float' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.HALF_FLOAT_OES;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === AlphaFormat ) return gl.ALPHA;\n\t\tif ( p === RGBFormat ) return gl.RGB;\n\t\tif ( p === RGBAFormat ) return gl.RGBA;\n\t\tif ( p === LuminanceFormat ) return gl.LUMINANCE;\n\t\tif ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;\n\t\tif ( p === DepthFormat ) return gl.DEPTH_COMPONENT;\n\t\tif ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;\n\t\tif ( p === RedFormat ) return gl.RED;\n\n\t\t// WebGL2 formats.\n\n\t\tif ( p === RedIntegerFormat ) return gl.RED_INTEGER;\n\t\tif ( p === RGFormat ) return gl.RG;\n\t\tif ( p === RGIntegerFormat ) return gl.RG_INTEGER;\n\t\tif ( p === RGBIntegerFormat ) return gl.RGB_INTEGER;\n\t\tif ( p === RGBAIntegerFormat ) return gl.RGBA_INTEGER;\n\n\t\tif ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format ||\n\t\t\tp === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_s3tc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format ||\n\t\t\tp === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;\n\t\t\t\tif ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;\n\t\t\t\tif ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;\n\t\t\t\tif ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_ETC1_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc1' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.COMPRESSED_RGB_ETC1_WEBGL;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_ETC2_Format ) return extension.COMPRESSED_RGB8_ETC2;\n\t\t\t\tif ( p === RGBA_ETC2_EAC_Format ) return extension.COMPRESSED_RGBA8_ETC2_EAC;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format ||\n\t\t\tp === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format ||\n\t\t\tp === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format ||\n\t\t\tp === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format ||\n\t\t\tp === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_4x4_Format || p === SRGB8_ALPHA8_ASTC_5x4_Format || p === SRGB8_ALPHA8_ASTC_5x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_6x5_Format || p === SRGB8_ALPHA8_ASTC_6x6_Format || p === SRGB8_ALPHA8_ASTC_8x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_8x6_Format || p === SRGB8_ALPHA8_ASTC_8x8_Format || p === SRGB8_ALPHA8_ASTC_10x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_10x6_Format || p === SRGB8_ALPHA8_ASTC_10x8_Format || p === SRGB8_ALPHA8_ASTC_10x10_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_12x10_Format || p === SRGB8_ALPHA8_ASTC_12x12_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_astc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\t// TODO Complete?\n\n\t\t\t\treturn p;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGBA_BPTC_Format ) {\n\n\t\t\textension = extensions.get( 'EXT_texture_compression_bptc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\t// TODO Complete?\n\n\t\t\t\treturn p;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === UnsignedInt248Type ) {\n\n\t\t\tif ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;\n\n\t\t\textension = extensions.get( 'WEBGL_depth_texture' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.UNSIGNED_INT_24_8_WEBGL;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn { convert: convert };\n\n}\n\n\nexport { WebGLUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { PerspectiveCamera } from './PerspectiveCamera.js';\n\nfunction ArrayCamera( array ) {\n\n\tPerspectiveCamera.call( this );\n\n\tthis.cameras = array || [];\n\n}\n\nArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), {\n\n\tconstructor: ArrayCamera,\n\n\tisArrayCamera: true\n\n} );\n\n\nexport { ArrayCamera };\n","import { Object3D } from '../core/Object3D.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Group() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Group';\n\n}\n\nGroup.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Group,\n\n\tisGroup: true\n\n} );\n\n\nexport { Group };\n","import { Group } from '../../objects/Group.js';\n\n/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nfunction WebXRController() {\n\n\tthis._targetRay = null;\n\tthis._grip = null;\n\n}\n\nObject.assign( WebXRController.prototype, {\n\n\tconstructor: WebXRController,\n\n\tgetTargetRaySpace: function () {\n\n\t\tif ( this._targetRay === null ) {\n\n\t\t\tthis._targetRay = new Group();\n\t\t\tthis._targetRay.matrixAutoUpdate = false;\n\t\t\tthis._targetRay.visible = false;\n\n\t\t}\n\n\t\treturn this._targetRay;\n\n\t},\n\n\tgetGripSpace: function () {\n\n\t\tif ( this._grip === null ) {\n\n\t\t\tthis._grip = new Group();\n\t\t\tthis._grip.matrixAutoUpdate = false;\n\t\t\tthis._grip.visible = false;\n\n\t\t}\n\n\t\treturn this._grip;\n\n\t},\n\n\tdispatchEvent: function ( event ) {\n\n\t\tif ( this._targetRay !== null ) {\n\n\t\t\tthis._targetRay.dispatchEvent( event );\n\n\t\t}\n\n\t\tif ( this._grip !== null ) {\n\n\t\t\tthis._grip.dispatchEvent( event );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tdisconnect: function ( inputSource ) {\n\n\t\tthis.dispatchEvent( { type: 'disconnected', data: inputSource } );\n\n\t\tif ( this._targetRay !== null ) {\n\n\t\t\tthis._targetRay.visible = false;\n\n\t\t}\n\n\t\tif ( this._grip !== null ) {\n\n\t\t\tthis._grip.visible = false;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tupdate: function ( inputSource, frame, referenceSpace ) {\n\n\t\tlet inputPose = null;\n\t\tlet gripPose = null;\n\n\t\tconst targetRay = this._targetRay;\n\t\tconst grip = this._grip;\n\n\t\tif ( inputSource ) {\n\n\t\t\tif ( targetRay !== null ) {\n\n\t\t\t\tinputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );\n\n\t\t\t\tif ( inputPose !== null ) {\n\n\t\t\t\t\ttargetRay.matrix.fromArray( inputPose.transform.matrix );\n\t\t\t\t\ttargetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( grip !== null && inputSource.gripSpace ) {\n\n\t\t\t\tgripPose = frame.getPose( inputSource.gripSpace, referenceSpace );\n\n\t\t\t\tif ( gripPose !== null ) {\n\n\t\t\t\t\tgrip.matrix.fromArray( gripPose.transform.matrix );\n\t\t\t\t\tgrip.matrix.decompose( grip.position, grip.rotation, grip.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( targetRay !== null ) {\n\n\t\t\ttargetRay.visible = ( inputPose !== null );\n\n\t\t}\n\n\t\tif ( grip !== null ) {\n\n\t\t\tgrip.visible = ( gripPose !== null );\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { WebXRController };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { ArrayCamera } from '../../cameras/ArrayCamera.js';\nimport { EventDispatcher } from '../../core/EventDispatcher.js';\nimport { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js';\nimport { Vector3 } from '../../math/Vector3.js';\nimport { Vector4 } from '../../math/Vector4.js';\nimport { WebGLAnimation } from '../webgl/WebGLAnimation.js';\nimport { WebXRController } from './WebXRController.js';\n\nfunction WebXRManager( renderer, gl ) {\n\n\tconst scope = this;\n\n\tlet session = null;\n\n\tlet framebufferScaleFactor = 1.0;\n\n\tlet referenceSpace = null;\n\tlet referenceSpaceType = 'local-floor';\n\n\tlet pose = null;\n\n\tconst controllers = [];\n\tconst inputSourcesMap = new Map();\n\n\t//\n\n\tconst cameraL = new PerspectiveCamera();\n\tcameraL.layers.enable( 1 );\n\tcameraL.viewport = new Vector4();\n\n\tconst cameraR = new PerspectiveCamera();\n\tcameraR.layers.enable( 2 );\n\tcameraR.viewport = new Vector4();\n\n\tconst cameras = [ cameraL, cameraR ];\n\n\tconst cameraVR = new ArrayCamera();\n\tcameraVR.layers.enable( 1 );\n\tcameraVR.layers.enable( 2 );\n\n\tlet _currentDepthNear = null;\n\tlet _currentDepthFar = null;\n\n\t//\n\n\tthis.enabled = false;\n\n\tthis.isPresenting = false;\n\n\tthis.getController = function ( index ) {\n\n\t\tlet controller = controllers[ index ];\n\n\t\tif ( controller === undefined ) {\n\n\t\t\tcontroller = new WebXRController();\n\t\t\tcontrollers[ index ] = controller;\n\n\t\t}\n\n\t\treturn controller.getTargetRaySpace();\n\n\t};\n\n\tthis.getControllerGrip = function ( index ) {\n\n\t\tlet controller = controllers[ index ];\n\n\t\tif ( controller === undefined ) {\n\n\t\t\tcontroller = new WebXRController();\n\t\t\tcontrollers[ index ] = controller;\n\n\t\t}\n\n\t\treturn controller.getGripSpace();\n\n\t};\n\n\t//\n\n\tfunction onSessionEvent( event ) {\n\n\t\tconst controller = inputSourcesMap.get( event.inputSource );\n\n\t\tif ( controller ) {\n\n\t\t\tcontroller.dispatchEvent( { type: event.type } );\n\n\t\t}\n\n\t}\n\n\tfunction onSessionEnd() {\n\n\t\tinputSourcesMap.forEach( function ( controller, inputSource ) {\n\n\t\t\tcontroller.disconnect( inputSource );\n\n\t\t} );\n\n\t\tinputSourcesMap.clear();\n\n\t\t//\n\n\t\trenderer.setFramebuffer( null );\n\t\trenderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830\n\t\tanimation.stop();\n\n\t\tscope.isPresenting = false;\n\n\t\tscope.dispatchEvent( { type: 'sessionend' } );\n\n\t}\n\n\tfunction onRequestReferenceSpace( value ) {\n\n\t\treferenceSpace = value;\n\n\t\tanimation.setContext( session );\n\t\tanimation.start();\n\n\t\tscope.isPresenting = true;\n\n\t\tscope.dispatchEvent( { type: 'sessionstart' } );\n\n\t}\n\n\tthis.setFramebufferScaleFactor = function ( value ) {\n\n\t\tframebufferScaleFactor = value;\n\n\t\tif ( scope.isPresenting === true ) {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' );\n\n\t\t}\n\n\t};\n\n\tthis.setReferenceSpaceType = function ( value ) {\n\n\t\treferenceSpaceType = value;\n\n\t\tif ( scope.isPresenting === true ) {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' );\n\n\t\t}\n\n\t};\n\n\tthis.getReferenceSpace = function () {\n\n\t\treturn referenceSpace;\n\n\t};\n\n\tthis.getSession = function () {\n\n\t\treturn session;\n\n\t};\n\n\tthis.setSession = function ( value ) {\n\n\t\tsession = value;\n\n\t\tif ( session !== null ) {\n\n\t\t\tsession.addEventListener( 'select', onSessionEvent );\n\t\t\tsession.addEventListener( 'selectstart', onSessionEvent );\n\t\t\tsession.addEventListener( 'selectend', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeeze', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeezestart', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeezeend', onSessionEvent );\n\t\t\tsession.addEventListener( 'end', onSessionEnd );\n\n\t\t\tconst attributes = gl.getContextAttributes();\n\n\t\t\tif ( attributes.xrCompatible !== true ) {\n\n\t\t\t\tgl.makeXRCompatible();\n\n\t\t\t}\n\n\t\t\tconst layerInit = {\n\t\t\t\tantialias: attributes.antialias,\n\t\t\t\talpha: attributes.alpha,\n\t\t\t\tdepth: attributes.depth,\n\t\t\t\tstencil: attributes.stencil,\n\t\t\t\tframebufferScaleFactor: framebufferScaleFactor\n\t\t\t};\n\n\t\t\t// eslint-disable-next-line no-undef\n\t\t\tconst baseLayer = new XRWebGLLayer( session, gl, layerInit );\n\n\t\t\tsession.updateRenderState( { baseLayer: baseLayer } );\n\n\t\t\tsession.requestReferenceSpace( referenceSpaceType ).then( onRequestReferenceSpace );\n\n\t\t\t//\n\n\t\t\tsession.addEventListener( 'inputsourceschange', updateInputSources );\n\n\t\t}\n\n\t};\n\n\tfunction updateInputSources( event ) {\n\n\t\tconst inputSources = session.inputSources;\n\n\t\t// Assign inputSources to available controllers\n\n\t\tfor ( let i = 0; i < controllers.length; i ++ ) {\n\n\t\t\tinputSourcesMap.set( inputSources[ i ], controllers[ i ] );\n\n\t\t}\n\n\t\t// Notify disconnected\n\n\t\tfor ( let i = 0; i < event.removed.length; i ++ ) {\n\n\t\t\tconst inputSource = event.removed[ i ];\n\t\t\tconst controller = inputSourcesMap.get( inputSource );\n\n\t\t\tif ( controller ) {\n\n\t\t\t\tcontroller.dispatchEvent( { type: 'disconnected', data: inputSource } );\n\t\t\t\tinputSourcesMap.delete( inputSource );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Notify connected\n\n\t\tfor ( let i = 0; i < event.added.length; i ++ ) {\n\n\t\t\tconst inputSource = event.added[ i ];\n\t\t\tconst controller = inputSourcesMap.get( inputSource );\n\n\t\t\tif ( controller ) {\n\n\t\t\t\tcontroller.dispatchEvent( { type: 'connected', data: inputSource } );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t//\n\n\tconst cameraLPos = new Vector3();\n\tconst cameraRPos = new Vector3();\n\n\t/**\n\t * @author jsantell / https://www.jsantell.com/\n\t *\n\t * Assumes 2 cameras that are parallel and share an X-axis, and that\n\t * the cameras' projection and world matrices have already been set.\n\t * And that near and far planes are identical for both cameras.\n\t * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765\n\t */\n\tfunction setProjectionFromUnion( camera, cameraL, cameraR ) {\n\n\t\tcameraLPos.setFromMatrixPosition( cameraL.matrixWorld );\n\t\tcameraRPos.setFromMatrixPosition( cameraR.matrixWorld );\n\n\t\tconst ipd = cameraLPos.distanceTo( cameraRPos );\n\n\t\tconst projL = cameraL.projectionMatrix.elements;\n\t\tconst projR = cameraR.projectionMatrix.elements;\n\n\t\t// VR systems will have identical far and near planes, and\n\t\t// most likely identical top and bottom frustum extents.\n\t\t// Use the left camera for these values.\n\t\tconst near = projL[ 14 ] / ( projL[ 10 ] - 1 );\n\t\tconst far = projL[ 14 ] / ( projL[ 10 ] + 1 );\n\t\tconst topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];\n\t\tconst bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];\n\n\t\tconst leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];\n\t\tconst rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];\n\t\tconst left = near * leftFov;\n\t\tconst right = near * rightFov;\n\n\t\t// Calculate the new camera's position offset from the\n\t\t// left camera. xOffset should be roughly half `ipd`.\n\t\tconst zOffset = ipd / ( - leftFov + rightFov );\n\t\tconst xOffset = zOffset * - leftFov;\n\n\t\t// TODO: Better way to apply this offset?\n\t\tcameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.translateX( xOffset );\n\t\tcamera.translateZ( zOffset );\n\t\tcamera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t\t// Find the union of the frustum values of the cameras and scale\n\t\t// the values so that the near plane's position does not change in world space,\n\t\t// although must now be relative to the new union camera.\n\t\tconst near2 = near + zOffset;\n\t\tconst far2 = far + zOffset;\n\t\tconst left2 = left - xOffset;\n\t\tconst right2 = right + ( ipd - xOffset );\n\t\tconst top2 = topFov * far / far2 * near2;\n\t\tconst bottom2 = bottomFov * far / far2 * near2;\n\n\t\tcamera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );\n\n\t}\n\n\tfunction updateCamera( camera, parent ) {\n\n\t\tif ( parent === null ) {\n\n\t\t\tcamera.matrixWorld.copy( camera.matrix );\n\n\t\t} else {\n\n\t\t\tcamera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix );\n\n\t\t}\n\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t}\n\n\tthis.getCamera = function ( camera ) {\n\n\t\tcameraVR.near = cameraR.near = cameraL.near = camera.near;\n\t\tcameraVR.far = cameraR.far = cameraL.far = camera.far;\n\n\t\tif ( _currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far ) {\n\n\t\t\t// Note that the new renderState won't apply until the next frame. See #18320\n\n\t\t\tsession.updateRenderState( {\n\t\t\t\tdepthNear: cameraVR.near,\n\t\t\t\tdepthFar: cameraVR.far\n\t\t\t} );\n\n\t\t\t_currentDepthNear = cameraVR.near;\n\t\t\t_currentDepthFar = cameraVR.far;\n\n\t\t}\n\n\t\tconst parent = camera.parent;\n\t\tconst cameras = cameraVR.cameras;\n\n\t\tupdateCamera( cameraVR, parent );\n\n\t\tfor ( let i = 0; i < cameras.length; i ++ ) {\n\n\t\t\tupdateCamera( cameras[ i ], parent );\n\n\t\t}\n\n\t\t// update camera and its children\n\n\t\tcamera.matrixWorld.copy( cameraVR.matrixWorld );\n\n\t\tconst children = camera.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].updateMatrixWorld( true );\n\n\t\t}\n\n\t\t// update projection matrix for proper view frustum culling\n\n\t\tif ( cameras.length === 2 ) {\n\n\t\t\tsetProjectionFromUnion( cameraVR, cameraL, cameraR );\n\n\t\t} else {\n\n\t\t\t// assume single camera setup (AR)\n\n\t\t\tcameraVR.projectionMatrix.copy( cameraL.projectionMatrix );\n\n\t\t}\n\n\t\treturn cameraVR;\n\n\t};\n\n\t// Animation Loop\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame( time, frame ) {\n\n\t\tpose = frame.getViewerPose( referenceSpace );\n\n\t\tif ( pose !== null ) {\n\n\t\t\tconst views = pose.views;\n\t\t\tconst baseLayer = session.renderState.baseLayer;\n\n\t\t\trenderer.setFramebuffer( baseLayer.framebuffer );\n\n\t\t\tlet cameraVRNeedsUpdate = false;\n\n\t\t\t// check if it's necessary to rebuild cameraVR's camera list\n\n\t\t\tif ( views.length !== cameraVR.cameras.length ) {\n\n\t\t\t\tcameraVR.cameras.length = 0;\n\t\t\t\tcameraVRNeedsUpdate = true;\n\n\t\t\t}\n\n\t\t\tfor ( let i = 0; i < views.length; i ++ ) {\n\n\t\t\t\tconst view = views[ i ];\n\t\t\t\tconst viewport = baseLayer.getViewport( view );\n\n\t\t\t\tconst camera = cameras[ i ];\n\t\t\t\tcamera.matrix.fromArray( view.transform.matrix );\n\t\t\t\tcamera.projectionMatrix.fromArray( view.projectionMatrix );\n\t\t\t\tcamera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );\n\n\t\t\t\tif ( i === 0 ) {\n\n\t\t\t\t\tcameraVR.matrix.copy( camera.matrix );\n\n\t\t\t\t}\n\n\t\t\t\tif ( cameraVRNeedsUpdate === true ) {\n\n\t\t\t\t\tcameraVR.cameras.push( camera );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tconst inputSources = session.inputSources;\n\n\t\tfor ( let i = 0; i < controllers.length; i ++ ) {\n\n\t\t\tconst controller = controllers[ i ];\n\t\t\tconst inputSource = inputSources[ i ];\n\n\t\t\tcontroller.update( inputSource, frame, referenceSpace );\n\n\t\t}\n\n\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );\n\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop( onAnimationFrame );\n\n\tthis.setAnimationLoop = function ( callback ) {\n\n\t\tonAnimationFrameCallback = callback;\n\n\t};\n\n\tthis.dispose = function () {};\n\n}\n\nObject.assign( WebXRManager.prototype, EventDispatcher.prototype );\n\nexport { WebXRManager };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide } from \"../../constants.js\";\n\nfunction WebGLMaterials( properties ) {\n\n\tfunction refreshFogUniforms( uniforms, fog ) {\n\n\t\tuniforms.fogColor.value.copy( fog.color );\n\n\t\tif ( fog.isFog ) {\n\n\t\t\tuniforms.fogNear.value = fog.near;\n\t\t\tuniforms.fogFar.value = fog.far;\n\n\t\t} else if ( fog.isFogExp2 ) {\n\n\t\t\tuniforms.fogDensity.value = fog.density;\n\n\t\t}\n\n\t}\n\n\tfunction refreshMaterialUniforms( uniforms, material, environment, pixelRatio, height ) {\n\n\t\tif ( material.isMeshBasicMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\n\t\t} else if ( material.isMeshLambertMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsLambert( uniforms, material );\n\n\t\t} else if ( material.isMeshToonMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsToon( uniforms, material );\n\n\t\t} else if ( material.isMeshPhongMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsPhong( uniforms, material );\n\n\t\t} else if ( material.isMeshStandardMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material, environment );\n\n\t\t\tif ( material.isMeshPhysicalMaterial ) {\n\n\t\t\t\trefreshUniformsPhysical( uniforms, material, environment );\n\n\t\t\t} else {\n\n\t\t\t\trefreshUniformsStandard( uniforms, material, environment );\n\n\t\t\t}\n\n\t\t} else if ( material.isMeshMatcapMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsMatcap( uniforms, material );\n\n\t\t} else if ( material.isMeshDepthMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsDepth( uniforms, material );\n\n\t\t} else if ( material.isMeshDistanceMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsDistance( uniforms, material );\n\n\t\t} else if ( material.isMeshNormalMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsNormal( uniforms, material );\n\n\t\t} else if ( material.isLineBasicMaterial ) {\n\n\t\t\trefreshUniformsLine( uniforms, material );\n\n\t\t\tif ( material.isLineDashedMaterial ) {\n\n\t\t\t\trefreshUniformsDash( uniforms, material );\n\n\t\t\t}\n\n\t\t} else if ( material.isPointsMaterial ) {\n\n\t\t\trefreshUniformsPoints( uniforms, material, pixelRatio, height );\n\n\t\t} else if ( material.isSpriteMaterial ) {\n\n\t\t\trefreshUniformsSprites( uniforms, material );\n\n\t\t} else if ( material.isShadowMaterial ) {\n\n\t\t\tuniforms.color.value.copy( material.color );\n\t\t\tuniforms.opacity.value = material.opacity;\n\n\t\t} else if ( material.isShaderMaterial ) {\n\n\t\t\tmaterial.uniformsNeedUpdate = false; // #15581\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsCommon( uniforms, material, environment ) {\n\n\t\tuniforms.opacity.value = material.opacity;\n\n\t\tif ( material.color ) {\n\n\t\t\tuniforms.diffuse.value.copy( material.color );\n\n\t\t}\n\n\t\tif ( material.emissive ) {\n\n\t\t\tuniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity );\n\n\t\t}\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\tif ( material.specularMap ) {\n\n\t\t\tuniforms.specularMap.value = material.specularMap;\n\n\t\t}\n\n\t\tconst envMap = material.envMap || environment;\n\n\t\tif ( envMap ) {\n\n\t\t\tuniforms.envMap.value = envMap;\n\n\t\t\tuniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1;\n\n\t\t\tuniforms.reflectivity.value = material.reflectivity;\n\t\t\tuniforms.refractionRatio.value = material.refractionRatio;\n\n\t\t\tuniforms.maxMipLevel.value = properties.get( envMap ).__maxMipLevel;\n\n\t\t}\n\n\t\tif ( material.lightMap ) {\n\n\t\t\tuniforms.lightMap.value = material.lightMap;\n\t\t\tuniforms.lightMapIntensity.value = material.lightMapIntensity;\n\n\t\t}\n\n\t\tif ( material.aoMap ) {\n\n\t\t\tuniforms.aoMap.value = material.aoMap;\n\t\t\tuniforms.aoMapIntensity.value = material.aoMapIntensity;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. specular map\n\t\t// 3. normal map\n\t\t// 4. bump map\n\t\t// 5. alpha map\n\t\t// 6. emissive map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.specularMap ) {\n\n\t\t\tuvScaleMap = material.specularMap;\n\n\t\t} else if ( material.displacementMap ) {\n\n\t\t\tuvScaleMap = material.displacementMap;\n\n\t\t} else if ( material.normalMap ) {\n\n\t\t\tuvScaleMap = material.normalMap;\n\n\t\t} else if ( material.bumpMap ) {\n\n\t\t\tuvScaleMap = material.bumpMap;\n\n\t\t} else if ( material.roughnessMap ) {\n\n\t\t\tuvScaleMap = material.roughnessMap;\n\n\t\t} else if ( material.metalnessMap ) {\n\n\t\t\tuvScaleMap = material.metalnessMap;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t} else if ( material.emissiveMap ) {\n\n\t\t\tuvScaleMap = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\t// backwards compatibility\n\t\t\tif ( uvScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\tuvScaleMap = uvScaleMap.texture;\n\n\t\t\t}\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities for uv2\n\t\t// 1. ao map\n\t\t// 2. light map\n\n\t\tlet uv2ScaleMap;\n\n\t\tif ( material.aoMap ) {\n\n\t\t\tuv2ScaleMap = material.aoMap;\n\n\t\t} else if ( material.lightMap ) {\n\n\t\t\tuv2ScaleMap = material.lightMap;\n\n\t\t}\n\n\t\tif ( uv2ScaleMap !== undefined ) {\n\n\t\t\t// backwards compatibility\n\t\t\tif ( uv2ScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\tuv2ScaleMap = uv2ScaleMap.texture;\n\n\t\t\t}\n\n\t\t\tif ( uv2ScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuv2ScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uv2Transform.value.copy( uv2ScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsLine( uniforms, material ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\n\t}\n\n\tfunction refreshUniformsDash( uniforms, material ) {\n\n\t\tuniforms.dashSize.value = material.dashSize;\n\t\tuniforms.totalSize.value = material.dashSize + material.gapSize;\n\t\tuniforms.scale.value = material.scale;\n\n\t}\n\n\tfunction refreshUniformsPoints( uniforms, material, pixelRatio, height ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.size.value = material.size * pixelRatio;\n\t\tuniforms.scale.value = height * 0.5;\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsSprites( uniforms, material ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.rotation.value = material.rotation;\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsLambert( uniforms, material ) {\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsPhong( uniforms, material ) {\n\n\t\tuniforms.specular.value.copy( material.specular );\n\t\tuniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsToon( uniforms, material ) {\n\n\t\tif ( material.gradientMap ) {\n\n\t\t\tuniforms.gradientMap.value = material.gradientMap;\n\n\t\t}\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsStandard( uniforms, material, environment ) {\n\n\t\tuniforms.roughness.value = material.roughness;\n\t\tuniforms.metalness.value = material.metalness;\n\n\t\tif ( material.roughnessMap ) {\n\n\t\t\tuniforms.roughnessMap.value = material.roughnessMap;\n\n\t\t}\n\n\t\tif ( material.metalnessMap ) {\n\n\t\t\tuniforms.metalnessMap.value = material.metalnessMap;\n\n\t\t}\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t\tif ( material.envMap || environment ) {\n\n\t\t\t//uniforms.envMap.value = material.envMap; // part of uniforms common\n\t\t\tuniforms.envMapIntensity.value = material.envMapIntensity;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsPhysical( uniforms, material, environment ) {\n\n\t\trefreshUniformsStandard( uniforms, material, environment );\n\n\t\tuniforms.reflectivity.value = material.reflectivity; // also part of uniforms common\n\n\t\tuniforms.clearcoat.value = material.clearcoat;\n\t\tuniforms.clearcoatRoughness.value = material.clearcoatRoughness;\n\t\tif ( material.sheen ) uniforms.sheen.value.copy( material.sheen );\n\n\t\tif ( material.clearcoatMap ) {\n\n\t\t\tuniforms.clearcoatMap.value = material.clearcoatMap;\n\n\t\t}\n\n\t\tif ( material.clearcoatRoughnessMap ) {\n\n\t\t\tuniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap;\n\n\t\t}\n\n\t\tif ( material.clearcoatNormalMap ) {\n\n\t\t\tuniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale );\n\t\t\tuniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;\n\n\t\t\tif ( material.side === BackSide ) {\n\n\t\t\t\tuniforms.clearcoatNormalScale.value.negate();\n\n\t\t\t}\n\n\t\t}\n\n\t\tuniforms.transparency.value = material.transparency;\n\n\t}\n\n\tfunction refreshUniformsMatcap( uniforms, material ) {\n\n\t\tif ( material.matcap ) {\n\n\t\t\tuniforms.matcap.value = material.matcap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsDepth( uniforms, material ) {\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsDistance( uniforms, material ) {\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t\tuniforms.referencePosition.value.copy( material.referencePosition );\n\t\tuniforms.nearDistance.value = material.nearDistance;\n\t\tuniforms.farDistance.value = material.farDistance;\n\n\t}\n\n\tfunction refreshUniformsNormal( uniforms, material ) {\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\trefreshFogUniforms: refreshFogUniforms,\n\t\trefreshMaterialUniforms: refreshMaterialUniforms\n\t};\n\n}\n\nexport { WebGLMaterials };\n","/**\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n * @author tschw\n */\n\nimport {\n\tRGBAFormat,\n\tHalfFloatType,\n\tFloatType,\n\tUnsignedByteType,\n\tLinearEncoding,\n\tNoToneMapping\n} from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { DataTexture } from '../textures/DataTexture.js';\nimport { Frustum } from '../math/Frustum.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { UniformsLib } from './shaders/UniformsLib.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector4 } from '../math/Vector4.js';\nimport { WebGLAnimation } from './webgl/WebGLAnimation.js';\nimport { WebGLAttributes } from './webgl/WebGLAttributes.js';\nimport { WebGLBackground } from './webgl/WebGLBackground.js';\nimport { WebGLBindingStates } from './webgl/WebGLBindingStates.js';\nimport { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';\nimport { WebGLCapabilities } from './webgl/WebGLCapabilities.js';\nimport { WebGLClipping } from './webgl/WebGLClipping.js';\nimport { WebGLExtensions } from './webgl/WebGLExtensions.js';\nimport { WebGLGeometries } from './webgl/WebGLGeometries.js';\nimport { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';\nimport { WebGLInfo } from './webgl/WebGLInfo.js';\nimport { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';\nimport { WebGLObjects } from './webgl/WebGLObjects.js';\nimport { WebGLPrograms } from './webgl/WebGLPrograms.js';\nimport { WebGLProperties } from './webgl/WebGLProperties.js';\nimport { WebGLRenderLists } from './webgl/WebGLRenderLists.js';\nimport { WebGLRenderStates } from './webgl/WebGLRenderStates.js';\nimport { WebGLShadowMap } from './webgl/WebGLShadowMap.js';\nimport { WebGLState } from './webgl/WebGLState.js';\nimport { WebGLTextures } from './webgl/WebGLTextures.js';\nimport { WebGLUniforms } from './webgl/WebGLUniforms.js';\nimport { WebGLUtils } from './webgl/WebGLUtils.js';\nimport { WebXRManager } from './webxr/WebXRManager.js';\nimport { WebGLMaterials } from \"./webgl/WebGLMaterials.js\";\n\nfunction WebGLRenderer( parameters ) {\n\n\tparameters = parameters || {};\n\n\tconst _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ),\n\t\t_context = parameters.context !== undefined ? parameters.context : null,\n\n\t\t_alpha = parameters.alpha !== undefined ? parameters.alpha : false,\n\t\t_depth = parameters.depth !== undefined ? parameters.depth : true,\n\t\t_stencil = parameters.stencil !== undefined ? parameters.stencil : true,\n\t\t_antialias = parameters.antialias !== undefined ? parameters.antialias : false,\n\t\t_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,\n\t\t_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,\n\t\t_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',\n\t\t_failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;\n\n\tlet currentRenderList = null;\n\tlet currentRenderState = null;\n\n\t// public properties\n\n\tthis.domElement = _canvas;\n\n\t// Debug configuration container\n\tthis.debug = {\n\n\t\t/**\n\t\t * Enables error checking and reporting when shader programs are being compiled\n\t\t * @type {boolean}\n\t\t */\n\t\tcheckShaderErrors: true\n\t};\n\n\t// clearing\n\n\tthis.autoClear = true;\n\tthis.autoClearColor = true;\n\tthis.autoClearDepth = true;\n\tthis.autoClearStencil = true;\n\n\t// scene graph\n\n\tthis.sortObjects = true;\n\n\t// user-defined clipping\n\n\tthis.clippingPlanes = [];\n\tthis.localClippingEnabled = false;\n\n\t// physically based shading\n\n\tthis.gammaFactor = 2.0;\t// for backwards compatibility\n\tthis.outputEncoding = LinearEncoding;\n\n\t// physical lights\n\n\tthis.physicallyCorrectLights = false;\n\n\t// tone mapping\n\n\tthis.toneMapping = NoToneMapping;\n\tthis.toneMappingExposure = 1.0;\n\n\t// morphs\n\n\tthis.maxMorphTargets = 8;\n\tthis.maxMorphNormals = 4;\n\n\t// internal properties\n\n\tconst _this = this;\n\n\tlet _isContextLost = false;\n\n\t// internal state cache\n\n\tlet _framebuffer = null;\n\n\tlet _currentActiveCubeFace = 0;\n\tlet _currentActiveMipmapLevel = 0;\n\tlet _currentRenderTarget = null;\n\tlet _currentFramebuffer = null;\n\tlet _currentMaterialId = - 1;\n\n\tlet _currentCamera = null;\n\tlet _currentArrayCamera = null;\n\n\tconst _currentViewport = new Vector4();\n\tconst _currentScissor = new Vector4();\n\tlet _currentScissorTest = null;\n\n\t//\n\n\tlet _width = _canvas.width;\n\tlet _height = _canvas.height;\n\n\tlet _pixelRatio = 1;\n\tlet _opaqueSort = null;\n\tlet _transparentSort = null;\n\n\tconst _viewport = new Vector4( 0, 0, _width, _height );\n\tconst _scissor = new Vector4( 0, 0, _width, _height );\n\tlet _scissorTest = false;\n\n\t// frustum\n\n\tconst _frustum = new Frustum();\n\n\t// clipping\n\n\tconst _clipping = new WebGLClipping();\n\tlet _clippingEnabled = false;\n\tlet _localClippingEnabled = false;\n\n\t// camera matrices cache\n\n\tconst _projScreenMatrix = new Matrix4();\n\n\tconst _vector3 = new Vector3();\n\n\tconst _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };\n\n\tfunction getTargetPixelRatio() {\n\n\t\treturn _currentRenderTarget === null ? _pixelRatio : 1;\n\n\t}\n\n\t// initialize\n\n\tlet _gl = _context;\n\n\tfunction getContext( contextNames, contextAttributes ) {\n\n\t\tfor ( let i = 0; i < contextNames.length; i ++ ) {\n\n\t\t\tconst contextName = contextNames[ i ];\n\t\t\tconst context = _canvas.getContext( contextName, contextAttributes );\n\t\t\tif ( context !== null ) return context;\n\n\t\t}\n\n\t\treturn null;\n\n\t}\n\n\ttry {\n\n\t\tconst contextAttributes = {\n\t\t\talpha: _alpha,\n\t\t\tdepth: _depth,\n\t\t\tstencil: _stencil,\n\t\t\tantialias: _antialias,\n\t\t\tpremultipliedAlpha: _premultipliedAlpha,\n\t\t\tpreserveDrawingBuffer: _preserveDrawingBuffer,\n\t\t\tpowerPreference: _powerPreference,\n\t\t\tfailIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat\n\t\t};\n\n\t\t// event listeners must be registered before WebGL context is created, see #12753\n\n\t\t_canvas.addEventListener( 'webglcontextlost', onContextLost, false );\n\t\t_canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\tif ( _gl === null ) {\n\n\t\t\tconst contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];\n\n\t\t\tif ( _this.isWebGL1Renderer === true ) {\n\n\t\t\t\tcontextNames.shift();\n\n\t\t\t}\n\n\t\t\t_gl = getContext( contextNames, contextAttributes );\n\n\t\t\tif ( _gl === null ) {\n\n\t\t\t\tif ( getContext( contextNames ) ) {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context with your selected attributes.' );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Some experimental-webgl implementations do not have getShaderPrecisionFormat\n\n\t\tif ( _gl.getShaderPrecisionFormat === undefined ) {\n\n\t\t\t_gl.getShaderPrecisionFormat = function () {\n\n\t\t\t\treturn { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };\n\n\t\t\t};\n\n\t\t}\n\n\t} catch ( error ) {\n\n\t\tconsole.error( 'THREE.WebGLRenderer: ' + error.message );\n\t\tthrow error;\n\n\t}\n\n\tlet extensions, capabilities, state, info;\n\tlet properties, textures, attributes, geometries, objects;\n\tlet programCache, materials, renderLists, renderStates;\n\n\tlet background, morphtargets, bufferRenderer, indexedBufferRenderer;\n\n\tlet utils, bindingStates;\n\n\tfunction initGLContext() {\n\n\t\textensions = new WebGLExtensions( _gl );\n\n\t\tcapabilities = new WebGLCapabilities( _gl, extensions, parameters );\n\n\t\tif ( capabilities.isWebGL2 === false ) {\n\n\t\t\textensions.get( 'WEBGL_depth_texture' );\n\t\t\textensions.get( 'OES_texture_float' );\n\t\t\textensions.get( 'OES_texture_half_float' );\n\t\t\textensions.get( 'OES_texture_half_float_linear' );\n\t\t\textensions.get( 'OES_standard_derivatives' );\n\t\t\textensions.get( 'OES_element_index_uint' );\n\t\t\textensions.get( 'OES_vertex_array_object' );\n\t\t\textensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t}\n\n\t\textensions.get( 'OES_texture_float_linear' );\n\n\t\tutils = new WebGLUtils( _gl, extensions, capabilities );\n\n\t\tstate = new WebGLState( _gl, extensions, capabilities );\n\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );\n\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );\n\n\t\tinfo = new WebGLInfo( _gl );\n\t\tproperties = new WebGLProperties();\n\t\ttextures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );\n\t\tattributes = new WebGLAttributes( _gl, capabilities );\n\t\tbindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );\n\t\tgeometries = new WebGLGeometries( _gl, attributes, info, bindingStates );\n\t\tobjects = new WebGLObjects( _gl, geometries, attributes, info );\n\t\tmorphtargets = new WebGLMorphtargets( _gl );\n\t\tprogramCache = new WebGLPrograms( _this, extensions, capabilities, bindingStates );\n\t\tmaterials = new WebGLMaterials( properties );\n\t\trenderLists = new WebGLRenderLists();\n\t\trenderStates = new WebGLRenderStates();\n\n\t\tbackground = new WebGLBackground( _this, state, objects, _premultipliedAlpha );\n\n\t\tbufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );\n\t\tindexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );\n\n\t\tinfo.programs = programCache.programs;\n\n\t\t_this.capabilities = capabilities;\n\t\t_this.extensions = extensions;\n\t\t_this.properties = properties;\n\t\t_this.renderLists = renderLists;\n\t\t_this.state = state;\n\t\t_this.info = info;\n\n\t}\n\n\tinitGLContext();\n\n\t// xr\n\n\tconst xr = new WebXRManager( _this, _gl );\n\n\tthis.xr = xr;\n\n\t// shadow map\n\n\tconst shadowMap = new WebGLShadowMap( _this, objects, capabilities.maxTextureSize );\n\n\tthis.shadowMap = shadowMap;\n\n\t// API\n\n\tthis.getContext = function () {\n\n\t\treturn _gl;\n\n\t};\n\n\tthis.getContextAttributes = function () {\n\n\t\treturn _gl.getContextAttributes();\n\n\t};\n\n\tthis.forceContextLoss = function () {\n\n\t\tconst extension = extensions.get( 'WEBGL_lose_context' );\n\t\tif ( extension ) extension.loseContext();\n\n\t};\n\n\tthis.forceContextRestore = function () {\n\n\t\tconst extension = extensions.get( 'WEBGL_lose_context' );\n\t\tif ( extension ) extension.restoreContext();\n\n\t};\n\n\tthis.getPixelRatio = function () {\n\n\t\treturn _pixelRatio;\n\n\t};\n\n\tthis.setPixelRatio = function ( value ) {\n\n\t\tif ( value === undefined ) return;\n\n\t\t_pixelRatio = value;\n\n\t\tthis.setSize( _width, _height, false );\n\n\t};\n\n\tthis.getSize = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getsize() now requires a Vector2 as an argument' );\n\n\t\t\ttarget = new Vector2();\n\n\t\t}\n\n\t\treturn target.set( _width, _height );\n\n\t};\n\n\tthis.setSize = function ( width, height, updateStyle ) {\n\n\t\tif ( xr.isPresenting ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Can\\'t change size while VR device is presenting.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\t_width = width;\n\t\t_height = height;\n\n\t\t_canvas.width = Math.floor( width * _pixelRatio );\n\t\t_canvas.height = Math.floor( height * _pixelRatio );\n\n\t\tif ( updateStyle !== false ) {\n\n\t\t\t_canvas.style.width = width + 'px';\n\t\t\t_canvas.style.height = height + 'px';\n\n\t\t}\n\n\t\tthis.setViewport( 0, 0, width, height );\n\n\t};\n\n\tthis.getDrawingBufferSize = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument' );\n\n\t\t\ttarget = new Vector2();\n\n\t\t}\n\n\t\treturn target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();\n\n\t};\n\n\tthis.setDrawingBufferSize = function ( width, height, pixelRatio ) {\n\n\t\t_width = width;\n\t\t_height = height;\n\n\t\t_pixelRatio = pixelRatio;\n\n\t\t_canvas.width = Math.floor( width * pixelRatio );\n\t\t_canvas.height = Math.floor( height * pixelRatio );\n\n\t\tthis.setViewport( 0, 0, width, height );\n\n\t};\n\n\tthis.getCurrentViewport = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument' );\n\n\t\t\ttarget = new Vector4();\n\n\t\t}\n\n\t\treturn target.copy( _currentViewport );\n\n\t};\n\n\tthis.getViewport = function ( target ) {\n\n\t\treturn target.copy( _viewport );\n\n\t};\n\n\tthis.setViewport = function ( x, y, width, height ) {\n\n\t\tif ( x.isVector4 ) {\n\n\t\t\t_viewport.set( x.x, x.y, x.z, x.w );\n\n\t\t} else {\n\n\t\t\t_viewport.set( x, y, width, height );\n\n\t\t}\n\n\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );\n\n\t};\n\n\tthis.getScissor = function ( target ) {\n\n\t\treturn target.copy( _scissor );\n\n\t};\n\n\tthis.setScissor = function ( x, y, width, height ) {\n\n\t\tif ( x.isVector4 ) {\n\n\t\t\t_scissor.set( x.x, x.y, x.z, x.w );\n\n\t\t} else {\n\n\t\t\t_scissor.set( x, y, width, height );\n\n\t\t}\n\n\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );\n\n\t};\n\n\tthis.getScissorTest = function () {\n\n\t\treturn _scissorTest;\n\n\t};\n\n\tthis.setScissorTest = function ( boolean ) {\n\n\t\tstate.setScissorTest( _scissorTest = boolean );\n\n\t};\n\n\tthis.setOpaqueSort = function ( method ) {\n\n\t\t_opaqueSort = method;\n\n\t};\n\n\tthis.setTransparentSort = function ( method ) {\n\n\t\t_transparentSort = method;\n\n\t};\n\n\t// Clearing\n\n\tthis.getClearColor = function () {\n\n\t\treturn background.getClearColor();\n\n\t};\n\n\tthis.setClearColor = function () {\n\n\t\tbackground.setClearColor.apply( background, arguments );\n\n\t};\n\n\tthis.getClearAlpha = function () {\n\n\t\treturn background.getClearAlpha();\n\n\t};\n\n\tthis.setClearAlpha = function () {\n\n\t\tbackground.setClearAlpha.apply( background, arguments );\n\n\t};\n\n\tthis.clear = function ( color, depth, stencil ) {\n\n\t\tlet bits = 0;\n\n\t\tif ( color === undefined || color ) bits |= _gl.COLOR_BUFFER_BIT;\n\t\tif ( depth === undefined || depth ) bits |= _gl.DEPTH_BUFFER_BIT;\n\t\tif ( stencil === undefined || stencil ) bits |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t_gl.clear( bits );\n\n\t};\n\n\tthis.clearColor = function () {\n\n\t\tthis.clear( true, false, false );\n\n\t};\n\n\tthis.clearDepth = function () {\n\n\t\tthis.clear( false, true, false );\n\n\t};\n\n\tthis.clearStencil = function () {\n\n\t\tthis.clear( false, false, true );\n\n\t};\n\n\t//\n\n\tthis.dispose = function () {\n\n\t\t_canvas.removeEventListener( 'webglcontextlost', onContextLost, false );\n\t\t_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\trenderLists.dispose();\n\t\trenderStates.dispose();\n\t\tproperties.dispose();\n\t\tobjects.dispose();\n\t\tbindingStates.dispose();\n\n\t\txr.dispose();\n\n\t\tanimation.stop();\n\n\t};\n\n\t// Events\n\n\tfunction onContextLost( event ) {\n\n\t\tevent.preventDefault();\n\n\t\tconsole.log( 'THREE.WebGLRenderer: Context Lost.' );\n\n\t\t_isContextLost = true;\n\n\t}\n\n\tfunction onContextRestore( /* event */ ) {\n\n\t\tconsole.log( 'THREE.WebGLRenderer: Context Restored.' );\n\n\t\t_isContextLost = false;\n\n\t\tinitGLContext();\n\n\t}\n\n\tfunction onMaterialDispose( event ) {\n\n\t\tconst material = event.target;\n\n\t\tmaterial.removeEventListener( 'dispose', onMaterialDispose );\n\n\t\tdeallocateMaterial( material );\n\n\t}\n\n\t// Buffer deallocation\n\n\tfunction deallocateMaterial( material ) {\n\n\t\treleaseMaterialProgramReference( material );\n\n\t\tproperties.remove( material );\n\n\t}\n\n\n\tfunction releaseMaterialProgramReference( material ) {\n\n\t\tconst programInfo = properties.get( material ).program;\n\n\t\tmaterial.program = undefined;\n\n\t\tif ( programInfo !== undefined ) {\n\n\t\t\tprogramCache.releaseProgram( programInfo );\n\n\t\t}\n\n\t}\n\n\t// Buffer rendering\n\n\tfunction renderObjectImmediate( object, program ) {\n\n\t\tobject.render( function ( object ) {\n\n\t\t\t_this.renderBufferImmediate( object, program );\n\n\t\t} );\n\n\t}\n\n\tthis.renderBufferImmediate = function ( object, program ) {\n\n\t\tbindingStates.initAttributes();\n\n\t\tconst buffers = properties.get( object );\n\n\t\tif ( object.hasPositions && ! buffers.position ) buffers.position = _gl.createBuffer();\n\t\tif ( object.hasNormals && ! buffers.normal ) buffers.normal = _gl.createBuffer();\n\t\tif ( object.hasUvs && ! buffers.uv ) buffers.uv = _gl.createBuffer();\n\t\tif ( object.hasColors && ! buffers.color ) buffers.color = _gl.createBuffer();\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tif ( object.hasPositions ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.position );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.position );\n\t\t\t_gl.vertexAttribPointer( programAttributes.position, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasNormals ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.normal );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.normal );\n\t\t\t_gl.vertexAttribPointer( programAttributes.normal, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasUvs ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.uv );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.uvArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.uv );\n\t\t\t_gl.vertexAttribPointer( programAttributes.uv, 2, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasColors ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.color );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.colorArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.color );\n\t\t\t_gl.vertexAttribPointer( programAttributes.color, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tbindingStates.disableUnusedAttributes();\n\n\t\t_gl.drawArrays( _gl.TRIANGLES, 0, object.count );\n\n\t\tobject.count = 0;\n\n\t};\n\n\tthis.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {\n\n\t\tif ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)\n\n\t\tconst frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );\n\n\t\tconst program = setProgram( camera, scene, material, object );\n\n\t\tstate.setMaterial( material, frontFaceCW );\n\n\t\t//\n\n\t\tlet index = geometry.index;\n\t\tconst position = geometry.attributes.position;\n\n\t\t//\n\n\t\tif ( index === null ) {\n\n\t\t\tif ( position === undefined || position.count === 0 ) return;\n\n\t\t} else if ( index.count === 0 ) {\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t//\n\n\t\tlet rangeFactor = 1;\n\n\t\tif ( material.wireframe === true ) {\n\n\t\t\tindex = geometries.getWireframeAttribute( geometry );\n\t\t\trangeFactor = 2;\n\n\t\t}\n\n\t\tif ( material.morphTargets || material.morphNormals ) {\n\n\t\t\tmorphtargets.update( object, geometry, material, program );\n\n\t\t}\n\n\t\tbindingStates.setup( object, material, program, geometry, index );\n\n\t\tlet attribute;\n\t\tlet renderer = bufferRenderer;\n\n\t\tif ( index !== null ) {\n\n\t\t\tattribute = attributes.get( index );\n\n\t\t\trenderer = indexedBufferRenderer;\n\t\t\trenderer.setIndex( attribute );\n\n\t\t}\n\n\t\t//\n\n\t\tconst dataCount = ( index !== null ) ? index.count : position.count;\n\n\t\tconst rangeStart = geometry.drawRange.start * rangeFactor;\n\t\tconst rangeCount = geometry.drawRange.count * rangeFactor;\n\n\t\tconst groupStart = group !== null ? group.start * rangeFactor : 0;\n\t\tconst groupCount = group !== null ? group.count * rangeFactor : Infinity;\n\n\t\tconst drawStart = Math.max( rangeStart, groupStart );\n\t\tconst drawEnd = Math.min( dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1;\n\n\t\tconst drawCount = Math.max( 0, drawEnd - drawStart + 1 );\n\n\t\tif ( drawCount === 0 ) return;\n\n\t\t//\n\n\t\tif ( object.isMesh ) {\n\n\t\t\tif ( material.wireframe === true ) {\n\n\t\t\t\tstate.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );\n\t\t\t\trenderer.setMode( _gl.LINES );\n\n\t\t\t} else {\n\n\t\t\t\trenderer.setMode( _gl.TRIANGLES );\n\n\t\t\t}\n\n\t\t} else if ( object.isLine ) {\n\n\t\t\tlet lineWidth = material.linewidth;\n\n\t\t\tif ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material\n\n\t\t\tstate.setLineWidth( lineWidth * getTargetPixelRatio() );\n\n\t\t\tif ( object.isLineSegments ) {\n\n\t\t\t\trenderer.setMode( _gl.LINES );\n\n\t\t\t} else if ( object.isLineLoop ) {\n\n\t\t\t\trenderer.setMode( _gl.LINE_LOOP );\n\n\t\t\t} else {\n\n\t\t\t\trenderer.setMode( _gl.LINE_STRIP );\n\n\t\t\t}\n\n\t\t} else if ( object.isPoints ) {\n\n\t\t\trenderer.setMode( _gl.POINTS );\n\n\t\t} else if ( object.isSprite ) {\n\n\t\t\trenderer.setMode( _gl.TRIANGLES );\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh ) {\n\n\t\t\trenderer.renderInstances( geometry, drawStart, drawCount, object.count );\n\n\t\t} else if ( geometry.isInstancedBufferGeometry ) {\n\n\t\t\tconst instanceCount = Math.min( geometry.instanceCount, geometry._maxInstanceCount );\n\n\t\t\trenderer.renderInstances( geometry, drawStart, drawCount, instanceCount );\n\n\t\t} else {\n\n\t\t\trenderer.render( drawStart, drawCount );\n\n\t\t}\n\n\t};\n\n\t// Compile\n\n\tthis.compile = function ( scene, camera ) {\n\n\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\tcurrentRenderState.init();\n\n\t\tscene.traverse( function ( object ) {\n\n\t\t\tif ( object.isLight ) {\n\n\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\tcurrentRenderState.setupLights( camera );\n\n\t\tconst compiled = new WeakMap();\n\n\t\tscene.traverse( function ( object ) {\n\n\t\t\tlet material = object.material;\n\n\t\t\tif ( material ) {\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0; i < material.length; i ++ ) {\n\n\t\t\t\t\t\tlet material2 = material[ i ];\n\n\t\t\t\t\t\tif ( compiled.has( material2 ) === false ) {\n\n\t\t\t\t\t\t\tinitMaterial( material2, scene, object );\n\t\t\t\t\t\t\tcompiled.set( material2 );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( compiled.has( material ) === false ) {\n\n\t\t\t\t\tinitMaterial( material, scene, object );\n\t\t\t\t\tcompiled.set( material );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t};\n\n\t// Animation Loop\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame( time ) {\n\n\t\tif ( xr.isPresenting ) return;\n\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time );\n\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop( onAnimationFrame );\n\n\tif ( typeof window !== 'undefined' ) animation.setContext( window );\n\n\tthis.setAnimationLoop = function ( callback ) {\n\n\t\tonAnimationFrameCallback = callback;\n\t\txr.setAnimationLoop( callback );\n\n\t\t( callback === null ) ? animation.stop() : animation.start();\n\n\t};\n\n\t// Rendering\n\n\tthis.render = function ( scene, camera ) {\n\n\t\tlet renderTarget, forceClear;\n\n\t\tif ( arguments[ 2 ] !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.' );\n\t\t\trenderTarget = arguments[ 2 ];\n\n\t\t}\n\n\t\tif ( arguments[ 3 ] !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.' );\n\t\t\tforceClear = arguments[ 3 ];\n\n\t\t}\n\n\t\tif ( camera !== undefined && camera.isCamera !== true ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( _isContextLost === true ) return;\n\n\t\t// reset caching for this frame\n\n\t\tbindingStates.resetDefaultState();\n\t\t_currentMaterialId = - 1;\n\t\t_currentCamera = null;\n\n\t\t// update scene graph\n\n\t\tif ( scene.autoUpdate === true ) scene.updateMatrixWorld();\n\n\t\t// update camera matrices and frustum\n\n\t\tif ( camera.parent === null ) camera.updateMatrixWorld();\n\n\t\tif ( xr.enabled === true && xr.isPresenting === true ) {\n\n\t\t\tcamera = xr.getCamera( camera );\n\n\t\t}\n\n\t\t//\n\t\tif ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget );\n\n\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\tcurrentRenderState.init();\n\n\t\t_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );\n\t\t_frustum.setFromProjectionMatrix( _projScreenMatrix );\n\n\t\t_localClippingEnabled = this.localClippingEnabled;\n\t\t_clippingEnabled = _clipping.init( this.clippingPlanes, _localClippingEnabled, camera );\n\n\t\tcurrentRenderList = renderLists.get( scene, camera );\n\t\tcurrentRenderList.init();\n\n\t\tprojectObject( scene, camera, 0, _this.sortObjects );\n\n\t\tcurrentRenderList.finish();\n\n\t\tif ( _this.sortObjects === true ) {\n\n\t\t\tcurrentRenderList.sort( _opaqueSort, _transparentSort );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( _clippingEnabled === true ) _clipping.beginShadows();\n\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\tshadowMap.render( shadowsArray, scene, camera );\n\n\t\tcurrentRenderState.setupLights( camera );\n\n\t\tif ( _clippingEnabled === true ) _clipping.endShadows();\n\n\t\t//\n\n\t\tif ( this.info.autoReset === true ) this.info.reset();\n\n\t\tif ( renderTarget !== undefined ) {\n\n\t\t\tthis.setRenderTarget( renderTarget );\n\n\t\t}\n\n\t\t//\n\n\t\tbackground.render( currentRenderList, scene, camera, forceClear );\n\n\t\t// render scene\n\n\t\tconst opaqueObjects = currentRenderList.opaque;\n\t\tconst transparentObjects = currentRenderList.transparent;\n\n\t\tif ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );\n\t\tif ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera );\n\n\t\t//\n\n\t\tif ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );\n\n\t\t//\n\n\t\tif ( _currentRenderTarget !== null ) {\n\n\t\t\t// Generate mipmap if we're using any kind of mipmap filtering\n\n\t\t\ttextures.updateRenderTargetMipmap( _currentRenderTarget );\n\n\t\t\t// resolve multisample renderbuffers to a single-sample texture if necessary\n\n\t\t\ttextures.updateMultisampleRenderTarget( _currentRenderTarget );\n\n\t\t}\n\n\t\t// Ensure depth buffer writing is enabled so it can be cleared on next render\n\n\t\tstate.buffers.depth.setTest( true );\n\t\tstate.buffers.depth.setMask( true );\n\t\tstate.buffers.color.setMask( true );\n\n\t\tstate.setPolygonOffset( false );\n\n\t\t// _gl.finish();\n\n\t\tcurrentRenderList = null;\n\t\tcurrentRenderState = null;\n\n\t};\n\n\tfunction projectObject( object, camera, groupOrder, sortObjects ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tconst visible = object.layers.test( camera.layers );\n\n\t\tif ( visible ) {\n\n\t\t\tif ( object.isGroup ) {\n\n\t\t\t\tgroupOrder = object.renderOrder;\n\n\t\t\t} else if ( object.isLOD ) {\n\n\t\t\t\tif ( object.autoUpdate === true ) object.update( camera );\n\n\t\t\t} else if ( object.isLight ) {\n\n\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isSprite ) {\n\n\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update( object );\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif ( material.visible ) {\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isImmediateRenderObject ) {\n\n\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t}\n\n\t\t\t\tcurrentRenderList.push( object, null, object.material, groupOrder, _vector3.z, null );\n\n\t\t\t} else if ( object.isMesh || object.isLine || object.isPoints ) {\n\n\t\t\t\tif ( object.isSkinnedMesh ) {\n\n\t\t\t\t\t// update skeleton only once in a frame\n\n\t\t\t\t\tif ( object.skeleton.frame !== info.render.frame ) {\n\n\t\t\t\t\t\tobject.skeleton.update();\n\t\t\t\t\t\tobject.skeleton.frame = info.render.frame;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update( object );\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\t\tcurrentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tprojectObject( children[ i ], camera, groupOrder, sortObjects );\n\n\t\t}\n\n\t}\n\n\tfunction renderObjects( renderList, scene, camera ) {\n\n\t\tconst overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;\n\n\t\tfor ( let i = 0, l = renderList.length; i < l; i ++ ) {\n\n\t\t\tconst renderItem = renderList[ i ];\n\n\t\t\tconst object = renderItem.object;\n\t\t\tconst geometry = renderItem.geometry;\n\t\t\tconst material = overrideMaterial === null ? renderItem.material : overrideMaterial;\n\t\t\tconst group = renderItem.group;\n\n\t\t\tif ( camera.isArrayCamera ) {\n\n\t\t\t\t_currentArrayCamera = camera;\n\n\t\t\t\tconst cameras = camera.cameras;\n\n\t\t\t\tfor ( let j = 0, jl = cameras.length; j < jl; j ++ ) {\n\n\t\t\t\t\tconst camera2 = cameras[ j ];\n\n\t\t\t\t\tif ( object.layers.test( camera2.layers ) ) {\n\n\t\t\t\t\t\tstate.viewport( _currentViewport.copy( camera2.viewport ) );\n\n\t\t\t\t\t\tcurrentRenderState.setupLights( camera2 );\n\n\t\t\t\t\t\trenderObject( object, scene, camera2, geometry, material, group );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_currentArrayCamera = null;\n\n\t\t\t\trenderObject( object, scene, camera, geometry, material, group );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction renderObject( object, scene, camera, geometry, material, group ) {\n\n\t\tobject.onBeforeRender( _this, scene, camera, geometry, material, group );\n\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t\tobject.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );\n\t\tobject.normalMatrix.getNormalMatrix( object.modelViewMatrix );\n\n\t\tif ( object.isImmediateRenderObject ) {\n\n\t\t\tconst program = setProgram( camera, scene, material, object );\n\n\t\t\tstate.setMaterial( material );\n\n\t\t\tbindingStates.reset();\n\n\t\t\trenderObjectImmediate( object, program );\n\n\t\t} else {\n\n\t\t\t_this.renderBufferDirect( camera, scene, geometry, material, object, group );\n\n\t\t}\n\n\t\tobject.onAfterRender( _this, scene, camera, geometry, material, group );\n\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t}\n\n\tfunction initMaterial( material, scene, object ) {\n\n\t\tif ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\tconst materialProperties = properties.get( material );\n\n\t\tconst lights = currentRenderState.state.lights;\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\tconst lightsStateVersion = lights.state.version;\n\n\t\tconst parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object );\n\t\tconst programCacheKey = programCache.getProgramCacheKey( parameters );\n\n\t\tlet program = materialProperties.program;\n\t\tlet programChange = true;\n\n\t\tif ( program === undefined ) {\n\n\t\t\t// new material\n\t\t\tmaterial.addEventListener( 'dispose', onMaterialDispose );\n\n\t\t} else if ( program.cacheKey !== programCacheKey ) {\n\n\t\t\t// changed glsl or parameters\n\t\t\treleaseMaterialProgramReference( material );\n\n\t\t} else if ( materialProperties.lightsStateVersion !== lightsStateVersion ) {\n\n\t\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\t\tprogramChange = false;\n\n\t\t} else if ( parameters.shaderID !== undefined ) {\n\n\t\t\t// same glsl and uniform list\n\t\t\treturn;\n\n\t\t} else {\n\n\t\t\t// only rebuild uniform list\n\t\t\tprogramChange = false;\n\n\t\t}\n\n\t\tif ( programChange ) {\n\n\t\t\tprogram = programCache.acquireProgram( parameters, programCacheKey );\n\n\t\t\tmaterialProperties.program = program;\n\t\t\tmaterialProperties.uniforms = parameters.uniforms;\n\t\t\tmaterialProperties.outputEncoding = parameters.outputEncoding;\n\t\t\tmaterial.program = program;\n\n\t\t}\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tif ( material.morphTargets ) {\n\n\t\t\tmaterial.numSupportedMorphTargets = 0;\n\n\t\t\tfor ( let i = 0; i < _this.maxMorphTargets; i ++ ) {\n\n\t\t\t\tif ( programAttributes[ 'morphTarget' + i ] >= 0 ) {\n\n\t\t\t\t\tmaterial.numSupportedMorphTargets ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( material.morphNormals ) {\n\n\t\t\tmaterial.numSupportedMorphNormals = 0;\n\n\t\t\tfor ( let i = 0; i < _this.maxMorphNormals; i ++ ) {\n\n\t\t\t\tif ( programAttributes[ 'morphNormal' + i ] >= 0 ) {\n\n\t\t\t\t\tmaterial.numSupportedMorphNormals ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst uniforms = materialProperties.uniforms;\n\n\t\tif ( ! material.isShaderMaterial &&\n\t\t\t! material.isRawShaderMaterial ||\n\t\t\tmaterial.clipping === true ) {\n\n\t\t\tmaterialProperties.numClippingPlanes = _clipping.numPlanes;\n\t\t\tmaterialProperties.numIntersection = _clipping.numIntersection;\n\t\t\tuniforms.clippingPlanes = _clipping.uniform;\n\n\t\t}\n\n\t\tmaterialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tmaterialProperties.fog = scene.fog;\n\n\t\t// store the light setup it was created for\n\n\t\tmaterialProperties.needsLights = materialNeedsLights( material );\n\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\tif ( materialProperties.needsLights ) {\n\n\t\t\t// wire up the material to this renderer's lighting state\n\n\t\t\tuniforms.ambientLightColor.value = lights.state.ambient;\n\t\t\tuniforms.lightProbe.value = lights.state.probe;\n\t\t\tuniforms.directionalLights.value = lights.state.directional;\n\t\t\tuniforms.directionalLightShadows.value = lights.state.directionalShadow;\n\t\t\tuniforms.spotLights.value = lights.state.spot;\n\t\t\tuniforms.spotLightShadows.value = lights.state.spotShadow;\n\t\t\tuniforms.rectAreaLights.value = lights.state.rectArea;\n\t\t\tuniforms.pointLights.value = lights.state.point;\n\t\t\tuniforms.pointLightShadows.value = lights.state.pointShadow;\n\t\t\tuniforms.hemisphereLights.value = lights.state.hemi;\n\n\t\t\tuniforms.directionalShadowMap.value = lights.state.directionalShadowMap;\n\t\t\tuniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;\n\t\t\tuniforms.spotShadowMap.value = lights.state.spotShadowMap;\n\t\t\tuniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix;\n\t\t\tuniforms.pointShadowMap.value = lights.state.pointShadowMap;\n\t\t\tuniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;\n\t\t\t// TODO (abelnation): add area lights shadow info to uniforms\n\n\t\t}\n\n\t\tconst progUniforms = materialProperties.program.getUniforms(),\n\t\t\tuniformsList =\n\t\t\t\tWebGLUniforms.seqWithValue( progUniforms.seq, uniforms );\n\n\t\tmaterialProperties.uniformsList = uniformsList;\n\n\t}\n\n\tfunction setProgram( camera, scene, material, object ) {\n\n\t\tif ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\ttextures.resetTextureUnits();\n\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tconst encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding;\n\n\t\tconst materialProperties = properties.get( material );\n\t\tconst lights = currentRenderState.state.lights;\n\n\t\tif ( _clippingEnabled === true ) {\n\n\t\t\tif ( _localClippingEnabled === true || camera !== _currentCamera ) {\n\n\t\t\t\tconst useCache =\n\t\t\t\t\tcamera === _currentCamera &&\n\t\t\t\t\tmaterial.id === _currentMaterialId;\n\n\t\t\t\t// we might want to call this function with some ClippingGroup\n\t\t\t\t// object instead of the material, once it becomes feasible\n\t\t\t\t// (#8465, #8379)\n\t\t\t\t_clipping.setState(\n\t\t\t\t\tmaterial.clippingPlanes, material.clipIntersection, material.clipShadows,\n\t\t\t\t\tcamera, materialProperties, useCache );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( material.version === materialProperties.__version ) {\n\n\t\t\tif ( materialProperties.program === undefined ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( material.fog && materialProperties.fog !== fog ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.environment !== environment ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.numClippingPlanes !== undefined &&\n\t\t\t\t( materialProperties.numClippingPlanes !== _clipping.numPlanes ||\n\t\t\t\tmaterialProperties.numIntersection !== _clipping.numIntersection ) ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.outputEncoding !== encoding ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tinitMaterial( material, scene, object );\n\t\t\tmaterialProperties.__version = material.version;\n\n\t\t}\n\n\t\tlet refreshProgram = false;\n\t\tlet refreshMaterial = false;\n\t\tlet refreshLights = false;\n\n\t\tconst program = materialProperties.program,\n\t\t\tp_uniforms = program.getUniforms(),\n\t\t\tm_uniforms = materialProperties.uniforms;\n\n\t\tif ( state.useProgram( program.program ) ) {\n\n\t\t\trefreshProgram = true;\n\t\t\trefreshMaterial = true;\n\t\t\trefreshLights = true;\n\n\t\t}\n\n\t\tif ( material.id !== _currentMaterialId ) {\n\n\t\t\t_currentMaterialId = material.id;\n\n\t\t\trefreshMaterial = true;\n\n\t\t}\n\n\t\tif ( refreshProgram || _currentCamera !== camera ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );\n\n\t\t\tif ( capabilities.logarithmicDepthBuffer ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'logDepthBufFC',\n\t\t\t\t\t2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );\n\n\t\t\t}\n\n\t\t\tif ( _currentCamera !== camera ) {\n\n\t\t\t\t_currentCamera = camera;\n\n\t\t\t\t// lighting uniforms depend on the camera so enforce an update\n\t\t\t\t// now, in case this material supports lights - or later, when\n\t\t\t\t// the next material that does gets activated:\n\n\t\t\t\trefreshMaterial = true;\t\t// set to true on material change\n\t\t\t\trefreshLights = true;\t\t// remains set until update done\n\n\t\t\t}\n\n\t\t\t// load material specific uniforms\n\t\t\t// (shader material also gets them for the sake of genericity)\n\n\t\t\tif ( material.isShaderMaterial ||\n\t\t\t\tmaterial.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.envMap ) {\n\n\t\t\t\tconst uCamPos = p_uniforms.map.cameraPosition;\n\n\t\t\t\tif ( uCamPos !== undefined ) {\n\n\t\t\t\t\tuCamPos.setValue( _gl,\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( camera.matrixWorld ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.isShaderMaterial ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true );\n\n\t\t\t}\n\n\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.isShaderMaterial ||\n\t\t\t\tmaterial.isShadowMaterial ||\n\t\t\t\tmaterial.skinning ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// skinning uniforms must be set even if material didn't change\n\t\t// auto-setting of texture unit for bone texture must go before other textures\n\t\t// otherwise textures used for skinning can take over texture units reserved for other material textures\n\n\t\tif ( material.skinning ) {\n\n\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrix' );\n\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );\n\n\t\t\tconst skeleton = object.skeleton;\n\n\t\t\tif ( skeleton ) {\n\n\t\t\t\tconst bones = skeleton.bones;\n\n\t\t\t\tif ( capabilities.floatVertexTextures ) {\n\n\t\t\t\t\tif ( skeleton.boneTexture === undefined ) {\n\n\t\t\t\t\t\t// layout (1 matrix = 4 pixels)\n\t\t\t\t\t\t// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)\n\t\t\t\t\t\t// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)\n\t\t\t\t\t\t// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)\n\t\t\t\t\t\t// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)\n\t\t\t\t\t\t// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)\n\n\n\t\t\t\t\t\tlet size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix\n\t\t\t\t\t\tsize = MathUtils.ceilPowerOfTwo( size );\n\t\t\t\t\t\tsize = Math.max( size, 4 );\n\n\t\t\t\t\t\tconst boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel\n\t\t\t\t\t\tboneMatrices.set( skeleton.boneMatrices ); // copy current values\n\n\t\t\t\t\t\tconst boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );\n\n\t\t\t\t\t\tskeleton.boneMatrices = boneMatrices;\n\t\t\t\t\t\tskeleton.boneTexture = boneTexture;\n\t\t\t\t\t\tskeleton.boneTextureSize = size;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );\n\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tp_uniforms.setOptional( _gl, skeleton, 'boneMatrices' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) {\n\n\t\t\tmaterialProperties.receiveShadow = object.receiveShadow;\n\t\t\tp_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );\n\n\t\t}\n\n\t\tif ( refreshMaterial ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );\n\n\t\t\tif ( materialProperties.needsLights ) {\n\n\t\t\t\t// the current material requires lighting info\n\n\t\t\t\t// note: all lighting uniforms are always set correctly\n\t\t\t\t// they simply reference the renderer's state for their\n\t\t\t\t// values\n\t\t\t\t//\n\t\t\t\t// use the current material's .needsUpdate flags to set\n\t\t\t\t// the GL state when required\n\n\t\t\t\tmarkUniformsLightsNeedsUpdate( m_uniforms, refreshLights );\n\n\t\t\t}\n\n\t\t\t// refresh uniforms common to several materials\n\n\t\t\tif ( fog && material.fog ) {\n\n\t\t\t\tmaterials.refreshFogUniforms( m_uniforms, fog );\n\n\t\t\t}\n\n\t\t\tmaterials.refreshMaterialUniforms( m_uniforms, material, environment, _pixelRatio, _height );\n\n\t\t\t// RectAreaLight Texture\n\t\t\t// TODO (mrdoob): Find a nicer implementation\n\n\t\t\tif ( m_uniforms.ltc_1 !== undefined ) m_uniforms.ltc_1.value = UniformsLib.LTC_1;\n\t\t\tif ( m_uniforms.ltc_2 !== undefined ) m_uniforms.ltc_2.value = UniformsLib.LTC_2;\n\n\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );\n\n\t\t}\n\n\t\tif ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {\n\n\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );\n\t\t\tmaterial.uniformsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( material.isSpriteMaterial ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'center', object.center );\n\n\t\t}\n\n\t\t// common matrices\n\n\t\tp_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );\n\t\tp_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );\n\t\tp_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );\n\n\t\treturn program;\n\n\t}\n\n\t// If uniforms are marked as clean, they don't need to be loaded to the GPU.\n\n\tfunction markUniformsLightsNeedsUpdate( uniforms, value ) {\n\n\t\tuniforms.ambientLightColor.needsUpdate = value;\n\t\tuniforms.lightProbe.needsUpdate = value;\n\n\t\tuniforms.directionalLights.needsUpdate = value;\n\t\tuniforms.directionalLightShadows.needsUpdate = value;\n\t\tuniforms.pointLights.needsUpdate = value;\n\t\tuniforms.pointLightShadows.needsUpdate = value;\n\t\tuniforms.spotLights.needsUpdate = value;\n\t\tuniforms.spotLightShadows.needsUpdate = value;\n\t\tuniforms.rectAreaLights.needsUpdate = value;\n\t\tuniforms.hemisphereLights.needsUpdate = value;\n\n\t}\n\n\tfunction materialNeedsLights( material ) {\n\n\t\treturn material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial ||\n\t\t\tmaterial.isMeshStandardMaterial || material.isShadowMaterial ||\n\t\t\t( material.isShaderMaterial && material.lights === true );\n\n\t}\n\n\t//\n\tthis.setFramebuffer = function ( value ) {\n\n\t\tif ( _framebuffer !== value && _currentRenderTarget === null ) _gl.bindFramebuffer( _gl.FRAMEBUFFER, value );\n\n\t\t_framebuffer = value;\n\n\t};\n\n\tthis.getActiveCubeFace = function () {\n\n\t\treturn _currentActiveCubeFace;\n\n\t};\n\n\tthis.getActiveMipmapLevel = function () {\n\n\t\treturn _currentActiveMipmapLevel;\n\n\t};\n\n\tthis.getRenderTarget = function () {\n\n\t\treturn _currentRenderTarget;\n\n\t};\n\n\tthis.setRenderTarget = function ( renderTarget, activeCubeFace, activeMipmapLevel ) {\n\n\t\t_currentRenderTarget = renderTarget;\n\t\t_currentActiveCubeFace = activeCubeFace;\n\t\t_currentActiveMipmapLevel = activeMipmapLevel;\n\n\t\tif ( renderTarget && properties.get( renderTarget ).__webglFramebuffer === undefined ) {\n\n\t\t\ttextures.setupRenderTarget( renderTarget );\n\n\t\t}\n\n\t\tlet framebuffer = _framebuffer;\n\t\tlet isCube = false;\n\n\t\tif ( renderTarget ) {\n\n\t\t\tconst __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\t\tif ( renderTarget.isWebGLCubeRenderTarget ) {\n\n\t\t\t\tframebuffer = __webglFramebuffer[ activeCubeFace || 0 ];\n\t\t\t\tisCube = true;\n\n\t\t\t} else if ( renderTarget.isWebGLMultisampleRenderTarget ) {\n\n\t\t\t\tframebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;\n\n\t\t\t} else {\n\n\t\t\t\tframebuffer = __webglFramebuffer;\n\n\t\t\t}\n\n\t\t\t_currentViewport.copy( renderTarget.viewport );\n\t\t\t_currentScissor.copy( renderTarget.scissor );\n\t\t\t_currentScissorTest = renderTarget.scissorTest;\n\n\t\t} else {\n\n\t\t\t_currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor();\n\t\t\t_currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();\n\t\t\t_currentScissorTest = _scissorTest;\n\n\t\t}\n\n\t\tif ( _currentFramebuffer !== framebuffer ) {\n\n\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\t\t\t_currentFramebuffer = framebuffer;\n\n\t\t}\n\n\t\tstate.viewport( _currentViewport );\n\t\tstate.scissor( _currentScissor );\n\t\tstate.setScissorTest( _currentScissorTest );\n\n\t\tif ( isCube ) {\n\n\t\t\tconst textureProperties = properties.get( renderTarget.texture );\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + ( activeCubeFace || 0 ), textureProperties.__webglTexture, activeMipmapLevel || 0 );\n\n\t\t}\n\n\t};\n\n\tthis.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {\n\n\t\tif ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet framebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\tif ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {\n\n\t\t\tframebuffer = framebuffer[ activeCubeFaceIndex ];\n\n\t\t}\n\n\t\tif ( framebuffer ) {\n\n\t\t\tlet restore = false;\n\n\t\t\tif ( framebuffer !== _currentFramebuffer ) {\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\n\t\t\t\trestore = true;\n\n\t\t\t}\n\n\t\t\ttry {\n\n\t\t\t\tconst texture = renderTarget.texture;\n\t\t\t\tconst textureFormat = texture.format;\n\t\t\t\tconst textureType = texture.type;\n\n\t\t\t\tif ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // IE11, Edge and Chrome Mac < 52 (#9513)\n\t\t\t\t\t! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_float' ) || extensions.get( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox\n\t\t\t\t\t! ( textureType === HalfFloatType && ( capabilities.isWebGL2 ? extensions.get( 'EXT_color_buffer_float' ) : extensions.get( 'EXT_color_buffer_half_float' ) ) ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( _gl.checkFramebufferStatus( _gl.FRAMEBUFFER ) === _gl.FRAMEBUFFER_COMPLETE ) {\n\n\t\t\t\t\t// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)\n\n\t\t\t\t\tif ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {\n\n\t\t\t\t\t\t_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' );\n\n\t\t\t\t}\n\n\t\t\t} finally {\n\n\t\t\t\tif ( restore ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, _currentFramebuffer );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\tthis.copyFramebufferToTexture = function ( position, texture, level ) {\n\n\t\tif ( level === undefined ) level = 0;\n\n\t\tconst levelScale = Math.pow( 2, - level );\n\t\tconst width = Math.floor( texture.image.width * levelScale );\n\t\tconst height = Math.floor( texture.image.height * levelScale );\n\t\tconst glFormat = utils.convert( texture.format );\n\n\t\ttextures.setTexture2D( texture, 0 );\n\n\t\t_gl.copyTexImage2D( _gl.TEXTURE_2D, level, glFormat, position.x, position.y, width, height, 0 );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tthis.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) {\n\n\t\tif ( level === undefined ) level = 0;\n\n\t\tconst width = srcTexture.image.width;\n\t\tconst height = srcTexture.image.height;\n\t\tconst glFormat = utils.convert( dstTexture.format );\n\t\tconst glType = utils.convert( dstTexture.type );\n\n\t\ttextures.setTexture2D( dstTexture, 0 );\n\n\t\t// As another texture upload may have changed pixelStorei\n\t\t// parameters, make sure they are correct for the dstTexture\n\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );\n\t\t_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );\n\t\t_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );\n\n\t\tif ( srcTexture.isDataTexture ) {\n\n\t\t\t_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );\n\n\t\t} else {\n\n\t\t\tif ( srcTexture.isCompressedTexture ) {\n\n\t\t\t\t_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Generate mipmaps only when copying level 0\n\t\tif ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tthis.initTexture = function ( texture ) {\n\n\t\ttextures.setTexture2D( texture, 0 );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef\n\n\t}\n\n}\n\nexport { WebGLRenderer };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nimport { Color } from '../math/Color.js';\n\nfunction Fog( color, near, far ) {\n\n\tthis.name = '';\n\n\tthis.color = new Color( color );\n\n\tthis.near = ( near !== undefined ) ? near : 1;\n\tthis.far = ( far !== undefined ) ? far : 1000;\n\n}\n\nObject.assign( Fog.prototype, {\n\n\tisFog: true,\n\n\tclone: function () {\n\n\t\treturn new Fog( this.color, this.near, this.far );\n\n\t},\n\n\ttoJSON: function ( /* meta */ ) {\n\n\t\treturn {\n\t\t\ttype: 'Fog',\n\t\t\tcolor: this.color.getHex(),\n\t\t\tnear: this.near,\n\t\t\tfar: this.far\n\t\t};\n\n\t}\n\n} );\n\nexport { Fog };\n","import { Material } from './Material.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n *\n * linewidth: ,\n * linecap: \"round\",\n * linejoin: \"round\"\n * }\n */\n\nfunction LineBasicMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'LineBasicMaterial';\n\n\tthis.color = new Color( 0xffffff );\n\n\tthis.linewidth = 1;\n\tthis.linecap = 'round';\n\tthis.linejoin = 'round';\n\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nLineBasicMaterial.prototype = Object.create( Material.prototype );\nLineBasicMaterial.prototype.constructor = LineBasicMaterial;\n\nLineBasicMaterial.prototype.isLineBasicMaterial = true;\n\nLineBasicMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.linewidth = source.linewidth;\n\tthis.linecap = source.linecap;\n\tthis.linejoin = source.linejoin;\n\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { LineBasicMaterial };\n","import { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { LineBasicMaterial } from '../materials/LineBasicMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _start = new Vector3();\nconst _end = new Vector3();\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\n\nfunction Line( geometry, material, mode ) {\n\n\tif ( mode === 1 ) {\n\n\t\tconsole.error( 'THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.' );\n\n\t}\n\n\tObject3D.call( this );\n\n\tthis.type = 'Line';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new LineBasicMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nLine.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Line,\n\n\tisLine: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\tcomputeLineDistances: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t// we assume non-indexed geometry\n\n\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\t\tconst lineDistances = [ 0 ];\n\n\t\t\t\tfor ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {\n\n\t\t\t\t\t_start.fromBufferAttribute( positionAttribute, i - 1 );\n\t\t\t\t\t_end.fromBufferAttribute( positionAttribute, i );\n\n\t\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\t\tlineDistances[ i ] += _start.distanceTo( _end );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst lineDistances = geometry.lineDistances;\n\n\t\t\tlineDistances[ 0 ] = 0;\n\n\t\t\tfor ( let i = 1, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\tlineDistances[ i ] += vertices[ i - 1 ].distanceTo( vertices[ i ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Line.threshold;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\t\t_sphere.radius += threshold;\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\tconst localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\n\t\tconst vStart = new Vector3();\n\t\tconst vEnd = new Vector3();\n\t\tconst interSegment = new Vector3();\n\t\tconst interRay = new Vector3();\n\t\tconst step = ( this && this.isLineSegments ) ? 2 : 1;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst attributes = geometry.attributes;\n\t\t\tconst positions = attributes.position.array;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tconst indices = index.array;\n\n\t\t\t\tfor ( let i = 0, l = indices.length - 1; i < l; i += step ) {\n\n\t\t\t\t\tconst a = indices[ i ];\n\t\t\t\t\tconst b = indices[ i + 1 ];\n\n\t\t\t\t\tvStart.fromArray( positions, a * 3 );\n\t\t\t\t\tvEnd.fromArray( positions, b * 3 );\n\n\t\t\t\t\tconst distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0, l = positions.length / 3 - 1; i < l; i += step ) {\n\n\t\t\t\t\tvStart.fromArray( positions, 3 * i );\n\t\t\t\t\tvEnd.fromArray( positions, 3 * i + 3 );\n\n\t\t\t\t\tconst distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst nbVertices = vertices.length;\n\n\t\t\tfor ( let i = 0; i < nbVertices - 1; i += step ) {\n\n\t\t\t\tconst distSq = _ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );\n\n\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\tintersects.push( {\n\n\t\t\t\t\tdistance: distance,\n\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\tindex: i,\n\t\t\t\t\tface: null,\n\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\tobject: this\n\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\n\nexport { Line };\n","import { Line } from './Line.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _start = new Vector3();\nconst _end = new Vector3();\n\nfunction LineSegments( geometry, material ) {\n\n\tLine.call( this, geometry, material );\n\n\tthis.type = 'LineSegments';\n\n}\n\nLineSegments.prototype = Object.assign( Object.create( Line.prototype ), {\n\n\tconstructor: LineSegments,\n\n\tisLineSegments: true,\n\n\tcomputeLineDistances: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t// we assume non-indexed geometry\n\n\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\t\tconst lineDistances = [];\n\n\t\t\t\tfor ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {\n\n\t\t\t\t\t_start.fromBufferAttribute( positionAttribute, i );\n\t\t\t\t\t_end.fromBufferAttribute( positionAttribute, i + 1 );\n\n\t\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst lineDistances = geometry.lineDistances;\n\n\t\t\tfor ( let i = 0, l = vertices.length; i < l; i += 2 ) {\n\n\t\t\t\t_start.copy( vertices[ i ] );\n\t\t\t\t_end.copy( vertices[ i + 1 ] );\n\n\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { LineSegments };\n","import { Material } from './Material.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n * map: new THREE.Texture( ),\n * alphaMap: new THREE.Texture( ),\n *\n * size: ,\n * sizeAttenuation: \n *\n * morphTargets: \n * }\n */\n\nfunction PointsMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'PointsMaterial';\n\n\tthis.color = new Color( 0xffffff );\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.size = 1;\n\tthis.sizeAttenuation = true;\n\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nPointsMaterial.prototype = Object.create( Material.prototype );\nPointsMaterial.prototype.constructor = PointsMaterial;\n\nPointsMaterial.prototype.isPointsMaterial = true;\n\nPointsMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.size = source.size;\n\tthis.sizeAttenuation = source.sizeAttenuation;\n\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { PointsMaterial };\n","import { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { PointsMaterial } from '../materials/PointsMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\nconst _position = new Vector3();\n\nfunction Points( geometry, material ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Points';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new PointsMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nPoints.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Points,\n\n\tisPoints: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Points.threshold;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\t\t_sphere.radius += threshold;\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\tconst localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst attributes = geometry.attributes;\n\t\t\tconst positions = attributes.position.array;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tconst indices = index.array;\n\n\t\t\t\tfor ( let i = 0, il = indices.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst a = indices[ i ];\n\n\t\t\t\t\t_position.fromArray( positions, a * 3 );\n\n\t\t\t\t\ttestPoint( _position, a, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0, l = positions.length / 3; i < l; i ++ ) {\n\n\t\t\t\t\t_position.fromArray( positions, i * 3 );\n\n\t\t\t\t\ttestPoint( _position, i, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst vertices = geometry.vertices;\n\n\t\t\tfor ( let i = 0, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\ttestPoint( vertices[ i ], i, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\nfunction testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) {\n\n\tconst rayPointDistanceSq = _ray.distanceSqToPoint( point );\n\n\tif ( rayPointDistanceSq < localThresholdSq ) {\n\n\t\tconst intersectPoint = new Vector3();\n\n\t\t_ray.closestPointToPoint( point, intersectPoint );\n\t\tintersectPoint.applyMatrix4( matrixWorld );\n\n\t\tconst distance = raycaster.ray.origin.distanceTo( intersectPoint );\n\n\t\tif ( distance < raycaster.near || distance > raycaster.far ) return;\n\n\t\tintersects.push( {\n\n\t\t\tdistance: distance,\n\t\t\tdistanceToRay: Math.sqrt( rayPointDistanceSq ),\n\t\t\tpoint: intersectPoint,\n\t\t\tindex: index,\n\t\t\tface: null,\n\t\t\tobject: object\n\n\t\t} );\n\n\t}\n\n}\n\nexport { Points };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Texture } from './Texture.js';\n\nfunction CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {\n\n\tTexture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );\n\n\tthis.needsUpdate = true;\n\n}\n\nCanvasTexture.prototype = Object.create( Texture.prototype );\nCanvasTexture.prototype.constructor = CanvasTexture;\nCanvasTexture.prototype.isCanvasTexture = true;\n\nexport { CanvasTexture };\n","/**\n * @author clockworkgeek / https://github.com/clockworkgeek\n * @author timothypratley / https://github.com/timothypratley\n * @author WestLangley / http://github.com/WestLangley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\n\n// PolyhedronGeometry\n\nfunction PolyhedronGeometry( vertices, indices, radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'PolyhedronGeometry';\n\n\tthis.parameters = {\n\t\tvertices: vertices,\n\t\tindices: indices,\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new PolyhedronBufferGeometry( vertices, indices, radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nPolyhedronGeometry.prototype = Object.create( Geometry.prototype );\nPolyhedronGeometry.prototype.constructor = PolyhedronGeometry;\n\n// PolyhedronBufferGeometry\n\nfunction PolyhedronBufferGeometry( vertices, indices, radius, detail ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'PolyhedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tvertices: vertices,\n\t\tindices: indices,\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tradius = radius || 1;\n\tdetail = detail || 0;\n\n\t// default buffer data\n\n\tconst vertexBuffer = [];\n\tconst uvBuffer = [];\n\n\t// the subdivision creates the vertex buffer data\n\n\tsubdivide( detail );\n\n\t// all vertices should lie on a conceptual sphere with a given radius\n\n\tapplyRadius( radius );\n\n\t// finally, create the uv data\n\n\tgenerateUVs();\n\n\t// build non-indexed geometry\n\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );\n\n\tif ( detail === 0 ) {\n\n\t\tthis.computeVertexNormals(); // flat normals\n\n\t} else {\n\n\t\tthis.normalizeNormals(); // smooth normals\n\n\t}\n\n\t// helper functions\n\n\tfunction subdivide( detail ) {\n\n\t\tconst a = new Vector3();\n\t\tconst b = new Vector3();\n\t\tconst c = new Vector3();\n\n\t\t// iterate over all faces and apply a subdivison with the given detail value\n\n\t\tfor ( let i = 0; i < indices.length; i += 3 ) {\n\n\t\t\t// get the vertices of the face\n\n\t\t\tgetVertexByIndex( indices[ i + 0 ], a );\n\t\t\tgetVertexByIndex( indices[ i + 1 ], b );\n\t\t\tgetVertexByIndex( indices[ i + 2 ], c );\n\n\t\t\t// perform subdivision\n\n\t\t\tsubdivideFace( a, b, c, detail );\n\n\t\t}\n\n\t}\n\n\tfunction subdivideFace( a, b, c, detail ) {\n\n\t\tconst cols = Math.pow( 2, detail );\n\n\t\t// we use this multidimensional array as a data structure for creating the subdivision\n\n\t\tconst v = [];\n\n\t\t// construct all of the vertices for this subdivision\n\n\t\tfor ( let i = 0; i <= cols; i ++ ) {\n\n\t\t\tv[ i ] = [];\n\n\t\t\tconst aj = a.clone().lerp( c, i / cols );\n\t\t\tconst bj = b.clone().lerp( c, i / cols );\n\n\t\t\tconst rows = cols - i;\n\n\t\t\tfor ( let j = 0; j <= rows; j ++ ) {\n\n\t\t\t\tif ( j === 0 && i === cols ) {\n\n\t\t\t\t\tv[ i ][ j ] = aj;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tv[ i ][ j ] = aj.clone().lerp( bj, j / rows );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// construct all of the faces\n\n\t\tfor ( let i = 0; i < cols; i ++ ) {\n\n\t\t\tfor ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {\n\n\t\t\t\tconst k = Math.floor( j / 2 );\n\n\t\t\t\tif ( j % 2 === 0 ) {\n\n\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\t\t\t\t\tpushVertex( v[ i ][ k ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction applyRadius( radius ) {\n\n\t\tconst vertex = new Vector3();\n\n\t\t// iterate over the entire buffer and apply the radius to each vertex\n\n\t\tfor ( let i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\tvertex.normalize().multiplyScalar( radius );\n\n\t\t\tvertexBuffer[ i + 0 ] = vertex.x;\n\t\t\tvertexBuffer[ i + 1 ] = vertex.y;\n\t\t\tvertexBuffer[ i + 2 ] = vertex.z;\n\n\t\t}\n\n\t}\n\n\tfunction generateUVs() {\n\n\t\tconst vertex = new Vector3();\n\n\t\tfor ( let i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\tconst u = azimuth( vertex ) / 2 / Math.PI + 0.5;\n\t\t\tconst v = inclination( vertex ) / Math.PI + 0.5;\n\t\t\tuvBuffer.push( u, 1 - v );\n\n\t\t}\n\n\t\tcorrectUVs();\n\n\t\tcorrectSeam();\n\n\t}\n\n\tfunction correctSeam() {\n\n\t\t// handle case when face straddles the seam, see #3269\n\n\t\tfor ( let i = 0; i < uvBuffer.length; i += 6 ) {\n\n\t\t\t// uv data of a single face\n\n\t\t\tconst x0 = uvBuffer[ i + 0 ];\n\t\t\tconst x1 = uvBuffer[ i + 2 ];\n\t\t\tconst x2 = uvBuffer[ i + 4 ];\n\n\t\t\tconst max = Math.max( x0, x1, x2 );\n\t\t\tconst min = Math.min( x0, x1, x2 );\n\n\t\t\t// 0.9 is somewhat arbitrary\n\n\t\t\tif ( max > 0.9 && min < 0.1 ) {\n\n\t\t\t\tif ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1;\n\t\t\t\tif ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1;\n\t\t\t\tif ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction pushVertex( vertex ) {\n\n\t\tvertexBuffer.push( vertex.x, vertex.y, vertex.z );\n\n\t}\n\n\tfunction getVertexByIndex( index, vertex ) {\n\n\t\tconst stride = index * 3;\n\n\t\tvertex.x = vertices[ stride + 0 ];\n\t\tvertex.y = vertices[ stride + 1 ];\n\t\tvertex.z = vertices[ stride + 2 ];\n\n\t}\n\n\tfunction correctUVs() {\n\n\t\tconst a = new Vector3();\n\t\tconst b = new Vector3();\n\t\tconst c = new Vector3();\n\n\t\tconst centroid = new Vector3();\n\n\t\tconst uvA = new Vector2();\n\t\tconst uvB = new Vector2();\n\t\tconst uvC = new Vector2();\n\n\t\tfor ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {\n\n\t\t\ta.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] );\n\t\t\tb.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] );\n\t\t\tc.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] );\n\n\t\t\tuvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] );\n\t\t\tuvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] );\n\t\t\tuvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] );\n\n\t\t\tcentroid.copy( a ).add( b ).add( c ).divideScalar( 3 );\n\n\t\t\tconst azi = azimuth( centroid );\n\n\t\t\tcorrectUV( uvA, j + 0, a, azi );\n\t\t\tcorrectUV( uvB, j + 2, b, azi );\n\t\t\tcorrectUV( uvC, j + 4, c, azi );\n\n\t\t}\n\n\t}\n\n\tfunction correctUV( uv, stride, vector, azimuth ) {\n\n\t\tif ( ( azimuth < 0 ) && ( uv.x === 1 ) ) {\n\n\t\t\tuvBuffer[ stride ] = uv.x - 1;\n\n\t\t}\n\n\t\tif ( ( vector.x === 0 ) && ( vector.z === 0 ) ) {\n\n\t\t\tuvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5;\n\n\t\t}\n\n\t}\n\n\t// Angle around the Y axis, counter-clockwise when looking from above.\n\n\tfunction azimuth( vector ) {\n\n\t\treturn Math.atan2( vector.z, - vector.x );\n\n\t}\n\n\n\t// Angle above the XZ plane.\n\n\tfunction inclination( vector ) {\n\n\t\treturn Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) );\n\n\t}\n\n}\n\nPolyhedronBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nPolyhedronBufferGeometry.prototype.constructor = PolyhedronBufferGeometry;\n\n\nexport { PolyhedronGeometry, PolyhedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// TetrahedronGeometry\n\nfunction TetrahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'TetrahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new TetrahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nTetrahedronGeometry.prototype = Object.create( Geometry.prototype );\nTetrahedronGeometry.prototype.constructor = TetrahedronGeometry;\n\n// TetrahedronBufferGeometry\n\nfunction TetrahedronBufferGeometry( radius, detail ) {\n\n\tconst vertices = [\n\t\t1, 1, 1, \t- 1, - 1, 1, \t- 1, 1, - 1, \t1, - 1, - 1\n\t];\n\n\tconst indices = [\n\t\t2, 1, 0, \t0, 3, 2,\t1, 3, 0,\t2, 3, 1\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'TetrahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nTetrahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nTetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry;\n\n\nexport { TetrahedronGeometry, TetrahedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// OctahedronGeometry\n\nfunction OctahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'OctahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nOctahedronGeometry.prototype = Object.create( Geometry.prototype );\nOctahedronGeometry.prototype.constructor = OctahedronGeometry;\n\n// OctahedronBufferGeometry\n\nfunction OctahedronBufferGeometry( radius, detail ) {\n\n\tconst vertices = [\n\t\t1, 0, 0, \t- 1, 0, 0,\t0, 1, 0,\n\t\t0, - 1, 0, \t0, 0, 1,\t0, 0, - 1\n\t];\n\n\tconst indices = [\n\t\t0, 2, 4,\t0, 4, 3,\t0, 3, 5,\n\t\t0, 5, 2,\t1, 2, 5,\t1, 5, 3,\n\t\t1, 3, 4,\t1, 4, 2\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'OctahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nOctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nOctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;\n\n\nexport { OctahedronGeometry, OctahedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// IcosahedronGeometry\n\nfunction IcosahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'IcosahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nIcosahedronGeometry.prototype = Object.create( Geometry.prototype );\nIcosahedronGeometry.prototype.constructor = IcosahedronGeometry;\n\n// IcosahedronBufferGeometry\n\nfunction IcosahedronBufferGeometry( radius, detail ) {\n\n\tconst t = ( 1 + Math.sqrt( 5 ) ) / 2;\n\n\tconst vertices = [\n\t\t- 1, t, 0, \t1, t, 0, \t- 1, - t, 0, \t1, - t, 0,\n\t\t 0, - 1, t, \t0, 1, t,\t0, - 1, - t, \t0, 1, - t,\n\t\t t, 0, - 1, \tt, 0, 1, \t- t, 0, - 1, \t- t, 0, 1\n\t];\n\n\tconst indices = [\n\t\t 0, 11, 5, \t0, 5, 1, \t0, 1, 7, \t0, 7, 10, \t0, 10, 11,\n\t\t 1, 5, 9, \t5, 11, 4,\t11, 10, 2,\t10, 7, 6,\t7, 1, 8,\n\t\t 3, 9, 4, \t3, 4, 2,\t3, 2, 6,\t3, 6, 8,\t3, 8, 9,\n\t\t 4, 9, 5, \t2, 4, 11,\t6, 2, 10,\t8, 6, 7,\t9, 8, 1\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'IcosahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nIcosahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nIcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;\n\n\nexport { IcosahedronGeometry, IcosahedronBufferGeometry };\n","/**\n * @author oosmoxiecode\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n// TorusGeometry\n\nfunction TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'TorusGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\ttube: tube,\n\t\tradialSegments: radialSegments,\n\t\ttubularSegments: tubularSegments,\n\t\tarc: arc\n\t};\n\n\tthis.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );\n\tthis.mergeVertices();\n\n}\n\nTorusGeometry.prototype = Object.create( Geometry.prototype );\nTorusGeometry.prototype.constructor = TorusGeometry;\n\n// TorusBufferGeometry\n\nfunction TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'TorusBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\ttube: tube,\n\t\tradialSegments: radialSegments,\n\t\ttubularSegments: tubularSegments,\n\t\tarc: arc\n\t};\n\n\tradius = radius || 1;\n\ttube = tube || 0.4;\n\tradialSegments = Math.floor( radialSegments ) || 8;\n\ttubularSegments = Math.floor( tubularSegments ) || 6;\n\tarc = arc || Math.PI * 2;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// helper variables\n\n\tconst center = new Vector3();\n\tconst vertex = new Vector3();\n\tconst normal = new Vector3();\n\n\t// generate vertices, normals and uvs\n\n\tfor ( let j = 0; j <= radialSegments; j ++ ) {\n\n\t\tfor ( let i = 0; i <= tubularSegments; i ++ ) {\n\n\t\t\tconst u = i / tubularSegments * arc;\n\t\t\tconst v = j / radialSegments * Math.PI * 2;\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = ( radius + tube * Math.cos( v ) ) * Math.cos( u );\n\t\t\tvertex.y = ( radius + tube * Math.cos( v ) ) * Math.sin( u );\n\t\t\tvertex.z = tube * Math.sin( v );\n\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tcenter.x = radius * Math.cos( u );\n\t\t\tcenter.y = radius * Math.sin( u );\n\t\t\tnormal.subVectors( vertex, center ).normalize();\n\n\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t// uv\n\n\t\t\tuvs.push( i / tubularSegments );\n\t\t\tuvs.push( j / radialSegments );\n\n\t\t}\n\n\t}\n\n\t// generate indices\n\n\tfor ( let j = 1; j <= radialSegments; j ++ ) {\n\n\t\tfor ( let i = 1; i <= tubularSegments; i ++ ) {\n\n\t\t\t// indices\n\n\t\t\tconst a = ( tubularSegments + 1 ) * j + i - 1;\n\t\t\tconst b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;\n\t\t\tconst c = ( tubularSegments + 1 ) * ( j - 1 ) + i;\n\t\t\tconst d = ( tubularSegments + 1 ) * j + i;\n\n\t\t\t// faces\n\n\t\t\tindices.push( a, b, d );\n\t\t\tindices.push( b, c, d );\n\n\t\t}\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n}\n\nTorusBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nTorusBufferGeometry.prototype.constructor = TorusBufferGeometry;\n\n\nexport { TorusGeometry, TorusBufferGeometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\n\n// CylinderGeometry\n\nfunction CylinderGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'CylinderGeometry';\n\n\tthis.parameters = {\n\t\tradiusTop: radiusTop,\n\t\tradiusBottom: radiusBottom,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n\tthis.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );\n\tthis.mergeVertices();\n\n}\n\nCylinderGeometry.prototype = Object.create( Geometry.prototype );\nCylinderGeometry.prototype.constructor = CylinderGeometry;\n\n// CylinderBufferGeometry\n\nfunction CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'CylinderBufferGeometry';\n\n\tthis.parameters = {\n\t\tradiusTop: radiusTop,\n\t\tradiusBottom: radiusBottom,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n\tconst scope = this;\n\n\tradiusTop = radiusTop !== undefined ? radiusTop : 1;\n\tradiusBottom = radiusBottom !== undefined ? radiusBottom : 1;\n\theight = height || 1;\n\n\tradialSegments = Math.floor( radialSegments ) || 8;\n\theightSegments = Math.floor( heightSegments ) || 1;\n\n\topenEnded = openEnded !== undefined ? openEnded : false;\n\tthetaStart = thetaStart !== undefined ? thetaStart : 0.0;\n\tthetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// helper variables\n\n\tlet index = 0;\n\tconst indexArray = [];\n\tconst halfHeight = height / 2;\n\tlet groupStart = 0;\n\n\t// generate geometry\n\n\tgenerateTorso();\n\n\tif ( openEnded === false ) {\n\n\t\tif ( radiusTop > 0 ) generateCap( true );\n\t\tif ( radiusBottom > 0 ) generateCap( false );\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\tfunction generateTorso() {\n\n\t\tconst normal = new Vector3();\n\t\tconst vertex = new Vector3();\n\n\t\tlet groupCount = 0;\n\n\t\t// this will be used to calculate the normal\n\t\tconst slope = ( radiusBottom - radiusTop ) / height;\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( let y = 0; y <= heightSegments; y ++ ) {\n\n\t\t\tconst indexRow = [];\n\n\t\t\tconst v = y / heightSegments;\n\n\t\t\t// calculate the radius of the current row\n\n\t\t\tconst radius = v * ( radiusBottom - radiusTop ) + radiusTop;\n\n\t\t\tfor ( let x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\t\tconst u = x / radialSegments;\n\n\t\t\t\tconst theta = u * thetaLength + thetaStart;\n\n\t\t\t\tconst sinTheta = Math.sin( theta );\n\t\t\t\tconst cosTheta = Math.cos( theta );\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\tvertex.y = - v * height + halfHeight;\n\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormal.set( sinTheta, slope, cosTheta ).normalize();\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( u, 1 - v );\n\n\t\t\t\t// save index of vertex in respective row\n\n\t\t\t\tindexRow.push( index ++ );\n\n\t\t\t}\n\n\t\t\t// now save vertices of the row in our index array\n\n\t\t\tindexArray.push( indexRow );\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( let x = 0; x < radialSegments; x ++ ) {\n\n\t\t\tfor ( let y = 0; y < heightSegments; y ++ ) {\n\n\t\t\t\t// we use the index array to access the correct indices\n\n\t\t\t\tconst a = indexArray[ y ][ x ];\n\t\t\t\tconst b = indexArray[ y + 1 ][ x ];\n\t\t\t\tconst c = indexArray[ y + 1 ][ x + 1 ];\n\t\t\t\tconst d = indexArray[ y ][ x + 1 ];\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t// update group counter\n\n\t\t\t\tgroupCount += 6;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\tscope.addGroup( groupStart, groupCount, 0 );\n\n\t\t// calculate new start value for groups\n\n\t\tgroupStart += groupCount;\n\n\t}\n\n\tfunction generateCap( top ) {\n\n\t\tlet centerIndexStart, centerIndexEnd;\n\n\t\tconst uv = new Vector2();\n\t\tconst vertex = new Vector3();\n\n\t\tlet groupCount = 0;\n\n\t\tconst radius = ( top === true ) ? radiusTop : radiusBottom;\n\t\tconst sign = ( top === true ) ? 1 : - 1;\n\n\t\t// save the index of the first center vertex\n\t\tcenterIndexStart = index;\n\n\t\t// first we generate the center vertex data of the cap.\n\t\t// because the geometry needs one set of uvs per face,\n\t\t// we must generate a center vertex per face/segment\n\n\t\tfor ( let x = 1; x <= radialSegments; x ++ ) {\n\n\t\t\t// vertex\n\n\t\t\tvertices.push( 0, halfHeight * sign, 0 );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t// uv\n\n\t\t\tuvs.push( 0.5, 0.5 );\n\n\t\t\t// increase index\n\n\t\t\tindex ++;\n\n\t\t}\n\n\t\t// save the index of the last center vertex\n\n\t\tcenterIndexEnd = index;\n\n\t\t// now we generate the surrounding vertices, normals and uvs\n\n\t\tfor ( let x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\tconst u = x / radialSegments;\n\t\t\tconst theta = u * thetaLength + thetaStart;\n\n\t\t\tconst cosTheta = Math.cos( theta );\n\t\t\tconst sinTheta = Math.sin( theta );\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = radius * sinTheta;\n\t\t\tvertex.y = halfHeight * sign;\n\t\t\tvertex.z = radius * cosTheta;\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t// uv\n\n\t\t\tuv.x = ( cosTheta * 0.5 ) + 0.5;\n\t\t\tuv.y = ( sinTheta * 0.5 * sign ) + 0.5;\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\t// increase index\n\n\t\t\tindex ++;\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( let x = 0; x < radialSegments; x ++ ) {\n\n\t\t\tconst c = centerIndexStart + x;\n\t\t\tconst i = centerIndexEnd + x;\n\n\t\t\tif ( top === true ) {\n\n\t\t\t\t// face top\n\n\t\t\t\tindices.push( i, i + 1, c );\n\n\t\t\t} else {\n\n\t\t\t\t// face bottom\n\n\t\t\t\tindices.push( i + 1, i, c );\n\n\t\t\t}\n\n\t\t\tgroupCount += 3;\n\n\t\t}\n\n\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\tscope.addGroup( groupStart, groupCount, top === true ? 1 : 2 );\n\n\t\t// calculate new start value for groups\n\n\t\tgroupStart += groupCount;\n\n\t}\n\n}\n\nCylinderBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nCylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;\n\n\nexport { CylinderGeometry, CylinderBufferGeometry };\n","/**\n * @author abelnation / http://github.com/abelnation\n */\n\nimport { CylinderGeometry } from './CylinderGeometry.js';\nimport { CylinderBufferGeometry } from './CylinderGeometry.js';\n\n// ConeGeometry\n\nfunction ConeGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tCylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\tthis.type = 'ConeGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n}\n\nConeGeometry.prototype = Object.create( CylinderGeometry.prototype );\nConeGeometry.prototype.constructor = ConeGeometry;\n\n// ConeBufferGeometry\n\nfunction ConeBufferGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tCylinderBufferGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\tthis.type = 'ConeBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n}\n\nConeBufferGeometry.prototype = Object.create( CylinderBufferGeometry.prototype );\nConeBufferGeometry.prototype.constructor = ConeBufferGeometry;\n\n\nexport { ConeGeometry, ConeBufferGeometry };\n","import { Object3D } from '../core/Object3D.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction Light( color, intensity ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Light';\n\n\tthis.color = new Color( color );\n\tthis.intensity = intensity !== undefined ? intensity : 1;\n\n\tthis.receiveShadow = undefined;\n\n}\n\nLight.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Light,\n\n\tisLight: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\t\tthis.intensity = source.intensity;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.color = this.color.getHex();\n\t\tdata.object.intensity = this.intensity;\n\n\t\tif ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();\n\n\t\tif ( this.distance !== undefined ) data.object.distance = this.distance;\n\t\tif ( this.angle !== undefined ) data.object.angle = this.angle;\n\t\tif ( this.decay !== undefined ) data.object.decay = this.decay;\n\t\tif ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;\n\n\t\tif ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { Light };\n","import { Matrix4 } from '../math/Matrix4.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector4 } from '../math/Vector4.js';\nimport { Frustum } from '../math/Frustum.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction LightShadow( camera ) {\n\n\tthis.camera = camera;\n\n\tthis.bias = 0;\n\tthis.normalBias = 0;\n\tthis.radius = 1;\n\n\tthis.mapSize = new Vector2( 512, 512 );\n\n\tthis.map = null;\n\tthis.mapPass = null;\n\tthis.matrix = new Matrix4();\n\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\n\tthis._frustum = new Frustum();\n\tthis._frameExtents = new Vector2( 1, 1 );\n\n\tthis._viewportCount = 1;\n\n\tthis._viewports = [\n\n\t\tnew Vector4( 0, 0, 1, 1 )\n\n\t];\n\n}\n\nObject.assign( LightShadow.prototype, {\n\n\t_projScreenMatrix: new Matrix4(),\n\n\t_lightPositionWorld: new Vector3(),\n\n\t_lookTarget: new Vector3(),\n\n\tgetViewportCount: function () {\n\n\t\treturn this._viewportCount;\n\n\t},\n\n\tgetFrustum: function () {\n\n\t\treturn this._frustum;\n\n\t},\n\n\tupdateMatrices: function ( light ) {\n\n\t\tconst shadowCamera = this.camera,\n\t\t\tshadowMatrix = this.matrix,\n\t\t\tprojScreenMatrix = this._projScreenMatrix,\n\t\t\tlookTarget = this._lookTarget,\n\t\t\tlightPositionWorld = this._lightPositionWorld;\n\n\t\tlightPositionWorld.setFromMatrixPosition( light.matrixWorld );\n\t\tshadowCamera.position.copy( lightPositionWorld );\n\n\t\tlookTarget.setFromMatrixPosition( light.target.matrixWorld );\n\t\tshadowCamera.lookAt( lookTarget );\n\t\tshadowCamera.updateMatrixWorld();\n\n\t\tprojScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );\n\t\tthis._frustum.setFromProjectionMatrix( projScreenMatrix );\n\n\t\tshadowMatrix.set(\n\t\t\t0.5, 0.0, 0.0, 0.5,\n\t\t\t0.0, 0.5, 0.0, 0.5,\n\t\t\t0.0, 0.0, 0.5, 0.5,\n\t\t\t0.0, 0.0, 0.0, 1.0\n\t\t);\n\n\t\tshadowMatrix.multiply( shadowCamera.projectionMatrix );\n\t\tshadowMatrix.multiply( shadowCamera.matrixWorldInverse );\n\n\t},\n\n\tgetViewport: function ( viewportIndex ) {\n\n\t\treturn this._viewports[ viewportIndex ];\n\n\t},\n\n\tgetFrameExtents: function () {\n\n\t\treturn this._frameExtents;\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.camera = source.camera.clone();\n\n\t\tthis.bias = source.bias;\n\t\tthis.radius = source.radius;\n\n\t\tthis.mapSize.copy( source.mapSize );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst object = {};\n\n\t\tif ( this.bias !== 0 ) object.bias = this.bias;\n\t\tif ( this.normalBias !== 0 ) object.normalBias = this.normalBias;\n\t\tif ( this.radius !== 1 ) object.radius = this.radius;\n\t\tif ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray();\n\n\t\tobject.camera = this.camera.toJSON( false ).object;\n\t\tdelete object.camera.matrix;\n\n\t\treturn object;\n\n\t}\n\n} );\n\n\nexport { LightShadow };\n","import { LightShadow } from './LightShadow.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction SpotLightShadow() {\n\n\tLightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) );\n\n}\n\nSpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {\n\n\tconstructor: SpotLightShadow,\n\n\tisSpotLightShadow: true,\n\n\tupdateMatrices: function ( light ) {\n\n\t\tconst camera = this.camera;\n\n\t\tconst fov = MathUtils.RAD2DEG * 2 * light.angle;\n\t\tconst aspect = this.mapSize.width / this.mapSize.height;\n\t\tconst far = light.distance || camera.far;\n\n\t\tif ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {\n\n\t\t\tcamera.fov = fov;\n\t\t\tcamera.aspect = aspect;\n\t\t\tcamera.far = far;\n\t\t\tcamera.updateProjectionMatrix();\n\n\t\t}\n\n\t\tLightShadow.prototype.updateMatrices.call( this, light );\n\n\t}\n\n} );\n\n\nexport { SpotLightShadow };\n","import { Light } from './Light.js';\nimport { SpotLightShadow } from './SpotLightShadow.js';\nimport { Object3D } from '../core/Object3D.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction SpotLight( color, intensity, distance, angle, penumbra, decay ) {\n\n\tLight.call( this, color, intensity );\n\n\tthis.type = 'SpotLight';\n\n\tthis.position.copy( Object3D.DefaultUp );\n\tthis.updateMatrix();\n\n\tthis.target = new Object3D();\n\n\tObject.defineProperty( this, 'power', {\n\t\tget: function () {\n\n\t\t\t// intensity = power per solid angle.\n\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\treturn this.intensity * Math.PI;\n\n\t\t},\n\t\tset: function ( power ) {\n\n\t\t\t// intensity = power per solid angle.\n\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\tthis.intensity = power / Math.PI;\n\n\t\t}\n\t} );\n\n\tthis.distance = ( distance !== undefined ) ? distance : 0;\n\tthis.angle = ( angle !== undefined ) ? angle : Math.PI / 3;\n\tthis.penumbra = ( penumbra !== undefined ) ? penumbra : 0;\n\tthis.decay = ( decay !== undefined ) ? decay : 1;\t// for physically correct lights, should be 2.\n\n\tthis.shadow = new SpotLightShadow();\n\n}\n\nSpotLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\tconstructor: SpotLight,\n\n\tisSpotLight: true,\n\n\tcopy: function ( source ) {\n\n\t\tLight.prototype.copy.call( this, source );\n\n\t\tthis.distance = source.distance;\n\t\tthis.angle = source.angle;\n\t\tthis.penumbra = source.penumbra;\n\t\tthis.decay = source.decay;\n\n\t\tthis.target = source.target.clone();\n\n\t\tthis.shadow = source.shadow.clone();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { SpotLight };\n","import { Camera } from './Camera.js';\nimport { Object3D } from '../core/Object3D.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author arose / http://github.com/arose\n */\n\nfunction OrthographicCamera( left, right, top, bottom, near, far ) {\n\n\tCamera.call( this );\n\n\tthis.type = 'OrthographicCamera';\n\n\tthis.zoom = 1;\n\tthis.view = null;\n\n\tthis.left = ( left !== undefined ) ? left : - 1;\n\tthis.right = ( right !== undefined ) ? right : 1;\n\tthis.top = ( top !== undefined ) ? top : 1;\n\tthis.bottom = ( bottom !== undefined ) ? bottom : - 1;\n\n\tthis.near = ( near !== undefined ) ? near : 0.1;\n\tthis.far = ( far !== undefined ) ? far : 2000;\n\n\tthis.updateProjectionMatrix();\n\n}\n\nOrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\tconstructor: OrthographicCamera,\n\n\tisOrthographicCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\tthis.left = source.left;\n\t\tthis.right = source.right;\n\t\tthis.top = source.top;\n\t\tthis.bottom = source.bottom;\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\n\t\tthis.zoom = source.zoom;\n\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\treturn this;\n\n\t},\n\n\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\tif ( this.view === null ) {\n\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tclearViewOffset: function () {\n\n\t\tif ( this.view !== null ) {\n\n\t\t\tthis.view.enabled = false;\n\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tupdateProjectionMatrix: function () {\n\n\t\tconst dx = ( this.right - this.left ) / ( 2 * this.zoom );\n\t\tconst dy = ( this.top - this.bottom ) / ( 2 * this.zoom );\n\t\tconst cx = ( this.right + this.left ) / 2;\n\t\tconst cy = ( this.top + this.bottom ) / 2;\n\n\t\tlet left = cx - dx;\n\t\tlet right = cx + dx;\n\t\tlet top = cy + dy;\n\t\tlet bottom = cy - dy;\n\n\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\tconst scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom;\n\t\t\tconst scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom;\n\n\t\t\tleft += scaleW * this.view.offsetX;\n\t\t\tright = left + scaleW * this.view.width;\n\t\t\ttop -= scaleH * this.view.offsetY;\n\t\t\tbottom = top - scaleH * this.view.height;\n\n\t\t}\n\n\t\tthis.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far );\n\n\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.zoom = this.zoom;\n\t\tdata.object.left = this.left;\n\t\tdata.object.right = this.right;\n\t\tdata.object.top = this.top;\n\t\tdata.object.bottom = this.bottom;\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\n\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { OrthographicCamera };\n","import { Light } from './Light.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction AmbientLight( color, intensity ) {\n\n\tLight.call( this, color, intensity );\n\n\tthis.type = 'AmbientLight';\n\n\tthis.castShadow = undefined;\n\n}\n\nAmbientLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\tconstructor: AmbientLight,\n\n\tisAmbientLight: true\n\n} );\n\n\nexport { AmbientLight };\n","import { Matrix4 } from '../math/Matrix4.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { PerspectiveCamera } from './PerspectiveCamera.js';\n\nconst _eyeRight = new Matrix4();\nconst _eyeLeft = new Matrix4();\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction StereoCamera() {\n\n\tthis.type = 'StereoCamera';\n\n\tthis.aspect = 1;\n\n\tthis.eyeSep = 0.064;\n\n\tthis.cameraL = new PerspectiveCamera();\n\tthis.cameraL.layers.enable( 1 );\n\tthis.cameraL.matrixAutoUpdate = false;\n\n\tthis.cameraR = new PerspectiveCamera();\n\tthis.cameraR.layers.enable( 2 );\n\tthis.cameraR.matrixAutoUpdate = false;\n\n\tthis._cache = {\n\t\tfocus: null,\n\t\tfov: null,\n\t\taspect: null,\n\t\tnear: null,\n\t\tfar: null,\n\t\tzoom: null,\n\t\teyeSep: null\n\t};\n\n}\n\nObject.assign( StereoCamera.prototype, {\n\n\tupdate: function ( camera ) {\n\n\t\tconst cache = this._cache;\n\n\t\tconst needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov ||\n\t\t\tcache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near ||\n\t\t\tcache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep;\n\n\t\tif ( needsUpdate ) {\n\n\t\t\tcache.focus = camera.focus;\n\t\t\tcache.fov = camera.fov;\n\t\t\tcache.aspect = camera.aspect * this.aspect;\n\t\t\tcache.near = camera.near;\n\t\t\tcache.far = camera.far;\n\t\t\tcache.zoom = camera.zoom;\n\t\t\tcache.eyeSep = this.eyeSep;\n\n\t\t\t// Off-axis stereoscopic effect based on\n\t\t\t// http://paulbourke.net/stereographics/stereorender/\n\n\t\t\tconst projectionMatrix = camera.projectionMatrix.clone();\n\t\t\tconst eyeSepHalf = cache.eyeSep / 2;\n\t\t\tconst eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;\n\t\t\tconst ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;\n\t\t\tlet xmin, xmax;\n\n\t\t\t// translate xOffset\n\n\t\t\t_eyeLeft.elements[ 12 ] = - eyeSepHalf;\n\t\t\t_eyeRight.elements[ 12 ] = eyeSepHalf;\n\n\t\t\t// for left eye\n\n\t\t\txmin = - ymax * cache.aspect + eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect + eyeSepOnProjection;\n\n\t\t\tprojectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );\n\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\tthis.cameraL.projectionMatrix.copy( projectionMatrix );\n\n\t\t\t// for right eye\n\n\t\t\txmin = - ymax * cache.aspect - eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect - eyeSepOnProjection;\n\n\t\t\tprojectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );\n\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\tthis.cameraR.projectionMatrix.copy( projectionMatrix );\n\n\t\t}\n\n\t\tthis.cameraL.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeLeft );\n\t\tthis.cameraR.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeRight );\n\n\t}\n\n} );\n\n\nexport { StereoCamera };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Uniform( value ) {\n\n\tif ( typeof value === 'string' ) {\n\n\t\tconsole.warn( 'THREE.Uniform: Type parameter is no longer needed.' );\n\t\tvalue = arguments[ 1 ];\n\n\t}\n\n\tthis.value = value;\n\n}\n\nUniform.prototype.clone = function () {\n\n\treturn new Uniform( this.value.clone === undefined ? this.value : this.value.clone() );\n\n};\n\nexport { Uniform };\n","/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","\n/**\n * @license\n *\n * chroma.js - JavaScript library for color conversions\n * \n * Copyright (c) 2011-2017, Gregor Aisch\n * All rights reserved.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n * \n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * \n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n * \n * 3. The name Gregor Aisch may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n(function() {\n var Color, DEG2RAD, LAB_CONSTANTS, PI, PITHIRD, RAD2DEG, TWOPI, _average_lrgb, _guess_formats, _guess_formats_sorted, _input, _interpolators, abs, atan2, bezier, blend, blend_f, brewer, burn, chroma, clip_rgb, cmyk2rgb, colors, cos, css2rgb, darken, dodge, each, floor, hcg2rgb, hex2rgb, hsi2rgb, hsl2css, hsl2rgb, hsv2rgb, interpolate, interpolate_hsx, interpolate_lab, interpolate_lrgb, interpolate_num, interpolate_rgb, lab2lch, lab2rgb, lab_xyz, lch2lab, lch2rgb, lighten, limit, log, luminance_x, m, max, multiply, normal, num2rgb, overlay, pow, rgb2cmyk, rgb2css, rgb2hcg, rgb2hex, rgb2hsi, rgb2hsl, rgb2hsv, rgb2lab, rgb2lch, rgb2luminance, rgb2num, rgb2temperature, rgb2xyz, rgb_xyz, rnd, root, round, screen, sin, sqrt, temperature2rgb, type, unpack, w3cx11, xyz_lab, xyz_rgb,\n slice = [].slice;\n\n type = (function() {\n\n /*\n for browser-safe type checking+\n ported from jQuery's $.type\n */\n var classToType, len, name, o, ref;\n classToType = {};\n ref = \"Boolean Number String Function Array Date RegExp Undefined Null\".split(\" \");\n for (o = 0, len = ref.length; o < len; o++) {\n name = ref[o];\n classToType[\"[object \" + name + \"]\"] = name.toLowerCase();\n }\n return function(obj) {\n var strType;\n strType = Object.prototype.toString.call(obj);\n return classToType[strType] || \"object\";\n };\n })();\n\n limit = function(x, min, max) {\n if (min == null) {\n min = 0;\n }\n if (max == null) {\n max = 1;\n }\n if (x < min) {\n x = min;\n }\n if (x > max) {\n x = max;\n }\n return x;\n };\n\n unpack = function(args) {\n if (args.length >= 3) {\n return Array.prototype.slice.call(args);\n } else {\n return args[0];\n }\n };\n\n clip_rgb = function(rgb) {\n var i, o;\n rgb._clipped = false;\n rgb._unclipped = rgb.slice(0);\n for (i = o = 0; o < 3; i = ++o) {\n if (i < 3) {\n if (rgb[i] < 0 || rgb[i] > 255) {\n rgb._clipped = true;\n }\n if (rgb[i] < 0) {\n rgb[i] = 0;\n }\n if (rgb[i] > 255) {\n rgb[i] = 255;\n }\n } else if (i === 3) {\n if (rgb[i] < 0) {\n rgb[i] = 0;\n }\n if (rgb[i] > 1) {\n rgb[i] = 1;\n }\n }\n }\n if (!rgb._clipped) {\n delete rgb._unclipped;\n }\n return rgb;\n };\n\n PI = Math.PI, round = Math.round, cos = Math.cos, floor = Math.floor, pow = Math.pow, log = Math.log, sin = Math.sin, sqrt = Math.sqrt, atan2 = Math.atan2, max = Math.max, abs = Math.abs;\n\n TWOPI = PI * 2;\n\n PITHIRD = PI / 3;\n\n DEG2RAD = PI / 180;\n\n RAD2DEG = 180 / PI;\n\n chroma = function() {\n if (arguments[0] instanceof Color) {\n return arguments[0];\n }\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, arguments, function(){});\n };\n\n chroma[\"default\"] = chroma;\n\n _interpolators = [];\n\n if ((typeof module !== \"undefined\" && module !== null) && (module.exports != null)) {\n module.exports = chroma;\n }\n\n if (typeof define === 'function' && define.amd) {\n define([], function() {\n return chroma;\n });\n } else {\n root = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n root.chroma = chroma;\n }\n\n chroma.version = '1.4.1';\n\n _input = {};\n\n _guess_formats = [];\n\n _guess_formats_sorted = false;\n\n Color = (function() {\n function Color() {\n var arg, args, chk, len, len1, me, mode, o, w;\n me = this;\n args = [];\n for (o = 0, len = arguments.length; o < len; o++) {\n arg = arguments[o];\n if (arg != null) {\n args.push(arg);\n }\n }\n if (args.length > 1) {\n mode = args[args.length - 1];\n }\n if (_input[mode] != null) {\n me._rgb = clip_rgb(_input[mode](unpack(args.slice(0, -1))));\n } else {\n if (!_guess_formats_sorted) {\n _guess_formats = _guess_formats.sort(function(a, b) {\n return b.p - a.p;\n });\n _guess_formats_sorted = true;\n }\n for (w = 0, len1 = _guess_formats.length; w < len1; w++) {\n chk = _guess_formats[w];\n mode = chk.test.apply(chk, args);\n if (mode) {\n break;\n }\n }\n if (mode) {\n me._rgb = clip_rgb(_input[mode].apply(_input, args));\n }\n }\n if (me._rgb == null) {\n console.warn('unknown format: ' + args);\n }\n if (me._rgb == null) {\n me._rgb = [0, 0, 0];\n }\n if (me._rgb.length === 3) {\n me._rgb.push(1);\n }\n }\n\n Color.prototype.toString = function() {\n return this.hex();\n };\n\n return Color;\n\n })();\n\n chroma._input = _input;\n\n\n /**\n \tColorBrewer colors for chroma.js\n \n \tCopyright (c) 2002 Cynthia Brewer, Mark Harrower, and The \n \tPennsylvania State University.\n \n \tLicensed under the Apache License, Version 2.0 (the \"License\"); \n \tyou may not use this file except in compliance with the License.\n \tYou may obtain a copy of the License at\t\n \thttp://www.apache.org/licenses/LICENSE-2.0\n \n \tUnless required by applicable law or agreed to in writing, software distributed\n \tunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n \tCONDITIONS OF ANY KIND, either express or implied. See the License for the\n \tspecific language governing permissions and limitations under the License.\n \n @preserve\n */\n\n chroma.brewer = brewer = {\n OrRd: ['#fff7ec', '#fee8c8', '#fdd49e', '#fdbb84', '#fc8d59', '#ef6548', '#d7301f', '#b30000', '#7f0000'],\n PuBu: ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858'],\n BuPu: ['#f7fcfd', '#e0ecf4', '#bfd3e6', '#9ebcda', '#8c96c6', '#8c6bb1', '#88419d', '#810f7c', '#4d004b'],\n Oranges: ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'],\n BuGn: ['#f7fcfd', '#e5f5f9', '#ccece6', '#99d8c9', '#66c2a4', '#41ae76', '#238b45', '#006d2c', '#00441b'],\n YlOrBr: ['#ffffe5', '#fff7bc', '#fee391', '#fec44f', '#fe9929', '#ec7014', '#cc4c02', '#993404', '#662506'],\n YlGn: ['#ffffe5', '#f7fcb9', '#d9f0a3', '#addd8e', '#78c679', '#41ab5d', '#238443', '#006837', '#004529'],\n Reds: ['#fff5f0', '#fee0d2', '#fcbba1', '#fc9272', '#fb6a4a', '#ef3b2c', '#cb181d', '#a50f15', '#67000d'],\n RdPu: ['#fff7f3', '#fde0dd', '#fcc5c0', '#fa9fb5', '#f768a1', '#dd3497', '#ae017e', '#7a0177', '#49006a'],\n Greens: ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b'],\n YlGnBu: ['#ffffd9', '#edf8b1', '#c7e9b4', '#7fcdbb', '#41b6c4', '#1d91c0', '#225ea8', '#253494', '#081d58'],\n Purples: ['#fcfbfd', '#efedf5', '#dadaeb', '#bcbddc', '#9e9ac8', '#807dba', '#6a51a3', '#54278f', '#3f007d'],\n GnBu: ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081'],\n Greys: ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525', '#000000'],\n YlOrRd: ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026'],\n PuRd: ['#f7f4f9', '#e7e1ef', '#d4b9da', '#c994c7', '#df65b0', '#e7298a', '#ce1256', '#980043', '#67001f'],\n Blues: ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'],\n PuBuGn: ['#fff7fb', '#ece2f0', '#d0d1e6', '#a6bddb', '#67a9cf', '#3690c0', '#02818a', '#016c59', '#014636'],\n Viridis: ['#440154', '#482777', '#3f4a8a', '#31678e', '#26838f', '#1f9d8a', '#6cce5a', '#b6de2b', '#fee825'],\n Spectral: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'],\n RdYlGn: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850', '#006837'],\n RdBu: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#f7f7f7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061'],\n PiYG: ['#8e0152', '#c51b7d', '#de77ae', '#f1b6da', '#fde0ef', '#f7f7f7', '#e6f5d0', '#b8e186', '#7fbc41', '#4d9221', '#276419'],\n PRGn: ['#40004b', '#762a83', '#9970ab', '#c2a5cf', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#a6dba0', '#5aae61', '#1b7837', '#00441b'],\n RdYlBu: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee090', '#ffffbf', '#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695'],\n BrBG: ['#543005', '#8c510a', '#bf812d', '#dfc27d', '#f6e8c3', '#f5f5f5', '#c7eae5', '#80cdc1', '#35978f', '#01665e', '#003c30'],\n RdGy: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#ffffff', '#e0e0e0', '#bababa', '#878787', '#4d4d4d', '#1a1a1a'],\n PuOr: ['#7f3b08', '#b35806', '#e08214', '#fdb863', '#fee0b6', '#f7f7f7', '#d8daeb', '#b2abd2', '#8073ac', '#542788', '#2d004b'],\n Set2: ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3'],\n Accent: ['#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f', '#bf5b17', '#666666'],\n Set1: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'],\n Set3: ['#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f'],\n Dark2: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666'],\n Paired: ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928'],\n Pastel2: ['#b3e2cd', '#fdcdac', '#cbd5e8', '#f4cae4', '#e6f5c9', '#fff2ae', '#f1e2cc', '#cccccc'],\n Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2']\n };\n\n (function() {\n var key, results;\n results = [];\n for (key in brewer) {\n results.push(brewer[key.toLowerCase()] = brewer[key]);\n }\n return results;\n })();\n\n\n /**\n \tX11 color names\n \n \thttp://www.w3.org/TR/css3-color/#svg-color\n */\n\n w3cx11 = {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflower: '#6495ed',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkgrey: '#a9a9a9',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkslategrey: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n grey: '#808080',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n indianred: '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n laserlemon: '#ffff54',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrod: '#fafad2',\n lightgoldenrodyellow: '#fafad2',\n lightgray: '#d3d3d3',\n lightgreen: '#90ee90',\n lightgrey: '#d3d3d3',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightslategrey: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n maroon2: '#7f0000',\n maroon3: '#b03060',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370db',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#db7093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n purple2: '#7f007f',\n purple3: '#a020f0',\n rebeccapurple: '#663399',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32'\n };\n\n chroma.colors = colors = w3cx11;\n\n lab2rgb = function() {\n var a, args, b, g, l, r, x, y, z;\n args = unpack(arguments);\n l = args[0], a = args[1], b = args[2];\n y = (l + 16) / 116;\n x = isNaN(a) ? y : y + a / 500;\n z = isNaN(b) ? y : y - b / 200;\n y = LAB_CONSTANTS.Yn * lab_xyz(y);\n x = LAB_CONSTANTS.Xn * lab_xyz(x);\n z = LAB_CONSTANTS.Zn * lab_xyz(z);\n r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z);\n g = xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);\n b = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n xyz_rgb = function(r) {\n return 255 * (r <= 0.00304 ? 12.92 * r : 1.055 * pow(r, 1 / 2.4) - 0.055);\n };\n\n lab_xyz = function(t) {\n if (t > LAB_CONSTANTS.t1) {\n return t * t * t;\n } else {\n return LAB_CONSTANTS.t2 * (t - LAB_CONSTANTS.t0);\n }\n };\n\n LAB_CONSTANTS = {\n Kn: 18,\n Xn: 0.950470,\n Yn: 1,\n Zn: 1.088830,\n t0: 0.137931034,\n t1: 0.206896552,\n t2: 0.12841855,\n t3: 0.008856452\n };\n\n rgb2lab = function() {\n var b, g, r, ref, ref1, x, y, z;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n ref1 = rgb2xyz(r, g, b), x = ref1[0], y = ref1[1], z = ref1[2];\n return [116 * y - 16, 500 * (x - y), 200 * (y - z)];\n };\n\n rgb_xyz = function(r) {\n if ((r /= 255) <= 0.04045) {\n return r / 12.92;\n } else {\n return pow((r + 0.055) / 1.055, 2.4);\n }\n };\n\n xyz_lab = function(t) {\n if (t > LAB_CONSTANTS.t3) {\n return pow(t, 1 / 3);\n } else {\n return t / LAB_CONSTANTS.t2 + LAB_CONSTANTS.t0;\n }\n };\n\n rgb2xyz = function() {\n var b, g, r, ref, x, y, z;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = rgb_xyz(r);\n g = rgb_xyz(g);\n b = rgb_xyz(b);\n x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / LAB_CONSTANTS.Xn);\n y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / LAB_CONSTANTS.Yn);\n z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / LAB_CONSTANTS.Zn);\n return [x, y, z];\n };\n\n chroma.lab = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['lab']), function(){});\n };\n\n _input.lab = lab2rgb;\n\n Color.prototype.lab = function() {\n return rgb2lab(this._rgb);\n };\n\n bezier = function(colors) {\n var I, I0, I1, c, lab0, lab1, lab2, lab3, ref, ref1, ref2;\n colors = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(chroma(c));\n }\n return results;\n })();\n if (colors.length === 2) {\n ref = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref[0], lab1 = ref[1];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push(lab0[i] + t * (lab1[i] - lab0[i]));\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 3) {\n ref1 = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref1[0], lab1 = ref1[1], lab2 = ref1[2];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push((1 - t) * (1 - t) * lab0[i] + 2 * (1 - t) * t * lab1[i] + t * t * lab2[i]);\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 4) {\n ref2 = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref2[0], lab1 = ref2[1], lab2 = ref2[2], lab3 = ref2[3];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push((1 - t) * (1 - t) * (1 - t) * lab0[i] + 3 * (1 - t) * (1 - t) * t * lab1[i] + 3 * (1 - t) * t * t * lab2[i] + t * t * t * lab3[i]);\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 5) {\n I0 = bezier(colors.slice(0, 3));\n I1 = bezier(colors.slice(2, 5));\n I = function(t) {\n if (t < 0.5) {\n return I0(t * 2);\n } else {\n return I1((t - 0.5) * 2);\n }\n };\n }\n return I;\n };\n\n chroma.bezier = function(colors) {\n var f;\n f = bezier(colors);\n f.scale = function() {\n return chroma.scale(f);\n };\n return f;\n };\n\n chroma.cubehelix = function(start, rotations, hue, gamma, lightness) {\n var dh, dl, f;\n if (start == null) {\n start = 300;\n }\n if (rotations == null) {\n rotations = -1.5;\n }\n if (hue == null) {\n hue = 1;\n }\n if (gamma == null) {\n gamma = 1;\n }\n if (lightness == null) {\n lightness = [0, 1];\n }\n dh = 0;\n if (type(lightness) === 'array') {\n dl = lightness[1] - lightness[0];\n } else {\n dl = 0;\n lightness = [lightness, lightness];\n }\n f = function(fract) {\n var a, amp, b, cos_a, g, h, l, r, sin_a;\n a = TWOPI * ((start + 120) / 360 + rotations * fract);\n l = pow(lightness[0] + dl * fract, gamma);\n h = dh !== 0 ? hue[0] + fract * dh : hue;\n amp = h * l * (1 - l) / 2;\n cos_a = cos(a);\n sin_a = sin(a);\n r = l + amp * (-0.14861 * cos_a + 1.78277 * sin_a);\n g = l + amp * (-0.29227 * cos_a - 0.90649 * sin_a);\n b = l + amp * (+1.97294 * cos_a);\n return chroma(clip_rgb([r * 255, g * 255, b * 255, 1]));\n };\n f.start = function(s) {\n if (s == null) {\n return start;\n }\n start = s;\n return f;\n };\n f.rotations = function(r) {\n if (r == null) {\n return rotations;\n }\n rotations = r;\n return f;\n };\n f.gamma = function(g) {\n if (g == null) {\n return gamma;\n }\n gamma = g;\n return f;\n };\n f.hue = function(h) {\n if (h == null) {\n return hue;\n }\n hue = h;\n if (type(hue) === 'array') {\n dh = hue[1] - hue[0];\n if (dh === 0) {\n hue = hue[1];\n }\n } else {\n dh = 0;\n }\n return f;\n };\n f.lightness = function(h) {\n if (h == null) {\n return lightness;\n }\n if (type(h) === 'array') {\n lightness = h;\n dl = h[1] - h[0];\n } else {\n lightness = [h, h];\n dl = 0;\n }\n return f;\n };\n f.scale = function() {\n return chroma.scale(f);\n };\n f.hue(hue);\n return f;\n };\n\n chroma.random = function() {\n var code, digits, i, o;\n digits = '0123456789abcdef';\n code = '#';\n for (i = o = 0; o < 6; i = ++o) {\n code += digits.charAt(floor(Math.random() * 16));\n }\n return new Color(code);\n };\n\n _interpolators = [];\n\n interpolate = function(col1, col2, f, m) {\n var interpol, len, o, res;\n if (f == null) {\n f = 0.5;\n }\n if (m == null) {\n m = 'rgb';\n }\n\n /*\n interpolates between colors\n f = 0 --> me\n f = 1 --> col\n */\n if (type(col1) !== 'object') {\n col1 = chroma(col1);\n }\n if (type(col2) !== 'object') {\n col2 = chroma(col2);\n }\n for (o = 0, len = _interpolators.length; o < len; o++) {\n interpol = _interpolators[o];\n if (m === interpol[0]) {\n res = interpol[1](col1, col2, f, m);\n break;\n }\n }\n if (res == null) {\n throw \"color mode \" + m + \" is not supported\";\n }\n return res.alpha(col1.alpha() + f * (col2.alpha() - col1.alpha()));\n };\n\n chroma.interpolate = interpolate;\n\n Color.prototype.interpolate = function(col2, f, m) {\n return interpolate(this, col2, f, m);\n };\n\n chroma.mix = interpolate;\n\n Color.prototype.mix = Color.prototype.interpolate;\n\n _input.rgb = function() {\n var k, ref, results, v;\n ref = unpack(arguments);\n results = [];\n for (k in ref) {\n v = ref[k];\n results.push(v);\n }\n return results;\n };\n\n chroma.rgb = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['rgb']), function(){});\n };\n\n Color.prototype.rgb = function(round) {\n if (round == null) {\n round = true;\n }\n if (round) {\n return this._rgb.map(Math.round).slice(0, 3);\n } else {\n return this._rgb.slice(0, 3);\n }\n };\n\n Color.prototype.rgba = function(round) {\n if (round == null) {\n round = true;\n }\n if (!round) {\n return this._rgb.slice(0);\n }\n return [Math.round(this._rgb[0]), Math.round(this._rgb[1]), Math.round(this._rgb[2]), this._rgb[3]];\n };\n\n _guess_formats.push({\n p: 3,\n test: function(n) {\n var a;\n a = unpack(arguments);\n if (type(a) === 'array' && a.length === 3) {\n return 'rgb';\n }\n if (a.length === 4 && type(a[3]) === \"number\" && a[3] >= 0 && a[3] <= 1) {\n return 'rgb';\n }\n }\n });\n\n _input.lrgb = _input.rgb;\n\n interpolate_lrgb = function(col1, col2, f, m) {\n var xyz0, xyz1;\n xyz0 = col1._rgb;\n xyz1 = col2._rgb;\n return new Color(sqrt(pow(xyz0[0], 2) * (1 - f) + pow(xyz1[0], 2) * f), sqrt(pow(xyz0[1], 2) * (1 - f) + pow(xyz1[1], 2) * f), sqrt(pow(xyz0[2], 2) * (1 - f) + pow(xyz1[2], 2) * f), m);\n };\n\n _average_lrgb = function(colors) {\n var col, f, len, o, rgb, xyz;\n f = 1 / colors.length;\n xyz = [0, 0, 0, 0];\n for (o = 0, len = colors.length; o < len; o++) {\n col = colors[o];\n rgb = col._rgb;\n xyz[0] += pow(rgb[0], 2) * f;\n xyz[1] += pow(rgb[1], 2) * f;\n xyz[2] += pow(rgb[2], 2) * f;\n xyz[3] += rgb[3] * f;\n }\n xyz[0] = sqrt(xyz[0]);\n xyz[1] = sqrt(xyz[1]);\n xyz[2] = sqrt(xyz[2]);\n if (xyz[3] > 1) {\n xyz[3] = 1;\n }\n return new Color(clip_rgb(xyz));\n };\n\n _interpolators.push(['lrgb', interpolate_lrgb]);\n\n chroma.average = function(colors, mode) {\n var A, alpha, c, cnt, dx, dy, first, i, l, len, o, xyz, xyz2;\n if (mode == null) {\n mode = 'rgb';\n }\n l = colors.length;\n colors = colors.map(function(c) {\n return chroma(c);\n });\n first = colors.splice(0, 1)[0];\n if (mode === 'lrgb') {\n return _average_lrgb(colors);\n }\n xyz = first.get(mode);\n cnt = [];\n dx = 0;\n dy = 0;\n for (i in xyz) {\n xyz[i] = xyz[i] || 0;\n cnt.push(isNaN(xyz[i]) ? 0 : 1);\n if (mode.charAt(i) === 'h' && !isNaN(xyz[i])) {\n A = xyz[i] / 180 * PI;\n dx += cos(A);\n dy += sin(A);\n }\n }\n alpha = first.alpha();\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n xyz2 = c.get(mode);\n alpha += c.alpha();\n for (i in xyz) {\n if (!isNaN(xyz2[i])) {\n cnt[i] += 1;\n if (mode.charAt(i) === 'h') {\n A = xyz2[i] / 180 * PI;\n dx += cos(A);\n dy += sin(A);\n } else {\n xyz[i] += xyz2[i];\n }\n }\n }\n }\n for (i in xyz) {\n if (mode.charAt(i) === 'h') {\n A = atan2(dy / cnt[i], dx / cnt[i]) / PI * 180;\n while (A < 0) {\n A += 360;\n }\n while (A >= 360) {\n A -= 360;\n }\n xyz[i] = A;\n } else {\n xyz[i] = xyz[i] / cnt[i];\n }\n }\n return chroma(xyz, mode).alpha(alpha / l);\n };\n\n hex2rgb = function(hex) {\n var a, b, g, r, rgb, u;\n if (hex.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)) {\n if (hex.length === 4 || hex.length === 7) {\n hex = hex.substr(1);\n }\n if (hex.length === 3) {\n hex = hex.split(\"\");\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\n }\n u = parseInt(hex, 16);\n r = u >> 16;\n g = u >> 8 & 0xFF;\n b = u & 0xFF;\n return [r, g, b, 1];\n }\n if (hex.match(/^#?([A-Fa-f0-9]{8})$/)) {\n if (hex.length === 9) {\n hex = hex.substr(1);\n }\n u = parseInt(hex, 16);\n r = u >> 24 & 0xFF;\n g = u >> 16 & 0xFF;\n b = u >> 8 & 0xFF;\n a = round((u & 0xFF) / 0xFF * 100) / 100;\n return [r, g, b, a];\n }\n if ((_input.css != null) && (rgb = _input.css(hex))) {\n return rgb;\n }\n throw \"unknown color: \" + hex;\n };\n\n rgb2hex = function(channels, mode) {\n var a, b, g, hxa, r, str, u;\n if (mode == null) {\n mode = 'auto';\n }\n r = channels[0], g = channels[1], b = channels[2], a = channels[3];\n if (mode === 'auto') {\n mode = a < 1 ? 'rgba' : 'rgb';\n }\n r = Math.round(r);\n g = Math.round(g);\n b = Math.round(b);\n u = r << 16 | g << 8 | b;\n str = \"000000\" + u.toString(16);\n str = str.substr(str.length - 6);\n hxa = '0' + round(a * 255).toString(16);\n hxa = hxa.substr(hxa.length - 2);\n return \"#\" + (function() {\n switch (mode.toLowerCase()) {\n case 'rgba':\n return str + hxa;\n case 'argb':\n return hxa + str;\n default:\n return str;\n }\n })();\n };\n\n _input.hex = function(h) {\n return hex2rgb(h);\n };\n\n chroma.hex = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hex']), function(){});\n };\n\n Color.prototype.hex = function(mode) {\n if (mode == null) {\n mode = 'auto';\n }\n return rgb2hex(this._rgb, mode);\n };\n\n _guess_formats.push({\n p: 4,\n test: function(n) {\n if (arguments.length === 1 && type(n) === \"string\") {\n return 'hex';\n }\n }\n });\n\n hsl2rgb = function() {\n var args, b, c, g, h, i, l, o, r, ref, s, t1, t2, t3;\n args = unpack(arguments);\n h = args[0], s = args[1], l = args[2];\n if (s === 0) {\n r = g = b = l * 255;\n } else {\n t3 = [0, 0, 0];\n c = [0, 0, 0];\n t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n t1 = 2 * l - t2;\n h /= 360;\n t3[0] = h + 1 / 3;\n t3[1] = h;\n t3[2] = h - 1 / 3;\n for (i = o = 0; o <= 2; i = ++o) {\n if (t3[i] < 0) {\n t3[i] += 1;\n }\n if (t3[i] > 1) {\n t3[i] -= 1;\n }\n if (6 * t3[i] < 1) {\n c[i] = t1 + (t2 - t1) * 6 * t3[i];\n } else if (2 * t3[i] < 1) {\n c[i] = t2;\n } else if (3 * t3[i] < 2) {\n c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6;\n } else {\n c[i] = t1;\n }\n }\n ref = [round(c[0] * 255), round(c[1] * 255), round(c[2] * 255)], r = ref[0], g = ref[1], b = ref[2];\n }\n if (args.length > 3) {\n return [r, g, b, args[3]];\n } else {\n return [r, g, b];\n }\n };\n\n rgb2hsl = function(r, g, b) {\n var h, l, min, ref, s;\n if (r !== void 0 && r.length >= 3) {\n ref = r, r = ref[0], g = ref[1], b = ref[2];\n }\n r /= 255;\n g /= 255;\n b /= 255;\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n l = (max + min) / 2;\n if (max === min) {\n s = 0;\n h = Number.NaN;\n } else {\n s = l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min);\n }\n if (r === max) {\n h = (g - b) / (max - min);\n } else if (g === max) {\n h = 2 + (b - r) / (max - min);\n } else if (b === max) {\n h = 4 + (r - g) / (max - min);\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n return [h, s, l];\n };\n\n chroma.hsl = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsl']), function(){});\n };\n\n _input.hsl = hsl2rgb;\n\n Color.prototype.hsl = function() {\n return rgb2hsl(this._rgb);\n };\n\n hsv2rgb = function() {\n var args, b, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, s, t, v;\n args = unpack(arguments);\n h = args[0], s = args[1], v = args[2];\n v *= 255;\n if (s === 0) {\n r = g = b = v;\n } else {\n if (h === 360) {\n h = 0;\n }\n if (h > 360) {\n h -= 360;\n }\n if (h < 0) {\n h += 360;\n }\n h /= 60;\n i = floor(h);\n f = h - i;\n p = v * (1 - s);\n q = v * (1 - s * f);\n t = v * (1 - s * (1 - f));\n switch (i) {\n case 0:\n ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];\n break;\n case 1:\n ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];\n break;\n case 2:\n ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];\n break;\n case 3:\n ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];\n break;\n case 4:\n ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];\n break;\n case 5:\n ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hsv = function() {\n var b, delta, g, h, min, r, ref, s, v;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n delta = max - min;\n v = max / 255.0;\n if (max === 0) {\n h = Number.NaN;\n s = 0;\n } else {\n s = delta / max;\n if (r === max) {\n h = (g - b) / delta;\n }\n if (g === max) {\n h = 2 + (b - r) / delta;\n }\n if (b === max) {\n h = 4 + (r - g) / delta;\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n }\n return [h, s, v];\n };\n\n chroma.hsv = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsv']), function(){});\n };\n\n _input.hsv = hsv2rgb;\n\n Color.prototype.hsv = function() {\n return rgb2hsv(this._rgb);\n };\n\n num2rgb = function(num) {\n var b, g, r;\n if (type(num) === \"number\" && num >= 0 && num <= 0xFFFFFF) {\n r = num >> 16;\n g = (num >> 8) & 0xFF;\n b = num & 0xFF;\n return [r, g, b, 1];\n }\n console.warn(\"unknown num color: \" + num);\n return [0, 0, 0, 1];\n };\n\n rgb2num = function() {\n var b, g, r, ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n return (r << 16) + (g << 8) + b;\n };\n\n chroma.num = function(num) {\n return new Color(num, 'num');\n };\n\n Color.prototype.num = function(mode) {\n if (mode == null) {\n mode = 'rgb';\n }\n return rgb2num(this._rgb, mode);\n };\n\n _input.num = num2rgb;\n\n _guess_formats.push({\n p: 1,\n test: function(n) {\n if (arguments.length === 1 && type(n) === \"number\" && n >= 0 && n <= 0xFFFFFF) {\n return 'num';\n }\n }\n });\n\n hcg2rgb = function() {\n var _c, _g, args, b, c, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, t, v;\n args = unpack(arguments);\n h = args[0], c = args[1], _g = args[2];\n c = c / 100;\n g = g / 100 * 255;\n _c = c * 255;\n if (c === 0) {\n r = g = b = _g;\n } else {\n if (h === 360) {\n h = 0;\n }\n if (h > 360) {\n h -= 360;\n }\n if (h < 0) {\n h += 360;\n }\n h /= 60;\n i = floor(h);\n f = h - i;\n p = _g * (1 - c);\n q = p + _c * (1 - f);\n t = p + _c * f;\n v = p + _c;\n switch (i) {\n case 0:\n ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];\n break;\n case 1:\n ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];\n break;\n case 2:\n ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];\n break;\n case 3:\n ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];\n break;\n case 4:\n ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];\n break;\n case 5:\n ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hcg = function() {\n var _g, b, c, delta, g, h, min, r, ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n delta = max - min;\n c = delta * 100 / 255;\n _g = min / (255 - delta) * 100;\n if (delta === 0) {\n h = Number.NaN;\n } else {\n if (r === max) {\n h = (g - b) / delta;\n }\n if (g === max) {\n h = 2 + (b - r) / delta;\n }\n if (b === max) {\n h = 4 + (r - g) / delta;\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n }\n return [h, c, _g];\n };\n\n chroma.hcg = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hcg']), function(){});\n };\n\n _input.hcg = hcg2rgb;\n\n Color.prototype.hcg = function() {\n return rgb2hcg(this._rgb);\n };\n\n css2rgb = function(css) {\n var aa, ab, hsl, i, m, o, rgb, w;\n css = css.toLowerCase();\n if ((chroma.colors != null) && chroma.colors[css]) {\n return hex2rgb(chroma.colors[css]);\n }\n if (m = css.match(/rgb\\(\\s*(\\-?\\d+),\\s*(\\-?\\d+)\\s*,\\s*(\\-?\\d+)\\s*\\)/)) {\n rgb = m.slice(1, 4);\n for (i = o = 0; o <= 2; i = ++o) {\n rgb[i] = +rgb[i];\n }\n rgb[3] = 1;\n } else if (m = css.match(/rgba\\(\\s*(\\-?\\d+),\\s*(\\-?\\d+)\\s*,\\s*(\\-?\\d+)\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n rgb = m.slice(1, 5);\n for (i = w = 0; w <= 3; i = ++w) {\n rgb[i] = +rgb[i];\n }\n } else if (m = css.match(/rgb\\(\\s*(\\-?\\d+(?:\\.\\d+)?)%,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*\\)/)) {\n rgb = m.slice(1, 4);\n for (i = aa = 0; aa <= 2; i = ++aa) {\n rgb[i] = round(rgb[i] * 2.55);\n }\n rgb[3] = 1;\n } else if (m = css.match(/rgba\\(\\s*(\\-?\\d+(?:\\.\\d+)?)%,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n rgb = m.slice(1, 5);\n for (i = ab = 0; ab <= 2; i = ++ab) {\n rgb[i] = round(rgb[i] * 2.55);\n }\n rgb[3] = +rgb[3];\n } else if (m = css.match(/hsl\\(\\s*(\\-?\\d+(?:\\.\\d+)?),\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*\\)/)) {\n hsl = m.slice(1, 4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n rgb = hsl2rgb(hsl);\n rgb[3] = 1;\n } else if (m = css.match(/hsla\\(\\s*(\\-?\\d+(?:\\.\\d+)?),\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n hsl = m.slice(1, 4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n rgb = hsl2rgb(hsl);\n rgb[3] = +m[4];\n }\n return rgb;\n };\n\n rgb2css = function(rgba) {\n var mode;\n mode = rgba[3] < 1 ? 'rgba' : 'rgb';\n if (mode === 'rgb') {\n return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ')';\n } else if (mode === 'rgba') {\n return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ',' + rgba[3] + ')';\n } else {\n\n }\n };\n\n rnd = function(a) {\n return round(a * 100) / 100;\n };\n\n hsl2css = function(hsl, alpha) {\n var mode;\n mode = alpha < 1 ? 'hsla' : 'hsl';\n hsl[0] = rnd(hsl[0] || 0);\n hsl[1] = rnd(hsl[1] * 100) + '%';\n hsl[2] = rnd(hsl[2] * 100) + '%';\n if (mode === 'hsla') {\n hsl[3] = alpha;\n }\n return mode + '(' + hsl.join(',') + ')';\n };\n\n _input.css = function(h) {\n return css2rgb(h);\n };\n\n chroma.css = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['css']), function(){});\n };\n\n Color.prototype.css = function(mode) {\n if (mode == null) {\n mode = 'rgb';\n }\n if (mode.slice(0, 3) === 'rgb') {\n return rgb2css(this._rgb);\n } else if (mode.slice(0, 3) === 'hsl') {\n return hsl2css(this.hsl(), this.alpha());\n }\n };\n\n _input.named = function(name) {\n return hex2rgb(w3cx11[name]);\n };\n\n _guess_formats.push({\n p: 5,\n test: function(n) {\n if (arguments.length === 1 && (w3cx11[n] != null)) {\n return 'named';\n }\n }\n });\n\n Color.prototype.name = function(n) {\n var h, k;\n if (arguments.length) {\n if (w3cx11[n]) {\n this._rgb = hex2rgb(w3cx11[n]);\n }\n this._rgb[3] = 1;\n this;\n }\n h = this.hex('rgb');\n for (k in w3cx11) {\n if (h === w3cx11[k]) {\n return k;\n }\n }\n return h;\n };\n\n lch2lab = function() {\n\n /*\n Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.\n These formulas were invented by David Dalrymple to obtain maximum contrast without going\n out of gamut if the parameters are in the range 0-1.\n \n A saturation multiplier was added by Gregor Aisch\n */\n var c, h, l, ref;\n ref = unpack(arguments), l = ref[0], c = ref[1], h = ref[2];\n h = h * DEG2RAD;\n return [l, cos(h) * c, sin(h) * c];\n };\n\n lch2rgb = function() {\n var L, a, args, b, c, g, h, l, r, ref, ref1;\n args = unpack(arguments);\n l = args[0], c = args[1], h = args[2];\n ref = lch2lab(l, c, h), L = ref[0], a = ref[1], b = ref[2];\n ref1 = lab2rgb(L, a, b), r = ref1[0], g = ref1[1], b = ref1[2];\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n lab2lch = function() {\n var a, b, c, h, l, ref;\n ref = unpack(arguments), l = ref[0], a = ref[1], b = ref[2];\n c = sqrt(a * a + b * b);\n h = (atan2(b, a) * RAD2DEG + 360) % 360;\n if (round(c * 10000) === 0) {\n h = Number.NaN;\n }\n return [l, c, h];\n };\n\n rgb2lch = function() {\n var a, b, g, l, r, ref, ref1;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n ref1 = rgb2lab(r, g, b), l = ref1[0], a = ref1[1], b = ref1[2];\n return lab2lch(l, a, b);\n };\n\n chroma.lch = function() {\n var args;\n args = unpack(arguments);\n return new Color(args, 'lch');\n };\n\n chroma.hcl = function() {\n var args;\n args = unpack(arguments);\n return new Color(args, 'hcl');\n };\n\n _input.lch = lch2rgb;\n\n _input.hcl = function() {\n var c, h, l, ref;\n ref = unpack(arguments), h = ref[0], c = ref[1], l = ref[2];\n return lch2rgb([l, c, h]);\n };\n\n Color.prototype.lch = function() {\n return rgb2lch(this._rgb);\n };\n\n Color.prototype.hcl = function() {\n return rgb2lch(this._rgb).reverse();\n };\n\n rgb2cmyk = function(mode) {\n var b, c, f, g, k, m, r, ref, y;\n if (mode == null) {\n mode = 'rgb';\n }\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = r / 255;\n g = g / 255;\n b = b / 255;\n k = 1 - Math.max(r, Math.max(g, b));\n f = k < 1 ? 1 / (1 - k) : 0;\n c = (1 - r - k) * f;\n m = (1 - g - k) * f;\n y = (1 - b - k) * f;\n return [c, m, y, k];\n };\n\n cmyk2rgb = function() {\n var alpha, args, b, c, g, k, m, r, y;\n args = unpack(arguments);\n c = args[0], m = args[1], y = args[2], k = args[3];\n alpha = args.length > 4 ? args[4] : 1;\n if (k === 1) {\n return [0, 0, 0, alpha];\n }\n r = c >= 1 ? 0 : 255 * (1 - c) * (1 - k);\n g = m >= 1 ? 0 : 255 * (1 - m) * (1 - k);\n b = y >= 1 ? 0 : 255 * (1 - y) * (1 - k);\n return [r, g, b, alpha];\n };\n\n _input.cmyk = function() {\n return cmyk2rgb(unpack(arguments));\n };\n\n chroma.cmyk = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['cmyk']), function(){});\n };\n\n Color.prototype.cmyk = function() {\n return rgb2cmyk(this._rgb);\n };\n\n _input.gl = function() {\n var i, k, o, rgb, v;\n rgb = (function() {\n var ref, results;\n ref = unpack(arguments);\n results = [];\n for (k in ref) {\n v = ref[k];\n results.push(v);\n }\n return results;\n }).apply(this, arguments);\n for (i = o = 0; o <= 2; i = ++o) {\n rgb[i] *= 255;\n }\n return rgb;\n };\n\n chroma.gl = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['gl']), function(){});\n };\n\n Color.prototype.gl = function() {\n var rgb;\n rgb = this._rgb;\n return [rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, rgb[3]];\n };\n\n rgb2luminance = function(r, g, b) {\n var ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = luminance_x(r);\n g = luminance_x(g);\n b = luminance_x(b);\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n };\n\n luminance_x = function(x) {\n x /= 255;\n if (x <= 0.03928) {\n return x / 12.92;\n } else {\n return pow((x + 0.055) / 1.055, 2.4);\n }\n };\n\n interpolate_rgb = function(col1, col2, f, m) {\n var xyz0, xyz1;\n xyz0 = col1._rgb;\n xyz1 = col2._rgb;\n return new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);\n };\n\n _interpolators.push(['rgb', interpolate_rgb]);\n\n Color.prototype.luminance = function(lum, mode) {\n var cur_lum, eps, max_iter, rgba, test;\n if (mode == null) {\n mode = 'rgb';\n }\n if (!arguments.length) {\n return rgb2luminance(this._rgb);\n }\n rgba = this._rgb;\n if (lum === 0) {\n rgba = [0, 0, 0, this._rgb[3]];\n } else if (lum === 1) {\n rgba = [255, 255, 255, this[3]];\n } else {\n cur_lum = rgb2luminance(this._rgb);\n eps = 1e-7;\n max_iter = 20;\n test = function(l, h) {\n var lm, m;\n m = l.interpolate(h, 0.5, mode);\n lm = m.luminance();\n if (Math.abs(lum - lm) < eps || !max_iter--) {\n return m;\n }\n if (lm > lum) {\n return test(l, m);\n }\n return test(m, h);\n };\n if (cur_lum > lum) {\n rgba = test(chroma('black'), this).rgba();\n } else {\n rgba = test(this, chroma('white')).rgba();\n }\n }\n return chroma(rgba).alpha(this.alpha());\n };\n\n temperature2rgb = function(kelvin) {\n var b, g, r, temp;\n temp = kelvin / 100;\n if (temp < 66) {\n r = 255;\n g = -155.25485562709179 - 0.44596950469579133 * (g = temp - 2) + 104.49216199393888 * log(g);\n b = temp < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (b = temp - 10) + 115.67994401066147 * log(b);\n } else {\n r = 351.97690566805693 + 0.114206453784165 * (r = temp - 55) - 40.25366309332127 * log(r);\n g = 325.4494125711974 + 0.07943456536662342 * (g = temp - 50) - 28.0852963507957 * log(g);\n b = 255;\n }\n return [r, g, b];\n };\n\n rgb2temperature = function() {\n var b, eps, g, maxTemp, minTemp, r, ref, rgb, temp;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n minTemp = 1000;\n maxTemp = 40000;\n eps = 0.4;\n while (maxTemp - minTemp > eps) {\n temp = (maxTemp + minTemp) * 0.5;\n rgb = temperature2rgb(temp);\n if ((rgb[2] / rgb[0]) >= (b / r)) {\n maxTemp = temp;\n } else {\n minTemp = temp;\n }\n }\n return round(temp);\n };\n\n chroma.temperature = chroma.kelvin = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['temperature']), function(){});\n };\n\n _input.temperature = _input.kelvin = _input.K = temperature2rgb;\n\n Color.prototype.temperature = function() {\n return rgb2temperature(this._rgb);\n };\n\n Color.prototype.kelvin = Color.prototype.temperature;\n\n chroma.contrast = function(a, b) {\n var l1, l2, ref, ref1;\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n l1 = a.luminance();\n l2 = b.luminance();\n if (l1 > l2) {\n return (l1 + 0.05) / (l2 + 0.05);\n } else {\n return (l2 + 0.05) / (l1 + 0.05);\n }\n };\n\n chroma.distance = function(a, b, mode) {\n var d, i, l1, l2, ref, ref1, sum_sq;\n if (mode == null) {\n mode = 'lab';\n }\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n l1 = a.get(mode);\n l2 = b.get(mode);\n sum_sq = 0;\n for (i in l1) {\n d = (l1[i] || 0) - (l2[i] || 0);\n sum_sq += d * d;\n }\n return Math.sqrt(sum_sq);\n };\n\n chroma.deltaE = function(a, b, L, C) {\n var L1, L2, a1, a2, b1, b2, c1, c2, c4, dH2, delA, delB, delC, delL, f, h1, ref, ref1, ref2, ref3, sc, sh, sl, t, v1, v2, v3;\n if (L == null) {\n L = 1;\n }\n if (C == null) {\n C = 1;\n }\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n ref2 = a.lab(), L1 = ref2[0], a1 = ref2[1], b1 = ref2[2];\n ref3 = b.lab(), L2 = ref3[0], a2 = ref3[1], b2 = ref3[2];\n c1 = sqrt(a1 * a1 + b1 * b1);\n c2 = sqrt(a2 * a2 + b2 * b2);\n sl = L1 < 16.0 ? 0.511 : (0.040975 * L1) / (1.0 + 0.01765 * L1);\n sc = (0.0638 * c1) / (1.0 + 0.0131 * c1) + 0.638;\n h1 = c1 < 0.000001 ? 0.0 : (atan2(b1, a1) * 180.0) / PI;\n while (h1 < 0) {\n h1 += 360;\n }\n while (h1 >= 360) {\n h1 -= 360;\n }\n t = (h1 >= 164.0) && (h1 <= 345.0) ? 0.56 + abs(0.2 * cos((PI * (h1 + 168.0)) / 180.0)) : 0.36 + abs(0.4 * cos((PI * (h1 + 35.0)) / 180.0));\n c4 = c1 * c1 * c1 * c1;\n f = sqrt(c4 / (c4 + 1900.0));\n sh = sc * (f * t + 1.0 - f);\n delL = L1 - L2;\n delC = c1 - c2;\n delA = a1 - a2;\n delB = b1 - b2;\n dH2 = delA * delA + delB * delB - delC * delC;\n v1 = delL / (L * sl);\n v2 = delC / (C * sc);\n v3 = sh;\n return sqrt(v1 * v1 + v2 * v2 + (dH2 / (v3 * v3)));\n };\n\n Color.prototype.get = function(modechan) {\n var channel, i, me, mode, ref, src;\n me = this;\n ref = modechan.split('.'), mode = ref[0], channel = ref[1];\n src = me[mode]();\n if (channel) {\n i = mode.indexOf(channel);\n if (i > -1) {\n return src[i];\n } else {\n return console.warn('unknown channel ' + channel + ' in mode ' + mode);\n }\n } else {\n return src;\n }\n };\n\n Color.prototype.set = function(modechan, value) {\n var channel, i, me, mode, ref, src;\n me = this;\n ref = modechan.split('.'), mode = ref[0], channel = ref[1];\n if (channel) {\n src = me[mode]();\n i = mode.indexOf(channel);\n if (i > -1) {\n if (type(value) === 'string') {\n switch (value.charAt(0)) {\n case '+':\n src[i] += +value;\n break;\n case '-':\n src[i] += +value;\n break;\n case '*':\n src[i] *= +(value.substr(1));\n break;\n case '/':\n src[i] /= +(value.substr(1));\n break;\n default:\n src[i] = +value;\n }\n } else {\n src[i] = value;\n }\n } else {\n console.warn('unknown channel ' + channel + ' in mode ' + mode);\n }\n } else {\n src = value;\n }\n return chroma(src, mode).alpha(me.alpha());\n };\n\n Color.prototype.clipped = function() {\n return this._rgb._clipped || false;\n };\n\n Color.prototype.alpha = function(a) {\n if (arguments.length) {\n return chroma.rgb([this._rgb[0], this._rgb[1], this._rgb[2], a]);\n }\n return this._rgb[3];\n };\n\n Color.prototype.darken = function(amount) {\n var lab, me;\n if (amount == null) {\n amount = 1;\n }\n me = this;\n lab = me.lab();\n lab[0] -= LAB_CONSTANTS.Kn * amount;\n return chroma.lab(lab).alpha(me.alpha());\n };\n\n Color.prototype.brighten = function(amount) {\n if (amount == null) {\n amount = 1;\n }\n return this.darken(-amount);\n };\n\n Color.prototype.darker = Color.prototype.darken;\n\n Color.prototype.brighter = Color.prototype.brighten;\n\n Color.prototype.saturate = function(amount) {\n var lch, me;\n if (amount == null) {\n amount = 1;\n }\n me = this;\n lch = me.lch();\n lch[1] += amount * LAB_CONSTANTS.Kn;\n if (lch[1] < 0) {\n lch[1] = 0;\n }\n return chroma.lch(lch).alpha(me.alpha());\n };\n\n Color.prototype.desaturate = function(amount) {\n if (amount == null) {\n amount = 1;\n }\n return this.saturate(-amount);\n };\n\n Color.prototype.premultiply = function() {\n var a, rgb;\n rgb = this.rgb();\n a = this.alpha();\n return chroma(rgb[0] * a, rgb[1] * a, rgb[2] * a, a);\n };\n\n blend = function(bottom, top, mode) {\n if (!blend[mode]) {\n throw 'unknown blend mode ' + mode;\n }\n return blend[mode](bottom, top);\n };\n\n blend_f = function(f) {\n return function(bottom, top) {\n var c0, c1;\n c0 = chroma(top).rgb();\n c1 = chroma(bottom).rgb();\n return chroma(f(c0, c1), 'rgb');\n };\n };\n\n each = function(f) {\n return function(c0, c1) {\n var i, o, out;\n out = [];\n for (i = o = 0; o <= 3; i = ++o) {\n out[i] = f(c0[i], c1[i]);\n }\n return out;\n };\n };\n\n normal = function(a, b) {\n return a;\n };\n\n multiply = function(a, b) {\n return a * b / 255;\n };\n\n darken = function(a, b) {\n if (a > b) {\n return b;\n } else {\n return a;\n }\n };\n\n lighten = function(a, b) {\n if (a > b) {\n return a;\n } else {\n return b;\n }\n };\n\n screen = function(a, b) {\n return 255 * (1 - (1 - a / 255) * (1 - b / 255));\n };\n\n overlay = function(a, b) {\n if (b < 128) {\n return 2 * a * b / 255;\n } else {\n return 255 * (1 - 2 * (1 - a / 255) * (1 - b / 255));\n }\n };\n\n burn = function(a, b) {\n return 255 * (1 - (1 - b / 255) / (a / 255));\n };\n\n dodge = function(a, b) {\n if (a === 255) {\n return 255;\n }\n a = 255 * (b / 255) / (1 - a / 255);\n if (a > 255) {\n return 255;\n } else {\n return a;\n }\n };\n\n blend.normal = blend_f(each(normal));\n\n blend.multiply = blend_f(each(multiply));\n\n blend.screen = blend_f(each(screen));\n\n blend.overlay = blend_f(each(overlay));\n\n blend.darken = blend_f(each(darken));\n\n blend.lighten = blend_f(each(lighten));\n\n blend.dodge = blend_f(each(dodge));\n\n blend.burn = blend_f(each(burn));\n\n chroma.blend = blend;\n\n chroma.analyze = function(data) {\n var len, o, r, val;\n r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE * -1,\n sum: 0,\n values: [],\n count: 0\n };\n for (o = 0, len = data.length; o < len; o++) {\n val = data[o];\n if ((val != null) && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) {\n r.min = val;\n }\n if (val > r.max) {\n r.max = val;\n }\n r.count += 1;\n }\n }\n r.domain = [r.min, r.max];\n r.limits = function(mode, num) {\n return chroma.limits(r, mode, num);\n };\n return r;\n };\n\n chroma.scale = function(colors, positions) {\n var _classes, _colorCache, _colors, _correctLightness, _domain, _fixed, _gamma, _max, _min, _mode, _nacol, _out, _padding, _pos, _spread, _useCache, classifyValue, f, getClass, getColor, resetCache, setColors, tmap;\n _mode = 'rgb';\n _nacol = chroma('#ccc');\n _spread = 0;\n _fixed = false;\n _domain = [0, 1];\n _pos = [];\n _padding = [0, 0];\n _classes = false;\n _colors = [];\n _out = false;\n _min = 0;\n _max = 1;\n _correctLightness = false;\n _colorCache = {};\n _useCache = true;\n _gamma = 1;\n setColors = function(colors) {\n var c, col, o, ref, ref1, w;\n if (colors == null) {\n colors = ['#fff', '#000'];\n }\n if ((colors != null) && type(colors) === 'string' && (chroma.brewer != null)) {\n colors = chroma.brewer[colors] || chroma.brewer[colors.toLowerCase()] || colors;\n }\n if (type(colors) === 'array') {\n if (colors.length === 1) {\n colors = [colors[0], colors[0]];\n }\n colors = colors.slice(0);\n for (c = o = 0, ref = colors.length - 1; 0 <= ref ? o <= ref : o >= ref; c = 0 <= ref ? ++o : --o) {\n col = colors[c];\n if (type(col) === \"string\") {\n colors[c] = chroma(col);\n }\n }\n _pos.length = 0;\n for (c = w = 0, ref1 = colors.length - 1; 0 <= ref1 ? w <= ref1 : w >= ref1; c = 0 <= ref1 ? ++w : --w) {\n _pos.push(c / (colors.length - 1));\n }\n }\n resetCache();\n return _colors = colors;\n };\n getClass = function(value) {\n var i, n;\n if (_classes != null) {\n n = _classes.length - 1;\n i = 0;\n while (i < n && value >= _classes[i]) {\n i++;\n }\n return i - 1;\n }\n return 0;\n };\n tmap = function(t) {\n return t;\n };\n classifyValue = function(value) {\n var i, maxc, minc, n, val;\n val = value;\n if (_classes.length > 2) {\n n = _classes.length - 1;\n i = getClass(value);\n minc = _classes[0] + (_classes[1] - _classes[0]) * (0 + _spread * 0.5);\n maxc = _classes[n - 1] + (_classes[n] - _classes[n - 1]) * (1 - _spread * 0.5);\n val = _min + ((_classes[i] + (_classes[i + 1] - _classes[i]) * 0.5 - minc) / (maxc - minc)) * (_max - _min);\n }\n return val;\n };\n getColor = function(val, bypassMap) {\n var c, col, i, k, o, p, ref, t;\n if (bypassMap == null) {\n bypassMap = false;\n }\n if (isNaN(val) || val === null) {\n return _nacol;\n }\n if (!bypassMap) {\n if (_classes && _classes.length > 2) {\n c = getClass(val);\n t = c / (_classes.length - 2);\n } else if (_max !== _min) {\n t = (val - _min) / (_max - _min);\n } else {\n t = 1;\n }\n } else {\n t = val;\n }\n if (!bypassMap) {\n t = tmap(t);\n }\n if (_gamma !== 1) {\n t = pow(t, _gamma);\n }\n t = _padding[0] + (t * (1 - _padding[0] - _padding[1]));\n t = Math.min(1, Math.max(0, t));\n k = Math.floor(t * 10000);\n if (_useCache && _colorCache[k]) {\n col = _colorCache[k];\n } else {\n if (type(_colors) === 'array') {\n for (i = o = 0, ref = _pos.length - 1; 0 <= ref ? o <= ref : o >= ref; i = 0 <= ref ? ++o : --o) {\n p = _pos[i];\n if (t <= p) {\n col = _colors[i];\n break;\n }\n if (t >= p && i === _pos.length - 1) {\n col = _colors[i];\n break;\n }\n if (t > p && t < _pos[i + 1]) {\n t = (t - p) / (_pos[i + 1] - p);\n col = chroma.interpolate(_colors[i], _colors[i + 1], t, _mode);\n break;\n }\n }\n } else if (type(_colors) === 'function') {\n col = _colors(t);\n }\n if (_useCache) {\n _colorCache[k] = col;\n }\n }\n return col;\n };\n resetCache = function() {\n return _colorCache = {};\n };\n setColors(colors);\n f = function(v) {\n var c;\n c = chroma(getColor(v));\n if (_out && c[_out]) {\n return c[_out]();\n } else {\n return c;\n }\n };\n f.classes = function(classes) {\n var d;\n if (classes != null) {\n if (type(classes) === 'array') {\n _classes = classes;\n _domain = [classes[0], classes[classes.length - 1]];\n } else {\n d = chroma.analyze(_domain);\n if (classes === 0) {\n _classes = [d.min, d.max];\n } else {\n _classes = chroma.limits(d, 'e', classes);\n }\n }\n return f;\n }\n return _classes;\n };\n f.domain = function(domain) {\n var c, d, k, len, o, ref, w;\n if (!arguments.length) {\n return _domain;\n }\n _min = domain[0];\n _max = domain[domain.length - 1];\n _pos = [];\n k = _colors.length;\n if (domain.length === k && _min !== _max) {\n for (o = 0, len = domain.length; o < len; o++) {\n d = domain[o];\n _pos.push((d - _min) / (_max - _min));\n }\n } else {\n for (c = w = 0, ref = k - 1; 0 <= ref ? w <= ref : w >= ref; c = 0 <= ref ? ++w : --w) {\n _pos.push(c / (k - 1));\n }\n }\n _domain = [_min, _max];\n return f;\n };\n f.mode = function(_m) {\n if (!arguments.length) {\n return _mode;\n }\n _mode = _m;\n resetCache();\n return f;\n };\n f.range = function(colors, _pos) {\n setColors(colors, _pos);\n return f;\n };\n f.out = function(_o) {\n _out = _o;\n return f;\n };\n f.spread = function(val) {\n if (!arguments.length) {\n return _spread;\n }\n _spread = val;\n return f;\n };\n f.correctLightness = function(v) {\n if (v == null) {\n v = true;\n }\n _correctLightness = v;\n resetCache();\n if (_correctLightness) {\n tmap = function(t) {\n var L0, L1, L_actual, L_diff, L_ideal, max_iter, pol, t0, t1;\n L0 = getColor(0, true).lab()[0];\n L1 = getColor(1, true).lab()[0];\n pol = L0 > L1;\n L_actual = getColor(t, true).lab()[0];\n L_ideal = L0 + (L1 - L0) * t;\n L_diff = L_actual - L_ideal;\n t0 = 0;\n t1 = 1;\n max_iter = 20;\n while (Math.abs(L_diff) > 1e-2 && max_iter-- > 0) {\n (function() {\n if (pol) {\n L_diff *= -1;\n }\n if (L_diff < 0) {\n t0 = t;\n t += (t1 - t) * 0.5;\n } else {\n t1 = t;\n t += (t0 - t) * 0.5;\n }\n L_actual = getColor(t, true).lab()[0];\n return L_diff = L_actual - L_ideal;\n })();\n }\n return t;\n };\n } else {\n tmap = function(t) {\n return t;\n };\n }\n return f;\n };\n f.padding = function(p) {\n if (p != null) {\n if (type(p) === 'number') {\n p = [p, p];\n }\n _padding = p;\n return f;\n } else {\n return _padding;\n }\n };\n f.colors = function(numColors, out) {\n var dd, dm, i, o, ref, result, results, samples, w;\n if (arguments.length < 2) {\n out = 'hex';\n }\n result = [];\n if (arguments.length === 0) {\n result = _colors.slice(0);\n } else if (numColors === 1) {\n result = [f(0.5)];\n } else if (numColors > 1) {\n dm = _domain[0];\n dd = _domain[1] - dm;\n result = (function() {\n results = [];\n for (var o = 0; 0 <= numColors ? o < numColors : o > numColors; 0 <= numColors ? o++ : o--){ results.push(o); }\n return results;\n }).apply(this).map(function(i) {\n return f(dm + i / (numColors - 1) * dd);\n });\n } else {\n colors = [];\n samples = [];\n if (_classes && _classes.length > 2) {\n for (i = w = 1, ref = _classes.length; 1 <= ref ? w < ref : w > ref; i = 1 <= ref ? ++w : --w) {\n samples.push((_classes[i - 1] + _classes[i]) * 0.5);\n }\n } else {\n samples = _domain;\n }\n result = samples.map(function(v) {\n return f(v);\n });\n }\n if (chroma[out]) {\n result = result.map(function(c) {\n return c[out]();\n });\n }\n return result;\n };\n f.cache = function(c) {\n if (c != null) {\n _useCache = c;\n return f;\n } else {\n return _useCache;\n }\n };\n f.gamma = function(g) {\n if (g != null) {\n _gamma = g;\n return f;\n } else {\n return _gamma;\n }\n };\n f.nodata = function(d) {\n if (d != null) {\n _nacol = chroma(d);\n return f;\n } else {\n return _nacol;\n }\n };\n return f;\n };\n\n if (chroma.scales == null) {\n chroma.scales = {};\n }\n\n chroma.scales.cool = function() {\n return chroma.scale([chroma.hsl(180, 1, .9), chroma.hsl(250, .7, .4)]);\n };\n\n chroma.scales.hot = function() {\n return chroma.scale(['#000', '#f00', '#ff0', '#fff'], [0, .25, .75, 1]).mode('rgb');\n };\n\n chroma.analyze = function(data, key, filter) {\n var add, k, len, o, r, val, visit;\n r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE * -1,\n sum: 0,\n values: [],\n count: 0\n };\n if (filter == null) {\n filter = function() {\n return true;\n };\n }\n add = function(val) {\n if ((val != null) && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) {\n r.min = val;\n }\n if (val > r.max) {\n r.max = val;\n }\n r.count += 1;\n }\n };\n visit = function(val, k) {\n if (filter(val, k)) {\n if ((key != null) && type(key) === 'function') {\n return add(key(val));\n } else if ((key != null) && type(key) === 'string' || type(key) === 'number') {\n return add(val[key]);\n } else {\n return add(val);\n }\n }\n };\n if (type(data) === 'array') {\n for (o = 0, len = data.length; o < len; o++) {\n val = data[o];\n visit(val);\n }\n } else {\n for (k in data) {\n val = data[k];\n visit(val, k);\n }\n }\n r.domain = [r.min, r.max];\n r.limits = function(mode, num) {\n return chroma.limits(r, mode, num);\n };\n return r;\n };\n\n chroma.limits = function(data, mode, num) {\n var aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, assignments, best, centroids, cluster, clusterSizes, dist, i, j, kClusters, limits, max_log, min, min_log, mindist, n, nb_iters, newCentroids, o, p, pb, pr, ref, ref1, ref10, ref11, ref12, ref13, ref14, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, repeat, sum, tmpKMeansBreaks, v, value, values, w;\n if (mode == null) {\n mode = 'equal';\n }\n if (num == null) {\n num = 7;\n }\n if (type(data) === 'array') {\n data = chroma.analyze(data);\n }\n min = data.min;\n max = data.max;\n sum = data.sum;\n values = data.values.sort(function(a, b) {\n return a - b;\n });\n if (num === 1) {\n return [min, max];\n }\n limits = [];\n if (mode.substr(0, 1) === 'c') {\n limits.push(min);\n limits.push(max);\n }\n if (mode.substr(0, 1) === 'e') {\n limits.push(min);\n for (i = o = 1, ref = num - 1; 1 <= ref ? o <= ref : o >= ref; i = 1 <= ref ? ++o : --o) {\n limits.push(min + (i / num) * (max - min));\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'l') {\n if (min <= 0) {\n throw 'Logarithmic scales are only possible for values > 0';\n }\n min_log = Math.LOG10E * log(min);\n max_log = Math.LOG10E * log(max);\n limits.push(min);\n for (i = w = 1, ref1 = num - 1; 1 <= ref1 ? w <= ref1 : w >= ref1; i = 1 <= ref1 ? ++w : --w) {\n limits.push(pow(10, min_log + (i / num) * (max_log - min_log)));\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'q') {\n limits.push(min);\n for (i = aa = 1, ref2 = num - 1; 1 <= ref2 ? aa <= ref2 : aa >= ref2; i = 1 <= ref2 ? ++aa : --aa) {\n p = (values.length - 1) * i / num;\n pb = floor(p);\n if (pb === p) {\n limits.push(values[pb]);\n } else {\n pr = p - pb;\n limits.push(values[pb] * (1 - pr) + values[pb + 1] * pr);\n }\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'k') {\n\n /*\n implementation based on\n http://code.google.com/p/figue/source/browse/trunk/figue.js#336\n simplified for 1-d input values\n */\n n = values.length;\n assignments = new Array(n);\n clusterSizes = new Array(num);\n repeat = true;\n nb_iters = 0;\n centroids = null;\n centroids = [];\n centroids.push(min);\n for (i = ab = 1, ref3 = num - 1; 1 <= ref3 ? ab <= ref3 : ab >= ref3; i = 1 <= ref3 ? ++ab : --ab) {\n centroids.push(min + (i / num) * (max - min));\n }\n centroids.push(max);\n while (repeat) {\n for (j = ac = 0, ref4 = num - 1; 0 <= ref4 ? ac <= ref4 : ac >= ref4; j = 0 <= ref4 ? ++ac : --ac) {\n clusterSizes[j] = 0;\n }\n for (i = ad = 0, ref5 = n - 1; 0 <= ref5 ? ad <= ref5 : ad >= ref5; i = 0 <= ref5 ? ++ad : --ad) {\n value = values[i];\n mindist = Number.MAX_VALUE;\n for (j = ae = 0, ref6 = num - 1; 0 <= ref6 ? ae <= ref6 : ae >= ref6; j = 0 <= ref6 ? ++ae : --ae) {\n dist = abs(centroids[j] - value);\n if (dist < mindist) {\n mindist = dist;\n best = j;\n }\n }\n clusterSizes[best]++;\n assignments[i] = best;\n }\n newCentroids = new Array(num);\n for (j = af = 0, ref7 = num - 1; 0 <= ref7 ? af <= ref7 : af >= ref7; j = 0 <= ref7 ? ++af : --af) {\n newCentroids[j] = null;\n }\n for (i = ag = 0, ref8 = n - 1; 0 <= ref8 ? ag <= ref8 : ag >= ref8; i = 0 <= ref8 ? ++ag : --ag) {\n cluster = assignments[i];\n if (newCentroids[cluster] === null) {\n newCentroids[cluster] = values[i];\n } else {\n newCentroids[cluster] += values[i];\n }\n }\n for (j = ah = 0, ref9 = num - 1; 0 <= ref9 ? ah <= ref9 : ah >= ref9; j = 0 <= ref9 ? ++ah : --ah) {\n newCentroids[j] *= 1 / clusterSizes[j];\n }\n repeat = false;\n for (j = ai = 0, ref10 = num - 1; 0 <= ref10 ? ai <= ref10 : ai >= ref10; j = 0 <= ref10 ? ++ai : --ai) {\n if (newCentroids[j] !== centroids[i]) {\n repeat = true;\n break;\n }\n }\n centroids = newCentroids;\n nb_iters++;\n if (nb_iters > 200) {\n repeat = false;\n }\n }\n kClusters = {};\n for (j = aj = 0, ref11 = num - 1; 0 <= ref11 ? aj <= ref11 : aj >= ref11; j = 0 <= ref11 ? ++aj : --aj) {\n kClusters[j] = [];\n }\n for (i = ak = 0, ref12 = n - 1; 0 <= ref12 ? ak <= ref12 : ak >= ref12; i = 0 <= ref12 ? ++ak : --ak) {\n cluster = assignments[i];\n kClusters[cluster].push(values[i]);\n }\n tmpKMeansBreaks = [];\n for (j = al = 0, ref13 = num - 1; 0 <= ref13 ? al <= ref13 : al >= ref13; j = 0 <= ref13 ? ++al : --al) {\n tmpKMeansBreaks.push(kClusters[j][0]);\n tmpKMeansBreaks.push(kClusters[j][kClusters[j].length - 1]);\n }\n tmpKMeansBreaks = tmpKMeansBreaks.sort(function(a, b) {\n return a - b;\n });\n limits.push(tmpKMeansBreaks[0]);\n for (i = am = 1, ref14 = tmpKMeansBreaks.length - 1; am <= ref14; i = am += 2) {\n v = tmpKMeansBreaks[i];\n if (!isNaN(v) && limits.indexOf(v) === -1) {\n limits.push(v);\n }\n }\n }\n return limits;\n };\n\n hsi2rgb = function(h, s, i) {\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp\n */\n var args, b, g, r;\n args = unpack(arguments);\n h = args[0], s = args[1], i = args[2];\n if (isNaN(h)) {\n h = 0;\n }\n h /= 360;\n if (h < 1 / 3) {\n b = (1 - s) / 3;\n r = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n g = 1 - (b + r);\n } else if (h < 2 / 3) {\n h -= 1 / 3;\n r = (1 - s) / 3;\n g = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n b = 1 - (r + g);\n } else {\n h -= 2 / 3;\n g = (1 - s) / 3;\n b = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n r = 1 - (g + b);\n }\n r = limit(i * r * 3);\n g = limit(i * g * 3);\n b = limit(i * b * 3);\n return [r * 255, g * 255, b * 255, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hsi = function() {\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/rgb2hsi.cpp\n */\n var b, g, h, i, min, r, ref, s;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n TWOPI = Math.PI * 2;\n r /= 255;\n g /= 255;\n b /= 255;\n min = Math.min(r, g, b);\n i = (r + g + b) / 3;\n s = 1 - min / i;\n if (s === 0) {\n h = 0;\n } else {\n h = ((r - g) + (r - b)) / 2;\n h /= Math.sqrt((r - g) * (r - g) + (r - b) * (g - b));\n h = Math.acos(h);\n if (b > g) {\n h = TWOPI - h;\n }\n h /= TWOPI;\n }\n return [h * 360, s, i];\n };\n\n chroma.hsi = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsi']), function(){});\n };\n\n _input.hsi = hsi2rgb;\n\n Color.prototype.hsi = function() {\n return rgb2hsi(this._rgb);\n };\n\n interpolate_hsx = function(col1, col2, f, m) {\n var dh, hue, hue0, hue1, lbv, lbv0, lbv1, res, sat, sat0, sat1, xyz0, xyz1;\n if (m === 'hsl') {\n xyz0 = col1.hsl();\n xyz1 = col2.hsl();\n } else if (m === 'hsv') {\n xyz0 = col1.hsv();\n xyz1 = col2.hsv();\n } else if (m === 'hcg') {\n xyz0 = col1.hcg();\n xyz1 = col2.hcg();\n } else if (m === 'hsi') {\n xyz0 = col1.hsi();\n xyz1 = col2.hsi();\n } else if (m === 'lch' || m === 'hcl') {\n m = 'hcl';\n xyz0 = col1.hcl();\n xyz1 = col2.hcl();\n }\n if (m.substr(0, 1) === 'h') {\n hue0 = xyz0[0], sat0 = xyz0[1], lbv0 = xyz0[2];\n hue1 = xyz1[0], sat1 = xyz1[1], lbv1 = xyz1[2];\n }\n if (!isNaN(hue0) && !isNaN(hue1)) {\n if (hue1 > hue0 && hue1 - hue0 > 180) {\n dh = hue1 - (hue0 + 360);\n } else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh = hue1 + 360 - hue0;\n } else {\n dh = hue1 - hue0;\n }\n hue = hue0 + f * dh;\n } else if (!isNaN(hue0)) {\n hue = hue0;\n if ((lbv1 === 1 || lbv1 === 0) && m !== 'hsv') {\n sat = sat0;\n }\n } else if (!isNaN(hue1)) {\n hue = hue1;\n if ((lbv0 === 1 || lbv0 === 0) && m !== 'hsv') {\n sat = sat1;\n }\n } else {\n hue = Number.NaN;\n }\n if (sat == null) {\n sat = sat0 + f * (sat1 - sat0);\n }\n lbv = lbv0 + f * (lbv1 - lbv0);\n return res = chroma[m](hue, sat, lbv);\n };\n\n _interpolators = _interpolators.concat((function() {\n var len, o, ref, results;\n ref = ['hsv', 'hsl', 'hsi', 'hcl', 'lch', 'hcg'];\n results = [];\n for (o = 0, len = ref.length; o < len; o++) {\n m = ref[o];\n results.push([m, interpolate_hsx]);\n }\n return results;\n })());\n\n interpolate_num = function(col1, col2, f, m) {\n var n1, n2;\n n1 = col1.num();\n n2 = col2.num();\n return chroma.num(n1 + (n2 - n1) * f, 'num');\n };\n\n _interpolators.push(['num', interpolate_num]);\n\n interpolate_lab = function(col1, col2, f, m) {\n var res, xyz0, xyz1;\n xyz0 = col1.lab();\n xyz1 = col2.lab();\n return res = new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);\n };\n\n _interpolators.push(['lab', interpolate_lab]);\n\n}).call(this);\n","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */\n/*global define:false, require:false, exports:false, module:false, signals:false */\n\n/** @license\n * JS Signals \n * Released under the MIT license\n * Author: Miller Medeiros\n * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM)\n */\n\n(function(global){\n\n // SignalBinding -------------------------------------------------\n //================================================================\n\n /**\n * Object that represents a binding between a Signal and a listener function.\n *
- This is an internal constructor and shouldn't be called by regular users.\n *
- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.\n * @author Miller Medeiros\n * @constructor\n * @internal\n * @name SignalBinding\n * @param {Signal} signal Reference to Signal object that listener is currently bound to.\n * @param {Function} listener Handler function bound to the signal.\n * @param {boolean} isOnce If binding should be executed just once.\n * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @param {Number} [priority] The priority level of the event listener. (default = 0).\n */\n function SignalBinding(signal, listener, isOnce, listenerContext, priority) {\n\n /**\n * Handler function bound to the signal.\n * @type Function\n * @private\n */\n this._listener = listener;\n\n /**\n * If binding should be executed just once.\n * @type boolean\n * @private\n */\n this._isOnce = isOnce;\n\n /**\n * Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @memberOf SignalBinding.prototype\n * @name context\n * @type Object|undefined|null\n */\n this.context = listenerContext;\n\n /**\n * Reference to Signal object that listener is currently bound to.\n * @type Signal\n * @private\n */\n this._signal = signal;\n\n /**\n * Listener priority\n * @type Number\n * @private\n */\n this._priority = priority || 0;\n }\n\n SignalBinding.prototype = {\n\n /**\n * If binding is active and should be executed.\n * @type boolean\n */\n active : true,\n\n /**\n * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)\n * @type Array|null\n */\n params : null,\n\n /**\n * Call listener passing arbitrary parameters.\n *

If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

\n * @param {Array} [paramsArr] Array of parameters that should be passed to the listener\n * @return {*} Value returned by the listener.\n */\n execute : function (paramsArr) {\n var handlerReturn, params;\n if (this.active && !!this._listener) {\n params = this.params? this.params.concat(paramsArr) : paramsArr;\n handlerReturn = this._listener.apply(this.context, params);\n if (this._isOnce) {\n this.detach();\n }\n }\n return handlerReturn;\n },\n\n /**\n * Detach binding from signal.\n * - alias to: mySignal.remove(myBinding.getListener());\n * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.\n */\n detach : function () {\n return this.isBound()? this._signal.remove(this._listener, this.context) : null;\n },\n\n /**\n * @return {Boolean} `true` if binding is still bound to the signal and have a listener.\n */\n isBound : function () {\n return (!!this._signal && !!this._listener);\n },\n\n /**\n * @return {boolean} If SignalBinding will only be executed once.\n */\n isOnce : function () {\n return this._isOnce;\n },\n\n /**\n * @return {Function} Handler function bound to the signal.\n */\n getListener : function () {\n return this._listener;\n },\n\n /**\n * @return {Signal} Signal that listener is currently bound to.\n */\n getSignal : function () {\n return this._signal;\n },\n\n /**\n * Delete instance properties\n * @private\n */\n _destroy : function () {\n delete this._signal;\n delete this._listener;\n delete this.context;\n },\n\n /**\n * @return {string} String representation of the object.\n */\n toString : function () {\n return '[SignalBinding isOnce:' + this._isOnce +', isBound:'+ this.isBound() +', active:' + this.active + ']';\n }\n\n };\n\n\n/*global SignalBinding:false*/\n\n // Signal --------------------------------------------------------\n //================================================================\n\n function validateListener(listener, fnName) {\n if (typeof listener !== 'function') {\n throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) );\n }\n }\n\n /**\n * Custom event broadcaster\n *
- inspired by Robert Penner's AS3 Signals.\n * @name Signal\n * @author Miller Medeiros\n * @constructor\n */\n function Signal() {\n /**\n * @type Array.\n * @private\n */\n this._bindings = [];\n this._prevParams = null;\n\n // enforce dispatch to aways work on same context (#47)\n var self = this;\n this.dispatch = function(){\n Signal.prototype.dispatch.apply(self, arguments);\n };\n }\n\n Signal.prototype = {\n\n /**\n * Signals Version Number\n * @type String\n * @const\n */\n VERSION : '1.0.0',\n\n /**\n * If Signal should keep record of previously dispatched parameters and\n * automatically execute listener during `add()`/`addOnce()` if Signal was\n * already dispatched before.\n * @type boolean\n */\n memorize : false,\n\n /**\n * @type boolean\n * @private\n */\n _shouldPropagate : true,\n\n /**\n * If Signal is active and should broadcast events.\n *

IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

\n * @type boolean\n */\n active : true,\n\n /**\n * @param {Function} listener\n * @param {boolean} isOnce\n * @param {Object} [listenerContext]\n * @param {Number} [priority]\n * @return {SignalBinding}\n * @private\n */\n _registerListener : function (listener, isOnce, listenerContext, priority) {\n\n var prevIndex = this._indexOfListener(listener, listenerContext),\n binding;\n\n if (prevIndex !== -1) {\n binding = this._bindings[prevIndex];\n if (binding.isOnce() !== isOnce) {\n throw new Error('You cannot add'+ (isOnce? '' : 'Once') +'() then add'+ (!isOnce? '' : 'Once') +'() the same listener without removing the relationship first.');\n }\n } else {\n binding = new SignalBinding(this, listener, isOnce, listenerContext, priority);\n this._addBinding(binding);\n }\n\n if(this.memorize && this._prevParams){\n binding.execute(this._prevParams);\n }\n\n return binding;\n },\n\n /**\n * @param {SignalBinding} binding\n * @private\n */\n _addBinding : function (binding) {\n //simplified insertion sort\n var n = this._bindings.length;\n do { --n; } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);\n this._bindings.splice(n + 1, 0, binding);\n },\n\n /**\n * @param {Function} listener\n * @return {number}\n * @private\n */\n _indexOfListener : function (listener, context) {\n var n = this._bindings.length,\n cur;\n while (n--) {\n cur = this._bindings[n];\n if (cur._listener === listener && cur.context === context) {\n return n;\n }\n }\n return -1;\n },\n\n /**\n * Check if listener was attached to Signal.\n * @param {Function} listener\n * @param {Object} [context]\n * @return {boolean} if Signal has the specified listener.\n */\n has : function (listener, context) {\n return this._indexOfListener(listener, context) !== -1;\n },\n\n /**\n * Add a listener to the signal.\n * @param {Function} listener Signal handler function.\n * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)\n * @return {SignalBinding} An Object representing the binding between the Signal and listener.\n */\n add : function (listener, listenerContext, priority) {\n validateListener(listener, 'add');\n return this._registerListener(listener, false, listenerContext, priority);\n },\n\n /**\n * Add listener to the signal that should be removed after first execution (will be executed only once).\n * @param {Function} listener Signal handler function.\n * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)\n * @return {SignalBinding} An Object representing the binding between the Signal and listener.\n */\n addOnce : function (listener, listenerContext, priority) {\n validateListener(listener, 'addOnce');\n return this._registerListener(listener, true, listenerContext, priority);\n },\n\n /**\n * Remove a single listener from the dispatch queue.\n * @param {Function} listener Handler function that should be removed.\n * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).\n * @return {Function} Listener handler function.\n */\n remove : function (listener, context) {\n validateListener(listener, 'remove');\n\n var i = this._indexOfListener(listener, context);\n if (i !== -1) {\n this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal\n this._bindings.splice(i, 1);\n }\n return listener;\n },\n\n /**\n * Remove all listeners from the Signal.\n */\n removeAll : function () {\n var n = this._bindings.length;\n while (n--) {\n this._bindings[n]._destroy();\n }\n this._bindings.length = 0;\n },\n\n /**\n * @return {number} Number of listeners attached to the Signal.\n */\n getNumListeners : function () {\n return this._bindings.length;\n },\n\n /**\n * Stop propagation of the event, blocking the dispatch to next listeners on the queue.\n *

IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

\n * @see Signal.prototype.disable\n */\n halt : function () {\n this._shouldPropagate = false;\n },\n\n /**\n * Dispatch/Broadcast Signal to all listeners added to the queue.\n * @param {...*} [params] Parameters that should be passed to each handler.\n */\n dispatch : function (params) {\n if (! this.active) {\n return;\n }\n\n var paramsArr = Array.prototype.slice.call(arguments),\n n = this._bindings.length,\n bindings;\n\n if (this.memorize) {\n this._prevParams = paramsArr;\n }\n\n if (! n) {\n //should come after memorize\n return;\n }\n\n bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch\n this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch.\n\n //execute all callbacks until end of the list or until a callback returns `false` or stops propagation\n //reverse loop since listeners with higher priority will be added at the end of the list\n do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);\n },\n\n /**\n * Forget memorized arguments.\n * @see Signal.memorize\n */\n forget : function(){\n this._prevParams = null;\n },\n\n /**\n * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).\n *

IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

\n */\n dispose : function () {\n this.removeAll();\n delete this._bindings;\n delete this._prevParams;\n },\n\n /**\n * @return {string} String representation of the object.\n */\n toString : function () {\n return '[Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']';\n }\n\n };\n\n\n // Namespace -----------------------------------------------------\n //================================================================\n\n /**\n * Signals namespace\n * @namespace\n * @name signals\n */\n var signals = Signal;\n\n /**\n * Custom event broadcaster\n * @see Signal\n */\n // alias for backwards compatibility (see #gh-44)\n signals.Signal = Signal;\n\n\n\n //exports to multiple environments\n if(typeof define === 'function' && define.amd){ //AMD\n define(function () { return signals; });\n } else if (typeof module !== 'undefined' && module.exports){ //node\n module.exports = signals;\n } else { //browser\n //use string because of Google closure compiler ADVANCED_MODE\n /*jslint sub:true */\n global['signals'] = signals;\n }\n\n}(this));\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/* global window, exports, define */\n\n!function() {\n 'use strict'\n\n var re = {\n not_string: /[^s]/,\n not_bool: /[^t]/,\n not_type: /[^T]/,\n not_primitive: /[^v]/,\n number: /[diefg]/,\n numeric_arg: /[bcdiefguxX]/,\n json: /[j]/,\n not_json: /[^j]/,\n text: /^[^\\x25]+/,\n modulo: /^\\x25{2}/,\n placeholder: /^\\x25(?:([1-9]\\d*)\\$|\\(([^)]+)\\))?(\\+)?(0|'[^$])?(-)?(\\d+)?(?:\\.(\\d+))?([b-gijostTuvxX])/,\n key: /^([a-z_][a-z_\\d]*)/i,\n key_access: /^\\.([a-z_][a-z_\\d]*)/i,\n index_access: /^\\[(\\d+)\\]/,\n sign: /^[+-]/\n }\n\n function sprintf(key) {\n // `arguments` is not an array, but should be fine for this call\n return sprintf_format(sprintf_parse(key), arguments)\n }\n\n function vsprintf(fmt, argv) {\n return sprintf.apply(null, [fmt].concat(argv || []))\n }\n\n function sprintf_format(parse_tree, argv) {\n var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign\n for (i = 0; i < tree_length; i++) {\n if (typeof parse_tree[i] === 'string') {\n output += parse_tree[i]\n }\n else if (typeof parse_tree[i] === 'object') {\n ph = parse_tree[i] // convenience purposes only\n if (ph.keys) { // keyword argument\n arg = argv[cursor]\n for (k = 0; k < ph.keys.length; k++) {\n if (arg == undefined) {\n throw new Error(sprintf('[sprintf] Cannot access property \"%s\" of undefined value \"%s\"', ph.keys[k], ph.keys[k-1]))\n }\n arg = arg[ph.keys[k]]\n }\n }\n else if (ph.param_no) { // positional argument (explicit)\n arg = argv[ph.param_no]\n }\n else { // positional argument (implicit)\n arg = argv[cursor++]\n }\n\n if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {\n arg = arg()\n }\n\n if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {\n throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))\n }\n\n if (re.number.test(ph.type)) {\n is_positive = arg >= 0\n }\n\n switch (ph.type) {\n case 'b':\n arg = parseInt(arg, 10).toString(2)\n break\n case 'c':\n arg = String.fromCharCode(parseInt(arg, 10))\n break\n case 'd':\n case 'i':\n arg = parseInt(arg, 10)\n break\n case 'j':\n arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)\n break\n case 'e':\n arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential()\n break\n case 'f':\n arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg)\n break\n case 'g':\n arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg)\n break\n case 'o':\n arg = (parseInt(arg, 10) >>> 0).toString(8)\n break\n case 's':\n arg = String(arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 't':\n arg = String(!!arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'T':\n arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'u':\n arg = parseInt(arg, 10) >>> 0\n break\n case 'v':\n arg = arg.valueOf()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'x':\n arg = (parseInt(arg, 10) >>> 0).toString(16)\n break\n case 'X':\n arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()\n break\n }\n if (re.json.test(ph.type)) {\n output += arg\n }\n else {\n if (re.number.test(ph.type) && (!is_positive || ph.sign)) {\n sign = is_positive ? '+' : '-'\n arg = arg.toString().replace(re.sign, '')\n }\n else {\n sign = ''\n }\n pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '\n pad_length = ph.width - (sign + arg).length\n pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''\n output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)\n }\n }\n }\n return output\n }\n\n var sprintf_cache = Object.create(null)\n\n function sprintf_parse(fmt) {\n if (sprintf_cache[fmt]) {\n return sprintf_cache[fmt]\n }\n\n var _fmt = fmt, match, parse_tree = [], arg_names = 0\n while (_fmt) {\n if ((match = re.text.exec(_fmt)) !== null) {\n parse_tree.push(match[0])\n }\n else if ((match = re.modulo.exec(_fmt)) !== null) {\n parse_tree.push('%')\n }\n else if ((match = re.placeholder.exec(_fmt)) !== null) {\n if (match[2]) {\n arg_names |= 1\n var field_list = [], replacement_field = match[2], field_match = []\n if ((field_match = re.key.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {\n if ((field_match = re.key_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else if ((field_match = re.index_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n }\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n match[2] = field_list\n }\n else {\n arg_names |= 2\n }\n if (arg_names === 3) {\n throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')\n }\n\n parse_tree.push(\n {\n placeholder: match[0],\n param_no: match[1],\n keys: match[2],\n sign: match[3],\n pad_char: match[4],\n align: match[5],\n width: match[6],\n precision: match[7],\n type: match[8]\n }\n )\n }\n else {\n throw new SyntaxError('[sprintf] unexpected placeholder')\n }\n _fmt = _fmt.substring(match[0].length)\n }\n return sprintf_cache[fmt] = parse_tree\n }\n\n /**\n * export to either browser or node.js\n */\n /* eslint-disable quote-props */\n if (typeof exports !== 'undefined') {\n exports['sprintf'] = sprintf\n exports['vsprintf'] = vsprintf\n }\n if (typeof window !== 'undefined') {\n window['sprintf'] = sprintf\n window['vsprintf'] = vsprintf\n\n if (typeof define === 'function' && define['amd']) {\n define(function() {\n return {\n 'sprintf': sprintf,\n 'vsprintf': vsprintf\n }\n })\n }\n }\n /* eslint-enable quote-props */\n}(); // eslint-disable-line\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0x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, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*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*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure) {\n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false) {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n const bonds = r.getBonds()\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const nn = atomIndices1.length\n\n for (let i = 0; i < nn; ++i) {\n const rai1 = atomIndices1[ i ]\n const rai2 = atomIndices2[ i ]\n const ai1 = rai1 + offset\n const ai2 = rai2 + offset\n const tmp = atomBondMap[ ai1 ]\n if (tmp !== undefined && tmp[ ai2 ] !== undefined) {\n bp.index = tmp[ ai2 ]\n const residueTypeBondIndex = r.residueType.getBondIndex(rai1, rai2)! // TODO\n // overwrite residueType bondOrder with value from existing bond\n bondOrders[ residueTypeBondIndex ] = bp.bondOrder\n } else {\n a1.index = ai1\n a2.index = ai2\n // only add bond if not already in bondStore\n bondStore.addBond(a1, a2, bondOrders[ i ])\n }\n }\n }\n\n // get RNA/DNA rung pseudo bonds\n const traceAtomIndex = r.residueType.traceAtomIndex\n const rungEndAtomIndex = r.residueType.rungEndAtomIndex\n if (traceAtomIndex !== -1 && rungEndAtomIndex !== -1) {\n a1.index = r.traceAtomIndex\n a2.index = r.rungEndAtomIndex\n rungBondStore.addBond(a1, a2)\n rungAtomSet.set(a1.index)\n rungAtomSet.set(a2.index)\n }\n })\n\n structure.atomSetDict.rung = rungAtomSet\n\n if (Debug) Log.timeEnd('calculateBondsWithin')\n}\n\nexport function calculateBondsBetween (structure: Structure, onlyAddBackbone = false, useExistingBonds = false) {\n if (Debug) Log.time('calculateBondsBetween')\n\n const bondStore = structure.bondStore\n const backboneBondStore = structure.backboneBondStore\n const backboneAtomSet = structure.getAtomSet(false)\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n if (backboneBondStore.count === 0) {\n backboneBondStore.resize(structure.residueStore.count)\n }\n\n function addBondIfConnected (rp1: ResidueProxy, rp2: ResidueProxy) {\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if ((useExistingBonds && ap1.hasBondTo(ap2)) || ap1.connectedTo(ap2)) {\n if (!onlyAddBackbone) {\n bondStore.addBond(ap1, ap2, 1) // assume single bond\n }\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n backboneBondStore.addBond(ap1, ap2)\n backboneAtomSet.set(ap1.index)\n backboneAtomSet.set(ap2.index)\n }\n }\n }\n\n structure.eachResidueN(2, addBondIfConnected)\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n\n // check for cyclic chains\n structure.eachChain(function (cp) {\n if (cp.residueCount === 0) return\n rp1.index = cp.residueOffset\n rp2.index = cp.residueOffset + cp.residueCount - 1\n addBondIfConnected(rp2, rp1)\n })\n\n structure.atomSetDict.backbone = backboneAtomSet\n\n if (!onlyAddBackbone) {\n if (Debug) Log.time('calculateBondsBetween inter')\n const spatialHash = structure.spatialHash\n structure.eachResidue(function (rp) {\n if (rp.backboneType === UnknownBackboneType && !rp.isWater()) {\n rp.eachAtom(function (ap) {\n if (ap.isMetal()) return\n spatialHash!.eachWithin(ap.x, ap.y, ap.z, 4, function (idx) { // TODO\n ap2.index = idx\n if (ap.modelIndex === ap2.modelIndex &&\n ap.residueIndex !== ap2.residueIndex &&\n !ap2.isMetal()\n ) {\n bondStore.addBondIfConnected(ap, ap2, 1) // assume single bond\n }\n })\n })\n }\n })\n if (Debug) Log.timeEnd('calculateBondsBetween inter')\n }\n\n if (Debug) Log.timeEnd('calculateBondsBetween')\n}\n\nexport function buildUnitcellAssembly (structure: Structure) {\n if (!structure.unitcell) return\n\n if (Debug) Log.time('buildUnitcellAssembly')\n\n const uc = structure.unitcell\n\n const structureCenterFrac = structure.center.clone().applyMatrix4(uc.cartToFrac)\n const centerFrac = structureCenterFrac.clone().floor()\n const symopDict: { [K: string]: Matrix4 } = getSymmetryOperations(uc.spacegroup)\n\n const centerFracSymop = new Vector3()\n const positionFracSymop = new Vector3()\n\n function getMatrixList (shift?: Vector3) {\n const matrixList: Matrix4[] = []\n\n Object.keys(symopDict).forEach(function (name) {\n const m = symopDict[ name ].clone()\n\n centerFracSymop.copy(structureCenterFrac).applyMatrix4(m).floor()\n positionFracSymop.setFromMatrixPosition(m)\n positionFracSymop.sub(centerFracSymop)\n positionFracSymop.add(centerFrac)\n\n if (shift) positionFracSymop.add(shift)\n\n m.setPosition(positionFracSymop)\n m.multiplyMatrices(uc.fracToCart, m)\n m.multiply(uc.cartToFrac)\n\n matrixList.push(m)\n })\n\n return matrixList\n }\n\n const unitcellAssembly = new Assembly('UNITCELL')\n const unitcellMatrixList = getMatrixList()\n const ncsMatrixList: Matrix4[] = []\n if (structure.biomolDict.NCS) {\n ncsMatrixList.push(\n new Matrix4(), ...structure.biomolDict.NCS.partList[ 0 ].matrixList\n )\n const ncsUnitcellMatrixList: Matrix4[] = []\n unitcellMatrixList.forEach(sm => {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n}\n\nclass PdbParser extends StructureParser {\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: number, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H') ? 1 : 0\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, 0, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, 1)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, 1)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}"],"names":["CullFaceNone","CullFaceBack","CullFaceFront","PCFShadowMap","PCFSoftShadowMap","VSMShadowMap","FrontSide","BackSide","DoubleSide","NoBlending","NormalBlending","AdditiveBlending","SubtractiveBlending","MultiplyBlending","CustomBlending","AddEquation","SubtractEquation","ReverseSubtractEquation","MinEquation","MaxEquation","ZeroFactor","OneFactor","SrcColorFactor","OneMinusSrcColorFactor","SrcAlphaFactor","OneMinusSrcAlphaFactor","DstAlphaFactor","OneMinusDstAlphaFactor","DstColorFactor","OneMinusDstColorFactor","SrcAlphaSaturateFactor","NeverDepth","AlwaysDepth","LessDepth","LessEqualDepth","EqualDepth","GreaterEqualDepth","GreaterDepth","NotEqualDepth","MultiplyOperation","MixOperation","AddOperation","NoToneMapping","LinearToneMapping","ReinhardToneMapping","CineonToneMapping","ACESFilmicToneMapping","CustomToneMapping","CubeReflectionMapping","CubeRefractionMapping","EquirectangularReflectionMapping","EquirectangularRefractionMapping","CubeUVReflectionMapping","CubeUVRefractionMapping","RepeatWrapping","ClampToEdgeWrapping","MirroredRepeatWrapping","NearestFilter","NearestMipmapNearestFilter","NearestMipmapLinearFilter","LinearFilter","LinearMipmapNearestFilter","LinearMipmapLinearFilter","UnsignedByteType","ByteType","ShortType","UnsignedShortType","IntType","UnsignedIntType","FloatType","HalfFloatType","UnsignedShort4444Type","UnsignedShort5551Type","UnsignedShort565Type","UnsignedInt248Type","AlphaFormat","RGBFormat","RGBAFormat","LuminanceFormat","LuminanceAlphaFormat","DepthFormat","DepthStencilFormat","RedFormat","RedIntegerFormat","RGFormat","RGIntegerFormat","RGBIntegerFormat","RGBAIntegerFormat","RGB_S3TC_DXT1_Format","RGBA_S3TC_DXT1_Format","RGBA_S3TC_DXT3_Format","RGBA_S3TC_DXT5_Format","RGB_PVRTC_4BPPV1_Format","RGB_PVRTC_2BPPV1_Format","RGBA_PVRTC_4BPPV1_Format","RGBA_PVRTC_2BPPV1_Format","RGB_ETC1_Format","RGB_ETC2_Format","RGBA_ETC2_EAC_Format","RGBA_ASTC_4x4_Format","RGBA_ASTC_5x4_Format","RGBA_ASTC_5x5_Format","RGBA_ASTC_6x5_Format","RGBA_ASTC_6x6_Format","RGBA_ASTC_8x5_Format","RGBA_ASTC_8x6_Format","RGBA_ASTC_8x8_Format","RGBA_ASTC_10x5_Format","RGBA_ASTC_10x6_Format","RGBA_ASTC_10x8_Format","RGBA_ASTC_10x10_Format","RGBA_ASTC_12x10_Format","RGBA_ASTC_12x12_Format","RGBA_BPTC_Format","SRGB8_ALPHA8_ASTC_4x4_Format","SRGB8_ALPHA8_ASTC_5x4_Format","SRGB8_ALPHA8_ASTC_5x5_Format","SRGB8_ALPHA8_ASTC_6x5_Format","SRGB8_ALPHA8_ASTC_6x6_Format","SRGB8_ALPHA8_ASTC_8x5_Format","SRGB8_ALPHA8_ASTC_8x6_Format","SRGB8_ALPHA8_ASTC_8x8_Format","SRGB8_ALPHA8_ASTC_10x5_Format","SRGB8_ALPHA8_ASTC_10x6_Format","SRGB8_ALPHA8_ASTC_10x8_Format","SRGB8_ALPHA8_ASTC_10x10_Format","SRGB8_ALPHA8_ASTC_12x10_Format","SRGB8_ALPHA8_ASTC_12x12_Format","LinearEncoding","sRGBEncoding","GammaEncoding","RGBEEncoding","LogLuvEncoding","RGBM7Encoding","RGBM16Encoding","RGBDEncoding","BasicDepthPacking","RGBADepthPacking","TangentSpaceNormalMap","ObjectSpaceNormalMap","KeepStencilOp","AlwaysStencilFunc","StaticDrawUsage","EventDispatcher","Object","assign","prototype","addEventListener","type","listener","undefined","this","_listeners","listeners","indexOf","push","hasEventListener","removeEventListener","listenerArray","index","splice","dispatchEvent","event","target","array","slice","i","l","length","call","_lut","toString","MathUtils","DEG2RAD","Math","PI","RAD2DEG","generateUUID","d0","random","d1","d2","d3","toUpperCase","clamp","value","min","max","euclideanModulo","n","m","mapLinear","x","a1","a2","b1","b2","lerp","y","t","smoothstep","smootherstep","randInt","low","high","floor","randFloat","randFloatSpread","range","degToRad","degrees","radToDeg","radians","isPowerOfTwo","ceilPowerOfTwo","pow","ceil","log","LN2","floorPowerOfTwo","setQuaternionFromProperEuler","q","a","b","c","order","cos","sin","c2","s2","c13","s13","c1_3","s1_3","c3_1","s3_1","set","console","warn","Vector2","Matrix3","elements","arguments","error","_canvas","defineProperties","width","get","height","isVector2","setScalar","scalar","setX","setY","setComponent","Error","getComponent","clone","constructor","copy","v","add","w","addVectors","addScalar","s","addScaledVector","sub","subVectors","subScalar","multiply","multiplyScalar","divide","divideScalar","applyMatrix3","e","clampScalar","minVal","maxVal","clampLength","round","roundToZero","negate","dot","cross","lengthSq","sqrt","manhattanLength","abs","normalize","angle","atan2","distanceTo","distanceToSquared","dx","dy","manhattanDistanceTo","setLength","alpha","lerpVectors","v1","v2","equals","fromArray","offset","toArray","fromBufferAttribute","attribute","getX","getY","rotateAround","center","isMatrix3","n11","n12","n13","n21","n22","n23","n31","n32","n33","te","identity","me","extractBasis","xAxis","yAxis","zAxis","setFromMatrix3Column","setFromMatrix4","multiplyMatrices","premultiply","ae","be","a11","a12","a13","a21","a22","a23","a31","a32","a33","b11","b12","b13","b21","b22","b23","b31","b32","b33","determinant","d","f","g","h","getInverse","matrix","throwOnDegenerate","t11","t12","t13","det","detInv","transpose","tmp","getNormalMatrix","matrix4","transposeIntoArray","r","setUvTransform","tx","ty","sx","sy","rotation","cx","cy","scale","rotate","theta","translate","ImageUtils","image","test","src","HTMLCanvasElement","canvas","document","createElementNS","context","getContext","ImageData","putImageData","drawImage","toDataURL","textureId","Texture","mapping","wrapS","wrapT","magFilter","minFilter","format","anisotropy","encoding","defineProperty","uuid","name","DEFAULT_IMAGE","mipmaps","DEFAULT_MAPPING","internalFormat","repeat","matrixAutoUpdate","generateMipmaps","premultiplyAlpha","flipY","unpackAlignment","version","onUpdate","Vector4","z","WebGLRenderTarget","options","scissor","scissorTest","viewport","texture","depthBuffer","stencilBuffer","depthTexture","Quaternion","_x","_y","_z","_w","create","isTexture","updateMatrix","source","toJSON","meta","isRootObject","textures","output","metadata","generator","wrap","images","url","Array","isArray","dispose","transformUv","uv","isVector4","setZ","setW","applyMatrix4","setAxisAngleFromQuaternion","acos","setAxisAngleFromRotationMatrix","epsilon","epsilon2","m11","m12","m13","m21","m22","m23","m31","m32","m33","xx","yy","zz","xy","xz","yz","getZ","getW","isWebGLRenderTarget","setSize","slerp","qa","qb","qm","slerpFlat","dst","dstOffset","src0","srcOffset0","src1","srcOffset1","x0","y0","z0","w0","x1","y1","z1","w1","dir","sqrSin","Number","EPSILON","len","tDir","multiplyQuaternionsFlat","_onChangeCallback","isQuaternion","quaternion","setFromEuler","euler","update","isEuler","c1","c3","s1","s3","setFromAxisAngle","axis","halfAngle","setFromRotationMatrix","trace","setFromUnitVectors","vFrom","vTo","angleTo","rotateTowards","step","inverse","conjugate","p","multiplyQuaternions","qax","qay","qaz","qaw","qbx","qby","qbz","qbw","cosHalfTheta","sqrSinHalfTheta","sinHalfTheta","halfTheta","ratioA","ratioB","_onChange","callback","_vector","Vector3","_quaternion","isVector3","multiplyVectors","applyEuler","applyQuaternion","applyAxisAngle","applyNormalMatrix","qx","qy","qz","qw","ix","iy","iz","iw","project","camera","matrixWorldInverse","projectionMatrix","unproject","projectionMatrixInverse","matrixWorld","transformDirection","crossVectors","ax","ay","az","bx","by","bz","projectOnVector","denominator","projectOnPlane","planeNormal","reflect","normal","dz","setFromSpherical","setFromSphericalCoords","radius","phi","sinPhiRadius","setFromCylindrical","setFromCylindricalCoords","setFromMatrixPosition","setFromMatrixScale","setFromMatrixColumn","sz","_v1","_m1","Matrix4","_zero","_one","isMatrix4","n14","n24","n34","n41","n42","n43","n44","copyPosition","makeBasis","extractRotation","scaleX","scaleY","scaleZ","makeRotationFromEuler","af","bf","ce","cf","de","df","ac","ad","bc","bd","makeRotationFromQuaternion","compose","lookAt","eye","up","a14","a24","a34","a41","a42","a43","a44","b14","b24","b34","b41","b42","b43","b44","setPosition","t14","getMaxScaleOnAxis","scaleXSq","scaleYSq","scaleZSq","makeTranslation","makeRotationX","makeRotationY","makeRotationZ","makeRotationAxis","makeScale","makeShear","position","x2","y2","z2","wx","wy","wz","decompose","invSX","invSY","invSZ","makePerspective","left","right","top","bottom","near","far","makeOrthographic","_matrix","Euler","DefaultOrder","_order","Layers","mask","RotationOrders","asin","setFromQuaternion","setFromVector3","reorder","newOrder","toVector3","optionalResult","channel","enable","enableAll","toggle","disable","disableAll","layers","_object3DId","_q1","_target","_position","_scale","_xAxis","_yAxis","_zAxis","_addedEvent","_removedEvent","Object3D","parent","children","DefaultUp","configurable","enumerable","modelViewMatrix","normalMatrix","DefaultMatrixAutoUpdate","matrixWorldNeedsUpdate","visible","castShadow","receiveShadow","frustumCulled","renderOrder","userData","Scene","background","environment","fog","overrideMaterial","autoUpdate","__THREE_DEVTOOLS__","CustomEvent","detail","isObject3D","onBeforeRender","onAfterRender","setRotationFromAxisAngle","setRotationFromEuler","setRotationFromMatrix","setRotationFromQuaternion","rotateOnAxis","rotateOnWorldAxis","rotateX","rotateY","rotateZ","translateOnAxis","distance","translateX","translateY","translateZ","localToWorld","vector","worldToLocal","updateWorldMatrix","isCamera","isLight","object","remove","attach","getObjectById","id","getObjectByProperty","getObjectByName","getWorldPosition","updateMatrixWorld","getWorldQuaternion","getWorldScale","getWorldDirection","raycast","traverse","traverseVisible","traverseAncestors","force","updateParents","updateChildren","geometries","materials","shapes","serialize","library","element","JSON","stringify","isInstancedMesh","count","instanceMatrix","isMesh","isLine","isPoints","geometry","parameters","shape","material","uuids","extractFromCache","cache","values","key","data","recursive","parse","child","isScene","_points","_box","Box3","_v0","_v2","_f0","_f1","_f2","_center","_extents","_triangleNormal","_testAxis","Infinity","satForAxes","axes","v0","extents","j","p0","p1","p2","isBox3","setFromArray","minX","minY","minZ","maxX","maxY","maxZ","setFromBufferAttribute","setFromPoints","points","makeEmpty","il","expandByPoint","setFromCenterAndSize","size","halfSize","setFromObject","expandByObject","box","isEmpty","getCenter","getSize","point","expandByVector","expandByScalar","boundingBox","computeBoundingBox","union","containsPoint","containsBox","getParameter","intersectsBox","intersectsSphere","sphere","clampPoint","intersectsPlane","plane","constant","intersectsTriangle","triangle","distanceToPoint","getBoundingSphere","intersect","Sphere","optionalCenter","maxRadiusSq","radiusSum","deltaLengthSq","getBoundingBox","_segCenter","_segDir","_diff","_edge1","_edge2","_normal","Ray","origin","direction","ray","at","recast","closestPointToPoint","directionDistance","distanceSqToPoint","distanceSqToSegment","optionalPointOnRay","optionalPointOnSegment","segExtent","a01","b0","s0","sqrDist","extDet","invDet","intersectSphere","tca","radius2","thc","t0","t1","distanceToPlane","intersectPlane","distToPoint","intersectBox","tmin","tmax","tymin","tymax","tzmin","tzmax","invdirx","invdiry","invdirz","intersectTriangle","backfaceCulling","sign","DdN","DdQxE2","DdE1xQ","QdN","_vector1","_vector2","_normalMatrix","Plane","isPlane","setComponents","setFromNormalAndCoplanarPoint","setFromCoplanarPoints","inverseNormalLength","distanceToSphere","projectPoint","intersectLine","line","delta","start","intersectsLine","startSign","endSign","end","coplanarPoint","optionalNormalMatrix","referencePoint","_v3","_vab","_vac","_vbc","_vap","_vbp","_vcp","Triangle","getNormal","targetLengthSq","getBarycoord","dot00","dot01","dot02","dot11","dot12","denom","invDenom","u","getUV","p3","uv1","uv2","uv3","isFrontFacing","setFromPointsAndIndices","i0","i1","i2","getArea","getMidpoint","getPlane","d4","vc","d5","d6","vb","va","_colorKeywords","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","_hslA","_hslB","Color","setRGB","hue2rgb","SRGBToLinear","LinearToSRGB","Face3","color","materialIndex","vertexNormals","isColor","vertexColors","setHex","setStyle","hex","setHSL","style","handleAlpha","string","parseFloat","exec","components","parseInt","charAt","setColorName","copyGammaToLinear","gammaFactor","copyLinearToGamma","safeInverse","convertGammaToLinear","convertLinearToGamma","copySRGBToLinear","copyLinearToSRGB","convertSRGBToLinear","convertLinearToSRGB","getHex","getHexString","getHSL","hue","saturation","lightness","getStyle","offsetHSL","addColors","color1","color2","lerpHSL","normalized","NAMES","materialId","Material","blending","side","flatShading","opacity","transparent","blendSrc","blendDst","blendEquation","blendSrcAlpha","blendDstAlpha","blendEquationAlpha","depthFunc","depthTest","depthWrite","stencilWriteMask","stencilFunc","stencilRef","stencilFuncMask","stencilFail","stencilZFail","stencilZPass","stencilWrite","clippingPlanes","clipIntersection","clipShadows","shadowSide","colorWrite","precision","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","dithering","alphaTest","premultipliedAlpha","toneMapped","MeshBasicMaterial","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","specularMap","alphaMap","envMap","combine","reflectivity","refractionRatio","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin","skinning","morphTargets","setValues","isMaterial","onBeforeCompile","customProgramCacheKey","newValue","currentValue","isRoot","roughness","metalness","sheen","emissive","emissiveIntensity","specular","shininess","clearcoat","clearcoatRoughness","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","clearcoatNormalScale","matcap","bumpMap","bumpScale","normalMap","normalMapType","normalScale","displacementMap","displacementScale","displacementBias","roughnessMap","metalnessMap","emissiveMap","envMapIntensity","gradientMap","sizeAttenuation","linewidth","dashSize","gapSize","morphNormals","srcPlanes","dstPlanes","isMeshBasicMaterial","BufferAttribute","itemSize","TypeError","usage","updateRange","Int8BufferAttribute","Int8Array","Uint8BufferAttribute","Uint8Array","Uint8ClampedBufferAttribute","Uint8ClampedArray","Int16BufferAttribute","Int16Array","Uint16BufferAttribute","Uint16Array","Int32BufferAttribute","Int32Array","Uint32BufferAttribute","Uint32Array","Float32BufferAttribute","Float32Array","Float64BufferAttribute","Float64Array","DirectGeometry","vertices","normals","colors","uvs","uvs2","groups","skinWeights","skinIndices","boundingSphere","verticesNeedUpdate","normalsNeedUpdate","colorsNeedUpdate","uvsNeedUpdate","groupsNeedUpdate","arrayMax","isBufferAttribute","onUploadCallback","setUsage","copyAt","index1","index2","copyArray","copyColorsArray","copyVector2sArray","vectors","copyVector3sArray","copyVector4sArray","setXY","setXYZ","setXYZW","onUpload","computeGroups","group","faces","face","fromGeometry","faceVertexUvs","hasFaceVertexUv","hasFaceVertexUv2","morphTargetsLength","morphTargetsPosition","morphNormalsLength","morphTargetsNormal","hasSkinIndices","hasSkinWeights","vertexUvs","morphTarget","morphNormal","_bufferGeometryId","_obj","_offset","_boxMorphTargets","BufferGeometry","attributes","morphAttributes","morphTargetsRelative","drawRange","isBufferGeometry","getIndex","setIndex","getAttribute","setAttribute","deleteAttribute","addGroup","clearGroups","setDrawRange","needsUpdate","tangent","computeBoundingSphere","positions","lineDistances","isGeometry","updateFromObject","direct","__directGeometry","elementsNeedUpdate","lineDistancesNeedUpdate","lineDistance","fromDirectGeometry","morphAttributesPosition","morphAttribute","isNaN","jl","computeFaceNormals","computeVertexNormals","positionAttribute","normalAttribute","pA","pB","pC","nA","nB","nC","cb","ab","vA","vB","vC","normalizeNormals","merge","attributeArray1","attribute2","attributeArray2","attributeOffset","toNonIndexed","convertBufferAttribute","indices","array2","geometry2","newAttribute","morphArray","keys","attributeData","hasMorphAttributes","attributeArray","_inverseMatrix","_ray","_sphere","_vA","_vB","_vC","_tempA","_tempB","_tempC","_morphA","_morphB","_morphC","_uvA","_uvB","_uvC","_intersectionPoint","_intersectionPointWorld","Mesh","updateMorphTargets","checkIntersection","raycaster","checkBufferGeometryIntersection","morphPosition","morphInfluences","morphTargetInfluences","influence","isSkinnedMesh","boneTransform","intersection","morphTargetDictionary","ml","String","intersects","groupMaterial","faceIndex","isMultiMaterial","fl","faceMaterial","fvA","fvB","fvC","uvs_f","_geometryId","Geometry","fromBufferGeometry","scope","addFace","areaWeighted","vl","computeFlatVertexNormals","computeMorphNormals","__originalFaceNormal","__originalVertexNormals","tmpGeo","faceNormals","dstNormalsFace","dstNormalsVertex","faceNormal","materialIndexOffset","vertexOffset","vertices1","vertices2","faces1","faces2","colors1","colors2","vertexCopy","faceCopy","faceVertexNormals","faceVertexColors","faceVertexUvs2","uvsCopy","k","kl","mergeMesh","mesh","mergeVertices","verticesMap","unique","changes","faceIndicesToRemove","idx","diff","sortFacesByMaterialIndex","_id","sort","uvs1","newUvs1","newUvs2","vertex","normalsHash","colorsHash","uvsHash","hasMaterial","hasFaceUv","hasFaceNormal","hasFaceVertexNormal","hasFaceColor","hasFaceVertexColor","faceType","setBit","getUvIndex","getNormalIndex","getColorIndex","enabled","hash","srcVertexNormal","destVertexNormal","BoxBufferGeometry","depth","widthSegments","heightSegments","depthSegments","super","numberOfVertices","groupStart","buildPlane","udir","vdir","gridX","gridY","segmentWidth","segmentHeight","widthHalf","heightHalf","depthHalf","gridX1","gridY1","vertexCounter","groupCount","cloneUniforms","property","mergeUniforms","uniforms","merged","UniformsUtils","default_vertex","default_fragment","ShaderMaterial","defines","vertexShader","fragmentShader","lights","clipping","extensions","derivatives","fragDepth","drawBuffers","shaderTextureLOD","defaultAttributeValues","index0AttributeName","uniformsNeedUpdate","Camera","PerspectiveCamera","fov","aspect","zoom","focus","view","filmGauge","filmOffset","updateProjectionMatrix","DataTexture","isShaderMaterial","isPerspectiveCamera","setFocalLength","focalLength","vExtentSlope","getFilmHeight","atan","getFocalLength","getEffectiveFOV","getFilmWidth","setViewOffset","fullWidth","fullHeight","offsetX","offsetY","clearViewOffset","skew","isDataTexture","Frustum","p4","p5","planes","frustum","setFromProjectionMatrix","me0","me1","me2","me3","me4","me5","me6","me7","me8","me9","me10","me11","me12","me13","me14","me15","intersectsObject","intersectsSprite","sprite","negRadius","UniformsLib","common","diffuse","uvTransform","uv2Transform","specularmap","envmap","flipEnvMap","maxMipLevel","aomap","lightmap","emissivemap","bumpmap","normalmap","displacementmap","roughnessmap","metalnessmap","gradientmap","fogDensity","fogNear","fogFar","fogColor","ambientLightColor","lightProbe","directionalLights","properties","directionalLightShadows","shadowBias","shadowNormalBias","shadowRadius","shadowMapSize","directionalShadowMap","directionalShadowMatrix","spotLights","coneCos","penumbraCos","decay","spotLightShadows","spotShadowMap","spotShadowMatrix","pointLights","pointLightShadows","shadowCameraNear","shadowCameraFar","pointShadowMap","pointShadowMatrix","hemisphereLights","skyColor","groundColor","rectAreaLights","WebGLAnimation","isAnimating","animationLoop","requestId","onAnimationFrame","time","frame","requestAnimationFrame","stop","cancelAnimationFrame","setAnimationLoop","setContext","WebGLAttributes","gl","capabilities","isWebGL2","buffers","WeakMap","isInterleavedBufferAttribute","deleteBuffer","buffer","delete","bufferType","createBuffer","bindBuffer","bufferData","bytesPerElement","BYTES_PER_ELEMENT","bufferSubData","subarray","updateBuffer","PlaneGeometry","PlaneBufferGeometry","width_half","height_half","segment_width","segment_height","ShaderChunk","alphamap_fragment","alphamap_pars_fragment","alphatest_fragment","aomap_fragment","aomap_pars_fragment","begin_vertex","beginnormal_vertex","bsdfs","bumpmap_pars_fragment","clipping_planes_fragment","clipping_planes_pars_fragment","clipping_planes_pars_vertex","clipping_planes_vertex","color_fragment","color_pars_fragment","color_pars_vertex","color_vertex","cube_uv_reflection_fragment","defaultnormal_vertex","displacementmap_pars_vertex","displacementmap_vertex","emissivemap_fragment","emissivemap_pars_fragment","encodings_fragment","encodings_pars_fragment","envmap_fragment","envmap_common_pars_fragment","envmap_pars_fragment","envmap_pars_vertex","envmap_physical_pars_fragment","envmap_vertex","fog_vertex","fog_pars_vertex","fog_fragment","fog_pars_fragment","gradientmap_pars_fragment","lightmap_fragment","lightmap_pars_fragment","lights_lambert_vertex","lights_pars_begin","lights_toon_fragment","lights_toon_pars_fragment","lights_phong_fragment","lights_phong_pars_fragment","lights_physical_fragment","lights_physical_pars_fragment","lights_fragment_begin","lights_fragment_maps","lights_fragment_end","logdepthbuf_fragment","logdepthbuf_pars_fragment","logdepthbuf_pars_vertex","logdepthbuf_vertex","map_fragment","map_pars_fragment","map_particle_fragment","map_particle_pars_fragment","metalnessmap_fragment","metalnessmap_pars_fragment","morphnormal_vertex","morphtarget_pars_vertex","morphtarget_vertex","normal_fragment_begin","normal_fragment_maps","normalmap_pars_fragment","clearcoat_normal_fragment_begin","clearcoat_normal_fragment_maps","clearcoat_pars_fragment","packing","premultiplied_alpha_fragment","project_vertex","dithering_fragment","dithering_pars_fragment","roughnessmap_fragment","roughnessmap_pars_fragment","shadowmap_pars_fragment","shadowmap_pars_vertex","shadowmap_vertex","shadowmask_pars_fragment","skinbase_vertex","skinning_pars_vertex","skinning_vertex","skinnormal_vertex","specularmap_fragment","specularmap_pars_fragment","tonemapping_fragment","tonemapping_pars_fragment","uv_pars_fragment","uv_pars_vertex","uv_vertex","uv2_pars_fragment","uv2_pars_vertex","uv2_vertex","worldpos_vertex","background_frag","background_vert","cube_frag","cube_vert","depth_frag","depth_vert","distanceRGBA_frag","distanceRGBA_vert","equirect_frag","equirect_vert","linedashed_frag","linedashed_vert","meshbasic_frag","meshbasic_vert","meshlambert_frag","meshlambert_vert","meshmatcap_frag","meshmatcap_vert","meshtoon_frag","meshtoon_vert","meshphong_frag","meshphong_vert","meshphysical_frag","meshphysical_vert","normal_frag","normal_vert","points_frag","points_vert","shadow_frag","shadow_vert","sprite_frag","sprite_vert","ShaderLib","basic","lambert","phong","standard","toon","dashed","totalSize","t2D","cube","equirect","tEquirect","distanceRGBA","referencePosition","nearDistance","farDistance","shadow","WebGLBackground","renderer","state","objects","clearColor","planeMesh","boxMesh","clearAlpha","currentBackground","currentBackgroundVersion","currentTonemapping","setClear","getClearColor","setClearColor","getClearAlpha","setClearAlpha","render","renderList","scene","forceClear","xr","session","getSession","environmentBlendMode","autoClear","clear","autoClearColor","autoClearDepth","autoClearStencil","isCubeTexture","isWebGLCubeRenderTarget","toneMapping","unshift","WebGLBindingStates","maxVertexAttributes","extension","vaoAvailable","bindingStates","defaultState","createBindingState","currentState","bindVertexArrayObject","vao","bindVertexArray","bindVertexArrayOES","deleteVertexArrayObject","deleteVertexArray","deleteVertexArrayOES","newAttributes","enabledAttributes","attributeDivisors","program","initAttributes","enableAttribute","enableAttributeAndDivisor","meshPerAttribute","enableVertexAttribArray","disableUnusedAttributes","disableVertexAttribArray","vertexAttribPointer","stride","vertexAttribIPointer","reset","resetDefaultState","setup","updateBuffers","programMap","stateMap","createVertexArray","createVertexArrayOES","getBindingState","cachedAttributes","geometryAttributes","cachedAttribute","geometryAttribute","saveCache","isInstancedBufferGeometry","programAttributes","getAttributes","materialDefaultAttributeValues","programAttribute","isInstancedInterleavedBuffer","_maxInstanceCount","isInstancedBufferAttribute","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","vertexAttrib1fv","setupVertexAttributes","geometryId","programId","releaseStatesOfGeometry","releaseStatesOfProgram","WebGLBufferRenderer","info","mode","setMode","drawArrays","renderInstances","primcount","methodName","WebGLCapabilities","maxAnisotropy","getMaxPrecision","getShaderPrecisionFormat","WebGL2RenderingContext","WebGL2ComputeRenderingContext","maxPrecision","logarithmicDepthBuffer","maxTextures","maxVertexTextures","maxTextureSize","maxCubemapSize","maxAttributes","maxVertexUniforms","maxVaryings","maxFragmentUniforms","vertexTextures","floatFragmentTextures","getMaxAnisotropy","MAX_TEXTURE_MAX_ANISOTROPY_EXT","floatVertexTextures","maxSamples","WebGLClipping","globalState","numGlobalPlanes","localClippingEnabled","renderingShadows","viewNormalMatrix","uniform","resetGlobalState","numPlanes","numIntersection","projectPlanes","skipTransform","nPlanes","dstArray","flatSize","viewMatrix","i4","init","enableLocalClipping","beginShadows","endShadows","setState","fromCache","nGlobal","lGlobal","clippingState","WebGLExtensions","getExtension","WebGLGeometries","wireframeAttributes","onGeometryDispose","buffergeometry","memory","updateWireframeAttribute","geometryIndex","geometryPosition","previousAttribute","_bufferGeometry","getWireframeAttribute","currentAttribute","WebGLIndexedBufferRenderer","drawElements","WebGLInfo","calls","triangles","lines","programs","autoReset","instanceCount","numericalSort","absNumericalSort","WebGLMorphtargets","influencesList","workInfluences","objectInfluences","influences","MAX_SAFE_INTEGER","morphInfluencesSum","morphBaseInfluence","getUniforms","setValue","WebGLObjects","updateMap","CubeTexture","DataTexture2DArray","wrapR","DataTexture3D","physical","transparency","isDataTexture2DArray","isDataTexture3D","emptyTexture","emptyTexture2dArray","emptyTexture3d","emptyCubeTexture","arrayCacheF32","arrayCacheI32","mat4array","mat3array","mat2array","flatten","nBlocks","blockSize","firstElem","arraysEqual","allocTexUnits","allocateTextureUnit","setValueV1f","uniform1f","addr","setValueV2f","uniform2f","uniform2fv","setValueV3f","uniform3f","uniform3fv","setValueV4f","uniform4f","uniform4fv","setValueM2","uniformMatrix2fv","setValueM3","uniformMatrix3fv","setValueM4","uniformMatrix4fv","setValueT1","unit","uniform1i","safeSetTexture2D","setValueT2DArray1","setTexture2DArray","setValueT3D1","setTexture3D","setValueT6","safeSetTextureCube","setValueV1i","setValueV2i","uniform2iv","setValueV3i","uniform3iv","setValueV4i","uniform4iv","setValueV1ui","uniform1ui","setValueV1fArray","uniform1fv","setValueV1iArray","uniform1iv","setValueV2iArray","setValueV3iArray","setValueV4iArray","setValueV2fArray","setValueV3fArray","setValueV4fArray","setValueM2Array","setValueM3Array","setValueM4Array","setValueT1Array","units","setValueT6Array","SingleUniform","activeInfo","getSingularSetter","PureArrayUniform","getPureArraySetter","StructuredUniform","seq","updateCache","RePathPart","addUniform","container","uniformObject","parseUniform","path","pathLength","lastIndex","match","matchEnd","idIsIndex","subscript","next","WebGLUniforms","getProgramParameter","getActiveUniform","getUniformLocation","WebGLShader","shader","createShader","shaderSource","compileShader","setOptional","upload","seqWithValue","programIdCount","getEncodingComponents","getShaderErrors","status","getShaderParameter","getShaderInfoLog","trim","split","join","addLineNumbers","getShaderSource","getTexelDecodingFunction","functionName","getTexelEncodingFunction","getToneMappingFunction","toneMappingName","filterEmptyLine","replaceLightNums","replace","numDirLights","numSpotLights","numRectAreaLights","numPointLights","numHemiLights","numDirLightShadows","numSpotLightShadows","numPointLightShadows","replaceClippingPlaneNums","numClippingPlanes","numClipIntersection","includePattern","resolveIncludes","includeReplacer","include","deprecatedUnrollLoopPattern","unrollLoopPattern","unrollLoops","loopReplacer","deprecatedLoopReplacer","snippet","generatePrecision","precisionstring","WebGLProgram","cacheKey","shadowMapTypeDefine","shadowMapType","generateShadowMapTypeDefine","envMapTypeDefine","envMapMode","generateEnvMapTypeDefine","envMapModeDefine","generateEnvMapModeDefine","envMapBlendingDefine","generateEnvMapBlendingDefine","gammaFactorDefine","customExtensions","extensionDerivatives","envMapCubeUV","tangentSpaceNormalMap","shaderID","extensionFragDepth","rendererExtensionFragDepth","extensionDrawBuffers","rendererExtensionDrawBuffers","extensionShaderTextureLOD","rendererExtensionShaderTextureLod","filter","generateExtensions","customDefines","chunks","generateDefines","createProgram","prefixVertex","prefixFragment","isRawShaderMaterial","shaderName","instancing","supportsVertexTextures","maxBones","useFog","fogExp2","objectSpaceNormalMap","vertexTangents","uvsVertexOnly","useVertexTexture","doubleSided","flipSided","shadowMapEnabled","physicallyCorrectLights","mapEncoding","matcapEncoding","envMapEncoding","emissiveMapEncoding","lightMapEncoding","outputEncoding","depthPacking","isGLSL3ShaderMaterial","versionRegex","fragmentGlsl","glVertexShader","glFragmentShader","attachShader","bindAttribLocation","linkProgram","debug","checkShaderErrors","programLog","getProgramInfoLog","vertexLog","fragmentLog","runnable","haveDiagnostics","vertexErrors","fragmentErrors","getError","diagnostics","prefix","cachedUniforms","deleteShader","getActiveAttrib","getAttribLocation","fetchAttributeLocations","destroy","deleteProgram","usedTimes","WebGLPrograms","shaderIDs","MeshDepthMaterial","MeshDistanceMaterial","MeshNormalMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial","MeshStandardMaterial","MeshPhysicalMaterial","MeshMatcapMaterial","LineBasicMaterial","LineDashedMaterial","PointsMaterial","ShadowMaterial","SpriteMaterial","parameterNames","getTextureEncodingFromMap","getParameters","shadows","nClipPlanes","nClipIntersection","isMeshStandardMaterial","bones","skeleton","nVertexUniforms","nVertexMatrices","allocateBones","shaderobject","getShaderObject","currentRenderTarget","getRenderTarget","isFogExp2","maxMorphTargets","maxMorphNormals","directional","spot","rectArea","hemi","shadowMap","getProgramCacheKey","acquireProgram","pl","preexistingProgram","releaseProgram","pop","WebGLProperties","painterSortStable","groupOrder","reversePainterSortStable","WebGLRenderList","renderItems","renderItemsIndex","opaque","defaultProgram","getNextRenderItem","renderItem","finish","customOpaqueSort","customTransparentSort","WebGLRenderLists","lists","onSceneDispose","cameras","list","UniformsCache","light","halfWidth","halfHeight","nextVersion","shadowCastingLightsFirst","lightA","lightB","WebGLLights","shadowCache","ShadowUniformsCache","directionalLength","pointLength","spotLength","rectAreaLength","hemiLength","numDirectionalShadows","numPointShadows","numSpotShadows","ambient","probe","directionalShadow","spotShadow","pointShadow","vector3","matrix42","intensity","isAmbientLight","isLightProbe","sh","coefficients","isDirectionalLight","shadowUniforms","bias","normalBias","mapSize","isSpotLight","penumbra","isRectAreaLight","isPointLight","isHemisphereLight","WebGLRenderState","lightsArray","shadowsArray","setupLights","pushLight","pushShadow","shadowLight","WebGLRenderStates","renderStates","renderState","has","isMeshDepthMaterial","isMeshDistanceMaterial","vsm_frag","vsm_vert","WebGLShadowMap","_renderer","_objects","_frustum","_shadowMapSize","_viewportSize","_viewport","_depthMaterials","_distanceMaterials","_materialCache","shadowMaterialVertical","SAMPLE_RATE","HALF_SAMPLE_RATE","shadow_pass","resolution","shadowMaterialHorizonal","HORIZONAL_PASS","fullScreenTri","fullScreenMesh","VSMPass","setRenderTarget","mapPass","renderBufferDirect","getDepthMaterialVariant","useMorphing","useSkinning","useInstancing","getDistanceMaterialVariant","getDepthMaterial","result","getMaterialVariant","customMaterial","customDepthMaterial","customDistanceMaterial","keyA","keyB","materialsForVariant","cachedMaterial","renderObject","shadowCamera","depthMaterial","activeCubeFace","getActiveCubeFace","activeMipmapLevel","getActiveMipmapLevel","_state","setBlending","setTest","setScissorTest","shadowFrameExtents","getFrameExtents","isPointLightShadow","pars","viewportCount","getViewportCount","vp","getViewport","updateMatrices","getFrustum","WebGLState","colorBuffer","locked","currentColorMask","currentColorClear","setMask","colorMask","setLocked","lock","currentDepthMask","currentDepthFunc","currentDepthClear","depthMask","setFunc","clearDepth","currentStencilMask","currentStencilFunc","currentStencilRef","currentStencilFuncMask","currentStencilFail","currentStencilZFail","currentStencilZPass","currentStencilClear","stencilTest","stencilMask","setOp","stencilOp","stencil","clearStencil","enabledCapabilities","currentProgram","currentBlendingEnabled","currentBlending","currentBlendEquation","currentBlendSrc","currentBlendDst","currentBlendEquationAlpha","currentBlendSrcAlpha","currentBlendDstAlpha","currentPremultipledAlpha","currentFlipSided","currentCullFace","currentLineWidth","currentPolygonOffsetFactor","currentPolygonOffsetUnits","lineWidthAvailable","glVersion","currentTextureSlot","currentBoundTextures","currentScissor","currentViewport","createTexture","bindTexture","texParameteri","texImage2D","emptyTextures","setFlipSided","setCullFace","equationToGL","MIN_EXT","MAX_EXT","factorToGL","blendEquationSeparate","blendFuncSeparate","blendFunc","frontFace","cullFace","setPolygonOffset","factor","activeTexture","webglSlot","useProgram","setMaterial","frontFaceCW","setLineWidth","lineWidth","webglType","webglTexture","boundTexture","unbindTexture","compressedTexImage2D","apply","texImage3D","WebGLTextures","_gl","utils","_videoTextures","useOffscreenCanvas","OffscreenCanvas","err","createCanvas","resizeImage","needsPowerOfTwo","needsNewCanvas","maxSize","HTMLImageElement","ImageBitmap","textureNeedsGenerateMipmaps","supportsMips","generateMipmap","__maxMipLevel","LOG2E","getInternalFormat","internalFormatName","glFormat","glType","filterFallback","onTextureDispose","textureProperties","__webglInit","deleteTexture","__webglTexture","deallocateTexture","isVideoTexture","onRenderTargetDispose","renderTarget","renderTargetProperties","deleteFramebuffer","__webglFramebuffer","__webglDepthbuffer","deleteRenderbuffer","__webglMultisampledFramebuffer","__webglColorRenderbuffer","__webglDepthRenderbuffer","deallocateRenderTarget","textureUnits","setTexture2D","slot","updateVideoTexture","__version","complete","uploadTexture","setTextureCube","initTexture","pixelStorei","isCompressed","isCompressedTexture","cubeImage","convert","glInternalFormat","setTextureParameters","mipmap","mipmapImage","setTextureCubeDynamic","wrappingToGL","filterToGL","textureType","__currentAnisotropy","texParameterf","TEXTURE_MAX_ANISOTROPY_EXT","textureNeedsPowerOfTwo","isDepthTexture","setupFrameBufferTexture","framebuffer","attachment","textureTarget","bindFramebuffer","framebufferTexture2D","setupRenderBufferStorage","renderbuffer","isMultisample","bindRenderbuffer","samples","getRenderTargetSamples","renderbufferStorageMultisample","renderbufferStorage","framebufferRenderbuffer","setupDepthRenderbuffer","isCube","webglDepthTexture","setupDepthTexture","createRenderbuffer","isWebGLMultisampleRenderTarget","warnedTexture2D","warnedTextureCube","textureUnit","resetTextureUnits","setupRenderTarget","createFramebuffer","updateRenderTargetMipmap","updateMultisampleRenderTarget","blitFramebuffer","WebGLUtils","HALF_FLOAT_OES","COMPRESSED_RGB_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT3_EXT","COMPRESSED_RGBA_S3TC_DXT5_EXT","COMPRESSED_RGB_PVRTC_4BPPV1_IMG","COMPRESSED_RGB_PVRTC_2BPPV1_IMG","COMPRESSED_RGBA_PVRTC_4BPPV1_IMG","COMPRESSED_RGBA_PVRTC_2BPPV1_IMG","COMPRESSED_RGB_ETC1_WEBGL","COMPRESSED_RGB8_ETC2","COMPRESSED_RGBA8_ETC2_EAC","UNSIGNED_INT_24_8_WEBGL","ArrayCamera","Group","WebXRController","_targetRay","_grip","WebXRManager","framebufferScaleFactor","referenceSpace","referenceSpaceType","pose","controllers","inputSourcesMap","Map","cameraL","cameraR","cameraVR","_currentDepthNear","_currentDepthFar","onSessionEvent","controller","inputSource","onSessionEnd","forEach","disconnect","setFramebuffer","animation","isPresenting","onRequestReferenceSpace","updateInputSources","inputSources","removed","added","getController","getTargetRaySpace","getControllerGrip","getGripSpace","setFramebufferScaleFactor","setReferenceSpaceType","getReferenceSpace","setSession","getContextAttributes","xrCompatible","makeXRCompatible","layerInit","antialias","baseLayer","XRWebGLLayer","updateRenderState","requestReferenceSpace","then","cameraLPos","cameraRPos","updateCamera","getCamera","depthNear","depthFar","ipd","projL","projR","topFov","bottomFov","leftFov","rightFov","zOffset","xOffset","near2","far2","left2","right2","top2","bottom2","setProjectionFromUnion","onAnimationFrameCallback","getViewerPose","views","cameraVRNeedsUpdate","transform","WebGLMaterials","refreshUniformsCommon","uvScaleMap","uv2ScaleMap","refreshUniformsStandard","refreshFogUniforms","isFog","density","refreshMaterialUniforms","pixelRatio","isMeshLambertMaterial","refreshUniformsLambert","isMeshToonMaterial","refreshUniformsToon","isMeshPhongMaterial","refreshUniformsPhong","isMeshPhysicalMaterial","refreshUniformsPhysical","isMeshMatcapMaterial","refreshUniformsMatcap","refreshUniformsDepth","refreshUniformsDistance","isMeshNormalMaterial","refreshUniformsNormal","isLineBasicMaterial","refreshUniformsLine","isLineDashedMaterial","refreshUniformsDash","isPointsMaterial","refreshUniformsPoints","isSpriteMaterial","refreshUniformsSprites","isShadowMaterial","WebGLRenderer","_context","_alpha","_depth","_stencil","_antialias","_premultipliedAlpha","_preserveDrawingBuffer","preserveDrawingBuffer","_powerPreference","powerPreference","_failIfMajorPerformanceCaveat","failIfMajorPerformanceCaveat","currentRenderList","currentRenderState","domElement","sortObjects","toneMappingExposure","_this","_isContextLost","_framebuffer","_currentActiveCubeFace","_currentActiveMipmapLevel","_currentRenderTarget","_currentFramebuffer","_currentMaterialId","_currentCamera","_currentArrayCamera","_currentViewport","_currentScissor","_currentScissorTest","_width","_height","_pixelRatio","_opaqueSort","_transparentSort","_scissor","_scissorTest","_clipping","_clippingEnabled","_localClippingEnabled","_projScreenMatrix","_vector3","_emptyScene","getTargetPixelRatio","programCache","renderLists","morphtargets","bufferRenderer","indexedBufferRenderer","contextNames","contextAttributes","contextName","onContextLost","onContextRestore","isWebGL1Renderer","shift","rangeMin","rangeMax","message","initGLContext","preventDefault","onMaterialDispose","releaseMaterialProgramReference","deallocateMaterial","programInfo","forceContextLoss","loseContext","forceContextRestore","restoreContext","getPixelRatio","setPixelRatio","updateStyle","setViewport","getDrawingBufferSize","setDrawingBufferSize","getCurrentViewport","getScissor","setScissor","getScissorTest","boolean","setOpaqueSort","method","setTransparentSort","bits","renderBufferImmediate","hasPositions","hasNormals","hasUvs","hasColors","setProgram","rangeFactor","dataCount","rangeStart","rangeCount","drawStart","drawEnd","drawCount","isLineSegments","isLineLoop","isSprite","compile","compiled","material2","initMaterial","projectObject","isGroup","isLOD","isImmediateRenderObject","renderObjects","isArrayCamera","camera2","renderObjectImmediate","materialProperties","lightsStateVersion","programCacheKey","programChange","numSupportedMorphTargets","numSupportedMorphNormals","needsLights","materialNeedsLights","progUniforms","uniformsList","useCache","refreshProgram","refreshMaterial","refreshLights","p_uniforms","m_uniforms","uCamPos","cameraPosition","isOrthographicCamera","boneTexture","boneMatrices","boneTextureSize","ltc_1","LTC_1","ltc_2","LTC_2","window","opaqueObjects","transparentObjects","readRenderTargetPixels","activeCubeFaceIndex","restore","textureFormat","checkFramebufferStatus","readPixels","copyFramebufferToTexture","level","levelScale","copyTexImage2D","copyTextureToTexture","srcTexture","dstTexture","texSubImage2D","compressedTexSubImage2D","Fog","linecap","linejoin","inputPose","gripPose","targetRay","grip","getPose","targetRaySpace","gripSpace","_start","_end","Line","computeLineDistances","threshold","params","localThreshold","localThresholdSq","vStart","vEnd","interSegment","interRay","nbVertices","LineSegments","Points","testPoint","rayPointDistanceSq","intersectPoint","distanceToRay","CanvasTexture","PolyhedronGeometry","PolyhedronBufferGeometry","vertexBuffer","uvBuffer","subdivideFace","cols","aj","bj","rows","pushVertex","getVertexByIndex","correctUV","azimuth","subdivide","applyRadius","centroid","uvA","uvB","uvC","azi","correctUVs","correctSeam","generateUVs","TetrahedronGeometry","TetrahedronBufferGeometry","OctahedronGeometry","OctahedronBufferGeometry","IcosahedronGeometry","IcosahedronBufferGeometry","TorusGeometry","tube","radialSegments","tubularSegments","arc","TorusBufferGeometry","CylinderGeometry","radiusTop","radiusBottom","openEnded","thetaStart","thetaLength","CylinderBufferGeometry","indexArray","generateCap","centerIndexStart","centerIndexEnd","cosTheta","sinTheta","slope","indexRow","generateTorso","ConeGeometry","ConeBufferGeometry","Light","LightShadow","_frameExtents","_viewportCount","_viewports","SpotLightShadow","SpotLight","power","OrthographicCamera","AmbientLight","isCanvasTexture","_lightPositionWorld","_lookTarget","shadowMatrix","projScreenMatrix","lookTarget","lightPositionWorld","viewportIndex","isSpotLightShadow","scaleW","scaleH","_eyeRight","_eyeLeft","StereoCamera","eyeSep","_cache","Uniform","getQuery","RegExp","location","search","decodeURIComponent","defaults","defaultValue","createParams","defaultParams","o","updateParams","newParams","getProtocol","protocol","getBrowser","ua","navigator","userAgent","openUrl","open","href","download","downloadName","isSafari","isChromeIos","createElement","str","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","readAsDataURL","objectUrlCreated","URL","createObjectURL","display","body","appendChild","click","removeChild","revokeObjectURL","lexicographicCompare","elm1","elm2","binarySearchIndexOf","compareFunction","mid","cmp","rangeInSortedArray","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sorted","uint8ToString","u8a","chunkSize","fromCharCode","getTypedArray","arrayType","arraySize","getUintArray","sizeOrArray","maxUint","ensureBuffer","ArrayBuffer","_ensureClassFromArray","ensureVector3","ensureMatrix4","ensureQuaternion","ensureFloat32Array","arg","toLowerCaseString","toLowerCase","eyeSepHalf","eyeSepOnProjection","ymax","xmin","xmax","Registry","_dict","names","deg","chars","rnd","spline","tension","t2","LAB_CONSTANTS","PITHIRD","TWOPI","_average_lrgb","_guess_formats","_guess_formats_sorted","_input","_interpolators","bezier","blend","blend_f","brewer","burn","chroma","clip_rgb","cmyk2rgb","css2rgb","darken","dodge","each","hcg2rgb","hex2rgb","hsi2rgb","hsl2css","hsl2rgb","hsv2rgb","interpolate","interpolate_hsx","interpolate_lab","interpolate_lrgb","interpolate_num","interpolate_rgb","lab2lch","lab2rgb","lab_xyz","lch2lab","lch2rgb","lighten","limit","luminance_x","num2rgb","overlay","rgb2cmyk","rgb2css","rgb2hcg","rgb2hex","rgb2hsi","rgb2hsl","rgb2hsv","rgb2lab","rgb2lch","rgb2luminance","rgb2num","rgb2temperature","rgb2xyz","rgb_xyz","screen","temperature2rgb","unpack","w3cx11","xyz_lab","xyz_rgb","classToType","ref","obj","strType","args","rgb","_clipped","_unclipped","func","ctor","module","exports","chk","len1","_rgb","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set2","Accent","Set1","Set3","Dark2","Paired","Pastel2","Pastel1","results","cornflower","laserlemon","lightgoldenrod","maroon2","maroon3","purple2","purple3","Yn","Xn","Zn","Kn","t3","ref1","lab","concat","I","I0","I1","lab0","lab1","lab2","lab3","ref2","cubehelix","rotations","gamma","dh","dl","fract","amp","cos_a","sin_a","code","col1","col2","interpol","res","mix","rgba","lrgb","xyz0","xyz1","xyz","average","A","cnt","first","xyz2","substr","css","channels","hxa","NaN","hsl","ref3","ref4","ref5","hsv","num","_c","_g","hcg","aa","named","L","lch","hcl","reverse","cmyk","luminance","lum","cur_lum","max_iter","lm","kelvin","temp","maxTemp","minTemp","temperature","K","contrast","l1","l2","sum_sq","deltaE","C","L1","L2","c4","delA","delB","delC","h1","sc","sl","v3","modechan","clipped","amount","brighten","darker","brighter","saturate","desaturate","c0","out","analyze","val","MAX_VALUE","sum","domain","limits","_classes","_colorCache","_colors","_correctLightness","_domain","_gamma","_max","_min","_mode","_nacol","_out","_padding","_pos","_spread","_useCache","getClass","getColor","resetCache","setColors","tmap","col","bypassMap","classes","_m","_o","spread","correctLightness","L0","L_actual","L_diff","L_ideal","pol","padding","numColors","dd","dm","nodata","scales","cool","hot","visit","ag","ah","ai","ak","al","am","assignments","best","centroids","cluster","clusterSizes","dist","kClusters","max_log","min_log","mindist","nb_iters","newCentroids","pb","pr","ref10","ref11","ref12","ref13","ref14","ref6","ref7","ref8","ref9","tmpKMeansBreaks","LOG10E","hsi","hue0","hue1","lbv0","lbv1","sat","sat0","sat1","n1","n2","colorSpace","ScaleDefaultParameters","tmpColor","manageColor","_name","descriptor","originalMethod","fromTo","bind","Colormaker","structure","atomProxy","getAtomProxy","getScale","chroma\n .scale","colorToArray","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","global","SignalBinding","signal","isOnce","listenerContext","priority","_listener","_isOnce","_signal","_priority","validateListener","fnName","Signal","_bindings","_prevParams","self","dispatch","active","execute","paramsArr","handlerReturn","detach","isBound","getListener","getSignal","_destroy","VERSION","memorize","_shouldPropagate","_registerListener","binding","prevIndex","_indexOfListener","_addBinding","cur","addOnce","removeAll","getNumListeners","halt","bindings","forget","signals","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","rules","subTests","hasOwnProperty","and","operator","na","ret","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","stringChanged","setString","silent","retSelection","newSelection","oldSelection","selectionStack","createNewContext","getPrevContext","pushRule","rule","not","cu","lastRule","indexList","resnameList","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","isAllSelection","isNoneSelection","SelectionColormaker","colormakerList","selectionList","dataList","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","rainbow","rwb","ColormakerModes","getWorkerDeps","vars","deps","sym","__deps","makeWorkerString","onmessage","__name","postId","__postId","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","Function","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","labelUnit","arcVisible","planeVisible","Debug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","ListingDatasource","TrajectoryDatasource","Streamer","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","decompressFn","_chunk","chunk","peekLines","charCodeAt","chunkToLines","chunkCount","asText","partialLine","isLast","lastIndexOf","str2","nextChunk","nextChunkOfLines","eachChunk","eachChunkOfLines","chunkNo","FileStreamer","Promise","resolve","reject","file","onload","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","response","statusText","responseType","send","Loader","ext","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","load","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","re","not_string","not_bool","not_type","not_primitive","number","numeric_arg","not_json","text","modulo","placeholder","key_access","index_access","sprintf","parse_tree","argv","ph","pad","pad_character","pad_length","is_positive","cursor","tree_length","param_no","toExponential","toFixed","toPrecision","valueOf","pad_char","align","sprintf_format","fmt","sprintf_cache","_fmt","arg_names","SyntaxError","field_list","replacement_field","field_match","sprintf_parse","vsprintf","Writer","getBlob","getData","mimeType","defaultName","defaultExt","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","Counter","countChanged","signalsWrapper.Signal","change","increment","decrement","listen","counter","unlisten","onZeroOnce","Stats","updated","maxDuration","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","startTime","currentTime","performance","now","reInclude","shaderCache","getShader","definesText","getDefines","shaderText","WebGLRenderingContext","wrcp","_getShaderParameter","_getShaderInfoLog","_getProgramParameter","pname","LINK_STATUS","_getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","viewer","_viewer","_factor","_onProgress","onProgress","_onFinish","onFinish","_n","_ctx","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","_finalize","renderAsync","setTimeout","TwoPI","circularMean","cosMean","sinMean","calculateCenterArray","array1","calculateDirectionArray","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","srcOffset","copyWithin","arrayMin","arraySum","arrayMean","ImageDefaultParameters","makeImage","originalClearAlpha","backgroundColor","setLineWidthAndPixelSize","invert","__seen","trimCanvas","bg","canvasHeight","canvasWidth","pixels","getImageData","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","requestRender","modelViewProjectionMatrix","projectionMatrixTranspose","updateCameraUniforms","loadShader","shaderType","COMPILE_STATUS","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","attrib","positionLocation","colorLoc","positionBuffer","ARRAY_BUFFER","STATIC_DRAW","FLOAT","whiteTex","whiteData","TEXTURE_2D","RGBA","UNSIGNED_BYTE","tex","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","FRAMEBUFFER","COLOR_ATTACHMENT0","FRAMEBUFFER_COMPLETE","TRIANGLES","COLOR_BUFFER_BIT","pixel","floatPixel","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","pu","Viewer","idOrElement","boundingBoxSize","boundingBoxLength","distVector","ticked","rendered","elm","getElementById","HTMLElement","innerWidth","innerHeight","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","perspectiveCamera","orthographicCamera","stereoCamera","stats","rotationGroup","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","spotLight","ambientLight","dpr","devicePixelRatio","innerHTML","supportsHalfFloat","dprWidth","dprHeight","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","sampleTarget","holdTarget","compositeUniforms","tForeground","compositeMaterial","compositeCamera","compositeScene","bbGeometry","bbMaterial","uColor","boundingBoxMesh","updateHelper","cameraDistance","instanceList","instance","addBuffer","wireframeGroup","pickable","setUserData","getMesh","wireframeMesh","getWireframeMesh","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","updateGeometry","geoBoundingBox","updateNode","node","getPickingPixels","imgBuffer","getImage","picking","imgBuffer2","ctx","imgData","setLight","setOutputEncoding","setColorWorkflow","setCamera","updateZoom","setClip","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","pick","pid","picker","pixelBuffer","oid","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","ortho","nearClip","updateMaterialUniforms","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","bi","arr","stack","sp","swap","tmp2","quicksortCmp","attr","sortProjectedPosition","__setVisibility","helper","__updateLights","__renderPickingGroup","__renderModelGroup","__renderSuperSample","baseSampleWeight","sampleWeight","__renderStereo","_renderTarget","__render","lastRenderedPicking","rendering","getTouchDistance","touches","pageX","pageY","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","lastTouchDistance","touchDistance","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","_getRotateXY","_getCameraRotation","_transformPanVector","pan","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","applyMatrix","zRotate","rotateComponent","tmpVec","PickingProxy","pickingData","getComponentsByObject","getObject","getPosition","closestBondAtom","atom1","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","getMaxRepresentationRadius","arrow","_objectIfType","cone","clash","contact","cylinder","ellipsoid","octahedron","tetrahedron","torus","surface","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","serial","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","getCameraDistance","getOrientation","orient","spin","basis","Animation","duration","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","AnimationControls","animationList","finishedList","rock","move","zoomMove","orientTo","timeout","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","kill","Representation","lazy","clipRadius","clipCenter","flatShaded","front","back","double","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","disableImpostor","getColorParams","getBufferParams","prepare","updateWhat","_make","manualAttach","disposed","setVisibility","noRenderRequest","updateParameters","int","float","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","rad","getFixedLengthWrappedDashData","remaining","drawing","k3","kprev","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","addFeature","features","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","calcAngles","ap1","ap2","angles","eachBondedAtom","calcPlaneAngle","v12","neighbours","ni","ValenceModel","atomCount","charge","implicitH","totalH","idealGeometry","eachAtom","chg","implH","totH","geom","hydrogenCount","bondToElementCount","formalCharge","assignCharge","assignH","degree","bondCount","valence","eachBond","bondOrder","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","hetero","flag","getOtherAtom","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","ap","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","atoms","getOffset","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","contactColor","ContactPicker","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","bp","center1","center2","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_contour","_wrap","vIndexLength","Matrix","copyTo","At","nrows","ncols","Ai","Ati","pAt","atd","multiplyABt","Ap","Cp","mrows","cd","multiply3x3","Cd","Ad","Bd","m10","m14","m15","m16","m17","m18","m20","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","hypot","FLT_MIN","svd","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","sd","beta","seed","val0","asum","JacobiSVDImpl","m4new","m4set","m4multiply","m4makeScale","m4makeTranslation","m4makeRotationY","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","nv3","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","tmpSize","tran","mroty","mscale","mtrans","Surface","geo","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","getAtomindex","VolumeSurface","mc","getSurface","smooth","volsurf","Volume","inverseMatrix","setData","setAtomindex","_mean","_rms","setStats","rms","setMatrix","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","setObjectMatrix","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","dynamic","wireframeIndexCount","defaultParameters","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","DYNAMIC_DRAW","makeMaterial","wm","pm","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","checkEdge","updateWireframeIndex","getRenderOrder","_getMesh","materialName","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","wu","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","getFocus","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","fontFamily","_clientRect","getVisibility","cr","zIndex","ComponentControls","RadiusFactoryTypes","covalent","bfactor","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","getRotationQuaternion","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","getAtomIndexByType","a3","a4","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","parentN","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","occupancy","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","modelStore","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","isIdentity","structureChainList","eachChain","partBox","getSelection","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","eachModel","chainnamesSorted","chainnamesIndex","helices","h2","helix","helixRun","chainChange","sheets","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","ModelProxy","chainEnd","_cp","Structure","refreshed","title","extraData","atomSetCache","boxes","bondSet","finalizeAtoms","finalizeBonds","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","getChainnameCount","Set","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","applyPositionTransform","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","_radius","MappedBuffer","mappingType","indexSize","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","PointBufferDefaultParameters","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","pickingTex","pickingMap","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","vn","dimLen","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","setScale","setTransform","getCenterUntransformed","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","trajectory","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","StructureRepresentation","radiusSize","radiusScale","assembly","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","selected","_break","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","CylinderGeometryBufferDefaultParameters","getGeo","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","lineOnly","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","getNormals","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","line1","line2","sector","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","probeRadius","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","ia","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","surfaceType","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","bbSize","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vSplit","fullLength","coneLength","BoxBuffer","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","TetrahedronBuffer","TorusBufferDefaultParameters","radiusRatio","TorusBuffer","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","sb","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","ensureArray","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","identityMatrix","covalentI","parseCore","begIcode","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","decodeInt32","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","lastBB0","lastBB1","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","sea","sky","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","elementName","vertexIndices","vertex_indices","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","raw","ended","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","getListing","jsonData","frameIndex","getPathUrl","renumberSerial","remarks","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","im","chargeSign","hasModels","formatString","getString","idString","titleString","countsString","chargeLines","pairs","nCharges","formatAtom","formatBond","_writeHeader","_writeCTab","_writeFooter","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","sizeScore","backboneOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","relativePath","pn","pathname","basePath","getAbsolutePath","vectorNorm1","vectorNorm2","vectorNorm3","structures","atomIndexDict","modelCount","wait","previous","later","leading","Date","clearTimeout","trailing"],"mappings":"2OAGA,MAAAA,EAAA,EACAC,EAAA,EACAC,EAAA,EAKAC,EAAA,E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G,EAAM2hJ,KAAK3hJ,MACVwhJ,IAAgC,IAApBr+P,EAAQu+P,UAAmBF,EAAWxhJ,GACvD,IAAIsmB,EAAYi7H,GAAQvhJ,EAAMwhJ,GAe9B,OAdAvgQ,EAAUjP,KACVu+F,EAAO54F,UACH2uI,GAAa,GAAKA,EAAYi7H,GAC5BpiI,IACFyiI,aAAaziI,GACbA,EAAU,MAEZqiI,EAAWxhJ,EACXl/C,EAAS6vB,EAAK9oB,MAAM5mE,EAASsvF,GACxB4uC,IAASl+H,EAAUsvF,EAAO,OACrB4uC,IAAgC,IAArBh8H,EAAQ0+P,WAC7B1iI,EAAUld,WAAWw/I,EAAOn7H,IAGvBxlE,CACT,CACF"} \ No newline at end of file diff --git a/dist/ngl.umd.js b/dist/ngl.umd.js index 3361450c..af2ec288 100644 --- a/dist/ngl.umd.js +++ b/dist/ngl.umd.js @@ -1,31 +1,28 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("promise-polyfill"),require("three"),require("chroma-js"),require("signals"),require("sprintf-js")):"function"==typeof define&&define.amd?define(["exports","promise-polyfill","three","chroma-js","signals","sprintf-js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).NGL={},t._Promise,t.three,t.chroma,t.signalsWrapper,t.sprintfJs)}(this,(function(t,e,r,i,o,n){"use strict";function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var c,u,l,h,p,d=a(e),f=s(i),m=s(o);function g(t){if("undefined"!=typeof window){var e=new RegExp(t+"=([^&#=]*)").exec(window.location.search);return e?decodeURIComponent(e[1]):void 0}}function y(t,e){return void 0!==t?t:e}function v(t,e){var r=Object.assign({},t);for(var i in e){void 0===t[i]&&(r[i]=e[i])}return r}function b(t,e){for(var r in e){var i=e[r];void 0!==i&&(t[r]=i)}return t}function x(){var t=window.location.protocol;return null===t.match(/http(s)?:/gi)?"http:":t}function _(){if("undefined"==typeof window)return!1;var t=window.navigator.userAgent;return/Opera|OPR/.test(t)?"Opera":/Chrome/i.test(t)?"Chrome":/Firefox/i.test(t)?"Firefox":/Mobile(\/.*)? Safari/i.test(t)?"Mobile Safari":/MSIE/i.test(t)?"Internet Explorer":!!/Safari/i.test(t)&&"Safari"}function w(t){window.open(t,"_blank")||(window.location.href=t)}function A(t,e){if(void 0===e&&(e="download"),t){var r="Safari"===_(),i=/CriOS\/[\d]+/.test(window.navigator.userAgent),o=document.createElement("a");if("undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(t,e);else if((r||i)&&FileReader)if(t instanceof Blob){var n=new FileReader;n.onloadend=function(){s(n.result)},n.readAsDataURL(t)}else s(t);else{var a=!1;t instanceof Blob&&(t=URL.createObjectURL(t),a=!0),"download"in o?(o.style.display="hidden",document.body.appendChild(o),o.href=t,o.download=e,o.target="_blank",o.click(),document.body.removeChild(o)):w(t),a&&window.URL.revokeObjectURL(t)}}function s(t){w(i?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"))}}function S(t,e){return te?1:0}function C(t,e,r){void 0===r&&(r=S);for(var i=0,o=t.length-1;i<=o;){var n=i+o>>1,a=r(e,t[n]);if(a>0)i=n+1;else{if(!(a<0))return n;o=n-1}}return-i-1}function P(t,e,r){var i=function(t,e){var r=t.length-1;if(t[r]>1;t[o]>=e?r=o-1:i=o+1}return r+1}(t,e),o=function(t,e){if(t[0]>e)return-1;for(var r=0,i=t.length-1;r<=i;){var o=r+i>>1;t[o]>e?i=o-1:r=o+1}return r-1}(t,r);return-1===i||-1===o||i>o?0:o-i+1}function I(t){return t.sort().filter((function(t,e,r){return 0===e||t!==r[e-1]}))}function O(t){var e=28672;if(t.length>e){for(var r=[],i=0;i65535?Uint32Array:Uint16Array)(t)}function D(t){return t.buffer&&t.buffer instanceof ArrayBuffer?t.buffer:t}function T(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function B(t){return T(t,r.Vector3)}function R(t){return T(t,r.Matrix4)}function F(t){return T(t,r.Quaternion)}function E(t){return e=t,r=Float32Array,e instanceof r?e:new r(e);var e,r}function $(t){return y(t,"").toString().toLowerCase()}"undefined"!=typeof window&&function(){window.console=window.console||{};for(var t,e,r=window.console,i={},o=function(){},n="memory".split(","),a="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");t=n.pop();)r[t]||(r[t]=i);for(;e=a.pop();)r[e]||(r[e]=o)}(),"undefined"==typeof window||void 0===window.HTMLCanvasElement||window.HTMLCanvasElement.prototype.toBlob||Object.defineProperty(window.HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,r){for(var i=window.atob(this.toDataURL(e,r).split(",")[1]),o=i.length,n=o>>2,a=new Uint8Array(o),s=new Uint32Array(a.buffer,0,n),c=0,u=0;c0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&t>-9007199254740992&&t<9007199254740992&&Math.floor(t)===t}),Number.isNaN||(Number.isNaN=function(t){return t!=t}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var e=arguments;if(null==t)throw new TypeError("Cannot convert first argument to object");for(var r,i=Object(t),o=!1,n=1;n1?arguments[1]:void 0,s=a?Number(a):0;Number.isNaN(s)&&(s=0);var c=Math.min(Math.max(s,0),i);if(n+c>i)return!1;for(var u=-1;++ur.length)&&(e=r.length),e-=t.length;var i=r.indexOf(t,e);return-1!==i&&i===e}),String.prototype.repeat||(String.prototype.repeat=function(t){if(null===this)throw new TypeError("can't convert "+this+" to object");var e=""+this;if(t=+t,Number.isNaN(t)&&(t=0),t<0)throw new RangeError("repeat count must be non-negative");if(t===1/0)throw new RangeError("repeat count must be less than infinity");if(t=Math.floor(t),0===e.length||0===t)return"";if(e.length*t>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.includes||(Array.prototype.includes=function(t){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),r=parseInt(e.length,10)||0;if(0===r)return!1;var i,o,n=parseInt(arguments[1],10)||0;for(n>=0?i=n:(i=r+n)<0&&(i=0);i0?1:-1)*Math.floor(Math.abs(e)):e}(t);return Math.min(Math.max(e,0),l)},function(t){var e=this,r=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var i,o=arguments.length>1?arguments[1]:void 0;if(void 0!==o){if(!u(o))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(i=arguments[2])}for(var n,a=h(r.length),s=u(e)?Object(new e(a)):new Array(a),c=0;c>=4,V[r]=j[19===r?3&t|8:t]);return V.join("")}function U(t,e,r){return Math.max(e,Math.min(r,t))}function H(t,e,r){return t+(e-t)*r}function W(t,e,r,i,o,n){var a=(r-t)*n,s=(i-e)*n,c=o*o;return(2*e-2*r+a+s)*(o*c)+(-3*e+3*r-2*a-s)*c+a*o+e}function q(t,e,r){var i;return i=function(t,e,r){return(t-e)/(r-e)}(r,t,e),(r=U(i,0,1))*r*(3-2*r)}var X="sRGB";var Y={scale:"uniform",mode:"hcl",domain:[0,1],value:16777215,reverse:!1},K=new r.Color;function Z(t,e,r){var i=r.value;return r.value=function(t,e){var r=i.bind(this,t,e)();return"linear"==X?(K.set(r),K.convertSRGBToLinear(),K.getHex()):r},r}var Q,J=function(t){void 0===t&&(t={}),this.parameters=v(t,Y),"string"==typeof this.parameters.value&&(this.parameters.value=K.set(this.parameters.value).getHex()),this.parameters.structure&&(this.atomProxy=this.parameters.structure.getAtomProxy())};J.prototype.getScale=function(t){void 0===t&&(t={});var e=v(t,this.parameters);return"rainbow"===e.scale?e.scale=["red","orange","yellow","green","blue"]:"rwb"===e.scale&&(e.scale=["red","white","blue"]),e.reverse&&(e.domain=e.domain.slice().reverse()),f.scale(e.scale).mode(e.mode).domain(e.domain).out("num")},J.prototype.colorToArray=function(t,e,r){return void 0===e&&(e=[]),void 0===r&&(r=0),e[r]=(t>>16&255)/255,e[r+1]=(t>>8&255)/255,e[r+2]=(255&t)/255,e},J.prototype.atomColorToArray=function(t,e,r){return this.colorToArray(this.atomColor?this.atomColor(t):0,e,r)},J.prototype.bondColor=function(t,e){return this.atomProxy&&this.atomColor?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):0},J.prototype.bondColorToArray=function(t,e,r,i){return this.colorToArray(this.bondColor(t,e),r,i)},J.prototype.volumeColorToArray=function(t,e,r){return this.colorToArray(this.volumeColor?this.volumeColor(t):0,e,r)},J.prototype.positionColorToArray=function(t,e,r){return this.colorToArray(this.positionColor?this.positionColor(t):0,e,r)},function(t){t[t.PROTEIN=1]="PROTEIN",t[t.NUCLEIC=2]="NUCLEIC",t[t.RNA=3]="RNA",t[t.DNA=4]="DNA",t[t.POLYMER=5]="POLYMER",t[t.WATER=6]="WATER",t[t.HELIX=7]="HELIX",t[t.SHEET=8]="SHEET",t[t.TURN=9]="TURN",t[t.BACKBONE=10]="BACKBONE",t[t.SIDECHAIN=11]="SIDECHAIN",t[t.ALL=12]="ALL",t[t.HETERO=13]="HETERO",t[t.ION=14]="ION",t[t.SACCHARIDE=15]="SACCHARIDE",t[t.SUGAR=15]="SUGAR",t[t.BONDED=16]="BONDED",t[t.RING=17]="RING",t[t.AROMATICRING=18]="AROMATICRING",t[t.METAL=19]="METAL",t[t.POLARH=20]="POLARH",t[t.NONE=21]="NONE"}(Q||(Q={}));var tt=["*","","ALL"],et=["NONE"],rt=[Q.BACKBONE,Q.SIDECHAIN,Q.BONDED,Q.RING,Q.AROMATICRING,Q.METAL,Q.POLARH],it=[Q.POLYMER,Q.WATER],ot=["ALA","GLY","SER"],nt=["CYS","SER","THR"],at=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],st=["PHE","TRP","TYR","HIS"],ct=["ASN","GLN"],ut=["ASP","GLU"],lt=["ARG","HIS","LYS"],ht=["ARG","ASP","GLU","HIS","LYS"],pt=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],dt=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],ft=["HIS","PHE","PRO","TRP","TYR"],mt=["ALA","GLY","ILE","LEU","VAL"];function gt(t,e){if(void 0===e.atomname&&void 0===e.element&&void 0===e.altloc&&void 0===e.atomindex&&void 0===e.keyword&&void 0===e.inscode&&void 0===e.resname&&void 0===e.sstruc&&void 0===e.resno&&void 0===e.chainname&&void 0===e.model)return-1;if(void 0!==e.keyword){if(e.keyword===Q.BACKBONE&&!t.isBackbone())return!1;if(e.keyword===Q.SIDECHAIN&&!t.isSidechain())return!1;if(e.keyword===Q.BONDED&&!t.isBonded())return!1;if(e.keyword===Q.RING&&!t.isRing())return!1;if(e.keyword===Q.AROMATICRING&&!t.isAromatic())return!1;if(e.keyword===Q.HETERO&&!t.isHetero())return!1;if(e.keyword===Q.PROTEIN&&!t.isProtein())return!1;if(e.keyword===Q.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===Q.RNA&&!t.isRna())return!1;if(e.keyword===Q.DNA&&!t.isDna())return!1;if(e.keyword===Q.POLYMER&&!t.isPolymer())return!1;if(e.keyword===Q.WATER&&!t.isWater())return!1;if(e.keyword===Q.HELIX&&!t.isHelix())return!1;if(e.keyword===Q.SHEET&&!t.isSheet())return!1;if(e.keyword===Q.TURN&&!t.isTurn())return!1;if(e.keyword===Q.ION&&!t.isIon())return!1;if(e.keyword===Q.SACCHARIDE&&!t.isSaccharide())return!1;if(e.keyword===Q.METAL&&!t.isMetal())return!1;if(e.keyword===Q.POLARH&&!t.isPolarHydrogen())return!1}if(void 0!==e.atomname&&e.atomname!==t.atomname)return!1;if(void 0!==e.element&&e.element!==t.element)return!1;if(void 0!==e.altloc&&e.altloc!==t.altloc)return!1;if(void 0!==e.atomindex&&C(e.atomindex,t.index)<0)return!1;if(void 0!==e.resname)if(Array.isArray(e.resname)){if(!e.resname.includes(t.resname))return!1}else if(e.resname!==t.resname)return!1;if(void 0!==e.sstruc&&e.sstruc!==t.sstruc)return!1;if(void 0!==e.resno)if(Array.isArray(e.resno)&&2===e.resno.length){if(e.resno[0]>t.resno||e.resno[1]t.resno||e.resno[1]0?t:null}function wt(t,e){void 0===e&&(e=!1);var r=t;return e&&(r=_t(t,(function(t){return void 0!==t.keyword&&!rt.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))}))),xt(r,gt)}function At(t,e){void 0===e&&(e=!1);var r=t;return e&&(r=_t(t,(function(t){return!(void 0===t.keyword||!rt.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))}))),xt(r,yt)}function St(t,e){void 0===e&&(e=!1);var r=t;return e&&(r=_t(t,(function(t){return void 0!==t.keyword&&!it.includes(t.keyword)||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode))))))}))),xt(r,vt)}function Ct(t,e){void 0===e&&(e=!1);var r=t;return e&&(r=_t(t,(function(t){return void 0!==t.keyword||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode)))))))}))),xt(r,bt)}var Pt=function(t){this.signals={stringChanged:new o.Signal},this.setString(t)},It={type:{configurable:!0}};It.type.get=function(){return"selection"},Pt.prototype.setString=function(t,e){if(void 0===t&&(t=this.string||""),t!==this.string){try{this.selection=function(t){var e={operator:void 0,rules:[]};if(!t)return e;var r,i,o=e,n=[];"("===(t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());for(var a=t.split(/\s+/),s=function(t){r={operator:t,rules:[]},void 0===o?(o=r,e=r):(o.rules.push(r),n.push(o),o=r)},c=function(t){i=o,void 0===(o=n.pop())&&(s(t),u(i))},u=function(t){o.rules.push(t)},l=!1,h=0;h0)if("NOT"===d)l=1;else if(1===l)l=2;else{if(2!==l)throw new Error("something went wrong with 'not'");l=!1,c()}if("AND"!==d)if("OR"!==d)if("NOT"!==p.toUpperCase()){if(+d!=+d){var f=Q[d];if(void 0!==f){u({keyword:f});continue}}if("HYDROGEN"!==d)if("SMALL"!==d)if("NUCLEOPHILIC"!==d)if("HYDROPHOBIC"!==d)if("AROMATIC"!==d)if("AMIDE"!==d)if("ACIDIC"!==d)if("BASIC"!==d)if("CHARGED"!==d)if("POLAR"!==d)if("NONPOLAR"!==d)if("CYCLIC"!==d)if("ALIPHATIC"!==d)if("SIDECHAINATTACHED"!==d)if("APOLARH"!==d)if("LIGAND"!==d)if(-1===tt.indexOf(d))if("@"!==p.charAt(0))if("#"!==p.charAt(0))if("_"!==p.charAt(0))if("["!==p[0]||"]"!==p[p.length-1])if(p.length>=1&&p.length<=4&&"^"!==p[0]&&":"!==p[0]&&"."!==p[0]&&"%"!==p[0]&&"/"!==p[0]&&isNaN(parseInt(p)))u({resname:d});else{var m={operator:"AND",rules:[]},g=p.split("/");if(g.length>1&&g[1]){if(isNaN(parseInt(g[1])))throw new Error("model must be an integer");m.rules.push({model:parseInt(g[1])})}var y=g[0].split("%");y.length>1&&m.rules.push({altloc:y[1]});var v=y[0].split(".");if(v.length>1&&v[1]){if(v[1].length>4)throw new Error("atomname must be one to four characters");m.rules.push({atomname:v[1].substring(0,4).toUpperCase()})}var b=v[0].split(":");b.length>1&&b[1]&&m.rules.push({chainname:b[1]});var x=b[0].split("^");if(x.length>1&&m.rules.push({inscode:x[1]}),x[0]){var _=void 0,w=void 0;"-"===x[0][0]&&(x[0]=x[0].substr(1),_=!0),x[0].includes("--")&&(x[0]=x[0].replace("--","-"),w=!0);var A=x[0].split("-");if(1===A.length){var S=parseInt(A[0]);if(isNaN(S))throw new Error("resi must be an integer");_&&(S*=-1),m.rules.push({resno:S})}else{if(2!==A.length)throw new Error("resi range must contain one '-'");var C=A.map((function(t){return parseInt(t)}));_&&(C[0]*=-1),w&&(C[1]*=-1),m.rules.push({resno:[C[0],C[1]]})}}if(1===m.rules.length)u(m.rules[0]);else{if(!(m.rules.length>1))throw new Error("empty selection chunk");u(m)}}else{var P=d.substr(1,p.length-2).split(","),I=P.length>1?P:P[0];u({resname:I})}else u({element:d.substr(1)});else console.error("# for element selection deprecated, use _"),u({element:d.substr(1)});else{var O=p.substr(1).split(",").map((function(t){return parseInt(t)}));O.sort((function(t,e){return t-e})),u({atomindex:O})}else u({keyword:Q.ALL});else u({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:Q.HETERO},{negate:!0,operator:void 0,rules:[{keyword:Q.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:Q.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:Q.WATER},{keyword:Q.ION}]}]}]});else u({operator:"AND",negate:!1,rules:[{element:"H"},{negate:!0,operator:void 0,rules:[{keyword:Q.POLARH}]}]});else u({operator:"OR",rules:[{keyword:Q.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:Q.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:Q.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"HO3'"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"HO5'"},{atomname:"C5'"},{atomname:"C5*"},{atomname:"H5'"},{atomname:"H5''"}]}]}]});else u({resname:mt});else u({resname:ft});else u({resname:dt});else u({resname:pt});else u({resname:ht});else u({resname:lt});else u({resname:ut});else u({resname:ct});else u({resname:st});else u({resname:at});else u({resname:nt});else u({resname:ot});else u({operator:"OR",rules:[{element:"H"},{element:"D"}]})}else l=1,s(),o.negate=!0;else"AND"===o.operator?c("OR"):o.operator="OR";else if("OR"===o.operator){var M=o.rules.pop();s("AND"),u(M)}else o.operator="AND"}else c(),o.negate&&c();else l=!1,s()}return void 0===e.operator&&1===e.rules.length&&e.rules[0].hasOwnProperty("operator")&&(e=e.rules[0]),e}(t)}catch(t){this.selection={error:t.message}}var r=this.selection;this.string=t,this.test=wt(r),this.residueTest=At(r),this.chainTest=St(r),this.modelTest=Ct(r),this.atomOnlyTest=wt(r,!0),this.residueOnlyTest=At(r,!0),this.chainOnlyTest=St(r,!0),this.modelOnlyTest=Ct(r,!0),e||this.signals.stringChanged.dispatch(this.string)}},Pt.prototype.isAllSelection=function(){return tt.includes(this.string.toUpperCase())},Pt.prototype.isNoneSelection=function(){return et.includes(this.string.toUpperCase())},Object.defineProperties(Pt.prototype,It);var Ot=function(t){function e(e){var i=this;t.call(this,e),this.colormakerList=[],this.selectionList=[],(e.dataList||[]).forEach((function(t){var e=t[0],o=t[1],n=t[2];void 0===n&&(n={}),Zt.hasScheme(e)?Object.assign(n,{scheme:e,structure:i.parameters.structure}):Object.assign(n,{scheme:"uniform",value:new r.Color(e).getHex()}),i.colormakerList.push(Zt.getScheme(n)),i.selectionList.push(new Pt(o))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){for(var e=0,r=this.selectionList.length;ei).lines},ae.prototype.chunkCount=function(){return Math.floor(this.data.length/this.chunkSize)+1},ae.prototype.asText=function(){return this.isBinary()?O(this.data):this.data},ae.prototype.chunkToLines=function(t,e,r){var i=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(i),partialLine:""};var o=[],n=this.isBinary()?O(t):t,a=n.lastIndexOf(i);if(-1===a)e+=n;else{var s=e+n.substr(0,a);o=o.concat(s.split(i)),e=a===n.length-i.length?"":n.substr(a+i.length)}return r&&""!==e&&o.push(e),{lines:o,partialLine:e}},ae.prototype.nextChunk=function(){var t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)},ae.prototype.nextChunkOfLines=function(){var t=this.nextChunk();if(void 0!==t){var e=this.__pointer>this.data.length,r=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=r.partialLine,r.lines}},ae.prototype.eachChunk=function(t){for(var e=this.chunkSize,r=this.data.length,i=this.chunkCount(),o=0;o1?(u.pop()||"").toLowerCase():"",h=e.match(/^(.+):\/\/(.+)$/);h&&(o=h[1].toLowerCase(),e=h[2]||"");var p=e.substring(0,e.lastIndexOf("/")+1);if(i.includes(l)){r=l;var d=e.length-l.length-1;l=(e.substr(0,d).split(".").pop()||"").toLowerCase();var f=c.length-l.length-1;c=c.substr(0,f)}else r=!1;return{path:e,name:s,ext:l,base:c,dir:p,compressed:r,protocol:o,query:a,src:t}}function fe(t){var e=de(t),r=Qt.get(e.protocol);return r&&!(e=de(r.getUrl(e.src))).ext&&r.getExt&&(e.ext=r.getExt(t)),e}function me(t,e){void 0===e&&(e={});var r,i=Object.assign(fe(t),e);return te.names.includes(i.ext)?r=new le(i.src,i):Yt.includes(i.ext)&&(r=new pe(i.src,i)),r?r.load():Promise.reject(new Error("autoLoad: ext '"+i.ext+"' unknown"))}var ge=function(){};ge.prototype.getBlob=function(){return new Blob([this.getData()],{type:this.mimeType})},ge.prototype.download=function(t,e){t=y(t,this.defaultName),e=y(e,this.defaultExt),A(this.getBlob(),t+"."+e)};var ye=function(t){function e(e,r){t.call(this),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";var i=Object.assign({},r);this.renumberSerial=y(i.renumberSerial,!0),this.remarks=function(t){return Array.isArray(t)?t:[t]}(y(i.remarks,[])),this.structure=e,this._records=[]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._writeRecords=function(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()},e.prototype._writeTitle=function(){this._records.push(n.sprintf("TITLE %-74s",this.structure.name))},e.prototype._writeRemarks=function(){var t=this;this.remarks.forEach((function(e){t._records.push(n.sprintf("REMARK %-73s",e))})),this.structure.trajectory&&(this._records.push(n.sprintf("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(n.sprintf("REMARK %-73s","Frame "+this.structure.trajectory.frame)))},e.prototype._writeAtoms=function(){var t=this,e=1,r=1,i=" ",o=" ",a=this.structure.modelStore.count>1;this.structure.eachModel((function(s){a&&t._records.push(n.sprintf("MODEL %4d%-66s",r++,"")),s.eachAtom((function(r){var a=r.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",s=t.renumberSerial?e:r.serial,c=r.atomname;(1===c.length||c.length<4&&1===r.element.length&&c[0]===r.element)&&(c=" "+c),r.formalCharge?(i=Math.abs(r.formalCharge).toPrecision(1),o=r.formalCharge>0?"+":"-"):(i=" ",o=" "),t._records.push(n.sprintf(a,s,c,r.resname,y(r.chainname," "),r.resno,r.x,r.y,r.z,y(r.occupancy,1),y(r.bfactor,0),"",y(r.element,""),i,o)),e+=1}),t.structure.getSelection()),a&&t._records.push(n.sprintf("%-80s","ENDMDL"))})),this._records.push(n.sprintf("%-80s","END"))},e.prototype.getString=function(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()},e.prototype.getData=function(){return this._writeRecords(),this._records.join("\n")},e}(ge),ve=function(t){function e(e){t.call(this),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=e,this._records=[]}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={idString:{configurable:!0},titleString:{configurable:!0},countsString:{configurable:!0},chargeLines:{configurable:!0}};return r.idString.get=function(){return this.structure.id},r.titleString.get=function(){return" "+this.structure.title},r.countsString.get=function(){return n.sprintf("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)},r.chargeLines.get=function(){var t=[];this.structure.eachAtom((function(e){null!=e.formalCharge&&0!==e.formalCharge&&t.push([e.index,e.formalCharge])}));for(var e=[],r=0;r>>0:0,o=t.byteLength-i,n=i;t instanceof ArrayBuffer||(t.byteLength!==t.buffer.byteLength&&(n=t.byteOffset+i),t=t.buffer),this._lastWrittenByte=r?o:0,this.buffer=t,this.length=o,this.byteLength=o,this.byteOffset=n,this._data=new DataView(this.buffer,n,o)};xe.prototype.available=function(t){return void 0===t&&(t=1),this.offset+t<=this.length},xe.prototype.isLittleEndian=function(){return this.littleEndian},xe.prototype.setLittleEndian=function(){return this.littleEndian=!0,this},xe.prototype.isBigEndian=function(){return!this.littleEndian},xe.prototype.setBigEndian=function(){return this.littleEndian=!1,this},xe.prototype.skip=function(t){return void 0===t&&(t=1),this.offset+=t,this},xe.prototype.seek=function(t){return this.offset=t,this},xe.prototype.mark=function(){return this._mark=this.offset,this},xe.prototype.reset=function(){return this.offset=this._mark,this},xe.prototype.pushMark=function(){return this._marks.push(this.offset),this},xe.prototype.popMark=function(){var t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this},xe.prototype.rewind=function(){return this.offset=0,this},xe.prototype.ensureAvailable=function(t){if(void 0===t&&(t=1),!this.available(t)){var e=2*(this.offset+t),r=new Uint8Array(e);r.set(new Uint8Array(this.buffer)),this.buffer=r.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this},xe.prototype.readBoolean=function(){return 0!==this.readUint8()},xe.prototype.readInt8=function(){return this._data.getInt8(this.offset++)},xe.prototype.readUint8=function(){return this._data.getUint8(this.offset++)},xe.prototype.readByte=function(){return this.readUint8()},xe.prototype.readBytes=function(t){void 0===t&&(t=1);for(var e=new Uint8Array(t),r=0;rthis._lastWrittenByte&&(this._lastWrittenByte=this.offset)};var _e=function(t){function e(e){t.call(this),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getData=function(){var t=this.surface.index.length/3,e=new xe(2*t+3*t*4*4+80+4);e.skip(80),e.writeUint32(t);for(var i=new r.Vector3,o=new r.Vector3,n=new r.Vector3,a=new r.Vector3,s=0;sthis.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=t,this.frames=0),t},ee.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),ee.add("shader/chunk/interior_fragment.glsl","if( gl_FrontFacing == false ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}"),ee.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),ee.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),ee.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"),ee.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),ee.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),ee.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),ee.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");var Se=/^(?!\/\/)\s*#include\s+(\S+)/gim,Ce={};function Pe(t,e){void 0===e&&(e={});var i=t+"|";for(var o in e)i+=o+":"+e[o];if(!Ce[i]){var n=function(t){if(void 0===t)return"";var e=[];for(var r in t){var i=t[r];i&&e.push("#define "+r+" "+i)}return e.join("\n")+"\n"}(e),a=ee.get("shader/"+t);if(!a)throw new Error("empty shader, '"+t+"'");a=a.replace(Se,(function(t,e){var i="shader/chunk/"+e+".glsl",o=ee.get(i)||r.ShaderChunk[e];if(!o)throw new Error("empty chunk, '"+e+"'");return o})),Ce[i]=n+a}return Ce[i]}if("undefined"!=typeof WebGLRenderingContext){var Ie=WebGLRenderingContext.prototype,Oe=Ie.getShaderParameter;Ie.getShaderParameter=function(){return!t.Debug||Oe.apply(this,arguments)};var Me=Ie.getShaderInfoLog;Ie.getShaderInfoLog=function(){return t.Debug?Me.apply(this,arguments):""};var ke=Ie.getProgramParameter;Ie.getProgramParameter=function(e,r){return!t.Debug&&r===Ie.LINK_STATUS||ke.apply(this,arguments)};var De=Ie.getProgramInfoLog;Ie.getProgramInfoLog=function(){return t.Debug?De.apply(this,arguments):""}}var Te=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];Te.forEach((function(t){t.forEach((function(t){t[0]*=.0625,t[1]*=.0625}))}));var Be=function(t,e,r,i){this.canvas=document.createElement("canvas"),this._viewer=r,this._factor=y(i.factor,2),this._antialias=y(i.antialias,!1),this._onProgress=i.onProgress,this._onFinish=i.onFinish,this._antialias&&(this._factor*=2),this._n=this._factor*this._factor,this._width=this._viewer.width,this._height=this._viewer.height,this._antialias?(this.canvas.width=this._width*this._factor/2,this.canvas.height=this._height*this._factor/2):(this.canvas.width=this._width*this._factor,this.canvas.height=this._height*this._factor),this._ctx=this.canvas.getContext("2d"),this._viewerSampleLevel=r.sampleLevel,this._viewer.setSampling(-1)};Be.prototype._renderTile=function(t){var e=this._viewer,r=this._width,i=this._height,o=this._factor,n=t%o*r,a=Math.floor(t/o)*i;if(e.camera.setViewOffset(r*o,i*o,n,a,r,i),e.render(),this._antialias){var s=Math.round((n+r)/2)-Math.round(n/2),c=Math.round((a+i)/2)-Math.round(a/2);this._ctx.drawImage(e.renderer.domElement,Math.round(n/2),Math.round(a/2),s,c)}else this._ctx.drawImage(e.renderer.domElement,Math.floor(n),Math.floor(a),Math.ceil(r),Math.ceil(i));"function"==typeof this._onProgress&&this._onProgress(t+1,this._n,!1)},Be.prototype._finalize=function(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,"function"==typeof this._onFinish&&this._onFinish(this._n+1,this._n,!1)},Be.prototype.render=function(){for(var t=0;t<=this._n;++t)t===this._n?this._finalize():this._renderTile(t)},Be.prototype.renderAsync=function(){for(var t=this,e=0,r=this._n,i=function(){e===r?t._finalize():t._renderTile(e),e+=1},o=0;o<=r;++o)setTimeout(i,0)};var Re=2*Math.PI,Fe=180/Math.PI;function Ee(t,e,r,i,o){void 0===r&&(r=1),void 0===i&&(i=0);var n=o?o.length:t.length/r,a=0,s=0;if(o)for(var c=0;ce&&(e=t[r]);return e}function qe(t){for(var e=1/0,r=0,i=t.length;r=0;a--){for(n=l-1;n>=0;n--)if(h[c=4*(a*l+n)]!==e||h[c+1]!==r||h[c+2]!==i||h[c+3]!==o){s=!0;break}if(s)break}var f=a;for(s=!1,n=l-1;n>=0;n--){for(a=u-1;a>=0;a--)if(h[c=4*(a*l+n)]!==e||h[c+1]!==r||h[c+2]!==i||h[c+3]!==o){s=!0;break}if(s)break}var m=n,g=document.createElement("canvas");return g.width=m-d,g.height=f-p,g.getContext("2d").drawImage(t,d,p,g.width,g.height,0,0,g.width,g.height),g}(t,a?0:255*e.r,a?0:255*e.g,a?0:255*e.b,a?0:255)}return t}function d(t,r,i){"function"==typeof e.onProgress&&e.onProgress(t,r,i)}return new Promise((function(e,r){var i=new Be(s,c,t,{factor:o,antialias:n,onProgress:d,onFinish:function(o,n){p(i.canvas).toBlob((function(i){s.setClearAlpha(u),h(!0),t.requestRender(),d(n,n,!0),i?e(i):r("error creating image")}),"image/png")}});s.setClearAlpha(a?0:1),h(),i.renderAsync()}))}var Qe=new r.Vector3,Je=new r.Matrix4,tr=new r.Matrix4;var er=new r.Vector2,rr=new r.Matrix4,ir=new r.Matrix4;function or(t,e){rr.getInverse(e.projectionMatrix),ir.copy(e.projectionMatrix).transpose(),t.traverse((function(t){var e=t.material;if(e){var r=e.uniforms;r&&(r.projectionMatrixInverse&&r.projectionMatrixInverse.value.copy(rr),r.projectionMatrixTranspose&&r.projectionMatrixTranspose.value.copy(ir))}}))}function nr(t,e,r){var i=t.createShader(r);if(i)return t.shaderSource(i,e),t.compileShader(i),t.getShaderParameter(i,t.COMPILE_STATUS)?i:(console.log("error compiling shader "+i+": "+t.getShaderInfoLog(i)),t.deleteShader(i),null);console.log("error creating WebGL shader "+r)}function ar(t,e){var r=t.getExtension(e);return r||console.log("extension '"+e+"' not available"),r}var sr=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function cr(t){var e=document.createElement("canvas");e.width=16,e.height=16,e.style.width="16px",e.style.height="16px";var r=e.getContext("webgl")||e.getContext("experimental-webgl");if(!r)return console.log("error creating webgl context for "+t),!1;if(!(r instanceof WebGLRenderingContext))return console.log("Got unexpected type for WebGL rendering context"),!1;ar(r,"OES_texture_float"),ar(r,"OES_texture_half_float"),ar(r,"WEBGL_color_buffer_float");var i=nr(r,"\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}",r.VERTEX_SHADER),o=nr(r,"\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}",r.FRAGMENT_SHADER);if(!i||!o)return!1;var n=function(t,e,r,i){var o=t.createProgram();if(o)return e.forEach((function(e){return t.attachShader(o,e)})),r&&r.forEach((function(e,r){t.bindAttribLocation(o,i?i[r]:r,e)})),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.log("error linking program: "+t.getProgramInfoLog(o)),t.deleteProgram(o),null);console.log("error creating WebGL program")}(r,[i,o]);if(!n)return console.log("error creating WebGL program"),!1;r.useProgram(n);var a=r.getAttribLocation(n,"a_position"),s=r.getUniformLocation(n,"u_color");if(!s)return console.log("error getting 'u_color' uniform location"),!1;var c=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,sr,r.STATIC_DRAW),r.enableVertexAttribArray(a),r.vertexAttribPointer(a,2,r.FLOAT,!1,0,0);var u=r.createTexture(),l=new Uint8Array([255,255,255,255]);r.bindTexture(r.TEXTURE_2D,u),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,l);var h=r.createTexture();r.bindTexture(r.TEXTURE_2D,h),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,t,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST);var p=r.createFramebuffer();if(r.bindFramebuffer(r.FRAMEBUFFER,p),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,h,0),r.checkFramebufferStatus(r.FRAMEBUFFER)!==r.FRAMEBUFFER_COMPLETE)return console.log("error creating framebuffer for "+t),!1;r.bindTexture(r.TEXTURE_2D,u),r.uniform4fv(s,[0,10,20,1]),r.drawArrays(r.TRIANGLES,0,6),r.bindTexture(r.TEXTURE_2D,h),r.bindFramebuffer(r.FRAMEBUFFER,null),r.clearColor(1,0,0,1),r.clear(r.COLOR_BUFFER_BIT),r.uniform4fv(s,[0,.1,.05,1]),r.drawArrays(r.TRIANGLES,0,6);var d=new Uint8Array(4);if(r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,d),0!==d[0]||d[1]<248||d[2]<248||d[3]<254)return console.log("not able to actually render to "+t+" texture"),!1;if(t===r.FLOAT){r.bindFramebuffer(r.FRAMEBUFFER,p);var f=new Float32Array(4);r.readPixels(0,0,1,1,r.RGBA,r.FLOAT,f);var m=r.getError();if(m)return console.log("error reading pixels as float: '"+function(t,e){switch(e){case t.NO_ERROR:return"no error";case t.INVALID_ENUM:return"invalid enum";case t.INVALID_VALUE:return"invalid value";case t.INVALID_OPERATION:return"invalid operation";case t.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case t.OUT_OF_MEMORY:return"out of memory";case t.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}(r,m)+"'"),!1}return!0}var ur=new Float32Array(100),lr=new Uint8Array(100),hr=[12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20],pr=new r.Matrix4;function dr(t,e,r,i,o){var n=o.uniforms,a=[];if(n&&(n.objectId&&(n.objectId.value=Vt?this.id:this.id/255,a.push("objectId")),(n.modelViewMatrixInverse||n.modelViewMatrixInverseTranspose||n.modelViewProjectionMatrix||n.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,this.matrixWorld),n.modelViewMatrixInverse&&(n.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),a.push("modelViewMatrixInverse")),n.modelViewMatrixInverseTranspose&&(n.modelViewMatrixInverse?n.modelViewMatrixInverseTranspose.value.copy(n.modelViewMatrixInverse.value).transpose():n.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),a.push("modelViewMatrixInverseTranspose")),n.modelViewProjectionMatrix&&(n.modelViewProjectionMatrix.value.multiplyMatrices(r.projectionMatrix,this.modelViewMatrix),a.push("modelViewProjectionMatrix")),n.modelViewProjectionMatrixInverse&&(n.modelViewProjectionMatrix?(pr.copy(n.modelViewProjectionMatrix.value),n.modelViewProjectionMatrixInverse.value.getInverse(pr)):(pr.multiplyMatrices(r.projectionMatrix,this.modelViewMatrix),n.modelViewProjectionMatrixInverse.value.getInverse(pr)),a.push("modelViewProjectionMatrixInverse")),a.length)){var s=t.properties.get(o);if(s.program){var c=t.getContext(),u=s.program;c.useProgram(u.program);var l=u.getUniforms();a.forEach((function(t){l.setValue(c,t,n[t].value)}))}}}var fr=function(t){if(this.boundingBox=new r.Box3,this.boundingBoxSize=new r.Vector3,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new r.Vector3,this.signals={ticked:new o.Signal,rendered:new o.Signal},"string"==typeof t){var e=document.getElementById(t);this.container=null===e?document.createElement("div"):e}else t instanceof HTMLElement?this.container=t:this.container=document.createElement("div");if(this.container===document.body)this.width=window.innerWidth||1,this.height=window.innerHeight||1;else{var i=this.container.getBoundingClientRect();this.width=i.width||1,this.height=i.height||1,this.container.style.overflow="hidden"}this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.container.appendChild(this.wrapper),this._initParams(),this._initStats(),this._initCamera(),this._initScene(),!1!==this._initRenderer()?(this._initHelper(),this.setBackground(),this.setFog(),this.animate=this.animate.bind(this)):qt.error("Viewer: could not initialize renderer")},mr={cameraDistance:{configurable:!0}};fr.prototype._initParams=function(){this.parameters={fogColor:new r.Color(0),fogNear:50,fogFar:100,backgroundColor:new r.Color(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new r.Color(14540253),lightIntensity:1,ambientColor:new r.Color(14540253),ambientIntensity:.2,sampleLevel:0,rendererEncoding:r.LinearEncoding}},fr.prototype._initCamera=function(){var t=new r.Vector3(0,0,0),e=this.width,i=this.height;this.perspectiveCamera=new r.PerspectiveCamera(this.parameters.cameraFov,e/i),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(t),this.orthographicCamera=new r.OrthographicCamera(e/-2,e/2,i/2,i/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(t),this.stereoCamera=new r.StereoCamera,this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;var o=this.parameters.cameraType;if("orthographic"===o)this.camera=this.orthographicCamera;else{if("perspective"!==o&&"stereo"!==o)throw new Error("Unknown cameraType '"+o+"'");this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()},fr.prototype._initStats=function(){this.stats=new Ae},fr.prototype._initScene=function(){this.scene||(this.scene=new r.Scene,this.scene.name="scene"),this.rotationGroup=new r.Group,this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new r.Group,this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new r.Group,this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new r.Group,this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new r.Group,this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new r.Group,this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new r.Fog(this.parameters.fogColor.getHex()),this.spotLight=new r.SpotLight(this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.spotLight),this.ambientLight=new r.AmbientLight(this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)},fr.prototype._initRenderer=function(){var e=window.devicePixelRatio,i=this.width,o=this.height;try{this.renderer=new r.WebGLRenderer({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(t){return this.wrapper.innerHTML='

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

',!1}this.renderer.setPixelRatio(e),this.renderer.setSize(i,o),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,this.renderer.outputEncoding=this.parameters.rendererEncoding;var n=this.renderer.getContext();this.renderer.capabilities.isWebGL2?(Ht(!0),Gt(this.renderer.extensions.get("EXT_color_buffer_float")),this.supportsHalfFloat=!0):(Ht(this.renderer.extensions.get("EXT_frag_depth")),this.renderer.extensions.get("OES_element_index_uint"),Gt(this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&cr(n.FLOAT)),this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&cr(36193)),this.wrapper.appendChild(this.renderer.domElement);var a=i*e,s=o*e;t.Debug&&console.log(JSON.stringify({Browser:Lt,OES_texture_float:!!this.renderer.extensions.get("OES_texture_float"),OES_texture_half_float:!!this.renderer.extensions.get("OES_texture_half_float"),WEBGL_color_buffer_float:!!this.renderer.extensions.get("WEBGL_color_buffer_float"),"testTextureSupport Float":cr(n.FLOAT),"testTextureSupport HalfFloat":cr(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:Vt},null,2)),this.pickingTarget=new r.WebGLRenderTarget(a,s,{minFilter:r.NearestFilter,magFilter:r.NearestFilter,stencilBuffer:!1,format:r.RGBAFormat,type:Vt?r.FloatType:r.UnsignedByteType}),this.pickingTarget.texture.generateMipmaps=!1,this.pickingTarget.texture.encoding=this.parameters.rendererEncoding,this.renderer.setRenderTarget(this.pickingTarget),this.renderer.clear(),this.renderer.setRenderTarget(null),this.sampleTarget=new r.WebGLRenderTarget(a,s,{minFilter:r.LinearFilter,magFilter:r.LinearFilter,format:r.RGBAFormat}),this.sampleTarget.texture.encoding=this.parameters.rendererEncoding,this.holdTarget=new r.WebGLRenderTarget(a,s,{minFilter:r.NearestFilter,magFilter:r.NearestFilter,format:r.RGBAFormat,type:r.UnsignedByteType}),this.holdTarget.texture.encoding=this.parameters.rendererEncoding,this.compositeUniforms={tForeground:new r.Uniform(this.sampleTarget.texture),scale:new r.Uniform(1)},this.compositeMaterial=new r.ShaderMaterial({uniforms:this.compositeUniforms,vertexShader:Pe("Quad.vert"),fragmentShader:Pe("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:r.AdditiveBlending,depthTest:!1,depthWrite:!1}),this.compositeCamera=new r.OrthographicCamera(-1,1,1,-1,0,1),this.compositeScene=new r.Scene,this.compositeScene.name="compositeScene",this.compositeScene.add(new r.Mesh(new r.PlaneGeometry(2,2),this.compositeMaterial))},fr.prototype._initHelper=function(){var t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),e=new Float32Array(24),i=new r.BufferGeometry;i.setIndex(new r.BufferAttribute(t,1)),i.setAttribute("position",new r.BufferAttribute(e,3));var o=new r.ShaderMaterial({uniforms:{uColor:{value:new r.Color("skyblue")}},vertexShader:Pe("BasicLine.vert"),fragmentShader:Pe("BasicLine.frag")});this.boundingBoxMesh=new r.LineSegments(i,o),this.helperGroup.add(this.boundingBoxMesh)},fr.prototype.updateHelper=function(){var t=this.boundingBoxMesh.geometry.attributes.position,e=t.array,r=this.boundingBox,i=r.min,o=r.max;e[0]=o.x,e[1]=o.y,e[2]=o.z,e[3]=i.x,e[4]=o.y,e[5]=o.z,e[6]=i.x,e[7]=i.y,e[8]=o.z,e[9]=o.x,e[10]=i.y,e[11]=o.z,e[12]=o.x,e[13]=o.y,e[14]=i.z,e[15]=i.x,e[16]=o.y,e[17]=i.z,e[18]=i.x,e[19]=i.y,e[20]=i.z,e[21]=o.x,e[22]=i.y,e[23]=i.z,t.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()},mr.cameraDistance.get=function(){return Math.abs(this.camera.position.z)},mr.cameraDistance.set=function(t){this.camera.position.z=-t},fr.prototype.add=function(e,r){var i=this;r?r.forEach((function(t){return i.addBuffer(e,t)})):this.addBuffer(e),e.group.name="meshGroup",e.wireframeGroup.name="wireframeGroup",e.parameters.background?(this.backgroundGroup.add(e.group),this.backgroundGroup.add(e.wireframeGroup)):(this.modelGroup.add(e.group),this.modelGroup.add(e.wireframeGroup)),e.pickable&&this.pickingGroup.add(e.pickingGroup),t.Debug&&this.updateHelper()},fr.prototype.addBuffer=function(t,e){function i(o){o instanceof r.Group?o.children.forEach(i):(o.userData.buffer=t,o.userData.instance=e,o.onBeforeRender=dr)}var o=t.getMesh();e&&o.applyMatrix4(e.matrix),i(o),t.group.add(o);var n=t.getWireframeMesh();if(e&&(n.matrix.copy(o.matrix),n.position.copy(o.position),n.quaternion.copy(o.quaternion),n.scale.copy(o.scale)),i(n),t.wireframeGroup.add(n),t.pickable){var a=t.getPickingMesh();e&&(a.matrix.copy(o.matrix),a.position.copy(o.position),a.quaternion.copy(o.quaternion),a.scale.copy(o.scale)),i(a),t.pickingGroup.add(a)}e?this._updateBoundingBox(t.geometry,t.matrix,e.matrix):this._updateBoundingBox(t.geometry,t.matrix)},fr.prototype.remove=function(e){this.translationGroup.children.forEach((function(t){t.remove(e.group),t.remove(e.wireframeGroup)})),e.pickable&&this.pickingGroup.remove(e.pickingGroup),this.updateBoundingBox(),t.Debug&&this.updateHelper()},fr.prototype._updateBoundingBox=function(t,e,r){var i=this.boundingBox;function o(t,e,r){null==t.boundingBox&&t.computeBoundingBox();var o=t.boundingBox.clone();e&&o.applyMatrix4(e),r&&o.applyMatrix4(r),o.min.equals(o.max)&&o.expandByScalar(5),i.union(o)}function n(t){var e,r;void 0!==t.geometry&&(t.userData.buffer&&(e=t.userData.buffer.matrix),t.userData.instance&&(r=t.userData.instance.matrix),o(t.geometry,e,r))}t?o(t,e,r):(i.makeEmpty(),this.modelGroup.traverse(n),this.backgroundGroup.traverse(n)),i.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()},fr.prototype.updateBoundingBox=function(){this._updateBoundingBox(),t.Debug&&this.updateHelper()},fr.prototype.getPickingPixels=function(){var t=this.width,e=this.height,r=t*e*4,i=Vt?new Float32Array(r):new Uint8Array(r);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,t,e,i),i},fr.prototype.getImage=function(t){var e=this;return new Promise((function(r){if(t){var i=e,o=i.width,n=i.height,a=o*n*4,s=e.getPickingPixels();if(Vt){for(var c=new Uint8Array(a),u=0;u500&&!this.isStill&&this.sampleLevel<3&&-1!==this.sampleLevel){var e=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=e,t.Debug&&qt.log("rendered still frame")}this.frameRequest=window.requestAnimationFrame(this.animate)},fr.prototype.pick=function(t,e){if("stereo"===this.parameters.cameraType)return{pid:0,instance:void 0,picker:void 0};t*=window.devicePixelRatio,e*=window.devicePixelRatio,t=Math.max(t-2,0),e=Math.max(e-2,0);var r,i,o=0,n=Vt?ur:lr;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,t,e,5,5,n);for(var a=0;a22&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame((function(){t.render(),t.stats.update()})))},fr.prototype.updateZoom=function(){var t=z(this.perspectiveCamera.fov),e=2*Math.tan(t/2)*this.cameraDistance;this.orthographicCamera.zoom=this.height/e},fr.prototype.absoluteToRelative=function(t){return 50*(1-t/this.bRadius)},fr.prototype.relativeToAbsolute=function(t){return this.bRadius*(1-t/50)},fr.prototype.__updateClipping=function(){var t=this.parameters;this.bRadius=Math.max(10,.5*this.boundingBoxLength),isFinite(this.bRadius)||(this.bRadius=50),this.camera.getWorldPosition(this.distVector),this.cDist=this.distVector.length(),this.cDist||(this.cameraDistance=Math.abs(t.cameraZ),this.cDist=Math.abs(t.cameraZ));var e=this.scene.fog;if(e.color.set(t.fogColor),"camera"===t.clipMode)this.camera.near=t.clipNear,this.camera.far=t.clipFar,e.near=t.fogNear,e.far=t.fogFar;else if("absolute"===t.clipScale)this.camera.near=this.cDist-t.clipNear,this.camera.far=this.cDist+t.clipFar,e.near=this.cDist-t.fogNear,e.far=this.cDist+t.fogFar;else{var r=(50-t.clipNear)/50,i=-(50-t.clipFar)/50;this.camera.near=this.cDist-this.bRadius*r,this.camera.far=this.cDist+this.bRadius*i;var o=(50-t.fogNear)/50,n=-(50-t.fogFar)/50;e.near=this.cDist-this.bRadius*o,e.far=this.cDist+this.bRadius*n}"camera"!==t.clipMode&&("PerspectiveCamera"===this.camera.type?(this.camera.near=Math.max(.1,t.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),e.near=Math.max(.1,e.near),e.far=Math.max(1,e.far)):"OrthographicCamera"===this.camera.type&&t.clipDist>0&&(this.camera.near=Math.max(t.clipDist,this.camera.near)))},fr.prototype.__updateCamera=function(){var t=this.camera;t.updateMatrix(),t.updateMatrixWorld(!0),t.updateProjectionMatrix(),function(t,e,i,o,n){var a=new r.Vector2;i.getSize(a);var s=a.height,c=i.getPixelRatio(),u="OrthographicCamera"===e.type;er.set(a.width,a.height),rr.getInverse(e.projectionMatrix),ir.copy(e.projectionMatrix).transpose(),t.traverse((function(t){var e=t.material;if(e){var r=e.uniforms;if(r){if(e.clipNear){var i=(50-e.clipNear)/50,a=o-n*i;r.clipNear.value=a}r.canvasHeight&&(r.canvasHeight.value=s),r.resolution&&r.resolution.value.copy(er),r.pixelRatio&&(r.pixelRatio.value=c),r.projectionMatrixInverse&&r.projectionMatrixInverse.value.copy(rr),r.projectionMatrixTranspose&&r.projectionMatrixTranspose.value.copy(ir),r.ortho&&(r.ortho.value=u)}}}))}(this.scene,t,this.renderer,this.cDist,this.bRadius),function(t,e){t.traverseVisible((function(t){if(t instanceof r.Points&&t.userData.buffer.parameters.sortParticles){var i=t.geometry.attributes,o=i.position.count;if(0!==o){var n,a,s,c,u,l,h;Je.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),tr.multiplyMatrices(e.projectionMatrix,Je),t.userData.sortData?(n=t.userData.sortData,s=n.__zArray,a=n.__sortArray,c=n.__cmpFn):(s=new Float32Array(o),a=new Uint32Array(o),n={__zArray:s,__sortArray:a,__cmpFn:c=function(t,e){var r=s[t],i=s[e];return r>i?1:re?1:t=u&&e(t[n],o)>0;)t[n+1]=t[n],--n;t[n+1]=o}if(-1===c)break;l=s[c--],u=s[c--]}else{for(a=l,h(u+l>>1,n=u+1),e(t[u],t[l])>0&&h(u,l),e(t[n],t[l])>0&&h(n,l),e(t[u],t[n])>0&&h(u,n),o=t[n];;){do{n++}while(e(t[n],o)<0);do{a--}while(e(t[a],o)>0);if(a=a-u?(s[++c]=n,s[++c]=l,l=a-1):(s[++c]=u,s[++c]=a-1,u=n)}}(a,c),i){var f=i[d],m=f.array,g=f.itemSize;n[d]||(n[d]=new Float32Array(g*o)),h=n[d],n[d]=m;for(var y=0;y0&&"stereo"!==this.parameters.cameraType?this.__renderSuperSample(e,r):this.__renderModelGroup(e,r)},fr.prototype.render=function(t,e){if(void 0===t&&(t=!1),this.rendering)qt.warn("'tried to call 'render' from within 'render'");else{this.rendering=!0;try{this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),"stereo"===this.parameters.cameraType?this.__renderStereo(t,e):this.__render(t,this.camera,e),this.lastRenderedPicking=t}finally{this.rendering=!1,this.renderPending=!1}this.signals.rendered.dispatch()}},fr.prototype.clear=function(){qt.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()},fr.prototype.dispose=function(){this.renderer.dispose(),window.cancelAnimationFrame(this.frameRequest)},Object.defineProperties(fr.prototype,mr);function gr(t){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;return Math.sqrt(e*e+r*r)}var yr=function(t,e){void 0===e&&(e={}),this.domElement=t,this.signals={moved:new o.Signal,scrolled:new o.Signal,dragged:new o.Signal,dropped:new o.Signal,clicked:new o.Signal,hovered:new o.Signal,doubleClicked:new o.Signal},this.position=new r.Vector2,this.prevPosition=new r.Vector2,this.down=new r.Vector2,this.canvasPosition=new r.Vector2,this.prevClickCP=new r.Vector2,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=0,this.buttons=0,this.pressed=!1,this.altKey=!1,this.ctrlKey=!1,this.metaKey=!1,this.shiftKey=!1,this.domElement.style.touchAction="none",this.hoverTimeout=y(e.hoverTimeout,50),this.handleScroll=y(e.handleScroll,!0),this.doubleClickSpeed=y(e.doubleClickSpeed,500),this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();var i={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,i),document.addEventListener("wheel",this._onMousewheel,i),document.addEventListener("MozMousePixelScroll",this._onMousewheel,i),document.addEventListener("mousemove",this._onMousemove,i),document.addEventListener("mousedown",this._onMousedown,i),document.addEventListener("mouseup",this._onMouseup,i),document.addEventListener("contextmenu",this._onContextmenu,i),document.addEventListener("touchstart",this._onTouchstart,i),document.addEventListener("touchend",this._onTouchend,i),document.addEventListener("touchmove",this._onTouchmove,i)},vr={key:{configurable:!0}};vr.key.get=function(){var t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t},yr.prototype.setParameters=function(t){void 0===t&&(t={}),this.hoverTimeout=y(t.hoverTimeout,this.hoverTimeout)},yr.prototype._listen=function(){var t=window.performance.now(),e=this.canvasPosition;this.doubleClickPending&&t-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),t-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(e.x,e.y))),this.frameRequest=window.requestAnimationFrame(this._listen)},yr.prototype._onMousewheel=function(t){var e=this;if(t.target===this.domElement&&this.handleScroll){t.preventDefault(),this._setKeys(t);var r=0;"deltaY"in t&&"deltaMode"in t&&void 0!==t.deltaY&&void 0!==t.deltaMode?r=t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?.025*-t.deltaY:t.deltaMode===WheelEvent.DOM_DELTA_LINE?-t.deltaY*(2.5/3):2.5*-t.deltaY:"deltaY"in t&&!("detail"in t)?r=.025*-t.deltaY:void 0!==t.wheelDelta?r=.025*-t.wheelDelta:void 0!==t.wheelDeltaY?r=.025*-t.wheelDeltaY:void 0!==t.detail&&(r=-t.detail/3),this.signals.scrolled.dispatch(r),setTimeout((function(){e.scrolled=!0}),this.hoverTimeout)}},yr.prototype._onMousemove=function(t){t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(t),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.clientX,t.clientY),this._setCanvasPosition(t);var e=this.prevPosition.x-this.position.x,r=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,r),this.pressed&&this.signals.dragged.dispatch(e,r)},yr.prototype._onMousedown=function(t){t.target===this.domElement&&(t.preventDefault(),this._setKeys(t),this.moving=!1,this.hovering=!1,this.down.set(t.clientX,t.clientY),this.position.set(t.clientX,t.clientY),this.which=t.which,this.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(o/2);else{this.which=3,this.buttons=2;var n=this.prevPosition.x-this.position.x,a=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(n,a),this.pressed&&this.signals.dragged.dispatch(n,a)}}},yr.prototype._distance=function(){return this.position.distanceTo(this.down)},yr.prototype._setCanvasPosition=function(t){var e,r,i=this.domElement.getBoundingClientRect();"clientX"in t&&"clientY"in t?(e=t.clientX-i.left,r=t.clientY-i.top):(e=t.offsetX,r=t.offsetY),this.canvasPosition.set(e,i.height-r)},yr.prototype._setKeys=function(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey},yr.prototype.dispose=function(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove),window.cancelAnimationFrame(this.frameRequest)},Object.defineProperties(yr.prototype,vr);var br=new r.Matrix4,xr=new r.Matrix4,_r=new r.Matrix4,wr=new r.Matrix4,Ar=new r.Matrix4,Sr=new r.Vector3,Cr=new r.Quaternion,Pr=new r.Quaternion,Ir=new r.Matrix4,Or=new r.Vector3,Mr=new r.Vector3,kr=function(t,e){void 0===e&&(e={}),this.stage=t,this.rotateSpeed=y(e.rotateSpeed,2),this.zoomSpeed=y(e.zoomSpeed,1.2),this.panSpeed=y(e.panSpeed,1),this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls},Dr={component:{configurable:!0},atom:{configurable:!0}};Dr.component.get=function(){return this.stage.transformComponent},Dr.atom.get=function(){return this.stage.transformAtom},kr.prototype._setPanVector=function(t,e,r){void 0===r&&(r=0);var i=this.controls.getCanvasScaleFactor(r);Or.set(t,e,0),Or.multiplyScalar(this.panSpeed*i)},kr.prototype._getRotateXY=function(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]},kr.prototype._getCameraRotation=function(t){return t.extractRotation(this.viewer.camera.matrixWorld),t.multiply(xr.makeRotationY(Math.PI)),t},kr.prototype._transformPanVector=function(){this.component&&(Ir.extractRotation(this.component.transform),Ir.premultiply(this.viewer.rotationGroup.matrix),Ir.getInverse(Ir),Ir.multiply(this._getCameraRotation(wr)),Or.applyMatrix4(Ir))},kr.prototype.zoom=function(t){this.controls.zoom(this.zoomSpeed*t*.02)},kr.prototype.pan=function(t,e){this._setPanVector(t,e),Ir.getInverse(this.viewer.rotationGroup.matrix),Ir.multiply(this._getCameraRotation(wr)),Or.applyMatrix4(Ir),this.controls.translate(Or)},kr.prototype.panComponent=function(t,e){this.component&&(this._setPanVector(t,e),this._transformPanVector(),this.component.position.add(Or),this.component.updateMatrix())},kr.prototype.panAtom=function(t,e){this.atom&&this.component&&(this.atom.positionToVector3(Mr),Mr.add(this.viewer.translationGroup.position),Mr.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(t,e,Mr.z),this._transformPanVector(),this.atom.positionAdd(Or),this.component.updateRepresentations({position:!0}))},kr.prototype.rotate=function(t,e){var r=this._getRotateXY(t,e),i=r[0],o=r[1];this._getCameraRotation(wr),Sr.set(1,0,0),Sr.applyMatrix4(wr),Cr.setFromAxisAngle(Sr,o),Sr.set(0,1,0),Sr.applyMatrix4(wr),Pr.setFromAxisAngle(Sr,i),Cr.multiply(Pr),wr.makeRotationFromQuaternion(Cr),this.controls.applyMatrix(wr)},kr.prototype.zRotate=function(t,e){var r=this.rotateSpeed*((-t+e)/-2)*.01;_r.makeRotationZ(r),this.controls.applyMatrix(_r)},kr.prototype.rotateComponent=function(t,e){if(this.component){var r=this._getRotateXY(t,e),i=r[0],o=r[1];this._getCameraRotation(Ar),wr.extractRotation(this.component.transform),wr.premultiply(this.viewer.rotationGroup.matrix),wr.getInverse(wr),wr.premultiply(Ar),Sr.set(1,0,0),Sr.applyMatrix4(wr),br.makeRotationAxis(Sr,o),Sr.set(0,1,0),Sr.applyMatrix4(wr),xr.makeRotationAxis(Sr,i),br.multiply(xr),Cr.setFromRotationMatrix(br),this.component.quaternion.premultiply(Cr),this.component.quaternion.normalize(),this.component.updateMatrix()}},Object.defineProperties(kr.prototype,Dr);var Tr=new r.Vector3;var Br=function(t,e){this.stage=e,this.pid=t.pid,this.picker=t.picker,this.instance=t.instance,this.stage=e,this.controls=e.viewerControls,this.mouse=e.mouseObserver},Rr={type:{configurable:!0},altKey:{configurable:!0},ctrlKey:{configurable:!0},metaKey:{configurable:!0},shiftKey:{configurable:!0},canvasPosition:{configurable:!0},component:{configurable:!0},object:{configurable:!0},position:{configurable:!0},closestBondAtom:{configurable:!0},closeAtom:{configurable:!0},arrow:{configurable:!0},atom:{configurable:!0},axes:{configurable:!0},bond:{configurable:!0},box:{configurable:!0},cone:{configurable:!0},clash:{configurable:!0},contact:{configurable:!0},cylinder:{configurable:!0},distance:{configurable:!0},ellipsoid:{configurable:!0},octahedron:{configurable:!0},point:{configurable:!0},mesh:{configurable:!0},slice:{configurable:!0},sphere:{configurable:!0},tetrahedron:{configurable:!0},torus:{configurable:!0},surface:{configurable:!0},unitcell:{configurable:!0},unknown:{configurable:!0},volume:{configurable:!0},wideline:{configurable:!0}};Rr.type.get=function(){return this.picker.type},Rr.altKey.get=function(){return this.mouse.altKey},Rr.ctrlKey.get=function(){return this.mouse.ctrlKey},Rr.metaKey.get=function(){return this.mouse.metaKey},Rr.shiftKey.get=function(){return this.mouse.shiftKey},Rr.canvasPosition.get=function(){return this.mouse.canvasPosition},Rr.component.get=function(){return this.stage.getComponentsByObject(this.picker.data).list[0]},Rr.object.get=function(){return this.picker.getObject(this.pid)},Rr.position.get=function(){return this.picker.getPosition(this.pid,this.instance,this.component)},Rr.closestBondAtom.get=function(){if("bond"===this.type&&this.bond){var t=this.bond,e=this.controls,r=this.canvasPosition,i=t.atom1.positionToVector3(),o=t.atom2.positionToVector3();i.applyMatrix4(this.component.matrix),o.applyMatrix4(this.component.matrix);var n,a,s,c=e.getPositionOnCanvas(i),u=e.getPositionOnCanvas(o);return a=c,s=u,(n=r).distanceTo(a)=i.length))return new Br(r,this.stage);console.error("pid >= picker.array.length")}};var Er=new r.Quaternion,$r=new r.Vector3,Lr=new r.Vector3,Nr=new r.Vector3,zr=new r.Vector3,jr=new r.Matrix4,Vr=new r.Vector3,Gr=new r.Matrix4,Ur=function(t){this.stage=t,this.signals={changed:new m.Signal},this.viewer=t.viewer},Hr={position:{configurable:!0},rotation:{configurable:!0}};Hr.position.get=function(){return this.viewer.translationGroup.position},Hr.rotation.get=function(){return this.viewer.rotationGroup.quaternion},Ur.prototype.changed=function(){this.viewer.requestRender(),this.signals.changed.dispatch()},Ur.prototype.getPositionOnCanvas=function(t,e){var i=T(e,r.Vector2),o=this.viewer;return Nr.copy(t).add(o.translationGroup.position).applyMatrix4(o.rotationGroup.matrix).project(o.camera),i.set((Nr.x+1)*o.width/2,(Nr.y+1)*o.height/2)},Ur.prototype.getCanvasScaleFactor=function(t){void 0===t&&(t=0);var e=this.viewer.camera;if(e instanceof r.OrthographicCamera)return 1/e.zoom;t=Math.abs(t),t+=this.getCameraDistance();var i=z(e.fov);return 2*t*Math.tan(i/2)/this.viewer.height},Ur.prototype.getOrientation=function(t){var e=R(t);e.copy(this.viewer.rotationGroup.matrix);var r=this.getCameraDistance();return e.scale(zr.set(r,r,r)),e.setPosition(this.viewer.translationGroup.position),e},Ur.prototype.orient=function(t){R(t).decompose($r,Er,Lr);var e=this.viewer;e.rotationGroup.setRotationFromQuaternion(Er),e.translationGroup.position.copy($r),e.cameraDistance=Lr.z,e.updateZoom(),this.changed()},Ur.prototype.translate=function(t){this.viewer.translationGroup.position.add(B(t)),this.changed()},Ur.prototype.center=function(t){this.viewer.translationGroup.position.copy(B(t)).negate(),this.changed()},Ur.prototype.zoom=function(t){this.distance(this.getCameraDistance()*(1-t))},Ur.prototype.getCameraDistance=function(){return this.viewer.cameraDistance},Ur.prototype.distance=function(t){this.viewer.cameraDistance=Math.max(Math.abs(t),.2),this.viewer.updateZoom(),this.changed()},Ur.prototype.spin=function(t,e){jr.getInverse(this.viewer.rotationGroup.matrix),Vr.copy(B(t)).applyMatrix4(jr),this.viewer.rotationGroup.rotateOnAxis(Vr,e),this.changed()},Ur.prototype.rotate=function(t){this.viewer.rotationGroup.setRotationFromQuaternion(F(t)),this.changed()},Ur.prototype.align=function(t){Gr.getInverse(R(t)),this.viewer.rotationGroup.setRotationFromMatrix(Gr),this.changed()},Ur.prototype.applyMatrix=function(t){this.viewer.rotationGroup.applyMatrix4(R(t)),this.changed()},Object.defineProperties(Ur.prototype,Hr);var Wr=function(t,e){for(var r,i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=y(t,1e3),this.controls=e,this.startTime=window.performance.now(),(r=this)._init.apply(r,i)},qr={done:{configurable:!0},paused:{configurable:!0}};qr.done.get=function(){return 1===this.alpha},qr.paused.get=function(){return this._paused},Wr.prototype.tick=function(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=q(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach((function(t){return t()})),this.done},Wr.prototype.pause=function(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0},Wr.prototype.resume=function(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)},Wr.prototype.toggle=function(){this._paused?this.resume():this.pause()},Wr.prototype.then=function(t){var e=this;return(this.done?Promise.resolve():new Promise((function(t){return e._resolveList.push(t)}))).then(t)},Object.defineProperties(Wr.prototype,qr);var Xr=function(t){function e(e,r){for(var i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];t.apply(this,[y(e,1/0),r].concat(i))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){Array.isArray(t)?this.axis=(new r.Vector3).fromArray(t):this.axis=y(t,new r.Vector3(0,1,0)),this.angle=y(e,.01)},e.prototype._tick=function(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)},e}(Wr),Yr=function(t){function e(e,r){for(var i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];t.apply(this,[y(e,1/0),r].concat(i)),this.angleSum=0,this.direction=1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,i){Array.isArray(t)?this.axis=(new r.Vector3).fromArray(t):this.axis=y(t,new r.Vector3(0,1,0)),this.angleStep=y(e,.01),this.angleEnd=y(i,.2)},e.prototype._tick=function(t){if(this.axis&&this.angleStep&&this.angleEnd){var e=q(0,1,Math.abs(this.angleSum)/this.angleEnd),r=this.angleStep*this.direction*(1.1-e);this.controls.spin(this.axis,r*t.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}},e}(Wr),Kr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.moveFrom=B(y(t,new r.Vector3)),this.moveTo=B(y(e,new r.Vector3))},e.prototype._tick=function(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()},e}(Wr),Zr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.zoomFrom=t,this.zoomTo=e},e.prototype._tick=function(){this.controls.distance(H(this.zoomFrom,this.zoomTo,this.alpha))},e}(Wr),Qr=function(t){function e(){t.apply(this,arguments),this._currentRotation=new r.Quaternion}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.rotateFrom=F(t),this.rotateTo=F(e),this._currentRotation=new r.Quaternion},e.prototype._tick=function(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)},e}(Wr),Jr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,r){this.valueFrom=t,this.valueTo=e,this.callback=r},e.prototype._tick=function(){this.callback(H(this.valueFrom,this.valueTo,this.alpha))},e}(Wr),ti=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t){this.callback=t},e.prototype._tick=function(){1===this.alpha&&this.callback()},e}(Wr),ei=function(t){void 0===t&&(t=[]),this._resolveList=[],this._list=t},ri={done:{configurable:!0}};ri.done.get=function(){return this._list.every((function(t){return t.done}))},ei.prototype.then=function(t){var e,r=this;return e=this.done?Promise.resolve():new Promise((function(t){r._resolveList.push(t),r._list.forEach((function(t){t.then((function(){r._resolveList.forEach((function(t){t()})),r._resolveList.length=0}))}))})),e.then(t)},Object.defineProperties(ei.prototype,ri);var ii=function(t){this.stage=t,this.animationList=[],this.finishedList=[],this.viewer=t.viewer,this.controls=t.viewerControls},oi={paused:{configurable:!0}};oi.paused.get=function(){return this.animationList.every((function(t){return t.paused}))},ii.prototype.add=function(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t},ii.prototype.remove=function(t){var e=this.animationList,r=e.indexOf(t);r>-1&&e.splice(r,1)},ii.prototype.run=function(t){for(var e=this.finishedList,r=this.animationList,i=r.length,o=0;o0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(t||!1)}else this.lazyProps.build=!0},ai.prototype.make=function(e,r){var i=this;t.Debug&&qt.time("Representation.make "+this.type);var o=function(){e?(i.update(e),i.viewer.requestRender(),i.tasks.decrement(),r&&r()):(i.clear(),i.create(),i.manualAttach||i.disposed||(t.Debug&&qt.time("Representation.attach "+i.type),i.attach((function(){t.Debug&&qt.timeEnd("Representation.attach "+i.type),i.tasks.decrement(),r&&r()})))),t.Debug&&qt.timeEnd("Representation.make "+i.type)};this.toBePrepared?this.prepare(o):o()},ai.prototype.attach=function(t){this.setVisibility(this.visible),t()},ai.prototype.setVisibility=function(t,e){if(this.visible=t,this.visible&&this.opacity){var r=this.lazyProps,i=r.bufferParams,o=r.what;if(r.build)return r.build=!1,this.build(),this;(Object.keys(i).length||Object.keys(o).length)&&(r.bufferParams={},r.what={},this.updateParameters(i,o))}return this.bufferList.forEach((function(e){e.setVisibility(t)})),e||this.viewer.requestRender(),this},ai.prototype.setParameters=function(t,e,r){void 0===e&&(e={}),void 0===r&&(r=!1);var i=t||{},o=this.parameters,n={};for(var a in this.opacity||void 0===i.opacity||(this.lazyProps.build?(this.lazyProps.build=!1,r=!0):(Object.assign(n,this.lazyProps.bufferParams),Object.assign(e,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(i.color,i),i)if(void 0!==i[a]&&void 0!==o[a]&&(o[a].int&&(i[a]=parseInt(i[a])),o[a].float&&(i[a]=parseFloat(i[a])),i[a]!==this[a]||i[a].equals&&!i[a].equals(this[a]))){if(this[a]&&this[a].copy&&i[a].copy?this[a].copy(i[a]):this[a]&&this[a].set?this[a].set(i[a]):this[a]=i[a],o[a].buffer)if(!0===o[a].buffer)n[a]=i[a];else n[o[a].buffer]=i[a];o[a].update&&(e[o[a].update]=!0),!o[a].rebuild||"impostor"===o[a].rebuild&&Ut&&!this.disableImpostor||(r=!0)}return r?this.build():this.updateParameters(n,e),this},ai.prototype.updateParameters=function(t,e){if(void 0===t&&(t={}),this.lazy&&(!this.visible||!this.opacity)&&!1===t.hasOwnProperty("opacity"))return Object.assign(this.lazyProps.bufferParams,t),void Object.assign(this.lazyProps.what,e);this.bufferList.forEach((function(e){e.setParameters(t)})),Object.keys(e).length&&this.update(e),this.viewer.requestRender()},ai.prototype.getParameters=function(){var t=this,e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach((function(r){null!==t.parameters[r]&&(e[r]=t[r])})),e},ai.prototype.clear=function(){var t=this;this.bufferList.forEach((function(e){t.viewer.remove(e),e.dispose()})),this.bufferList.length=0,this.viewer.requestRender()},ai.prototype.dispose=function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()};var si=function(e){var r=this;this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=e,this.blobUrl=window.URL.createObjectURL(Kt.get(e)),this.worker=new Worker(this.blobUrl),Kt.activeWorkerCount+=1,this.worker.onmessage=function(i){r.pending-=1;var o=i.data.__postId;t.Debug&&qt.timeEnd("Worker.postMessage "+e+" #"+o);var n=r.onmessageDict[o];n&&n.call(r.worker,i),delete r.onmessageDict[o],delete r.onerrorDict[o]},this.worker.onerror=function(t){if(r.pending-=1,t.data){var i=t.data.__postId,o=r.onerrorDict[i];o?o.call(r.worker,t):qt.error("Worker.onerror",i,e,t),delete r.onmessageDict[i],delete r.onerrorDict[i]}else qt.error("Worker.onerror",e,t)}};si.prototype.post=function(e,r,i,o){void 0===e&&(e={}),this.onmessageDict[this.postCount]=i,this.onerrorDict[this.postCount]=o,e.__name=this.name,e.__postId=this.postCount,e.__debug=t.Debug,t.Debug&&qt.time("Worker.postMessage "+this.name+" #"+this.postCount);try{this.worker.postMessage(e,r)}catch(t){qt.error("worker.post:",t),this.worker.postMessage(e)}return this.pending+=1,this.postCount+=1,this},si.prototype.terminate=function(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),Kt.activeWorkerCount-=1):qt.log("no worker to terminate")};var ci=function(t,e){void 0===e&&(e=2),this.pool=[],this.count=0,this.maxCount=Math.min(8,e),this.name=t};function ui(t){for(var e=t.length,i=e/3,o=0,n=0,a=0,s=0;so&&(o=u),l>n&&(n=l),h>a&&(a=h)}return[mi([e,r,i]),mi([o,n,a])]}function pi(t,e){for(var r=0,i=e.length;r0){var s=1/Math.sqrt(a);t[e]=i*s,t[e+1]=o*s,t[e+2]=n*s}}}function mi(t){return new Float32Array(t||3)}function gi(t,e,r){var i=e[0],o=e[1],n=e[2],a=r[0],s=r[1],c=r[2];t[0]=o*c-n*s,t[1]=n*a-i*c,t[2]=i*s-o*a}function yi(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function vi(t,e,r){t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2]}function bi(t,e,r){t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2]}function xi(t,e,r){void 0===r&&(r=0),t[0]=e[r],t[1]=e[r+1],t[2]=e[r+2]}function _i(t,e,r){void 0===r&&(r=0),e[r]=t[0],e[r+1]=t[1],e[r+2]=t[2]}function wi(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function Ai(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])}function Si(t,e,r){Ci(t,e,1/r)}function Ci(t,e,r){t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r}function Pi(t,e){var r=wi(e);0==r?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):Ci(t,e,1/Math.sqrt(r))}function Ii(t,e,r){t[0]=e[0]-r,t[1]=e[1]-r,t[2]=e[2]-r}function Oi(t,e,r){t[0]=e[0]+r,t[1]=e[1]+r,t[2]=e[2]+r}function Mi(t,e){t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2])}function ki(t,e){t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2])}function Di(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}function Ti(t,e){void 0===e&&(e=9);for(var i=Math.floor(e/2),o=t.position1.length/3,n=3*(i*o),a=1/e,s=Le(t.position1,t.position2),c=new Float32Array(n),u=new Float32Array(n),l=new r.Vector3,h=0;h0){var O=3*f;n[O]=t.position2[3*h-3],n[O+1]=t.position2[3*h-2],n[O+1]=t.position2[3*h-1]}var M=new Float32Array(o),k=new Float32Array(n),D=$e(M,k),T=new Float32Array(a),B={position:D,position1:M,position2:k,color:T,color2:T};return s&&(B.radius=new Float32Array(s)),c&&t.picking&&(t.picking.array=new Float32Array(c),B.picking=t.picking),u&&(B.primitiveId=new Float32Array(u)),B}ci.prototype.post=function(t,e,r,i){void 0===t&&(t={});var o=this.getNextWorker();return o?o.post(t,e,r,i):console.error("unable to get worker from pool"),this},ci.prototype.terminate=function(){this.pool.forEach((function(t){t.terminate()}))},ci.prototype.getNextWorker=function(){for(var t,e=1/0,r=0;r=this.count){t=new si(this.name),this.pool.push(t),this.count+=1;break}var i=this.pool[r];if(0===i.pending){t=i;break}i.pending>this.exp),this.boundY=1+(i.max.y-this.minY>>this.exp),this.boundZ=1+(i.max.z-this.minZ>>this.exp);for(var o=this.boundX*this.boundY*this.boundZ,n=void 0!==t.count?t.count:t.x.length,a=t.x,s=t.y,c=t.z,u=0,l=new Uint32Array(o),h=new Int32Array(n),p=0;p>this.exp,f=s[p]-this.minY>>this.exp,m=c[p]-this.minZ>>this.exp,g=(d*this.boundY+f)*this.boundZ+m;1===(l[g]+=1)&&(u+=1),h[p]=g}for(var y=new Uint16Array(u),v=0,b=0;v0&&(l[v]=b+1,y[b]=x,b+=1)}for(var _=new Uint32Array(u),w=1;w0){var I=P-1;S[_[I]+A[I]]=C,A[I]+=1}}this.grid=l,this.bucketCount=y,this.bucketOffset=_,this.bucketArray=S,this.xArray=a,this.yArray=s,this.zArray=c};Ki.prototype.within=function(t,e,r,i){var o=[];return this.eachWithin(t,e,r,i,(function(t){return o.push(t)})),o},Ki.prototype.eachWithin=function(t,e,r,i,o){for(var n=i*i,a=Math.max(0,t-i-this.minX>>this.exp),s=Math.max(0,e-i-this.minY>>this.exp),c=Math.max(0,r-i-this.minZ>>this.exp),u=Math.min(this.boundX,1+(t+i-this.minX>>this.exp)),l=Math.min(this.boundY,1+(e+i-this.minY>>this.exp)),h=Math.min(this.boundZ,1+(r+i-this.minZ>>this.exp)),p=a;p0)for(var y=g-1,v=this.bucketOffset[y],b=v+this.bucketCount[y],x=v;xn?a.set(this[i].subarray(0,n)):a.set(this[i]),this[i]=a}},Zi.prototype.growIfFull=function(){if(this.count>=this.length){var t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}},Zi.prototype.copyFrom=function(t,e,r,i){for(var o=0,n=this._fields.length;o0;)c-=1;s<=c&&(s===a?a=c:c===a&&(a=s),(u=s)!==(l=c)&&(r.copyFrom(e,0,u,1),e.copyWithin(u,l,1),e.copyFrom(r,l,0,1)),s+=1,c-=1)}while(s<=c);i(o,c),i(s,n)}var u,l}(0,this.count-1),qt.timeEnd("Store.sort")},Zi.prototype.clear=function(){this.count=0},Zi.prototype.dispose=function(){for(var t=0,e=this._fields.length;t>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}var eo=function(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()};function ro(t){for(var e=t.edgeCount,r=t.nodeCount,i=t.nodeArray1,o=t.nodeArray2,n=new Uint8Array(r),a=new Int32Array(r),s=0;s0){var i=t.types,o=t.groups,n=t.centers,a=t.atomSets;i.push(e.type),o.push(e.group),n.x.push(e.x/r),n.y.push(e.y/r),n.z.push(e.z/r),a.push(e.atomSet)}}eo.prototype.get=function(t){return 0!=(this._words[t>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,a=e>>>5,s=n+1;s>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>r,this},eo.prototype._isRangeValue=function(t,e,r){if(!(e>>5,a=e>>>5,s=n+1;s>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<1||1!==e.number&&(i.index=e.index,n[a++].subVectors(e,t))})),1===a&&i.eachBondedAtom((function(e){a>1||1!==e.number&&e.index!==t.index&&n[a++].subVectors(e,t)})),2===a){var s=n[0].cross(n[1]);return Math.abs(Math.PI/2-s.angleTo(o))}}function No(t,e){var r=t.structure,i=r.atomCount,o=new Int8Array(i),n=new Int8Array(i),a=new Int8Array(i),s=new Int8Array(i);return r.eachAtom((function(t){var r=t.index,i=function(t,e){var r=t.bondToElementCount(1),i=t.formalCharge||0,o="always"===e.assignCharge||"auto"===e.assignCharge&&0===i,n="always"===e.assignH||"auto"===e.assignH&&0===r,a=t.bondCount,s=function(t){var e=0;return t.eachBond((function(t){return e+=t.bondOrder})),e}(t),c=function(t){var e=t.structure.getBondProxy(),r=t.number,i=8===r||7===r;if(i&&4===t.bondCount)return!1;var o=!1;return t.eachBond((function(r){if(r.bondOrder>1)o=!0;else if(i){var n=r.getOtherAtom(t);n.eachBond((function(t){if(t.bondOrder>1){var e=n.number;if((15===e||16===e)&&8===t.getOtherAtom(n).number)return;o=!0}}),e)}})),o}(t),u=s-a>0,l=0,h=8;switch(t.number){case 1:o&&(0===a?(i=1,h=0):1===a&&(i=0,h=1));break;case 6:o&&(i=0),n&&(l=Math.max(0,4-s-Math.abs(i))),h=Fo(a+l+Math.max(0,-i));break;case 7:if(o)if(n)if(c&&s<4)i=a-r==1&&s-r==2?1:0;else{var p=!1;t.eachBondedAtom((function(t){(16===t.number||t.isMetal())&&(p=!0)})),i=p?0:1}else i=s-3;n&&(l=Math.max(0,3-s+i)),h=Fo(c&&!u?a+l-i:a+l+1-i);break;case 8:o&&(n||(i=s-2),1===s&&t.eachBondedAtom((function(e){e.eachBond((function(r){var o=r.getOtherAtom(e);o.index!==t.index&&8===o.number&&2===r.bondOrder&&(i=-1)}))}))),n&&(l=Math.max(0,2-s+i)),h=Fo(c&&!u?a+l-i+1:a+l-i+2);break;case 16:o&&(n||(i=s<=3&&!t.bondToElementCount(8)?s-2:0)),n&&s<2&&(l=Math.max(0,2-s+i)),s<=3&&(h=Fo(a+l-i+2));break;case 9:case 17:case 35:case 53:case 85:o&&(i=s-1);break;case 3:case 11:case 19:case 37:case 55:case 87:o&&(i=1-s);break;case 4:case 12:case 20:case 38:case 56:case 88:o&&(i=2-s);break;default:console.warn("Requested charge, protonation for an unhandled element",t.element)}return[i,l,l+r,h]}(t,e),c=i[0],u=i[1],l=i[2],h=i[3];o[r]=c,n[r]=u,a[r]=l,s[r]=h})),{charge:o,implicitH:n,totalH:a,idealGeometry:s}}function zo(t){if(t["@valenceModel"])return t["@valenceModel"];var e=No(t,{assignCharge:"auto",assignH:"auto"});return t["@valenceModel"]=e,e}function jo(t){return 15===t.number&&t.bondToElementCount(8)===t.bondCount}var Vo=["ARG","HIS","LYS"],Go=["GLU","ASP"];function Uo(t,e,i){void 0===i&&(i={});for(var o=y(i.maxIonicDist,Jo.maxIonicDist),n=y(i.maxPiStackingDist,Jo.maxPiStackingDist),a=y(i.maxPiStackingOffset,Jo.maxPiStackingOffset),s=y(i.maxPiStackingAngle,Jo.maxPiStackingAngle),c=y(i.maxCationPiDist,Jo.maxCationPiDist),u=y(i.maxCationPiOffset,Jo.maxCationPiOffset),l=y(i.masterModelIndex,Jo.masterModelIndex),h=Math.max(o+2,n,c),p=n*n,d=c*c,f=e.features,m=e.spatialHash,g=e.contactStore,v=e.featureSet,b=f.types,x=f.centers,_=f.atomSets,w=x.x,A=x.y,S=x.z,C=b.length,P=t.atomStore.x,I=t.atomStore.y,O=t.atomStore.z,M=t.getAtomProxy(),k=t.getAtomProxy(),D=new r.Vector3,T=new r.Vector3,B=new r.Vector3,R=new r.Vector3,F=new r.Vector3,E=new r.Vector3,$=new r.Vector3,L=function(t,e){D.set(P[t[0]],I[t[0]],O[t[0]]),T.set(P[t[1]],I[t[1]],O[t[1]]),B.set(P[t[2]],I[t[2]],O[t[2]]),R.subVectors(D,T),F.subVectors(D,B),e.crossVectors(R,F)},N=function(t,e,r){return D.set(w[t],A[t],S[t]),T.set(w[e],A[e],S[e]),D.sub(T).projectOnPlane(r).add(T).distanceTo(T)},z=function(t,e,r){v.setBits(t,e),g.addContact(t,e,r)},j=function(t){m.eachWithin(w[t],A[t],S[t],h,(function(e,r){if(!(e<=t||(M.index=_[t][0],k.index=_[e][0],en(M,k,l)))){var i=b[t],n=b[e];if(function(t,e){return 2===t&&1===e||1===t&&2===e}(i,n))(function(t,e,r){for(var i=t.length,o=e.length,n=0;n=180-s||c<=s+90&&c>=90-s)&&z(t,e,3)}}else if(function(t,e){return 3===t&&1===e||1===t&&3===e}(i,n)&&r<=d){var h=3===i?[t,e]:[e,t],f=h[0],m=h[1];L(_[f],E),N(m,f,E)<=u&&z(f,m,2)}}}))},V=0;V0&&(i[t.index]||(oo(o,t),no(e,o)))})))}))}(e,r),function(t,e){var r=zo(t.data).charge,i={};t.eachResidue((function(t){if(Go.includes(t.resname)){var o=io(2);t.eachAtom((function(t){8===t.number&&t.isSidechain()&&oo(o,t)})),no(e,o)}else if(Io.includes(t.resname)){var n=io(2);t.eachAtom((function(t){jo(t)&&(n.group=6,t.eachBondedAtom((function(t){8===t.number&&oo(n,t)})),no(e,n))}))}else Ao.includes(t.resname)||Io.includes(t.resname)||(t.eachAtom((function(t){var r=!1,o=io(2);!function(t){return 16===t.number&&3===t.bondToElementCount(8)}(t)?jo(t)?(o.group=6,r=!0):function(t){return 16===t.number&&4===t.bondToElementCount(8)}(t)?(o.group=5,r=!0):function(t){var e=0;return 6===t.number&&2===t.bondToElementCount(8)&&1===t.bondToElementCount(6)&&t.eachBondedAtom((function(t){8===t.number&&t.bondCount-t.bondToElementCount(1)==1&&++e})),2===e}(t)&&(o.group=10,r=!0):(o.group=4,r=!0),r&&(t.eachBondedAtom((function(t){8===t.number&&(i[t.index]=!0,oo(o,t))})),no(e,o))})),t.eachAtom((function(t){var o=io(2);r[t.index]<0&&(i[t.index]||(oo(o,t),no(e,o)))})))}))}(e,r),function(t,e){var r=t.getAtomProxy();t.eachResidue((function(t){var i=t.getAromaticRings();if(i){var o=t.atomOffset;i.forEach((function(t){var i=io(3);t.forEach((function(t){r.index=t+o,oo(i,r)})),no(e,i)}))}}))}(e,r),function(t,e){var r=zo(t.data),i=r.charge,o=r.implicitH,n=r.idealGeometry;t.eachAtom((function(t){var r=io(5),a=t.number;if(8===a)oo(r,t),no(e,r);else if(7===a){if(Ho(t))oo(r,t),no(e,r);else if(i[t.index]<1){var s=t.bondCount+o[t.index],c=n[t.index];(4===c&&s<4||3===c&&s<3||2===c&&s<2)&&(oo(r,t),no(e,r))}}else 16===a&&("CYS"!==t.resname&&"MET"!==t.resname&&-1!==t.formalCharge||(oo(r,t),no(e,r)))}))}(e,r),function(t,e){var r=zo(t.data).totalH;t.eachAtom((function(t){var i=io(4),o=t.number;(Ho(t)||r[t.index]>0&&(7===o||8===o||16===o))&&(oo(i,t),no(e,i))}))}(e,r),function(t,e){var r=zo(t.data).totalH;t.eachAtom((function(t){if(6===t.number&&r[t.index]>0&&(t.bondToElementCount(7)>0||t.bondToElementCount(8)>0||function(t){if(!t.isAromatic())return!1;var e=t.residueType.getRings();if(!e)return!1;var r=!1;return e.rings.forEach((function(e){r||e.some((function(e){return t.index-t.residueAtomOffset===e}))&&(r=e.some((function(e){var r=t.residueType.atomTypeIdList[e],i=t.atomMap.get(r).number;return 7===i||8===i})))})),r}(t))){var i=io(9);oo(i,t),no(e,i)}}))}(e,r),function(t,e){t.eachAtom((function(t){var r=!1,i=!1,o=Ao.includes(t.resname),n=Io.includes(t.resname);if(o||n?o?8===t.number?(["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(t.resname)&&t.isSidechain()||t.isBackbone())&&(r=!0,i=!0):16===t.number&&"CYS"===t.resname?(r=!0,i=!0):7===t.number&&"HIS"===t.resname&&t.isSidechain()&&(r=!0):n&&(8===t.number&&t.isBackbone()?(r=!0,i=!0):["N3","N4","N7"].includes(t.atomname)?r=!0:["O2","O4","O6"].includes(t.atomname)&&(r=!0,i=!0)):t.isHalogen()||8===t.number||16===t.number?(r=!0,i=!0):7===t.number&&(r=!0),r){var a=io(11);oo(a,t),no(e,a)}if(i){var s=io(10);oo(s,t),no(e,s)}}))}(e,r),function(t,e){t.eachAtom((function(t){if(t.isTransitionMetal()||30===t.number||48===t.number){var r=io(12);oo(r,t),no(e,r)}else if(Wo.includes(t.number)){var i=io(13);oo(i,t),no(e,i)}}))}(e,r),function(t,e){t.eachAtom((function(t){var r=io(8),i=!1;6===t.number?(i=!0,t.eachBondedAtom((function(t){var e=t.number;6!==e&&1!==e&&(i=!1)}))):9===t.number&&(i=!0),i&&(oo(r,t),no(e,r))}))}(e,r),function(t,e){t.eachAtom((function(t){if(Xo.includes(t.number)){var r=!1;if(t.eachBondedAtom((function(t){Yo.includes(t.number)&&(r=!0)})),r){var i=io(7);oo(i,t),no(e,i)}}}))}(e,r),function(t,e){t.eachAtom((function(t){if(qo.includes(t.number)&&1===t.bondToElementCount(6)){var r=io(6);oo(r,t),no(e,r)}}))}(e,r),t.Debug&&qt.timeEnd("calculateFeatures"),r}function on(e,i){void 0===i&&(i=Jo);var o=function(t){var e=t.types,r=t.centers;return{features:t,spatialHash:new Ki(r),contactStore:new Ji,featureSet:new eo(e.length,!1)}}(rn(e));t.Debug&&qt.time("calculateContacts"),Uo(e,o,i),function(t,e,r){void 0===r&&(r={});for(var i=y(r.maxHbondDist,Jo.maxHbondDist),o=y(r.maxHbondSulfurDist,Jo.maxHbondSulfurDist),n=z(y(r.maxHbondAccAngle,Jo.maxHbondAccAngle)),a=z(y(r.maxHbondDonAngle,Jo.maxHbondDonAngle)),s=z(y(r.maxHbondAccPlaneAngle,Jo.maxHbondAccPlaneAngle)),c=z(y(r.maxHbondDonPlaneAngle,Jo.maxHbondDonPlaneAngle)),u=y(r.masterModelIndex,Jo.masterModelIndex),l=Math.max(i,o),h=i*i,p=e.features,d=e.spatialHash,f=e.contactStore,m=e.featureSet,g=p.types,v=p.centers,b=p.atomSets,x=v.x,_=v.y,w=v.z,A=g.length,S=zo(t.data).idealGeometry,C=t.getAtomProxy(),P=t.getAtomProxy(),I=function(t){d.eachWithin(x[t],_[t],w[t],l,(function(e,r){if(!(e<=t)){var i=g[t],o=g[e],l=function(t,e){return 9===t&&5===e||5===t&&9===e}(i,o);if(l||function(t,e){return 5===t&&4===e||4===t&&5===e}(i,o)){var p=5===o?[t,e]:[e,t],d=p[0],y=p[1];if(C.index=b[d][0],P.index=b[y][0],P.index!==C.index&&!en(C,P,u)&&!(16!==C.number&&16!==P.number&&r>h||C.connectedTo(P))){var v=$o(C,P),x=Eo.get(S[C.index])||z(120);if(!v.some((function(t){return Math.abs(x-t)>a}))){if(3===S[C.index]){var _=Lo(C,P);if(void 0!==_&&_>c)return}var w=$o(P,C),A=Eo.get(S[P.index])||z(120);if(!w.some((function(t){return A-t>n}))){if(3===S[P.index]){var I=Lo(P,C);if(void 0!==I&&I>s)return}m.setBits(d,y);var O,M,k=l?8:function(t,e){return t.isWater()&&e.isWater()}(O=C,M=P)?9:function(t,e){return t.isBackbone()&&e.isBackbone()}(O,M)?10:4;f.addContact(d,y,k)}}}}}}))},O=0;Oo)){var m=$o(d,h);0!==m.length&&(m.some((function(t){return Zo-t>o}))||(u.setBits(t,e),c.addContact(t,e,5)))}}}))},_=0;_i&&!Qo(b,_,a)&&!Qo(x,_,a)&&!n.includes(r)&&!u.includes(r)&&w.distanceToSquared(_)>1&&A.distanceToSquared(_)>1&&(c.clear(e),t.Debug&&qt.log("removing",b.qualifiedName(),x.qualifiedName(),"because",_.qualifiedName()))}))})),t.Debug&&qt.timeEnd("refineLineOfSight")}(e,n,i),function(t,e){var r=e.contactSet,i=e.contactStore,o=e.features,n=i.type,a=i.index1,s=i.index2,c=o.atomSets,u=t.getAtomProxy(),l=t.getAtomProxy(),h={},p=function(t,e,i){var o=h[i]||[1/0,-1],n=o[0],a=o[1];t=d){B=v,M=!0;break}if(M)break}if(M)break}for(M=!1,y=n;y=d){T=y,M=!0;break}if(M)break}if(M)break}for(M=!1,m=o;m=d){k=m,M=!0;break}if(M)break}if(M)break}for(M=!1,v=l;v>=s;--v){for(y=u;y>=n;--y){for(m=c;m>=o;--m)if(t[h=e*r*v+e*y+m]>=d){$=v,M=!0;break}if(M)break}if(M)break}for(M=!1,y=u;y>=n;--y){for(v=$;v>=s;--v){for(m=c;m>=o;--m)if(t[h=e*r*v+e*y+m]>=d){F=y,M=!0;break}if(M)break}if(M)break}for(M=!1,m=c;m>=o;--m){for(y=F;y>=n;--y){for(v=$;v>=s;--v)if(t[h=e*r*v+e*y+m]>=d){R=m,M=!0;break}if(M)break}if(M)break}f?(o=Math.max(0,k-1),n=Math.max(0,T-1),s=Math.max(0,B-1),c=Math.min(e-1,R+1),u=Math.min(r-1,F+1),l=Math.min(i-1,$+1)):(o=Math.max(1,k-1),n=Math.max(1,T-1),s=Math.max(1,B-1),c=Math.min(e-2,R+1),u=Math.min(r-2,F+1),l=Math.min(i-2,$+1))}var L=15;for(v=s;v0?-1:1,n||(n=new Float32Array(3*b)));var I=3*b;if(a&&a.length===I||(a=new Int32Array(I)),s=0,c=0,void 0!==x){var O=x[0].map(Math.round),M=x[1].map(Math.round);u=e*Math.ceil(Math.abs(O[0])/e),l=r*Math.ceil(Math.abs(O[1])/r),h=i*Math.ceil(Math.abs(O[2])/i),$(O[0],O[1],O[2],M[0],M[1],M[2])}else u=l=h=0,$();return A.length=3*s,f||(S.length=3*s),C.length=c,o&&(P.length=s),{position:new Float32Array(A),normal:f?void 0:new Float32Array(S),index:k(C,A.length/3),atomindex:o?new Int32Array(P):void 0,contour:m}}}ne.add("arrow",dn),ne.add("box",An),ne.add("cone",vn),ne.add("cylinder",pn),ne.add("ellipsoid",_n),ne.add("octahedron",wn),ne.add("sphere",Pn),ne.add("tetrahedron",On),ne.add("torus",Mn),ne.add("point",Bn),ne.add("wideline",Rn),Object.assign($n,{__deps:[Fn,En,k]});var Ln=function(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)};function Nn(t,e){for(var r=0,i=0,o=e.rows,n=e.cols,a=0,s=0,c=0,u=e.data,l=t.data;r(e=Math.abs(e))?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}Ln.prototype.copyTo=function(t){t.data.set(this.data)};function Wn(t,e,r,i){var o=0,n=0,a=t.rows,s=t.cols,c=a,u=s;c>16)?T:-T,t[c*e+l]=D;for(h=0;h<2;h++)for(u=0;ur){var i=e;e=r,r=i}var o=t[e];return void 0===o?(t[e]=[r],!0):!o.includes(r)&&(o.push(r),!0)}var r=this.geometry,i=r.index;if(this.parameters.wireframe)if(i){var o,n=i.array,a=n.length;if(r.drawRange.count!==1/0&&(a=r.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*a)o=this.wireframeIndex;else o=k(2*a,r.attributes.position.count);var s=0;t.length=0;for(var c=0;c2*d?this.wireframeIndex:k(2*d,d);for(var f=0,m=0;fthis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new r.BufferAttribute(this.wireframeIndex,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0));else{var t=this.wireframeGeometry.getIndex();if(!t)return void qt.error("Index is null");t.set(this.wireframeIndex),t.needsUpdate=this.wireframeIndexCount>0,t.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}},ma.prototype.getRenderOrder=function(){var t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t},ma.prototype._getMesh=function(t){this.material||this.makeMaterial();var e,i=this.geometry,o=this[t];return(e=this.isLine?new r.LineSegments(i,o):this.isPoint?new r.Points(i,o):new r.Mesh(i,o)).frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e},ma.prototype.getMesh=function(){return this._getMesh("material")},ma.prototype.getWireframeMesh=function(){var t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),(t=new r.LineSegments(this.wireframeGeometry,this.wireframeMaterial)).frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},ma.prototype.getPickingMesh=function(){return this._getMesh("pickingMaterial")},ma.prototype.getShader=function(t,e){return Pe(t,this.getDefines(e))},ma.prototype.getVertexShader=function(t){return this.getShader(this.vertexShader,t)},ma.prototype.getFragmentShader=function(t){return this.getShader(this.fragmentShader,t)},ma.prototype.getDefines=function(t){var e={};return this.parameters.clipNear&&(e.NEAR_CLIP=1),this.parameters.clipRadius&&(e.RADIUS_CLIP=1),"picking"===t?e.PICKING=1:(("background"===t||this.parameters.background)&&(e.NOLIGHT=1),this.parameters.flatShaded&&(e.FLAT_SHADED=1),this.parameters.opaqueBack&&(e.OPAQUE_BACK=1),this.parameters.diffuseInterior&&(e.DIFFUSE_INTERIOR=1),this.parameters.useInteriorColor&&(e.USE_INTERIOR_COLOR=1)),e},ma.prototype.getParameters=function(){return this.parameters},ma.prototype.addUniforms=function(t){this.uniforms=r.UniformsUtils.merge([this.uniforms,t]),this.pickingUniforms=r.UniformsUtils.merge([this.pickingUniforms,t])},ma.prototype.addAttributes=function(t){for(var e in t){var i=void 0,o=t[e],n=this.attributeSize*ha[o.type];o.value?(n!==o.value.length&&qt.error("attribute value has wrong length",e),i=o.value):i=M("float32",n),this.geometry.setAttribute(e,new r.BufferAttribute(i,ha[o.type]).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0))}},ma.prototype.updateRenderOrder=function(){var t=this.getRenderOrder();function e(e){e.renderOrder=t}this.group.children.forEach(e),this.pickingGroup&&this.pickingGroup.children.forEach(e)},ma.prototype.updateShader=function(){var t=this.material,e=this.wireframeMaterial,r=this.pickingMaterial;t.vertexShader=this.getVertexShader(),t.fragmentShader=this.getFragmentShader(),t.needsUpdate=!0,e.vertexShader=this.getShader("Line.vert"),e.fragmentShader=this.getShader("Line.frag"),e.needsUpdate=!0,r.vertexShader=this.getVertexShader("picking"),r.fragmentShader=this.getFragmentShader("picking"),r.needsUpdate=!0},ma.prototype.setParameters=function(t){var e=t,r=this.parameterTypes,i=this.parameters,o={},n={},a=!1,s=!1;for(var c in e){var u=e[c];void 0!==u&&(i[c]=u,void 0!==r[c]&&(r[c].property&&(!0!==r[c].property?o[r[c].property]=u:o[c]=u),r[c].uniform&&(!0!==r[c].uniform?n[r[c].uniform]=u:n[c]=u),r[c].updateShader&&(a=!0),r[c].updateVisibility&&(s=!0),this.dynamic&&"wireframe"===c&&!0===u&&this.updateWireframeIndex(),"forceTransparent"===c&&(o.transparent=this.transparent),"matrix"===c&&(this.matrix=u)))}this.setProperties(o),this.setUniforms(n),a&&this.updateShader(),s&&this.setVisibility(this.visible)},ma.prototype.setAttributes=function(t){var e=this.geometry,i=e.attributes;for(var o in t)if("picking"!==o){var n=t[o],a=n.length;if("index"===o){var s=e.getIndex();if(!s){qt.error("Index is null");continue}e.setDrawRange(0,1/0),a>s.array.length?e.setIndex(new r.BufferAttribute(n,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(s.set(n),s.count=a,s.needsUpdate=a>0,s.updateRange.count=a,e.setDrawRange(0,a)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{var c=i[o];a>c.array.length?e.setAttribute(o,new r.BufferAttribute(n,c.itemSize).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(i[o].set(n),i[o].needsUpdate=a>0,i[o].updateRange.count=a)}}},ma.prototype.setUniforms=function(t){if(t){var e=this.material.uniforms,r=this.wireframeMaterial.uniforms,i=this.pickingMaterial.uniforms;for(var o in t)"opacity"===o&&this.setProperties({transparent:this.transparent}),void 0!==e[o]&&(e[o].value.isVector3?e[o].value.copy(t[o]):e[o].value.set?e[o].value.set(t[o]):e[o].value=t[o]),void 0!==r[o]&&(r[o].value.isVector3?r[o].value.copy(t[o]):r[o].value.set?r[o].value.set(t[o]):r[o].value=t[o]),void 0!==i[o]&&(i[o].value.isVector3?i[o].value.copy(t[o]):i[o].value.set?i[o].value.set(t[o]):i[o].value=t[o])}},ma.prototype.setProperties=function(t){if(t){var e=this.material,r=this.wireframeMaterial,i=this.pickingMaterial;for(var o in t){var n=o,a=t[n];"transparent"===n?this.updateRenderOrder():"side"===n&&(a=la(a)),e[n]=a,r[n]=a,i[n]=a}e.needsUpdate=!0,r.needsUpdate=!0,i.needsUpdate=!0}},ma.prototype.setVisibility=function(t){this.visible=t,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))},ma.prototype.dispose=function(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()},ma.prototype.toJSON=function(){var t={};for(var e in this)"group"!==e&&"wireframeGroup"!==e&&"pickingGroup"!=e&&"picking"!==e&&(t[e]=this[e]);return t},Object.defineProperties(ma.prototype,ga);var ya=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,e,r),this.vertexShader="Mesh.vert",this.fragmentShader="Mesh.frag",this.addAttributes({normal:{type:"v3",value:e.normal}}),void 0===e.normal&&this.geometry.computeVertexNormals()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(ma),va=function(t){function e(){t.apply(this,arguments),this.isSurface=!0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(ya);function ba(t){t.visible=!0}function xa(t){t.visible=!1}var _a=function(t){this.group=new r.Group,this.wireframeGroup=new r.Group,this.pickingGroup=new r.Group,this.frontMeshes=[],this.backMeshes=[],this.size=t.size,this.side=t.parameters.side,this.visible=t.visible,this.geometry=t.geometry,this.picking=t.picking,this.group=new r.Group,this.wireframeGroup=new r.Group,this.pickingGroup=new r.Group,this.matrix=t.matrix;var e=t,i=new t.constructor({position:new Float32Array(0)});e.makeMaterial(),i.makeMaterial(),i.picking=t.picking,i.geometry=t.geometry,i.wireframeGeometry=t.wireframeGeometry,i.setParameters(t.getParameters()),i.updateShader(),e.setParameters({side:"front"}),i.setParameters({side:"back",opacity:i.parameters.opacity}),this.buffer=t,this.frontBuffer=e,this.backBuffer=i},wa={matrix:{configurable:!0},pickable:{configurable:!0},parameters:{configurable:!0}};wa.matrix.set=function(t){ma.prototype.setMatrix.call(this,t)},wa.matrix.get=function(){return this.group.matrix.clone()},wa.pickable.get=function(){return!!this.picking&&!this.parameters.disablePicking},wa.parameters.get=function(){return this.buffer.parameters},_a.prototype.getParameters=function(){var t=Object.assign({},this.buffer.parameters);return t.side=this.side,t},_a.prototype.getMesh=function(t){var e,i;return t?(i=this.backBuffer.getPickingMesh(),e=this.frontBuffer.getPickingMesh()):(i=this.backBuffer.getMesh(),e=this.frontBuffer.getMesh()),this.frontMeshes.push(e),this.backMeshes.push(i),this.setParameters({side:this.side}),(new r.Group).add(i,e)},_a.prototype.getWireframeMesh=function(){return this.buffer.getWireframeMesh()},_a.prototype.getPickingMesh=function(){return this.getMesh(!0)},_a.prototype.setAttributes=function(t){this.buffer.setAttributes(t)},_a.prototype.setParameters=function(t){"front"===(t=Object.assign({},t)).side?(this.frontMeshes.forEach(ba),this.backMeshes.forEach(xa)):"back"===t.side?(this.frontMeshes.forEach(xa),this.backMeshes.forEach(ba)):"double"===t.side&&(this.frontMeshes.forEach(ba),this.backMeshes.forEach(ba)),void 0!==t.side&&(this.side=t.side),delete t.side,void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,this.frontBuffer.setParameters(t),void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),delete t.wireframe,this.backBuffer.setParameters(t)},_a.prototype.setVisibility=function(t){this.visible=t,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))},_a.prototype.dispose=function(){this.frontBuffer.dispose(),this.backBuffer.dispose()},_a.prototype.toJSON=function(){var t={};for(var e in this)["side","size","visible","matrix","parameters"].includes(e)&&(t[e]=this[e]);return t},Object.defineProperties(_a.prototype,wa),ee.add("shader/Line.vert","uniform float clipNear;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),ee.add("shader/Line.frag","uniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");var Aa=function(t){function e(){t.apply(this,arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(ma),Sa=function(t){function e(e,i,o){t.call(this,e,i,o),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},isolevelScroll:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),e instanceof ca?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new r.Vector3,this.__boxCenter=new r.Vector3,this.box=new r.Box3,this.__box=new r.Box3,this._position=new r.Vector3,this.inverseMatrix=new r.Matrix4,this.setBox=function(){this._position.copy(i.translationGroup.position).negate(),this._position.applyMatrix4(this.inverseMatrix),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.colorScheme=y(r.colorScheme,"uniform"),r.colorValue=y(r.colorValue,14540253),this.isolevelType=y(r.isolevelType,"sigma"),this.isolevel=y(r.isolevel,2),this.negateIsolevel=y(r.negateIsolevel,!1),this.isolevelScroll=y(r.isolevelScroll,!1),this.smooth=y(r.smooth,0),this.background=y(r.background,!1),this.opaqueBack=y(r.opaqueBack,!0),this.boxSize=y(r.boxSize,0),this.colorVolume=y(r.colorVolume,void 0),this.contour=y(r.contour,!1),this.useWorker=y(r.useWorker,!0),this.wrap=y(r.wrap,!1),t.prototype.init.call(this,r),this.inverseMatrix.getInverse(this.matrix),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach((function(t){e.viewer.add(t)})),this.setVisibility(this.visible),t()},e.prototype.prepare=function(t){var e,r=this;if(this.volume)if(e="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(e*=-1),!this.surface||this.__isolevel!==e||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=e,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);var i=function(e){r.surface=e,t()};this.useWorker?this.volume.getSurfaceWorker(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else t();else t()},e.prototype.create=function(){var t,e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};if(this.contour)t=new Aa(e,this.getBufferParams({wireframe:!1}));else{Object.assign(e,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});var r=new va(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new _a(r)}this.bufferList.push(t)},e.prototype.update=function(t){if(0!==this.bufferList.length){var e={};(t=t||{}).position&&(e.position=this.surface.getPosition()),t.color&&(e.color=this.surface.getColor(this.getColorParams())),t.index&&(e.index=this.surface.getIndex()),t.normal&&(e.normal=this.surface.getNormal()),this.bufferList.forEach((function(t){t.setAttributes(e)}))}},e.prototype.setParameters=function(e,r,i){return e&&void 0!==e.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===e.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===e.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=e.isolevelType),e&&e.boxCenter&&(this.boxCenter.copy(e.boxCenter),delete e.boxCenter),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),t.prototype.setParameters.call(this,e,r,i),e.matrix&&this.inverseMatrix.getInverse(e.matrix),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&void 0!==e.colorVolume&&r&&(r.color=!0),this.surface&&(void 0!==e.isolevel||void 0!==e.negateIsolevel||void 0!==e.smooth||void 0!==e.wrap||void 0!==e.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.volume=this.colorVolume,e},e.prototype.dispose=function(){this.viewer.signals.ticked.remove(this.setBox,this),t.prototype.dispose.call(this)},e}(ai),Ca=function(){};Ca.zoomScroll=function(t,e){t.trackballControls.zoom(e)},Ca.clipNearScroll=function(t,e){var r=t.getParameters();t.setParameters({clipNear:r.clipNear+e/10})},Ca.focusScroll=function(t,e){var r=t.getFocus(),i=Math.sign(e)*function(t,e,r){if(t>e)return t;var i=t/e;return((2*r-e)*i+(2*e-3*r))*i*i+r}((100-r)/10,5,.2);t.setFocus(r+i)},Ca.zoomFocusScroll=function(t,e){t.trackballControls.zoom(e);var r=t.viewer.camera.position.z;t.setFocus(100-Math.abs(r/8))},Ca.isolevelScroll=function(t,e){var r=Math.sign(e)/10;t.eachRepresentation((function(t,e){if(t.repr instanceof Sa){var i=t.getParameters();i.isolevelScroll&&t.setParameters({isolevel:i.isolevel+r})}}))},Ca.panDrag=function(t,e,r){t.trackballControls.pan(e,r)},Ca.rotateDrag=function(t,e,r){t.trackballControls.rotate(e,r)},Ca.zRotateDrag=function(t,e,r){t.trackballControls.zRotate(e,r)},Ca.zoomDrag=function(t,e,r){t.trackballControls.zoom((e+r)/-2)},Ca.zoomFocusDrag=function(t,e,r){t.trackballControls.zoom((e+r)/-2);var i=t.viewer.camera.position.z;t.setFocus(100-Math.abs(i/8))},Ca.panComponentDrag=function(t,e,r){t.trackballControls.panComponent(e,r)},Ca.panAtomDrag=function(t,e,r){t.trackballControls.panAtom(e,r)},Ca.rotateComponentDrag=function(t,e,r){t.trackballControls.rotateComponent(e,r)},Ca.movePick=function(t,e){e&&t.animationControls.move(e.position.clone())},Ca.tooltipPick=function(t,e){var r=t.tooltip;if(t.getParameters().tooltip&&e){var i=e.mouse.position;r.innerText=e.getLabel(),r.style.bottom=window.innerHeight-i.y+3+"px",r.style.left=i.x+3+"px",r.style.display="block"}else r.style.display="none"};var Pa={default:[["scroll",Ca.zoomScroll],["scroll-shift",Ca.focusScroll],["scroll-ctrl",Ca.isolevelScroll],["scroll-shift-ctrl",Ca.zoomFocusScroll],["drag-left",Ca.rotateDrag],["drag-right",Ca.panDrag],["drag-ctrl-left",Ca.panDrag],["drag-ctrl-right",Ca.zRotateDrag],["drag-shift-left",Ca.zoomDrag],["drag-middle",Ca.zoomFocusDrag],["drag-ctrl-shift-right",Ca.panComponentDrag],["drag-ctrl-shift-left",Ca.rotateComponentDrag],["clickPick-right",Ca.measurePick=function(t,e){if(e&&(e.atom||e.bond)){var r=e.atom||e.closestBondAtom;e.component.measurePick(r)}else t.measureClear()}],["clickPick-ctrl-left",Ca.measurePick],["clickPick-middle",Ca.movePick],["clickPick-left",Ca.movePick],["hoverPick",Ca.tooltipPick]],pymol:[["drag-left",Ca.rotateDrag],["drag-middle",Ca.panDrag],["drag-right",Ca.zoomDrag],["drag-shift-right",Ca.focusScroll],["clickPick-ctrl+shift-middle",Ca.movePick],["hoverPick",Ca.tooltipPick]],coot:[["scroll",Ca.isolevelScroll],["drag-left",Ca.rotateDrag],["drag-middle",Ca.panDrag],["drag-ctrl-left",Ca.panDrag],["drag-right",Ca.zoomFocusDrag],["drag-ctrl-right",Ca.focusScroll],["clickPick-middle",Ca.movePick],["hoverPick",Ca.tooltipPick]],astexviewer:[["drag-left",Ca.rotateDrag],["drag-ctrl-left",Ca.panDrag],["drag-shift-left",Ca.zoomDrag],["scroll",Ca.focusScroll],["clickPick-middle",Ca.movePick],["hoverPick",Ca.tooltipPick]]};function Ia(t){var e=t.split(/[-+]/),r="";e.includes("scroll")&&(r="scroll"),e.includes("drag")&&(r="drag"),e.includes("click")&&(r="click"),e.includes("doubleClick")&&(r="doubleClick"),e.includes("hover")&&(r="hover"),e.includes("clickPick")&&(r="clickPick"),e.includes("hoverPick")&&(r="hoverPick");var i=0;e.includes("alt")&&(i+=1),e.includes("ctrl")&&(i+=2),e.includes("meta")&&(i+=4),e.includes("shift")&&(i+=8);var o=0;return e.includes("left")&&(o+=1),e.includes("right")&&(o+=2),e.includes("middle")&&(o+=4),[r,i,o]}var Oa=function(t,e){void 0===e&&(e={}),this.stage=t,this.actionList=[],this.mouse=t.mouseObserver,this.disabled=e.disabled||!1,this.preset(e.preset||"default")};Oa.prototype.run=function(t){for(var e=this,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];if(!this.disabled){var o=this.mouse.key||0,n=this.mouse.buttons||0;this.actionList.forEach((function(i){i.type===t&&i.key===o&&i.button===n&&i.callback.apply(i,[e.stage].concat(r))}))}},Oa.prototype.add=function(t,e){var r=Ia(t),i=r[0],o=r[1],n=r[2];this.actionList.push({type:i,key:o,button:n,callback:e})},Oa.prototype.remove=function(t,e){var r=t.includes("*"),i=Ia(t),o=i[0],n=i[1],a=i[2],s=this.actionList.filter((function(t){return!((t.type===o||r&&""===o)&&(t.key===n||r&&0===n)&&(t.button===a||r&&0===a)&&(t.callback===e||void 0===e))}));this.actionList=s},Oa.prototype.preset=function(t){var e=this;this.clear(),(Pa[t]||[]).forEach((function(t){return e.add(t[0],t[1])}))},Oa.prototype.clear=function(){this.actionList.length=0};var Ma=function(){};Ma.autoView=function(t){t.autoView(1e3)},Ma.toggleAnimations=function(t){t.animationControls.toggle()},Ma.toggleRock=function(t){t.toggleRock()};var ka={default:[["i",Ma.toggleSpin=function(t){t.toggleSpin()}],["k",Ma.toggleRock],["p",Ma.toggleAnimations],["a",Ma.toggleAntialiasing=function(t){var e=t.getParameters();t.setParameters({sampleLevel:-1===e.sampleLevel?0:-1})}],["r",Ma.autoView]]},Da=function(t,e){void 0===e&&(e={}),this.stage=t,this.actionList=[],this.disabled=e.disabled||!1,this.preset(e.preset||"default")};Da.prototype.run=function(t){var e=this;this.disabled||this.actionList.forEach((function(r){r.key===t&&r.callback(e.stage)}))},Da.prototype.add=function(t,e){this.actionList.push({key:t,callback:e})},Da.prototype.remove=function(t,e){var r=this.actionList.filter((function(r){return!(r.key===t&&(r.callback===e||void 0===e))}));this.actionList=r},Da.prototype.preset=function(t){var e=this;this.clear(),(ka[t]||[]).forEach((function(t){return e.add(t[0],t[1])}))},Da.prototype.clear=function(){this.actionList.length=0};var Ta=function(t){this.stage=t,this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)};Ta.prototype._onClick=function(t,e){var r=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(r),this.controls.run("clickPick",r)},Ta.prototype._onHover=function(t,e){var r=this.stage.pickingControls.pick(t,e);r&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=r.component,this.stage.transformAtom=r.atom),this.stage.signals.hovered.dispatch(r),this.controls.run("hoverPick",r)},Ta.prototype.dispose=function(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Ba=function(t){this.stage=t,this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)};Ba.prototype._onMove=function(){this.stage.tooltip.style.display="none"},Ba.prototype._onScroll=function(t){this.controls.run("scroll",t)},Ba.prototype._onDrag=function(t,e){this.controls.run("drag",t,e)},Ba.prototype._onClick=function(t,e){this.controls.run("click",t,e)},Ba.prototype._onDblclick=function(t,e){this.controls.run("doubleClick",t,e)},Ba.prototype._onHover=function(t,e){this.controls.run("hover",t,e)},Ba.prototype.dispose=function(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Ra=function(t){this.stage=t,this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)};Ra.prototype._onTick=function(t){this.animationControls.run(t)},Ra.prototype.dispose=function(){this.viewer.signals.ticked.remove(this._onTick,this)};var Fa=!!Nt&&{passive:!0},Ea=function(t){this.stage=t,this.stage=t,this.controls=t.keyControls,this.domElement=t.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,Fa),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)};Ea.prototype._onKeydown=function(){},Ea.prototype._onKeyup=function(){},Ea.prototype._onKeypress=function(t){var e;e="key"in KeyboardEvent.prototype?t.key:String.fromCharCode(t.which||t.keyCode),this.controls.run(e)},Ea.prototype._focusDomElement=function(){this.domElement.focus()},Ea.prototype.dispose=function(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,Fa),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)};var $a=function(t,e,i,o){void 0===o&&(o={}),this.component=t,this.position=e,this.offsetX=y(o.offsetX,0),this.offsetY=y(o.offsetY,0),this.visible=y(o.visible,!0),this.stage=t.stage,this.viewer=t.stage.viewer,this._viewerPosition=new r.Vector3,this._updateViewerPosition(),this._canvasPosition=new r.Vector2,this._cameraPosition=new r.Vector3,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",left:"-10000px"}),this.viewer.wrapper.appendChild(this.element),this.setContent(i),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)};$a.prototype.setContent=function(t){var e=this.element.style.display;if("none"===e&&(this.element.style.left="-10000px",this.element.style.display="block"),t instanceof HTMLElement)this.element.appendChild(t);else{var r=document.createElement("div");r.innerText=t,Object.assign(r.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(r)}this._clientRect=this.element.getBoundingClientRect(),"none"===e&&(this.element.style.display=e)},$a.prototype.setVisibility=function(t){this.visible=t,this.updateVisibility()},$a.prototype.getVisibility=function(){return this.visible&&this.component.parameters.visible},$a.prototype.updateVisibility=function(){this.element.style.display=this.getVisibility()?"block":"none"},$a.prototype._updateViewerPosition=function(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)},$a.prototype._update=function(){if(this.getVisibility()){var t=this.element.style,e=this._canvasPosition,r=this._viewerPosition,i=this._clientRect;if(this._cameraPosition.copy(r).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)t.display="none";else{t.display="block";var o=this._cameraPosition.length(),n=this.viewer.scene.fog;t.opacity=(1-q(n.near,n.far,o)).toString(),t.zIndex=Math.round(100*(n.far-o)).toString(),this.stage.viewerControls.getPositionOnCanvas(r,e),t.bottom=this.offsetX+e.y+i.height/2+"px",t.left=this.offsetY+e.x-i.width/2+"px"}}},$a.prototype.dispose=function(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)};var La=new r.Matrix4,Na=new r.Vector3,za=new r.Quaternion,ja=function(t){this.component=t,this.signals={changed:new m.Signal},this.stage=t.stage,this.viewer=t.stage.viewer},Va={position:{configurable:!0},rotation:{configurable:!0}};Va.position.get=function(){return this.component.position},Va.rotation.get=function(){return this.component.quaternion},ja.prototype.changed=function(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()},ja.prototype.spin=function(t,e){La.getInverse(this.viewer.rotationGroup.matrix),Na.copy(B(t)).applyMatrix4(La),La.extractRotation(this.component.transform),La.premultiply(this.viewer.rotationGroup.matrix),La.getInverse(La),Na.copy(B(t)),Na.applyMatrix4(La),La.makeRotationAxis(Na,e),za.setFromRotationMatrix(La),this.component.quaternion.premultiply(za),this.changed()},Object.defineProperties(ja.prototype,Va);var Ga={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"},Ua=function(t){void 0===t&&(t={}),this.max=10,this.type=y(t.type,"size"),this.scale=y(t.scale,1),this.size=y(t.size,1),this.data=y(t.data,{})};Ua.prototype.atomRadius=function(t){var e;switch(this.type){case"vdw":e=t.vdw;break;case"covalent":e=t.covalent;break;case"bfactor":e=t.bfactor||1;break;case"sstruc":var r=t.sstruc;e="h"===r||"g"===r||"i"===r||"e"===r||"b"===r?.25:To.includes(t.atomname)?.4:.1;break;case"data":e=y(this.data[t.index],1);break;case"explicit":null===(e=t.radius)&&(e=this.size);break;default:e=this.size}return Math.min(e*this.scale,this.max)},Ua.types=Ga;var Ha=new r.Vector3(-1,-1,-1),Wa=new r.Matrix4,qa=function(t){var e=t.rows,i=e/3,o=new Ln(e,3),n=new Ln(3,3),a=new Ln(1,3),s=new Ln(3,3),c=new Ln(3,3),u=Vn(t);Gn(t,u),Nn(o,t),zn(n,o,o),Wn(n,a,s,c);var l=new r.Vector3(u[0],u[1],u[2]),h=new r.Vector3(s.data[0],s.data[3],s.data[6]),p=new r.Vector3(s.data[1],s.data[4],s.data[7]),d=new r.Vector3(s.data[2],s.data[5],s.data[8]),f=h.clone().multiplyScalar(Math.sqrt(a.data[0]/i)),m=p.clone().multiplyScalar(Math.sqrt(a.data[1]/i)),g=d.clone().multiplyScalar(Math.sqrt(a.data[2]/i));this.begA=l.clone().sub(f),this.endA=l.clone().add(f),this.begB=l.clone().sub(m),this.endB=l.clone().add(m),this.begC=l.clone().sub(g),this.endC=l.clone().add(g),this.center=l,this.vecA=f,this.vecB=m,this.vecC=g,this.normVecA=h,this.normVecB=p,this.normVecC=d};qa.prototype.getBasisMatrix=function(t){void 0===t&&(t=new r.Matrix4);var e=t;return e.makeBasis(this.normVecB,this.normVecA,this.normVecC),e.determinant()<0&&e.scale(Ha),e},qa.prototype.getRotationQuaternion=function(t){void 0===t&&(t=new r.Quaternion);var e=t;return e.setFromRotationMatrix(this.getBasisMatrix(Wa)),e.inverse()},qa.prototype.getProjectedScaleForAtoms=function(t){var e=-1/0,i=-1/0,o=-1/0,n=-1/0,a=-1/0,s=-1/0,c=new r.Vector3,u=new r.Vector3,l=this.center,h=this.normVecA,p=this.normVecB,d=this.normVecC;return t.eachAtom((function(t){li(c.copy(t),h,l);var r=u.subVectors(c,l).normalize().dot(h),f=c.distanceTo(l);r>0?f>e&&(e=f):f>i&&(i=f),li(c.copy(t),p,l);var m=u.subVectors(c,l).normalize().dot(p),g=c.distanceTo(l);m>0?g>o&&(o=g):g>n&&(n=g),li(c.copy(t),d,l);var y=u.subVectors(c,l).normalize().dot(d),v=c.distanceTo(l);y>0?v>a&&(a=v):v>s&&(s=v)})),{d1a:e,d2a:o,d3a:a,d1b:-i,d2b:-n,d3b:-s}};var Xa=function(t,e,r,i){this.volume=t,this.setFilter(e,r,i)},Ya={header:{configurable:!0},matrix:{configurable:!0},normalMatrix:{configurable:!0},inverseMatrix:{configurable:!0},center:{configurable:!0},boundingBox:{configurable:!0},min:{configurable:!0},max:{configurable:!0},mean:{configurable:!0},rms:{configurable:!0}};Ya.header.get=function(){return this.volume.header},Ya.matrix.get=function(){return this.volume.matrix},Ya.normalMatrix.get=function(){return this.volume.normalMatrix},Ya.inverseMatrix.get=function(){return this.volume.inverseMatrix},Ya.center.get=function(){return this.volume.center},Ya.boundingBox.get=function(){return this.volume.boundingBox},Ya.min.get=function(){return this.volume.min},Ya.max.get=function(){return this.volume.max},Ya.mean.get=function(){return this.volume.mean},Ya.rms.get=function(){return this.volume.rms},Xa.prototype._getFilterHash=function(t,e,r){return JSON.stringify([t,e,r])},Xa.prototype.setFilter=function(t,e,r){isNaN(t)&&this.header&&(t=this.header.DMEAN+2*this.header.ARMS),t=void 0===t||isNaN(t)?-1/0:t,e=y(e,1/0),r=y(r,!1);var i=this.volume.data,o=this.volume.position,n=this.volume.atomindex,a=this._getFilterHash(t,e,r);if(a!==this._filterHash){if(t===-1/0&&e===1/0)this.data=i,this.position=o,this.atomindex=n;else{var s=i.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*s),this._positionBuffer=new ArrayBuffer(3*s*4),n&&(this._atomindexBuffer=new ArrayBuffer(4*s)));var c,u=new Float32Array(this._dataBuffer),l=new Float32Array(this._positionBuffer);n&&(c=new Uint32Array(this._atomindexBuffer));for(var h=0,p=0;p=t&&f<=e||r&&(fe)){var m=3*h;u[h]=f,l[m+0]=o[d+0],l[m+1]=o[d+1],l[m+2]=o[d+2],n&&c&&(c[h]=n[p]),h+=1}}this.data=new Float32Array(this._dataBuffer,0,h),this.position=new Float32Array(this._positionBuffer,0,3*h),n&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,h))}this._filterHash=a}},Object.defineProperties(Xa.prototype,Ya),Xa.prototype.getValueForSigma=ca.prototype.getValueForSigma,Xa.prototype.getSigmaForValue=ca.prototype.getSigmaForValue,Xa.prototype.getDataAtomindex=ca.prototype.getDataAtomindex,Xa.prototype.getDataPosition=ca.prototype.getDataPosition,Xa.prototype.getDataColor=ca.prototype.getDataColor,Xa.prototype.getDataPicking=ca.prototype.getDataPicking,Xa.prototype.getDataSize=ca.prototype.getDataSize;var Ka=function(t,e){var r=ro({nodeArray1:t.atomIndex1,nodeArray2:t.atomIndex2,edgeCount:t.count,nodeCount:e});this.countArray=r.countArray,this.offsetArray=r.offsetArray,this.indexArray=r.indexArray},Za=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={_defaultFields:{configurable:!0}};return r._defaultFields.get=function(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]},e.prototype.addBond=function(t,e,r){this.growIfFull();var i=this.count,o=t.index,n=e.index;o0&&(s[M]=x.angleTo(_));var D=Math.cos(m.angleTo(g));l[M]=180/Math.PI*Math.acos(D);var T=m.length(),B=g.length();c[M]=Math.sqrt(B*T)/Math.max(2,2*(1-D)),u[M]=Math.abs(d.dot(x)),y.copy(m).multiplyScalar(c[M]/T),v.copy(g).multiplyScalar(c[M]/B),y.subVectors(P,y),v.subVectors(I,v),y.toArray(n,k+3),v.toArray(n,k+6),w.subVectors(C,A),w.toArray(h,k),_.copy(x),A.copy(y)}y.fromArray(n,3),v.fromArray(n,6),x.subVectors(y,v).normalize(),C.index=t.getAtomIndexByType(0,S),A.copy(C),b.copy(C),li(b,x,y),b.toArray(n,0),w.subVectors(A,y),w.toArray(h,0),y.fromArray(n,3*i-6),v.fromArray(n,3*i-9),x.subVectors(y,v).normalize(),C.index=t.getAtomIndexByType(i-1,S),A.copy(C),b.copy(C),li(b,x,y),b.toArray(n,3*i-3);for(var R=i-3;Re||l.bending[$]>t)&&(E=!0)),E){if($-g<4){g=$,E=!1;continue}B.index=D.traceAtomIndex,I=l.axis.subarray(3*g+3,3*$),O=l.center.subarray(3*g,3*$+3),p=ui(I).normalize(),d=ui(O),M.fromArray(O),li(M,p,d),k.fromArray(O,O.length-3),li(k,p,d),p.subVectors(k,M),p.toArray(v,y),d.toArray(b,y),M.toArray(x,y),k.toArray(_,y),f.atomColorToArray(B,w,y),A.push(B.index),S.push(m.atomRadius(B)),C.push(u+g),P.push(u+$+1-g),y+=3,g=$,E=!1}var L=new Float32Array(A);return{axis:new Float32Array(v),center:new Float32Array(b),begin:new Float32Array(x),end:new Float32Array(_),color:new Float32Array(w),picking:new fn(L,s),size:new Float32Array(S),residueOffset:C,residueCount:P}};var os=function(t){this.scoreFunction=t,this.content=[],this.scoreFunction=t};os.prototype.push=function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},os.prototype.pop=function(){var t=this.content[0],e=this.content.pop();return e&&this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},os.prototype.peek=function(){return this.content[0]},os.prototype.remove=function(t){for(var e=this.content.length,r=0;r0;){var r=Math.floor((t+1)/2)-1,i=this.content[r];if(!(this.scoreFunction(e)t?1:0}function y(e,t,i=g){let r=0,s=e.length-1;for(;r<=s;){const n=r+s>>1,o=i(t,e[n]);if(o>0)r=n+1;else{if(!(o<0))return n;s=n-1}}return-r-1}function b(e,t,i){const r=function(e,t){let i=e.length-1;if(e[i]>1;e[s]>=t?i=s-1:r=s+1}return i+1}(e,t),s=function(e,t){if(e[0]>t)return-1;let i=0,r=e.length-1;for(;i<=r;){const s=i+r>>1;e[s]>t?r=s-1:i=s+1}return i-1}(e,i);return-1===r||-1===s||r>s?0:s-r+1}function x(e){return e.sort().filter((function(e,t,i){return 0===t||e!==i[t-1]}))}function v(e){const t=28672;if(e.length>t){const i=[];for(let r=0;r65535?Uint32Array:Uint16Array)(e)}function _(e){return e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e}function S(e,t){return void 0===e?e=new t:Array.isArray(e)&&(e=(new t).fromArray(e)),e}function C(e){return S(e,t.Vector3)}function P(e){return S(e,t.Matrix4)}function I(e){return S(e,t.Quaternion)}function k(e){return t=e,i=Float32Array,t instanceof i?t:new i(t);var t,i}function M(e){return l(e,"").toString().toLowerCase()}class D{constructor(e){this.name=e,this._dict={}}add(e,t){this._dict[M(e)]=t}get(e){return this._dict[M(e)]}get names(){return Object.keys(this._dict)}}function T(e){return.01745*e}const B="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),R=new Array(36);function O(){let e,t=0;for(let i=0;i<36;i++)8===i||13===i||18===i||23===i?R[i]="-":14===i?R[i]="4":(t<=2&&(t=33554432+16777216*Math.random()|0),e=15&t,t>>=4,R[i]=B[19===i?3&e|8:e]);return R.join("")}function $(e,t,i){return Math.max(t,Math.min(i,e))}function F(e,t,i){return e+(t-e)*i}function E(e,t,i,r,s,n){const o=(i-e)*n,a=(r-t)*n,c=s*s;return(2*t-2*i+o+a)*(s*c)+(-3*t+3*i-2*o-a)*c+o*s+t}function L(e,t,i){var r;return r=function(e,t,i){return(e-t)/(i-t)}(i,e,t),(i=$(r,0,1))*i*(3-2*i)}var N="sRGB";const z={scale:"uniform",mode:"hcl",domain:[0,1],value:16777215,reverse:!1},V=new t.Color;function G(e,t,i){const r=i.value;return i.value=function(e,t){let i=r.bind(this,e,t)();return"linear"==N?(V.set(i),V.convertSRGBToLinear(),V.getHex()):i},i}class U{constructor(e={}){this.parameters=h(e,z),"string"==typeof this.parameters.value&&(this.parameters.value=V.set(this.parameters.value).getHex()),this.parameters.structure&&(this.atomProxy=this.parameters.structure.getAtomProxy())}getScale(e={}){const t=h(e,this.parameters);return"rainbow"===t.scale?t.scale=["red","orange","yellow","green","blue"]:"rwb"===t.scale&&(t.scale=["red","white","blue"]),t.reverse&&(t.domain=t.domain.slice().reverse()),o.scale(t.scale).mode(t.mode).domain(t.domain).out("num")}colorToArray(e,t=[],i=0){return t[i]=(e>>16&255)/255,t[i+1]=(e>>8&255)/255,t[i+2]=(255&e)/255,t}atomColorToArray(e,t,i){return this.colorToArray(this.atomColor?this.atomColor(e):0,t,i)}bondColor(e,t){return this.atomProxy&&this.atomColor?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):0}bondColorToArray(e,t,i,r){return this.colorToArray(this.bondColor(e,t),i,r)}volumeColorToArray(e,t,i){return this.colorToArray(this.volumeColor?this.volumeColor(e):0,t,i)}positionColorToArray(e,t,i){return this.colorToArray(this.positionColor?this.positionColor(e):0,t,i)}}var j;!function(e){e[e.PROTEIN=1]="PROTEIN",e[e.NUCLEIC=2]="NUCLEIC",e[e.RNA=3]="RNA",e[e.DNA=4]="DNA",e[e.POLYMER=5]="POLYMER",e[e.WATER=6]="WATER",e[e.HELIX=7]="HELIX",e[e.SHEET=8]="SHEET",e[e.TURN=9]="TURN",e[e.BACKBONE=10]="BACKBONE",e[e.SIDECHAIN=11]="SIDECHAIN",e[e.ALL=12]="ALL",e[e.HETERO=13]="HETERO",e[e.ION=14]="ION",e[e.SACCHARIDE=15]="SACCHARIDE",e[e.SUGAR=15]="SUGAR",e[e.BONDED=16]="BONDED",e[e.RING=17]="RING",e[e.AROMATICRING=18]="AROMATICRING",e[e.METAL=19]="METAL",e[e.POLARH=20]="POLARH",e[e.NONE=21]="NONE"}(j||(j={}));const H=["*","","ALL"],W=["NONE"],q=[j.BACKBONE,j.SIDECHAIN,j.BONDED,j.RING,j.AROMATICRING,j.METAL,j.POLARH],X=[j.POLYMER,j.WATER],Y=["ALA","GLY","SER"],K=["CYS","SER","THR"],Z=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Q=["PHE","TRP","TYR","HIS"],J=["ASN","GLN"],ee=["ASP","GLU"],te=["ARG","HIS","LYS"],ie=["ARG","ASP","GLU","HIS","LYS"],re=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],se=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],ne=["HIS","PHE","PRO","TRP","TYR"],oe=["ALA","GLY","ILE","LEU","VAL"];function ae(e,t){if(void 0===t.atomname&&void 0===t.element&&void 0===t.altloc&&void 0===t.atomindex&&void 0===t.keyword&&void 0===t.inscode&&void 0===t.resname&&void 0===t.sstruc&&void 0===t.resno&&void 0===t.chainname&&void 0===t.model)return-1;if(void 0!==t.keyword){if(t.keyword===j.BACKBONE&&!e.isBackbone())return!1;if(t.keyword===j.SIDECHAIN&&!e.isSidechain())return!1;if(t.keyword===j.BONDED&&!e.isBonded())return!1;if(t.keyword===j.RING&&!e.isRing())return!1;if(t.keyword===j.AROMATICRING&&!e.isAromatic())return!1;if(t.keyword===j.HETERO&&!e.isHetero())return!1;if(t.keyword===j.PROTEIN&&!e.isProtein())return!1;if(t.keyword===j.NUCLEIC&&!e.isNucleic())return!1;if(t.keyword===j.RNA&&!e.isRna())return!1;if(t.keyword===j.DNA&&!e.isDna())return!1;if(t.keyword===j.POLYMER&&!e.isPolymer())return!1;if(t.keyword===j.WATER&&!e.isWater())return!1;if(t.keyword===j.HELIX&&!e.isHelix())return!1;if(t.keyword===j.SHEET&&!e.isSheet())return!1;if(t.keyword===j.TURN&&!e.isTurn())return!1;if(t.keyword===j.ION&&!e.isIon())return!1;if(t.keyword===j.SACCHARIDE&&!e.isSaccharide())return!1;if(t.keyword===j.METAL&&!e.isMetal())return!1;if(t.keyword===j.POLARH&&!e.isPolarHydrogen())return!1}if(void 0!==t.atomname&&t.atomname!==e.atomname)return!1;if(void 0!==t.element&&t.element!==e.element)return!1;if(void 0!==t.altloc&&t.altloc!==e.altloc)return!1;if(void 0!==t.atomindex&&y(t.atomindex,e.index)<0)return!1;if(void 0!==t.resname)if(Array.isArray(t.resname)){if(!t.resname.includes(e.resname))return!1}else if(t.resname!==e.resname)return!1;if(void 0!==t.sstruc&&t.sstruc!==e.sstruc)return!1;if(void 0!==t.resno)if(Array.isArray(t.resno)&&2===t.resno.length){if(t.resno[0]>e.resno||t.resno[1]e.resno||t.resno[1]0?e:null}function me(e,t=!1){let i=e;return t&&(i=de(e,(function(e){return void 0!==e.keyword&&!q.includes(e.keyword)||(void 0!==e.model||(void 0!==e.chainname||(void 0!==e.resname||(void 0!==e.resno||void 0!==e.sstruc))))}))),ue(i,ae)}function pe(e,t=!1){let i=e;return t&&(i=de(e,(function(e){return!(void 0===e.keyword||!q.includes(e.keyword))||(void 0!==e.model||(void 0!==e.chainname||(void 0!==e.atomname||(void 0!==e.element||void 0!==e.altloc))))}))),ue(i,ce)}function fe(e,t=!1){let i=e;return t&&(i=de(e,(function(e){return void 0!==e.keyword&&!X.includes(e.keyword)||(void 0!==e.resname||(void 0!==e.resno||(void 0!==e.atomname||(void 0!==e.element||(void 0!==e.altloc||(void 0!==e.sstruc||void 0!==e.inscode))))))}))),ue(i,le)}function ge(e,t=!1){let i=e;return t&&(i=de(e,(function(e){return void 0!==e.keyword||(void 0!==e.chainname||(void 0!==e.resname||(void 0!==e.resno||(void 0!==e.atomname||(void 0!==e.element||(void 0!==e.altloc||(void 0!==e.sstruc||void 0!==e.inscode)))))))}))),ue(i,he)}class ye{constructor(e){this.signals={stringChanged:new r.Signal},this.setString(e)}get type(){return"selection"}setString(e,t){if(void 0===e&&(e=this.string||""),e===this.string)return;try{this.selection=function(e){let t={operator:void 0,rules:[]};if(!e)return t;let i,r,s=t;const n=[];"("===(e=e.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===e.substr(-1)&&(e=e.slice(1,-1).trim());const o=e.split(/\s+/),a=e=>{i={operator:e,rules:[]},void 0===s?(s=i,t=i):(s.rules.push(i),n.push(s),s=i)},c=function(e){r=s,s=n.pop(),void 0===s&&(a(e),l(r))},l=function(e){s.rules.push(e)};let h=!1;for(let e=0;e0)if("NOT"===i)h=1;else if(1===h)h=2;else{if(2!==h)throw new Error("something went wrong with 'not'");h=!1,c()}if("AND"===i){if("OR"===s.operator){const e=s.rules.pop();a("AND"),l(e)}else s.operator="AND";continue}if("OR"===i){"AND"===s.operator?c("OR"):s.operator="OR";continue}if("NOT"===t.toUpperCase()){h=1,a(),s.negate=!0;continue}if(+i!=+i){const e=j[i];if(void 0!==e){l({keyword:e});continue}}if("HYDROGEN"===i){l({operator:"OR",rules:[{element:"H"},{element:"D"}]});continue}if("SMALL"===i){l({resname:Y});continue}if("NUCLEOPHILIC"===i){l({resname:K});continue}if("HYDROPHOBIC"===i){l({resname:Z});continue}if("AROMATIC"===i){l({resname:Q});continue}if("AMIDE"===i){l({resname:J});continue}if("ACIDIC"===i){l({resname:ee});continue}if("BASIC"===i){l({resname:te});continue}if("CHARGED"===i){l({resname:ie});continue}if("POLAR"===i){l({resname:re});continue}if("NONPOLAR"===i){l({resname:se});continue}if("CYCLIC"===i){l({resname:ne});continue}if("ALIPHATIC"===i){l({resname:oe});continue}if("SIDECHAINATTACHED"===i){l({operator:"OR",rules:[{keyword:j.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:j.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:j.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"HO3'"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"HO5'"},{atomname:"C5'"},{atomname:"C5*"},{atomname:"H5'"},{atomname:"H5''"}]}]}]});continue}if("APOLARH"===i){l({operator:"AND",negate:!1,rules:[{element:"H"},{negate:!0,operator:void 0,rules:[{keyword:j.POLARH}]}]});continue}if("LIGAND"===i){l({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:j.HETERO},{negate:!0,operator:void 0,rules:[{keyword:j.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:j.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:j.WATER},{keyword:j.ION}]}]}]});continue}if(-1!==H.indexOf(i)){l({keyword:j.ALL});continue}if("@"===t.charAt(0)){const e=t.substr(1).split(",").map((e=>parseInt(e)));e.sort((function(e,t){return e-t})),l({atomindex:e});continue}if("#"===t.charAt(0)){console.error("# for element selection deprecated, use _"),l({element:i.substr(1)});continue}if("_"===t.charAt(0)){l({element:i.substr(1)});continue}if("["===t[0]&&"]"===t[t.length-1]){const e=i.substr(1,t.length-2).split(","),r=e.length>1?e:e[0];l({resname:r});continue}if(t.length>=1&&t.length<=4&&"^"!==t[0]&&":"!==t[0]&&"."!==t[0]&&"%"!==t[0]&&"/"!==t[0]&&isNaN(parseInt(t))){l({resname:i});continue}const r={operator:"AND",rules:[]},n=t.split("/");if(n.length>1&&n[1]){if(isNaN(parseInt(n[1])))throw new Error("model must be an integer");r.rules.push({model:parseInt(n[1])})}const u=n[0].split("%");u.length>1&&r.rules.push({altloc:u[1]});const d=u[0].split(".");if(d.length>1&&d[1]){if(d[1].length>4)throw new Error("atomname must be one to four characters");r.rules.push({atomname:d[1].substring(0,4).toUpperCase()})}const m=d[0].split(":");m.length>1&&m[1]&&r.rules.push({chainname:m[1]});const p=m[0].split("^");if(p.length>1&&r.rules.push({inscode:p[1]}),p[0]){let e,t;"-"===p[0][0]&&(p[0]=p[0].substr(1),e=!0),p[0].includes("--")&&(p[0]=p[0].replace("--","-"),t=!0);let i=p[0].split("-");if(1===i.length){let t=parseInt(i[0]);if(isNaN(t))throw new Error("resi must be an integer");e&&(t*=-1),r.rules.push({resno:t})}else{if(2!==i.length)throw new Error("resi range must contain one '-'");{const s=i.map((e=>parseInt(e)));e&&(s[0]*=-1),t&&(s[1]*=-1),r.rules.push({resno:[s[0],s[1]]})}}}if(1===r.rules.length)l(r.rules[0]);else{if(!(r.rules.length>1))throw new Error("empty selection chunk");l(r)}}return void 0===t.operator&&1===t.rules.length&&t.rules[0].hasOwnProperty("operator")&&(t=t.rules[0]),t}(e)}catch(e){this.selection={error:e.message}}const i=this.selection;this.string=e,this.test=me(i),this.residueTest=pe(i),this.chainTest=fe(i),this.modelTest=ge(i),this.atomOnlyTest=me(i,!0),this.residueOnlyTest=pe(i,!0),this.chainOnlyTest=fe(i,!0),this.modelOnlyTest=ge(i,!0),t||this.signals.stringChanged.dispatch(this.string)}isAllSelection(){return H.includes(this.string.toUpperCase())}isNoneSelection(){return W.includes(this.string.toUpperCase())}}class be extends U{constructor(e){super(e),this.colormakerList=[],this.selectionList=[];(e.dataList||[]).forEach((e=>{const[i,r,s={}]=e;Ee.hasScheme(i)?Object.assign(s,{scheme:i,structure:this.parameters.structure}):Object.assign(s,{scheme:"uniform",value:new t.Color(i).getHex()}),this.colormakerList.push(Ee.getScheme(s)),this.selectionList.push(new ye(r))}))}atomColor(e){for(let t=0,i=this.selectionList.length;t{}),e)}catch(e){}const Ie="undefined"!=typeof window&&void 0!==window.orientation;let ke=!1;function Me(e){ke=e}let De=!1;function Te(e){De=e}const Be={log:Function.prototype.bind.call(console.log,console),info:Function.prototype.bind.call(console.info,console),warn:Function.prototype.bind.call(console.warn,console),error:Function.prototype.bind.call(console.error,console),time:Function.prototype.bind.call(console.time,console),timeEnd:Function.prototype.bind.call(console.timeEnd,console)};let Re={color:"green",labelColor:8421504,labelAttachment:"bottom-center",labelSize:.7,labelZOffset:.5,labelYOffset:.1,labelBorder:!0,labelBorderColor:13882323,labelBorderWidth:.25,lineOpacity:.8,linewidth:5,opacity:.6,labelUnit:"angstrom",arcVisible:!0,planeVisible:!1};var Oe;e.Debug=!!(Oe=c("debug"))&&("string"!=typeof Oe||/^1|true|t|yes|y$/i.test(Oe));const $e=["ngl","js"],Fe=new class{constructor(){this.activeWorkerCount=0,this._funcDict={},this._depsDict={},this._blobDict={}}add(e,t,i){this._funcDict[e]=t,this._depsDict[e]=i}get(e){return this._blobDict[e]||(this._blobDict[e]=Se(this._funcDict[e],this._depsDict[e])),this._blobDict[e]}},Ee=new class{constructor(){this.schemes={},this.userSchemes={}}getScheme(e){const t=((e||{}).scheme||"").toLowerCase();let i;return i=t in this.schemes?this.schemes[t]:t in this.userSchemes?this.userSchemes[t]:U,new i(e)}getSchemes(){const e={};return Object.keys(this.schemes).forEach((function(t){e[t]=t})),Object.keys(this.userSchemes).forEach((function(t){e[t]=t.split("|")[1]})),e}getScales(){return xe}getModes(){return ve}add(e,t){e=e.toLowerCase(),this.schemes[e]=t}addScheme(e,t){return e instanceof U||(e=this._createScheme(e)),this._addUserScheme(e,t)}_addUserScheme(e,t){t=t||"";const i=`${O()}|${t}`.toLowerCase();return this.userSchemes[i]=e,i}removeScheme(e){e=e.toLowerCase(),delete this.userSchemes[e]}_createScheme(e){const t=function(t){U.call(this,t),e.call(this,t)};return(t.prototype=U.prototype).constructor=U,t}addSelectionScheme(e,t){return this._addUserScheme(class extends be{constructor(t){super(Object.assign({dataList:e},t))}},t)}hasScheme(e){return(e=e.toLowerCase())in this.schemes||e in this.userSchemes}},Le=new D("datasource"),Ne=new D("representatation"),ze=new class extends D{constructor(){super("parser")}__hasObjName(e,t){const i=this.get(e);return i&&i.prototype.__objName===t}isTrajectory(e){return this.__hasObjName(e,"frames")}isStructure(e){return this.__hasObjName(e,"structure")}isVolume(e){return this.__hasObjName(e,"volume")}isSurface(e){return this.__hasObjName(e,"surface")}isBinary(e){const t=this.get(e);return t&&t.prototype.isBinary}isXml(e){const t=this.get(e);return t&&t.prototype.isXml}isJson(e){const t=this.get(e);return t&&t.prototype.isJson}getTrajectoryExtensions(){return this.names.filter((e=>this.isTrajectory(e)))}getStructureExtensions(){return this.names.filter((e=>this.isStructure(e)))}getVolumeExtensions(){return this.names.filter((e=>this.isVolume(e)))}getSurfaceExtensions(){return this.names.filter((e=>this.isSurface(e)))}},Ve=new D("shader"),Ge=new D("decompressor"),Ue=new D("component"),je=new D("buffer"),He=new D("picker");e.ListingDatasource=void 0,e.TrajectoryDatasource=void 0;class We{constructor(e,t={}){this.chunkSize=10485760,this.newline="\n",this.__pointer=0,this.__partialLine="",this.compressed=l(t.compressed,!1),this.binary=l(t.binary,!1),this.json=l(t.json,!1),this.xml=l(t.xml,!1),this.src=e}isBinary(){return this.binary||this.compressed}read(){return this._read().then((e=>{const t=this.compressed?Ge.get(this.compressed):void 0;return this.compressed&&t?this.data=t(e):((this.binary||this.compressed)&&e instanceof ArrayBuffer&&(e=new Uint8Array(e)),this.data=e),this.data}))}_chunk(e,t){return t=Math.min(this.data.length,t),0===e&&this.data.length===t?this.data:this.isBinary()?this.data.subarray(e,t):this.data.substring(e,t)}chunk(e){const t=e+this.chunkSize;return this._chunk(e,t)}peekLines(e){const t=this.data,i=t.length,r=this.isBinary()?this.newline.charCodeAt(0):this.newline;let s,n=0;for(s=0;si).lines}chunkCount(){return Math.floor(this.data.length/this.chunkSize)+1}asText(){return this.isBinary()?v(this.data):this.data}chunkToLines(e,t,i){const r=this.newline;if(!this.isBinary()&&e.length===this.data.length)return{lines:e.split(r),partialLine:""};let s=[];const n=this.isBinary()?v(e):e,o=n.lastIndexOf(r);if(-1===o)t+=n;else{const e=t+n.substr(0,o);s=s.concat(e.split(r)),t=o===n.length-r.length?"":n.substr(o+r.length)}return i&&""!==t&&s.push(t),{lines:s,partialLine:t}}nextChunk(){const e=this.__pointer;if(!(e>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(e)}nextChunkOfLines(){const e=this.nextChunk();if(void 0===e)return;const t=this.__pointer>this.data.length,i=this.chunkToLines(e,this.__partialLine,t);return this.__partialLine=i.partialLine,i.lines}eachChunk(e){const t=this.chunkSize,i=this.data.length,r=this.chunkCount();for(let s=0;s{const s=i===r+1,n=this.chunkToLines(t,this.__partialLine,s);this.__partialLine=n.partialLine,e(n.lines,i,r)}))}dispose(){delete this.src}}class qe extends We{_read(){return new Promise(((e,t)=>{const i=this.src,r=new FileReader;r.onload=t=>{t.target&&e(t.target.result)},r.onerror=e=>t(e),this.binary||this.compressed?r.readAsArrayBuffer(i):r.readAsText(i)}))}}class Xe extends We{_read(){return new Promise(((e,t)=>{const i=this.src,r=new XMLHttpRequest;r.open("GET",i,!0),r.addEventListener("load",(()=>{if(200===r.status||304===r.status||0===r.status)try{e(r.response)}catch(e){t(e)}else t(r.statusText)}),!1),r.addEventListener("error",(e=>t("network error")),!1),this.isBinary()?r.responseType="arraybuffer":this.json?r.responseType="json":this.xml?r.responseType="document":r.responseType="text",r.send()}))}}class Ye{constructor(e,t={}){this.parameters=h(t,{ext:"",compressed:!1,binary:ze.isBinary(t.ext||""),name:"",dir:"",path:"",protocol:""});const i={compressed:this.parameters.compressed,binary:this.parameters.binary,json:ze.isJson(this.parameters.ext),xml:ze.isXml(this.parameters.ext)};"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob?this.streamer=new qe(e,i):this.streamer=new Xe(e,i)}}class Ke extends Ye{constructor(e,t={}){super(e,t),this.parserParams={voxelSize:t.voxelSize,firstModelOnly:t.firstModelOnly,asTrajectory:t.asTrajectory,cAlphaOnly:t.cAlphaOnly,delimiter:t.delimiter,comment:t.comment,columnNames:t.columnNames,name:this.parameters.name,path:this.parameters.path}}load(){return new(ze.get(this.parameters.ext))(this.streamer,this.parserParams).parse()}}class Ze{constructor(e,t,i){this.name=t,this.path=i,this.signals={elementAdded:new r.Signal,elementRemoved:new r.Signal,nameChanged:new r.Signal},this.type="Script",this.dir=i.substring(0,i.lastIndexOf("/")+1);try{this.fn=new Function("stage","__name","__path","__dir",e)}catch(e){Be.error("Script compilation failed",e),this.fn=function(){}}}run(e){return new Promise(((t,i)=>{try{this.fn.apply(null,[e,this.name,this.path,this.dir]),t()}catch(e){Be.error("Script.fn",e),i(e)}}))}}class Qe extends Ye{load(){return this.streamer.read().then((()=>new Ze(this.streamer.asText(),this.parameters.name,this.parameters.path)))}}function Je(e){const t=Ge.names;let i,r,s="";i=e instanceof File?e.name:e instanceof Blob?"":e;const n=i.lastIndexOf("?"),o=-1!==n?i.substring(n):"";i=i.substring(0,-1===n?i.length:n);const a=i.replace(/^.*[\\/]/,"");let c=a.substring(0,a.lastIndexOf("."));const l=a.split(".");let h=l.length>1?(l.pop()||"").toLowerCase():"";const u=i.match(/^(.+):\/\/(.+)$/);u&&(s=u[1].toLowerCase(),i=u[2]||"");const d=i.substring(0,i.lastIndexOf("/")+1);if(t.includes(h)){r=h;const e=i.length-h.length-1;h=(i.substr(0,e).split(".").pop()||"").toLowerCase();const t=c.length-h.length-1;c=c.substr(0,t)}else r=!1;return{path:i,name:a,ext:h,base:c,dir:d,compressed:r,protocol:s,query:o,src:e}}function et(e){let t=Je(e);const i=Le.get(t.protocol);return i&&(t=Je(i.getUrl(t.src)),!t.ext&&i.getExt&&(t.ext=i.getExt(e))),t}function tt(e,t={}){const i=Object.assign(et(e),t);let r;return ze.names.includes(i.ext)?r=new Ke(i.src,i):$e.includes(i.ext)&&(r=new Qe(i.src,i)),r?r.load():Promise.reject(new Error(`autoLoad: ext '${i.ext}' unknown`))}class it{getBlob(){return new Blob([this.getData()],{type:this.mimeType})}download(e,t){e=l(e,this.defaultName),t=l(t,this.defaultExt),f(this.getBlob(),`${e}.${t}`)}}const rt=[];class st{constructor(e,t={}){this._mark=0,this._marks=[],this.offset=0,this.littleEndian=!0;let i=!1;void 0===e&&(e=8192),"number"==typeof e?e=new ArrayBuffer(e):i=!0;const r=t.offset?t.offset>>>0:0;let s=e.byteLength-r,n=r;e instanceof ArrayBuffer||(e.byteLength!==e.buffer.byteLength&&(n=e.byteOffset+r),e=e.buffer),this._lastWrittenByte=i?s:0,this.buffer=e,this.length=s,this.byteLength=s,this.byteOffset=n,this._data=new DataView(this.buffer,n,s)}available(e){return void 0===e&&(e=1),this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e){return void 0===e&&(e=1),this.offset+=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(void 0===e)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e){if(void 0===e&&(e=1),!this.available(e)){const t=2*(this.offset+e),i=new Uint8Array(t);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e){void 0===e&&(e=1);for(var t=new Uint8Array(e),i=0;ithis._lastWrittenByte&&(this._lastWrittenByte=this.offset)}}class nt{constructor(){this.count=0,this.signals={countChanged:new a.Signal}}clear(){this.change(-this.count)}change(e){this.count+=e,this.signals.countChanged.dispatch(e,this.count),this.count<0&&Be.warn("Counter.count below zero",this.count)}increment(){this.change(1)}decrement(){this.change(-1)}listen(e){this.change(e.count),e.signals.countChanged.add(this.change,this)}unlisten(e){const t=e.signals.countChanged;t.has(this.change,this)&&t.remove(this.change,this)}onZeroOnce(e,t){if(0===this.count)e.call(t);else{const i=()=>{0===this.count&&(this.signals.countChanged.remove(i,this),e.call(t))};this.signals.countChanged.add(i,this)}}dispose(){this.clear(),this.signals.countChanged.dispose()}}Ve.add("shader/BasicLine.vert","void main(){\n#include begin_vertex\n#include project_vertex\n}"),Ve.add("shader/BasicLine.frag","uniform vec3 uColor;\n#include common\n#include fog_pars_fragment\nvoid main(){\ngl_FragColor = vec4( uColor, 1.0 );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}"),Ve.add("shader/Quad.vert","varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"),Ve.add("shader/Quad.frag","varying vec2 vUv;\nuniform sampler2D tForeground;\nuniform float scale;\nvoid main() {\nvec4 foreground = texture2D( tForeground, vUv );\ngl_FragColor = foreground * scale;\n}");class ot{constructor(){this.signals={updated:new a.Signal},this.maxDuration=-1/0,this.minDuration=1/0,this.avgDuration=14,this.lastDuration=1/0,this.prevFpsTime=0,this.lastFps=1/0,this.lastFrames=1,this.frames=0,this.count=0,this.begin()}update(){this.startTime=this.end(),this.currentTime=this.startTime,this.signals.updated.dispatch()}begin(){this.startTime=window.performance.now(),this.lastFrames=this.frames}end(){const e=window.performance.now();return this.count+=1,this.frames+=1,this.lastDuration=e-this.startTime,this.minDuration=Math.min(this.minDuration,this.lastDuration),this.maxDuration=Math.max(this.maxDuration,this.lastDuration),this.avgDuration-=this.avgDuration/30,this.avgDuration+=this.lastDuration/30,e>this.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=e,this.frames=0),e}}Ve.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),Ve.add("shader/chunk/interior_fragment.glsl","if( gl_FrontFacing == false ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}"),Ve.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),Ve.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),Ve.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"),Ve.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),Ve.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),Ve.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),Ve.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");const at=/^(?!\/\/)\s*#include\s+(\S+)/gim,ct={};function lt(e,i={}){let r=e+"|";for(const e in i)r+=e+":"+i[e];if(!ct[r]){const s=function(e){if(void 0===e)return"";const t=[];for(const i in e){const r=e[i];r&&t.push(`#define ${i} ${r}`)}return t.join("\n")+"\n"}(i);let n=Ve.get(`shader/${e}`);if(!n)throw new Error(`empty shader, '${e}'`);n=n.replace(at,(function(e,i){const r=`shader/chunk/${i}.glsl`,s=Ve.get(r)||t.ShaderChunk[i];if(!s)throw new Error(`empty chunk, '${i}'`);return s})),ct[r]=s+n}return ct[r]}if("undefined"!=typeof WebGLRenderingContext){const t=WebGLRenderingContext.prototype,i=t.getShaderParameter;t.getShaderParameter=function(){return!e.Debug||i.apply(this,arguments)};const r=t.getShaderInfoLog;t.getShaderInfoLog=function(){return e.Debug?r.apply(this,arguments):""};const s=t.getProgramParameter;t.getProgramParameter=function(i,r){return!e.Debug&&r===t.LINK_STATUS||s.apply(this,arguments)};const n=t.getProgramInfoLog;t.getProgramInfoLog=function(){return e.Debug?n.apply(this,arguments):""}}const ht=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];ht.forEach((e=>{e.forEach((e=>{e[0]*=.0625,e[1]*=.0625}))}));class ut{constructor(e,t,i,r){this.canvas=document.createElement("canvas"),this._viewer=i,this._factor=l(r.factor,2),this._antialias=l(r.antialias,!1),this._onProgress=r.onProgress,this._onFinish=r.onFinish,this._antialias&&(this._factor*=2),this._n=this._factor*this._factor,this._width=this._viewer.width,this._height=this._viewer.height,this._antialias?(this.canvas.width=this._width*this._factor/2,this.canvas.height=this._height*this._factor/2):(this.canvas.width=this._width*this._factor,this.canvas.height=this._height*this._factor),this._ctx=this.canvas.getContext("2d"),this._viewerSampleLevel=i.sampleLevel,this._viewer.setSampling(-1)}_renderTile(e){const t=this._viewer,i=this._width,r=this._height,s=this._factor,n=e%s*i,o=Math.floor(e/s)*r;if(t.camera.setViewOffset(i*s,r*s,n,o,i,r),t.render(),this._antialias){const e=Math.round((n+i)/2)-Math.round(n/2),s=Math.round((o+r)/2)-Math.round(o/2);this._ctx.drawImage(t.renderer.domElement,Math.round(n/2),Math.round(o/2),e,s)}else this._ctx.drawImage(t.renderer.domElement,Math.floor(n),Math.floor(o),Math.ceil(i),Math.ceil(r));"function"==typeof this._onProgress&&this._onProgress(e+1,this._n,!1)}_finalize(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,"function"==typeof this._onFinish&&this._onFinish(this._n+1,this._n,!1)}render(){for(let e=0;e<=this._n;++e)e===this._n?this._finalize():this._renderTile(e)}renderAsync(){let e=0;const t=this._n,i=()=>{e===t?this._finalize():this._renderTile(e),e+=1};for(let e=0;e<=t;++e)setTimeout(i,0)}}const dt=2*Math.PI,mt=180/Math.PI;function pt(e,t,i=1,r=0,s){const n=s?s.length:e.length/i;let o=0,a=0;if(s)for(let c=0;ct&&(t=e[i]);return t}function Ct(e){let t=1/0;for(let i=0,r=e.length;i=0;l--){for(c=o-1;c>=0;c--)if(u=4*(l*o+c),a[u]!==t||a[u+1]!==i||a[u+2]!==r||a[u+3]!==s){h=!0;break}if(h)break}const p=l;for(h=!1,c=o-1;c>=0;c--){for(l=n-1;l>=0;l--)if(u=4*(l*o+c),a[u]!==t||a[u+1]!==i||a[u+2]!==r||a[u+3]!==s){h=!0;break}if(h)break}const f=c,g=document.createElement("canvas");return g.width=f-m,g.height=p-d,g.getContext("2d").drawImage(e,m,d,g.width,g.height,0,0,g.width,g.height),g}(e,n?0:255*t.r,n?0:255*t.g,n?0:255*t.b,n?0:255)}return e}function m(e,i,r){"function"==typeof t.onProgress&&t.onProgress(e,i,r)}return new Promise((function(t,i){const l=new ut(o,a,e,{factor:r,antialias:s,onProgress:m,onFinish:function(r,s){d(l.canvas).toBlob((function(r){o.setClearAlpha(c),u(!0),e.requestRender(),m(s,s,!0),r?t(r):i("error creating image")}),"image/png")}});o.setClearAlpha(n?0:1),u(),l.renderAsync()}))}const Dt=new t.Vector3,Tt=new t.Matrix4,Bt=new t.Matrix4;const Rt=new t.Vector2,Ot=new t.Matrix4,$t=new t.Matrix4;function Ft(e,t){Ot.getInverse(t.projectionMatrix),$t.copy(t.projectionMatrix).transpose(),e.traverse((function(e){const t=e.material;if(!t)return;const i=t.uniforms;i&&(i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(Ot),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy($t))}))}function Et(e,t,i){const r=e.createShader(i);if(!r)return void console.log(`error creating WebGL shader ${i}`);e.shaderSource(r,t),e.compileShader(r);return e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.log(`error compiling shader ${r}: ${e.getShaderInfoLog(r)}`),e.deleteShader(r),null)}function Lt(e,t){const i=e.getExtension(t);return i||console.log(`extension '${t}' not available`),i}const Nt=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function zt(e){const t=document.createElement("canvas");t.width=16,t.height=16,t.style.width="16px",t.style.height="16px";const i=t.getContext("webgl")||t.getContext("experimental-webgl");if(!i)return console.log(`error creating webgl context for ${e}`),!1;if(!(i instanceof WebGLRenderingContext))return console.log("Got unexpected type for WebGL rendering context"),!1;Lt(i,"OES_texture_float"),Lt(i,"OES_texture_half_float"),Lt(i,"WEBGL_color_buffer_float");const r=Et(i,"\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}",i.VERTEX_SHADER),s=Et(i,"\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}",i.FRAGMENT_SHADER);if(!r||!s)return!1;const n=function(e,t,i,r){const s=e.createProgram();return s?(t.forEach((t=>e.attachShader(s,t))),i&&i.forEach(((t,i)=>{e.bindAttribLocation(s,r?r[i]:i,t)})),e.linkProgram(s),e.getProgramParameter(s,e.LINK_STATUS)?s:(console.log(`error linking program: ${e.getProgramInfoLog(s)}`),e.deleteProgram(s),null)):void console.log("error creating WebGL program")}(i,[r,s]);if(!n)return console.log("error creating WebGL program"),!1;i.useProgram(n);const o=i.getAttribLocation(n,"a_position"),a=i.getUniformLocation(n,"u_color");if(!a)return console.log("error getting 'u_color' uniform location"),!1;const c=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,Nt,i.STATIC_DRAW),i.enableVertexAttribArray(o),i.vertexAttribPointer(o,2,i.FLOAT,!1,0,0);const l=i.createTexture(),h=new Uint8Array([255,255,255,255]);i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,h);const u=i.createTexture();i.bindTexture(i.TEXTURE_2D,u),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,e,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST);const d=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,d),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,u,0);if(i.checkFramebufferStatus(i.FRAMEBUFFER)!==i.FRAMEBUFFER_COMPLETE)return console.log(`error creating framebuffer for ${e}`),!1;i.bindTexture(i.TEXTURE_2D,l),i.uniform4fv(a,[0,10,20,1]),i.drawArrays(i.TRIANGLES,0,6),i.bindTexture(i.TEXTURE_2D,u),i.bindFramebuffer(i.FRAMEBUFFER,null),i.clearColor(1,0,0,1),i.clear(i.COLOR_BUFFER_BIT),i.uniform4fv(a,[0,.1,.05,1]),i.drawArrays(i.TRIANGLES,0,6);const m=new Uint8Array(4);if(i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,m),0!==m[0]||m[1]<248||m[2]<248||m[3]<254)return console.log(`not able to actually render to ${e} texture`),!1;if(e===i.FLOAT){i.bindFramebuffer(i.FRAMEBUFFER,d);const e=new Float32Array(4);i.readPixels(0,0,1,1,i.RGBA,i.FLOAT,e);const t=i.getError();if(t)return console.log(`error reading pixels as float: '${function(e,t){switch(t){case e.NO_ERROR:return"no error";case e.INVALID_ENUM:return"invalid enum";case e.INVALID_VALUE:return"invalid value";case e.INVALID_OPERATION:return"invalid operation";case e.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case e.OUT_OF_MEMORY:return"out of memory";case e.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}(i,t)}'`),!1}return!0}const Vt=new Float32Array(100),Gt=new Uint8Array(100),Ut=[12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20],jt=new t.Matrix4;function Ht(e,t,i,r,s){const n=s.uniforms,o=[];if(n&&(n.objectId&&(n.objectId.value=ke?this.id:this.id/255,o.push("objectId")),(n.modelViewMatrixInverse||n.modelViewMatrixInverseTranspose||n.modelViewProjectionMatrix||n.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,this.matrixWorld),n.modelViewMatrixInverse&&(n.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),o.push("modelViewMatrixInverse")),n.modelViewMatrixInverseTranspose&&(n.modelViewMatrixInverse?n.modelViewMatrixInverseTranspose.value.copy(n.modelViewMatrixInverse.value).transpose():n.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),o.push("modelViewMatrixInverseTranspose")),n.modelViewProjectionMatrix&&(n.modelViewProjectionMatrix.value.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),n.modelViewProjectionMatrixInverse&&(n.modelViewProjectionMatrix?(jt.copy(n.modelViewProjectionMatrix.value),n.modelViewProjectionMatrixInverse.value.getInverse(jt)):(jt.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),n.modelViewProjectionMatrixInverse.value.getInverse(jt)),o.push("modelViewProjectionMatrixInverse")),o.length)){const t=e.properties.get(s);if(t.program){const i=e.getContext(),r=t.program;i.useProgram(r.program);const s=r.getUniforms();o.forEach((function(e){s.setValue(i,e,n[e].value)}))}}}class Wt{constructor(e){if(this.boundingBox=new t.Box3,this.boundingBoxSize=new t.Vector3,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new t.Vector3,this.signals={ticked:new r.Signal,rendered:new r.Signal},"string"==typeof e){const t=document.getElementById(e);this.container=null===t?document.createElement("div"):t}else e instanceof HTMLElement?this.container=e:this.container=document.createElement("div");if(this.container===document.body)this.width=window.innerWidth||1,this.height=window.innerHeight||1;else{const e=this.container.getBoundingClientRect();this.width=e.width||1,this.height=e.height||1,this.container.style.overflow="hidden"}this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.container.appendChild(this.wrapper),this._initParams(),this._initStats(),this._initCamera(),this._initScene(),!1!==this._initRenderer()?(this._initHelper(),this.setBackground(),this.setFog(),this.animate=this.animate.bind(this)):Be.error("Viewer: could not initialize renderer")}_initParams(){this.parameters={fogColor:new t.Color(0),fogNear:50,fogFar:100,backgroundColor:new t.Color(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new t.Color(14540253),lightIntensity:1,ambientColor:new t.Color(14540253),ambientIntensity:.2,sampleLevel:0,rendererEncoding:t.LinearEncoding}}_initCamera(){const e=new t.Vector3(0,0,0),{width:i,height:r}=this;this.perspectiveCamera=new t.PerspectiveCamera(this.parameters.cameraFov,i/r),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(e),this.orthographicCamera=new t.OrthographicCamera(i/-2,i/2,r/2,r/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(e),this.stereoCamera=new t.StereoCamera,this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;const s=this.parameters.cameraType;if("orthographic"===s)this.camera=this.orthographicCamera;else{if("perspective"!==s&&"stereo"!==s)throw new Error(`Unknown cameraType '${s}'`);this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()}_initStats(){this.stats=new ot}_initScene(){this.scene||(this.scene=new t.Scene,this.scene.name="scene"),this.rotationGroup=new t.Group,this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new t.Group,this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new t.Group,this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new t.Group,this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new t.Group,this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new t.Group,this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new t.Fog(this.parameters.fogColor.getHex()),this.spotLight=new t.SpotLight(this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.spotLight),this.ambientLight=new t.AmbientLight(this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)}_initRenderer(){const i=window.devicePixelRatio,{width:r,height:s}=this;try{this.renderer=new t.WebGLRenderer({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(e){return this.wrapper.innerHTML='

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

',!1}this.renderer.setPixelRatio(i),this.renderer.setSize(r,s),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,this.renderer.outputEncoding=this.parameters.rendererEncoding;const n=this.renderer.getContext();this.renderer.capabilities.isWebGL2?(Te(!0),Me(this.renderer.extensions.get("EXT_color_buffer_float")),this.supportsHalfFloat=!0):(Te(this.renderer.extensions.get("EXT_frag_depth")),this.renderer.extensions.get("OES_element_index_uint"),Me(this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&zt(n.FLOAT)),this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&zt(36193)),this.wrapper.appendChild(this.renderer.domElement);const o=r*i,a=s*i;e.Debug&&console.log(JSON.stringify({Browser:Ce,OES_texture_float:!!this.renderer.extensions.get("OES_texture_float"),OES_texture_half_float:!!this.renderer.extensions.get("OES_texture_half_float"),WEBGL_color_buffer_float:!!this.renderer.extensions.get("WEBGL_color_buffer_float"),"testTextureSupport Float":zt(n.FLOAT),"testTextureSupport HalfFloat":zt(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:ke},null,2)),this.pickingTarget=new t.WebGLRenderTarget(o,a,{minFilter:t.NearestFilter,magFilter:t.NearestFilter,stencilBuffer:!1,format:t.RGBAFormat,type:ke?t.FloatType:t.UnsignedByteType}),this.pickingTarget.texture.generateMipmaps=!1,this.pickingTarget.texture.encoding=this.parameters.rendererEncoding,this.renderer.setRenderTarget(this.pickingTarget),this.renderer.clear(),this.renderer.setRenderTarget(null),this.sampleTarget=new t.WebGLRenderTarget(o,a,{minFilter:t.LinearFilter,magFilter:t.LinearFilter,format:t.RGBAFormat}),this.sampleTarget.texture.encoding=this.parameters.rendererEncoding,this.holdTarget=new t.WebGLRenderTarget(o,a,{minFilter:t.NearestFilter,magFilter:t.NearestFilter,format:t.RGBAFormat,type:t.UnsignedByteType}),this.holdTarget.texture.encoding=this.parameters.rendererEncoding,this.compositeUniforms={tForeground:new t.Uniform(this.sampleTarget.texture),scale:new t.Uniform(1)},this.compositeMaterial=new t.ShaderMaterial({uniforms:this.compositeUniforms,vertexShader:lt("Quad.vert"),fragmentShader:lt("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:t.AdditiveBlending,depthTest:!1,depthWrite:!1}),this.compositeCamera=new t.OrthographicCamera(-1,1,1,-1,0,1),this.compositeScene=new t.Scene,this.compositeScene.name="compositeScene",this.compositeScene.add(new t.Mesh(new t.PlaneGeometry(2,2),this.compositeMaterial))}_initHelper(){const e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new t.BufferGeometry;r.setIndex(new t.BufferAttribute(e,1)),r.setAttribute("position",new t.BufferAttribute(i,3));const s=new t.ShaderMaterial({uniforms:{uColor:{value:new t.Color("skyblue")}},vertexShader:lt("BasicLine.vert"),fragmentShader:lt("BasicLine.frag")});this.boundingBoxMesh=new t.LineSegments(r,s),this.helperGroup.add(this.boundingBoxMesh)}updateHelper(){const e=this.boundingBoxMesh.geometry.attributes.position,t=e.array,{min:i,max:r}=this.boundingBox;t[0]=r.x,t[1]=r.y,t[2]=r.z,t[3]=i.x,t[4]=r.y,t[5]=r.z,t[6]=i.x,t[7]=i.y,t[8]=r.z,t[9]=r.x,t[10]=i.y,t[11]=r.z,t[12]=r.x,t[13]=r.y,t[14]=i.z,t[15]=i.x,t[16]=r.y,t[17]=i.z,t[18]=i.x,t[19]=i.y,t[20]=i.z,t[21]=r.x,t[22]=i.y,t[23]=i.z,e.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()}get cameraDistance(){return Math.abs(this.camera.position.z)}set cameraDistance(e){this.camera.position.z=-e}add(t,i){i?i.forEach((e=>this.addBuffer(t,e))):this.addBuffer(t),t.group.name="meshGroup",t.wireframeGroup.name="wireframeGroup",t.parameters.background?(this.backgroundGroup.add(t.group),this.backgroundGroup.add(t.wireframeGroup)):(this.modelGroup.add(t.group),this.modelGroup.add(t.wireframeGroup)),t.pickable&&this.pickingGroup.add(t.pickingGroup),e.Debug&&this.updateHelper()}addBuffer(e,i){function r(s){s instanceof t.Group?s.children.forEach(r):(s.userData.buffer=e,s.userData.instance=i,s.onBeforeRender=Ht)}const s=e.getMesh();i&&s.applyMatrix4(i.matrix),r(s),e.group.add(s);const n=e.getWireframeMesh();if(i&&(n.matrix.copy(s.matrix),n.position.copy(s.position),n.quaternion.copy(s.quaternion),n.scale.copy(s.scale)),r(n),e.wireframeGroup.add(n),e.pickable){const t=e.getPickingMesh();i&&(t.matrix.copy(s.matrix),t.position.copy(s.position),t.quaternion.copy(s.quaternion),t.scale.copy(s.scale)),r(t),e.pickingGroup.add(t)}i?this._updateBoundingBox(e.geometry,e.matrix,i.matrix):this._updateBoundingBox(e.geometry,e.matrix)}remove(t){this.translationGroup.children.forEach((function(e){e.remove(t.group),e.remove(t.wireframeGroup)})),t.pickable&&this.pickingGroup.remove(t.pickingGroup),this.updateBoundingBox(),e.Debug&&this.updateHelper()}_updateBoundingBox(e,t,i){const r=this.boundingBox;function s(e,t,i){null==e.boundingBox&&e.computeBoundingBox();const s=e.boundingBox.clone();t&&s.applyMatrix4(t),i&&s.applyMatrix4(i),s.min.equals(s.max)&&s.expandByScalar(5),r.union(s)}function n(e){if(void 0!==e.geometry){let t,i;e.userData.buffer&&(t=e.userData.buffer.matrix),e.userData.instance&&(i=e.userData.instance.matrix),s(e.geometry,t,i)}}e?s(e,t,i):(r.makeEmpty(),this.modelGroup.traverse(n),this.backgroundGroup.traverse(n)),r.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()}updateBoundingBox(){this._updateBoundingBox(),e.Debug&&this.updateHelper()}getPickingPixels(){const{width:e,height:t}=this,i=e*t*4,r=ke?new Float32Array(i):new Uint8Array(i);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,e,t,r),r}getImage(e){return new Promise((t=>{if(e){const{width:e,height:i}=this,r=e*i*4;let s=this.getPickingPixels();if(ke){const e=new Uint8Array(r);for(let t=0;t500&&!this.isStill&&this.sampleLevel<3&&-1!==this.sampleLevel){const t=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=t,e.Debug&&Be.log("rendered still frame")}this.frameRequest=window.requestAnimationFrame(this.animate)}pick(e,t){if("stereo"===this.parameters.cameraType)return{pid:0,instance:void 0,picker:void 0};e*=window.devicePixelRatio,t*=window.devicePixelRatio,e=Math.max(e-2,0),t=Math.max(t-2,0);let i,r,s=0;const n=ke?Vt:Gt;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,e,t,5,5,n);for(let e=0;e22&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame((()=>{this.render(),this.stats.update()})))}updateZoom(){const e=T(this.perspectiveCamera.fov),t=2*Math.tan(e/2)*this.cameraDistance;this.orthographicCamera.zoom=this.height/t}absoluteToRelative(e){return 50*(1-e/this.bRadius)}relativeToAbsolute(e){return this.bRadius*(1-e/50)}__updateClipping(){const e=this.parameters;this.bRadius=Math.max(10,.5*this.boundingBoxLength),isFinite(this.bRadius)||(this.bRadius=50),this.camera.getWorldPosition(this.distVector),this.cDist=this.distVector.length(),this.cDist||(this.cameraDistance=Math.abs(e.cameraZ),this.cDist=Math.abs(e.cameraZ));const t=this.scene.fog;if(t.color.set(e.fogColor),"camera"===e.clipMode)this.camera.near=e.clipNear,this.camera.far=e.clipFar,t.near=e.fogNear,t.far=e.fogFar;else if("absolute"===e.clipScale)this.camera.near=this.cDist-e.clipNear,this.camera.far=this.cDist+e.clipFar,t.near=this.cDist-e.fogNear,t.far=this.cDist+e.fogFar;else{const i=(50-e.clipNear)/50,r=-(50-e.clipFar)/50;this.camera.near=this.cDist-this.bRadius*i,this.camera.far=this.cDist+this.bRadius*r;const s=(50-e.fogNear)/50,n=-(50-e.fogFar)/50;t.near=this.cDist-this.bRadius*s,t.far=this.cDist+this.bRadius*n}"camera"!==e.clipMode&&("PerspectiveCamera"===this.camera.type?(this.camera.near=Math.max(.1,e.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),t.near=Math.max(.1,t.near),t.far=Math.max(1,t.far)):"OrthographicCamera"===this.camera.type&&e.clipDist>0&&(this.camera.near=Math.max(e.clipDist,this.camera.near)))}__updateCamera(){const e=this.camera;e.updateMatrix(),e.updateMatrixWorld(!0),e.updateProjectionMatrix(),function(e,i,r,s,n){let o=new t.Vector2;r.getSize(o);const a=o.height,c=r.getPixelRatio(),l="OrthographicCamera"===i.type;Rt.set(o.width,o.height),Ot.getInverse(i.projectionMatrix),$t.copy(i.projectionMatrix).transpose(),e.traverse((function(e){const t=e.material;if(!t)return;const i=t.uniforms;if(i){if(t.clipNear){const e=(50-t.clipNear)/50,r=s-n*e;i.clipNear.value=r}i.canvasHeight&&(i.canvasHeight.value=a),i.resolution&&i.resolution.value.copy(Rt),i.pixelRatio&&(i.pixelRatio.value=c),i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(Ot),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy($t),i.ortho&&(i.ortho.value=l)}}))}(this.scene,e,this.renderer,this.cDist,this.bRadius),function(e,i){e.traverseVisible((function(e){if(!(e instanceof t.Points&&e.userData.buffer.parameters.sortParticles))return;const r=e.geometry.attributes,s=r.position.count;if(0===s)return;let n,o,a,c,l,h,u,d;Tt.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),Bt.multiplyMatrices(i.projectionMatrix,Tt),e.userData.sortData?(n=e.userData.sortData,a=n.__zArray,o=n.__sortArray,c=n.__cmpFn):(a=new Float32Array(s),o=new Uint32Array(s),c=function(e,t){const i=a[e],r=a[t];return i>r?1:it?1:e=l&&t(e[o],n)>0;)e[o+1]=e[o],--o;e[o+1]=n}if(-1===c)break;h=s[c--],l=s[c--]}else{for(o=l+1,a=h,u(l+h>>1,o),t(e[l],e[h])>0&&u(l,h),t(e[o],e[h])>0&&u(o,h),t(e[l],e[o])>0&&u(l,o),n=e[o];;){do{o++}while(t(e[o],n)<0);do{a--}while(t(e[a],n)>0);if(a=a-l?(s[++c]=o,s[++c]=h,h=a-1):(s[++c]=l,s[++c]=a-1,l=o)}}(o,c);for(let e in r){const t=r[e],i=t.array,a=t.itemSize;n[e]||(n[e]=new Float32Array(a*s)),d=n[e],n[e]=i;for(let e=0;e0&&"stereo"!==this.parameters.cameraType?this.__renderSuperSample(t,i):this.__renderModelGroup(t,i)}render(e=!1,t){if(this.rendering)Be.warn("'tried to call 'render' from within 'render'");else{this.rendering=!0;try{this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),"stereo"===this.parameters.cameraType?this.__renderStereo(e,t):this.__render(e,this.camera,t),this.lastRenderedPicking=e}finally{this.rendering=!1,this.renderPending=!1}this.signals.rendered.dispatch()}}clear(){Be.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()}dispose(){this.renderer.dispose(),window.cancelAnimationFrame(this.frameRequest)}}function qt(e){const t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;return Math.sqrt(t*t+i*i)}class Xt{constructor(e,i={}){this.domElement=e,this.signals={moved:new r.Signal,scrolled:new r.Signal,dragged:new r.Signal,dropped:new r.Signal,clicked:new r.Signal,hovered:new r.Signal,doubleClicked:new r.Signal},this.position=new t.Vector2,this.prevPosition=new t.Vector2,this.down=new t.Vector2,this.canvasPosition=new t.Vector2,this.prevClickCP=new t.Vector2,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=0,this.buttons=0,this.pressed=!1,this.altKey=!1,this.ctrlKey=!1,this.metaKey=!1,this.shiftKey=!1,this.domElement.style.touchAction="none",this.hoverTimeout=l(i.hoverTimeout,50),this.handleScroll=l(i.handleScroll,!0),this.doubleClickSpeed=l(i.doubleClickSpeed,500),this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();const s={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,s),document.addEventListener("wheel",this._onMousewheel,s),document.addEventListener("MozMousePixelScroll",this._onMousewheel,s),document.addEventListener("mousemove",this._onMousemove,s),document.addEventListener("mousedown",this._onMousedown,s),document.addEventListener("mouseup",this._onMouseup,s),document.addEventListener("contextmenu",this._onContextmenu,s),document.addEventListener("touchstart",this._onTouchstart,s),document.addEventListener("touchend",this._onTouchend,s),document.addEventListener("touchmove",this._onTouchmove,s)}get key(){let e=0;return this.altKey&&(e+=1),this.ctrlKey&&(e+=2),this.metaKey&&(e+=4),this.shiftKey&&(e+=8),e}setParameters(e={}){this.hoverTimeout=l(e.hoverTimeout,this.hoverTimeout)}_listen(){const e=window.performance.now(),t=this.canvasPosition;this.doubleClickPending&&e-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),e-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(t.x,t.y))),this.frameRequest=window.requestAnimationFrame(this._listen)}_onMousewheel(e){if(e.target!==this.domElement||!this.handleScroll)return;e.preventDefault(),this._setKeys(e);let t=0;"deltaY"in e&&"deltaMode"in e&&void 0!==e.deltaY&&void 0!==e.deltaMode?t=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?.025*-e.deltaY:e.deltaMode===WheelEvent.DOM_DELTA_LINE?-e.deltaY*(2.5/3):2.5*-e.deltaY:"deltaY"in e&&!("detail"in e)?t=.025*-e.deltaY:void 0!==e.wheelDelta?t=.025*-e.wheelDelta:void 0!==e.wheelDeltaY?t=.025*-e.wheelDeltaY:void 0!==e.detail&&(t=-e.detail/3),this.signals.scrolled.dispatch(t),setTimeout((()=>{this.scrolled=!0}),this.hoverTimeout)}_onMousemove(e){e.target===this.domElement?(e.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(e),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(e.clientX,e.clientY),this._setCanvasPosition(e);const t=this.prevPosition.x-this.position.x,i=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(t,i),this.pressed&&this.signals.dragged.dispatch(t,i)}_onMousedown(e){e.target===this.domElement&&(e.preventDefault(),this._setKeys(e),this.moving=!1,this.hovering=!1,this.down.set(e.clientX,e.clientY),this.position.set(e.clientX,e.clientY),this.which=e.which,this.buttons=function(e){if("object"==typeof e){if("buttons"in e)return e.buttons;if("which"in e){const t=e.which;if(2===t)return 4;if(3===t)return 2;if(t>0)return 1<=0)return 1<2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(i/2);else{this.which=3,this.buttons=2;const e=this.prevPosition.x-this.position.x,t=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,t),this.pressed&&this.signals.dragged.dispatch(e,t)}}}}_distance(){return this.position.distanceTo(this.down)}_setCanvasPosition(e){const t=this.domElement.getBoundingClientRect();let i,r;"clientX"in e&&"clientY"in e?(i=e.clientX-t.left,r=e.clientY-t.top):(i=e.offsetX,r=e.offsetY),this.canvasPosition.set(i,t.height-r)}_setKeys(e){this.altKey=e.altKey,this.ctrlKey=e.ctrlKey,this.metaKey=e.metaKey,this.shiftKey=e.shiftKey}dispose(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove),window.cancelAnimationFrame(this.frameRequest)}}const Yt=new t.Matrix4,Kt=new t.Matrix4,Zt=new t.Matrix4,Qt=new t.Matrix4,Jt=new t.Matrix4,ei=new t.Vector3,ti=new t.Quaternion,ii=new t.Quaternion,ri=new t.Matrix4,si=new t.Vector3,ni=new t.Vector3;class oi{constructor(e,t={}){this.stage=e,this.rotateSpeed=l(t.rotateSpeed,2),this.zoomSpeed=l(t.zoomSpeed,1.2),this.panSpeed=l(t.panSpeed,1),this.viewer=e.viewer,this.mouse=e.mouseObserver,this.controls=e.viewerControls}get component(){return this.stage.transformComponent}get atom(){return this.stage.transformAtom}_setPanVector(e,t,i=0){const r=this.controls.getCanvasScaleFactor(i);si.set(e,t,0),si.multiplyScalar(this.panSpeed*r)}_getRotateXY(e,t){return[this.rotateSpeed*-e*.01,this.rotateSpeed*t*.01]}_getCameraRotation(e){return e.extractRotation(this.viewer.camera.matrixWorld),e.multiply(Kt.makeRotationY(Math.PI)),e}_transformPanVector(){this.component&&(ri.extractRotation(this.component.transform),ri.premultiply(this.viewer.rotationGroup.matrix),ri.getInverse(ri),ri.multiply(this._getCameraRotation(Qt)),si.applyMatrix4(ri))}zoom(e){this.controls.zoom(this.zoomSpeed*e*.02)}pan(e,t){this._setPanVector(e,t),ri.getInverse(this.viewer.rotationGroup.matrix),ri.multiply(this._getCameraRotation(Qt)),si.applyMatrix4(ri),this.controls.translate(si)}panComponent(e,t){this.component&&(this._setPanVector(e,t),this._transformPanVector(),this.component.position.add(si),this.component.updateMatrix())}panAtom(e,t){this.atom&&this.component&&(this.atom.positionToVector3(ni),ni.add(this.viewer.translationGroup.position),ni.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(e,t,ni.z),this._transformPanVector(),this.atom.positionAdd(si),this.component.updateRepresentations({position:!0}))}rotate(e,t){const[i,r]=this._getRotateXY(e,t);this._getCameraRotation(Qt),ei.set(1,0,0),ei.applyMatrix4(Qt),ti.setFromAxisAngle(ei,r),ei.set(0,1,0),ei.applyMatrix4(Qt),ii.setFromAxisAngle(ei,i),ti.multiply(ii),Qt.makeRotationFromQuaternion(ti),this.controls.applyMatrix(Qt)}zRotate(e,t){const i=this.rotateSpeed*((-e+t)/-2)*.01;Zt.makeRotationZ(i),this.controls.applyMatrix(Zt)}rotateComponent(e,t){if(!this.component)return;const[i,r]=this._getRotateXY(e,t);this._getCameraRotation(Jt),Qt.extractRotation(this.component.transform),Qt.premultiply(this.viewer.rotationGroup.matrix),Qt.getInverse(Qt),Qt.premultiply(Jt),ei.set(1,0,0),ei.applyMatrix4(Qt),Yt.makeRotationAxis(ei,r),ei.set(0,1,0),ei.applyMatrix4(Qt),Kt.makeRotationAxis(ei,i),Yt.multiply(Kt),ti.setFromRotationMatrix(Yt),this.component.quaternion.premultiply(ti),this.component.quaternion.normalize(),this.component.updateMatrix()}}const ai=new t.Vector3;class ci{constructor(e,t){this.stage=t,this.pid=e.pid,this.picker=e.picker,this.instance=e.instance,this.stage=t,this.controls=t.viewerControls,this.mouse=t.mouseObserver}get type(){return this.picker.type}get altKey(){return this.mouse.altKey}get ctrlKey(){return this.mouse.ctrlKey}get metaKey(){return this.mouse.metaKey}get shiftKey(){return this.mouse.shiftKey}get canvasPosition(){return this.mouse.canvasPosition}get component(){return this.stage.getComponentsByObject(this.picker.data).list[0]}get object(){return this.picker.getObject(this.pid)}get position(){return this.picker.getPosition(this.pid,this.instance,this.component)}get closestBondAtom(){if("bond"!==this.type||!this.bond)return;const e=this.bond,t=this.controls,i=this.canvasPosition,r=e.atom1.positionToVector3(),s=e.atom2.positionToVector3();r.applyMatrix4(this.component.matrix),s.applyMatrix4(this.component.matrix);const n=t.getPositionOnCanvas(r),o=t.getPositionOnCanvas(s);return c=n,l=o,(a=i).distanceTo(c)=e.length))return new ci(i,this.stage);console.error("pid >= picker.array.length")}}}const hi=new t.Quaternion,ui=new t.Vector3,di=new t.Vector3,mi=new t.Vector3,pi=new t.Vector3,fi=new t.Matrix4,gi=new t.Vector3,yi=new t.Matrix4;class bi{constructor(e){this.stage=e,this.signals={changed:new a.Signal},this.viewer=e.viewer}get position(){return this.viewer.translationGroup.position}get rotation(){return this.viewer.rotationGroup.quaternion}changed(){this.viewer.requestRender(),this.signals.changed.dispatch()}getPositionOnCanvas(e,i){const r=S(i,t.Vector2);const s=this.viewer;return mi.copy(e).add(s.translationGroup.position).applyMatrix4(s.rotationGroup.matrix).project(s.camera),r.set((mi.x+1)*s.width/2,(mi.y+1)*s.height/2)}getCanvasScaleFactor(e=0){const i=this.viewer.camera;if(i instanceof t.OrthographicCamera)return 1/i.zoom;{e=Math.abs(e),e+=this.getCameraDistance();const t=T(i.fov);return 2*e*Math.tan(t/2)/this.viewer.height}}getOrientation(e){const t=P(e);t.copy(this.viewer.rotationGroup.matrix);const i=this.getCameraDistance();return t.scale(pi.set(i,i,i)),t.setPosition(this.viewer.translationGroup.position),t}orient(e){P(e).decompose(ui,hi,di);const t=this.viewer;t.rotationGroup.setRotationFromQuaternion(hi),t.translationGroup.position.copy(ui),t.cameraDistance=di.z,t.updateZoom(),this.changed()}translate(e){this.viewer.translationGroup.position.add(C(e)),this.changed()}center(e){this.viewer.translationGroup.position.copy(C(e)).negate(),this.changed()}zoom(e){this.distance(this.getCameraDistance()*(1-e))}getCameraDistance(){return this.viewer.cameraDistance}distance(e){this.viewer.cameraDistance=Math.max(Math.abs(e),.2),this.viewer.updateZoom(),this.changed()}spin(e,t){fi.getInverse(this.viewer.rotationGroup.matrix),gi.copy(C(e)).applyMatrix4(fi),this.viewer.rotationGroup.rotateOnAxis(gi,t),this.changed()}rotate(e){this.viewer.rotationGroup.setRotationFromQuaternion(I(e)),this.changed()}align(e){yi.getInverse(P(e)),this.viewer.rotationGroup.setRotationFromMatrix(yi),this.changed()}applyMatrix(e){this.viewer.rotationGroup.applyMatrix4(P(e)),this.changed()}}class xi{constructor(e,t,...i){this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=l(e,1e3),this.controls=t,this.startTime=window.performance.now(),this._init(...i)}get done(){return 1===this.alpha}get paused(){return this._paused}tick(e){if(!this._paused)return this.elapsedDuration=e.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=L(0,1,this.elapsedDuration/this.duration),this._tick(e),this.done&&this._resolveList.forEach((e=>e())),this.done}pause(e){e&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0}resume(e){!e&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)}toggle(){this._paused?this.resume():this.pause()}then(e){let t;return t=this.done?Promise.resolve():new Promise((e=>this._resolveList.push(e))),t.then(e)}}class vi extends xi{constructor(e,t,...i){super(l(e,1/0),t,...i)}_init(e,i){Array.isArray(e)?this.axis=(new t.Vector3).fromArray(e):this.axis=l(e,new t.Vector3(0,1,0)),this.angle=l(i,.01)}_tick(e){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*e.lastDuration/16)}}class wi extends xi{constructor(e,t,...i){super(l(e,1/0),t,...i),this.angleSum=0,this.direction=1}_init(e,i,r){Array.isArray(e)?this.axis=(new t.Vector3).fromArray(e):this.axis=l(e,new t.Vector3(0,1,0)),this.angleStep=l(i,.01),this.angleEnd=l(r,.2)}_tick(e){if(!this.axis||!this.angleStep||!this.angleEnd)return;const t=L(0,1,Math.abs(this.angleSum)/this.angleEnd),i=this.angleStep*this.direction*(1.1-t);this.controls.spin(this.axis,i*e.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}}class Ai extends xi{_init(e,i){this.moveFrom=C(l(e,new t.Vector3)),this.moveTo=C(l(i,new t.Vector3))}_tick(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()}}class _i extends xi{_init(e,t){this.zoomFrom=e,this.zoomTo=t}_tick(){this.controls.distance(F(this.zoomFrom,this.zoomTo,this.alpha))}}class Si extends xi{constructor(){super(...arguments),this._currentRotation=new t.Quaternion}_init(e,i){this.rotateFrom=I(e),this.rotateTo=I(i),this._currentRotation=new t.Quaternion}_tick(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)}}class Ci extends xi{_init(e,t,i){this.valueFrom=e,this.valueTo=t,this.callback=i}_tick(){this.callback(F(this.valueFrom,this.valueTo,this.alpha))}}class Pi extends xi{_init(e){this.callback=e}_tick(){1===this.alpha&&this.callback()}}class Ii{constructor(e=[]){this._resolveList=[],this._list=e}get done(){return this._list.every((e=>e.done))}then(e){let t;return t=this.done?Promise.resolve():new Promise((e=>{this._resolveList.push(e),this._list.forEach((e=>{e.then((()=>{this._resolveList.forEach((e=>{e()})),this._resolveList.length=0}))}))})),t.then(e)}}class ki{constructor(e){this.stage=e,this.animationList=[],this.finishedList=[],this.viewer=e.viewer,this.controls=e.viewerControls}get paused(){return this.animationList.every((e=>e.paused))}add(e){return 0===e.duration?e.tick(this.viewer.stats):this.animationList.push(e),e}remove(e){const t=this.animationList,i=t.indexOf(e);i>-1&&t.splice(i,1)}run(e){const t=this.finishedList,i=this.animationList,r=i.length;for(let s=0;se.pause()))}resume(){this.animationList.forEach((e=>e.resume()))}toggle(){this.paused?this.resume():this.pause()}clear(){this.animationList.length=0}dispose(){this.clear()}}class Mi{constructor(e,t){if(this.fn=e,this.queue=[],this.pending=!1,this.next=this.next.bind(this),t){for(let e=0,i=t.length;ethis.run(e)))):this.pending=!1}push(e){this.queue.push(e),this.pending||this.next()}kill(){this.queue.length=0}length(){return this.queue.length}}class Di{constructor(e,t,i){this.type="",this.parameters={lazy:{type:"boolean"},clipNear:{type:"range",step:1,max:100,min:0,buffer:!0},clipRadius:{type:"number",precision:1,max:1e3,min:0,buffer:!0},clipCenter:{type:"vector3",precision:1,buffer:!0},flatShaded:{type:"boolean",buffer:!0},opacity:{type:"range",step:.01,max:1,min:0,buffer:!0},depthWrite:{type:"boolean",buffer:!0},side:{type:"select",buffer:!0,options:{front:"front",back:"back",double:"double"}},wireframe:{type:"boolean",buffer:!0},colorData:{type:"hidden",update:"color"},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:Ee.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:Ee.getModes()},roughness:{type:"range",step:.01,max:1,min:0,buffer:!0},metalness:{type:"range",step:.01,max:1,min:0,buffer:!0},diffuse:{type:"color",buffer:!0},diffuseInterior:{type:"boolean",buffer:!0},useInteriorColor:{type:"boolean",buffer:!0},interiorColor:{type:"color",buffer:!0},interiorDarkening:{type:"range",step:.01,max:1,min:0,buffer:!0},matrix:{type:"hidden",buffer:!0},disablePicking:{type:"boolean",rebuild:!0}},this.viewer=t,this.tasks=new nt,this.queue=new Mi(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=Ee.getSchemes()),this.toBePrepared=!1}init(e){const i=e||{};this.clipNear=l(i.clipNear,0),this.clipRadius=l(i.clipRadius,0),this.clipCenter=l(i.clipCenter,new t.Vector3),this.flatShaded=l(i.flatShaded,!1),this.side=l(i.side,"double"),this.opacity=l(i.opacity,1),this.depthWrite=l(i.depthWrite,!0),this.wireframe=l(i.wireframe,!1),this.setColor(i.color,i),this.colorData=l(i.colorData,void 0),this.colorScheme=l(i.colorScheme,"uniform"),this.colorScale=l(i.colorScale,""),this.colorReverse=l(i.colorReverse,!1),this.colorValue=l(i.colorValue,9474192),this.colorDomain=l(i.colorDomain,void 0),this.colorMode=l(i.colorMode,"hcl"),this.visible=l(i.visible,!0),this.quality=l(i.quality,void 0),this.roughness=l(i.roughness,.4),this.metalness=l(i.metalness,0),this.diffuse=l(i.diffuse,16777215),this.diffuseInterior=l(i.diffuseInterior,!1),this.useInteriorColor=l(i.useInteriorColor,!1),this.interiorColor=l(i.interiorColor,2236962),this.interiorDarkening=l(i.interiorDarkening,0),this.lazy=l(i.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=l(i.matrix,new t.Matrix4),this.disablePicking=l(i.disablePicking,!1);const r=this.parameters;!0===r.sphereDetail&&(r.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===r.radialSegments&&(r.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===r.openEnded&&(r.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===r.disableImpostor&&(r.disableImpostor={type:"boolean",rebuild:!0}),"low"===i.quality?(r.sphereDetail&&(this.sphereDetail=0),r.radialSegments&&(this.radialSegments=5)):"medium"===i.quality?(r.sphereDetail&&(this.sphereDetail=1),r.radialSegments&&(this.radialSegments=10)):"high"===i.quality?(r.sphereDetail&&(this.sphereDetail=2),r.radialSegments&&(this.radialSegments=20)):(r.sphereDetail&&(this.sphereDetail=l(i.sphereDetail,1)),r.radialSegments&&(this.radialSegments=l(i.radialSegments,10))),r.openEnded&&(this.openEnded=l(i.openEnded,!0)),r.disableImpostor&&(this.disableImpostor=l(i.disableImpostor,!1))}getColorParams(e){return Object.assign({data:this.colorData,scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode,colorSpace:this.colorSpace},e)}getBufferParams(e={}){return Object.assign({clipNear:this.clipNear,clipRadius:this.clipRadius,clipCenter:this.clipCenter,flatShaded:this.flatShaded,opacity:this.opacity,depthWrite:this.depthWrite,side:this.side,wireframe:this.wireframe,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,diffuseInterior:this.diffuseInterior,useInteriorColor:this.useInteriorColor,interiorColor:this.interiorColor,interiorDarkening:this.interiorDarkening,matrix:this.matrix,disablePicking:this.disablePicking},e)}setColor(e,i){const r=Object.keys(Ee.getSchemes());if("string"==typeof e&&r.includes(e.toLowerCase()))i?i.colorScheme=e:this.setParameters({colorScheme:e});else if(void 0!==e){let r=new t.Color(e).getHex();i?(i.colorScheme="uniform",i.colorValue=r):this.setParameters({colorScheme:"uniform",colorValue:r})}return this}prepare(e){}create(){}update(e){this.build()}build(e){if(!this.lazy||this.visible&&this.opacity){if(!this.toBePrepared)return this.tasks.increment(),void this.make();this.queue.length()>0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(e||!1)}else this.lazyProps.build=!0}make(t,i){e.Debug&&Be.time("Representation.make "+this.type);const r=()=>{t?(this.update(t),this.viewer.requestRender(),this.tasks.decrement(),i&&i()):(this.clear(),this.create(),this.manualAttach||this.disposed||(e.Debug&&Be.time("Representation.attach "+this.type),this.attach((()=>{e.Debug&&Be.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),i&&i()})))),e.Debug&&Be.timeEnd("Representation.make "+this.type)};this.toBePrepared?this.prepare(r):r()}attach(e){this.setVisibility(this.visible),e()}setVisibility(e,t){if(this.visible=e,this.visible&&this.opacity){const e=this.lazyProps,t=e.bufferParams,i=e.what;if(e.build)return e.build=!1,this.build(),this;(Object.keys(t).length||Object.keys(i).length)&&(e.bufferParams={},e.what={},this.updateParameters(t,i))}return this.bufferList.forEach((function(t){t.setVisibility(e)})),t||this.viewer.requestRender(),this}setParameters(e,t={},i=!1){const r=e||{},s=this.parameters,n={};this.opacity||void 0===r.opacity||(this.lazyProps.build?(this.lazyProps.build=!1,i=!0):(Object.assign(n,this.lazyProps.bufferParams),Object.assign(t,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(r.color,r);for(let e in r)if(void 0!==r[e]&&null!=s[e]&&(s[e].int&&(r[e]=parseInt(r[e])),s[e].float&&(r[e]=parseFloat(r[e])),r[e]!==this[e]||r[e].equals&&!r[e].equals(this[e]))){if(this[e]&&this[e].copy&&r[e].copy?this[e].copy(r[e]):this[e]&&this[e].set?this[e].set(r[e]):this[e]=r[e],s[e].buffer)if(!0===s[e].buffer)n[e]=r[e];else{n[s[e].buffer]=r[e]}s[e].update&&(t[s[e].update]=!0),!s[e].rebuild||"impostor"===s[e].rebuild&&De&&!this.disableImpostor||(i=!0)}return i?this.build():this.updateParameters(n,t),this}updateParameters(e={},t){if(this.lazy&&(!this.visible||!this.opacity)&&!1===e.hasOwnProperty("opacity"))return Object.assign(this.lazyProps.bufferParams,e),void Object.assign(this.lazyProps.what,t);this.bufferList.forEach((function(t){t.setParameters(e)})),Object.keys(t).length&&this.update(t),this.viewer.requestRender()}getParameters(){const e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach((t=>{null!==this.parameters[t]&&(e[t]=this[t])})),e}clear(){this.bufferList.forEach((e=>{this.viewer.remove(e),e.dispose()})),this.bufferList.length=0,this.viewer.requestRender()}dispose(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()}}class Ti{constructor(t){this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=t,this.blobUrl=window.URL.createObjectURL(Fe.get(t)),this.worker=new Worker(this.blobUrl),Fe.activeWorkerCount+=1,this.worker.onmessage=i=>{this.pending-=1;const r=i.data.__postId;e.Debug&&Be.timeEnd("Worker.postMessage "+t+" #"+r);const s=this.onmessageDict[r];s&&s.call(this.worker,i),delete this.onmessageDict[r],delete this.onerrorDict[r]},this.worker.onerror=e=>{if(this.pending-=1,e.data){const i=e.data.__postId,r=this.onerrorDict[i];r?r.call(this.worker,e):Be.error("Worker.onerror",i,t,e),delete this.onmessageDict[i],delete this.onerrorDict[i]}else Be.error("Worker.onerror",t,e)}}post(t={},i,r,s){this.onmessageDict[this.postCount]=r,this.onerrorDict[this.postCount]=s,t.__name=this.name,t.__postId=this.postCount,t.__debug=e.Debug,e.Debug&&Be.time(`Worker.postMessage ${this.name} #${this.postCount}`);try{this.worker.postMessage(t,i)}catch(e){Be.error("worker.post:",e),this.worker.postMessage(t)}return this.pending+=1,this.postCount+=1,this}terminate(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),Fe.activeWorkerCount-=1):Be.log("no worker to terminate")}}class Bi{constructor(e,t=2){this.pool=[],this.count=0,this.maxCount=Math.min(8,t),this.name=e}post(e={},t,i,r){const s=this.getNextWorker();return s?s.post(e,t,i,r):console.error("unable to get worker from pool"),this}terminate(){this.pool.forEach((function(e){e.terminate()}))}getNextWorker(){let e,t=1/0;for(let i=0;i=this.count){e=new Ti(this.name),this.pool.push(e),this.count+=1;break}const r=this.pool[i];if(0===r.pending){e=r;break}r.pendings&&(s=c),l>n&&(n=l),h>o&&(o=h)}return[Ni([t,i,r]),Ni([s,n,o])]}function Fi(e,t){for(let i=0,r=t.length;i0){const o=1/Math.sqrt(n);e[t]=i*o,e[t+1]=r*o,e[t+2]=s*o}}}function Ni(e){return new Float32Array(e||3)}function zi(e,t,i){const r=t[0],s=t[1],n=t[2],o=i[0],a=i[1],c=i[2];e[0]=s*c-n*a,e[1]=n*o-r*c,e[2]=r*a-s*o}function Vi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Gi(e,t,i){e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2]}function Ui(e,t,i){e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2]}function ji(e,t,i=0){e[0]=t[i],e[1]=t[i+1],e[2]=t[i+2]}function Hi(e,t,i=0){t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2]}function Wi(e){return e[0]*e[0]+e[1]*e[1]+e[2]*e[2]}function qi(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2])}function Xi(e,t,i){Yi(e,t,1/i)}function Yi(e,t,i){e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i}function Ki(e,t){const i=Wi(t);0==i?(e[0]=t[0],e[1]=t[1],e[2]=t[2]):Yi(e,t,1/Math.sqrt(i))}function Zi(e,t,i){e[0]=t[0]-i,e[1]=t[1]-i,e[2]=t[2]-i}function Qi(e,t,i){e[0]=t[0]+i,e[1]=t[1]+i,e[2]=t[2]+i}function Ji(e,t){e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2])}function er(e,t){e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2])}function tr(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2]}function ir(e,t){const i=e[0],r=e[1],s=e[2],n=t[0],o=t[1],a=t[2],c=r*a-s*o,l=s*n-i*a,h=i*o-r*n,u=Math.sqrt(c*c+l*l+h*h),d=i*n+r*o+s*a;return Math.atan2(u,d)}function rr(e,i=9){const r=Math.floor(i/2),s=e.position1.length/3,n=3*(r*s),o=1/i,a=gt(e.position1,e.position2),c=new Float32Array(n),l=new Float32Array(n),h=new t.Vector3;for(let t=0;t0){const t=3*p;n[t]=e.position2[3*u-3],n[t+1]=e.position2[3*u-2],n[t+1]=e.position2[3*u-1]}const y=new Float32Array(s),b=new Float32Array(n),x=ft(y,b),v=new Float32Array(o),w={position:x,position1:y,position2:b,color:v,color2:v};return a&&(w.radius=new Float32Array(a)),c&&e.picking&&(e.picking.array=new Float32Array(c),w.picking=e.picking),l&&(w.primitiveId=new Float32Array(l)),w}Bi.prototype.constructor=Bi,$i.__deps=[Ni],Xi.__deps=[Yi],Ki.__deps=[Yi,Wi];const or=new t.Vector3;class ar{static get Picker(){return He.get(this.type)}static get Buffer(){return je.get(this.type)}static getShapeKey(e){return this.type+e[0].toUpperCase()+e.substr(1)}static expandBoundingBox(e,t){}static valueToShape(e,t,i){const r=e._primitiveData[this.getShapeKey(t)];switch(this.fields[t]){case"v3":case"c":n=r,void 0!==(s=i).toArray?s=s.toArray():void 0!==s.x?s=[s.x,s.y,s.z]:void 0!==s.r&&(s=[s.r,s.g,s.b]),n.push.apply(n,s);break;default:r.push(i)}var s,n}static objectToShape(e,t){Object.keys(this.fields).forEach((i=>{this.valueToShape(e,i,t[i])})),this.valueToShape(e,"name",t.name),this.expandBoundingBox(e.boundingBox,t)}static valueFromShape(e,i,r){const s=e._primitiveData[this.getShapeKey(r)];switch(this.fields[r]){case"v3":return(new t.Vector3).fromArray(s,3*i);case"c":return(new t.Color).fromArray(s,3*i);default:return s[i]}}static objectFromShape(e,t){let i=this.valueFromShape(e,t,"name");void 0===i&&(i=`${this.type}: ${t} (${e.name})`);const r={shape:e,name:i};return Object.keys(this.fields).forEach((i=>{r[i]=this.valueFromShape(e,t,i)})),r}static arrayFromShape(e,t){const i=e._primitiveData[this.getShapeKey(t)];return"s"===this.fields[t]?i:new Float32Array(i)}static dataFromShape(e){const t={};return this.Picker&&(t.picking=new this.Picker(e)),Object.keys(this.fields).forEach((i=>{t[i]=this.arrayFromShape(e,i)})),t}static bufferFromShape(e,t){return new this.Buffer(this.dataFromShape(e),t)}}ar.type="",ar.fields={};class cr extends ar{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(or.fromArray(t.position))}}cr.type="sphere",cr.fields={position:"v3",color:"c",radius:"f"};class lr extends ar{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(or.fromArray(t.position))}}lr.type="box",lr.fields={position:"v3",color:"c",size:"f",heightAxis:"v3",depthAxis:"v3"};class hr extends lr{}hr.type="octahedron";class ur extends lr{}ur.type="tetrahedron";class dr extends ar{static positionFromShape(e,t){const i=this.valueFromShape(e,t,"position1"),r=this.valueFromShape(e,t,"position2");return i.add(r).multiplyScalar(.5)}static expandBoundingBox(e,t){e.expandByPoint(or.fromArray(t.position1)),e.expandByPoint(or.fromArray(t.position2))}static bufferFromShape(e,t={}){let i=this.dataFromShape(e);return"cylinder"===this.type&&t.dashedCylinder&&(i=sr(i)),new this.Buffer(i,t)}}dr.type="cylinder",dr.fields={position1:"v3",position2:"v3",color:"c",radius:"f"};class mr extends dr{}mr.type="arrow";class pr extends dr{}pr.type="cone";class fr extends cr{}fr.type="ellipsoid",fr.fields={position:"v3",color:"c",radius:"f",majorAxis:"v3",minorAxis:"v3"};class gr extends fr{}gr.type="torus";class yr extends ar{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(or.fromArray(t.position))}}yr.type="text",yr.fields={position:"v3",color:"c",size:"f",text:"s"};class br extends ar{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(or.fromArray(t.position))}}br.type="point",br.fields={position:"v3",color:"c"};class xr extends ar{static positionFromShape(e,t){const i=this.valueFromShape(e,t,"position1"),r=this.valueFromShape(e,t,"position2");return i.add(r).multiplyScalar(.5)}static expandBoundingBox(e,t){e.expandByPoint(or.fromArray(t.position1)),e.expandByPoint(or.fromArray(t.position2))}}xr.type="wideline",xr.fields={position1:"v3",position2:"v3",color:"c"};class vr{constructor(e,i){this.exp=3;const r=i||function(e){const{x:i,y:r,z:s}=e,n=new t.Box3,o=i.length,{min:a,max:c}=n;for(let e=0;e>this.exp),this.boundY=1+(r.max.y-this.minY>>this.exp),this.boundZ=1+(r.max.z-this.minZ>>this.exp);const s=this.boundX*this.boundY*this.boundZ,n=void 0!==e.count?e.count:e.x.length,o=e.x,a=e.y,c=e.z;let l=0;const h=new Uint32Array(s),u=new Int32Array(n);for(let e=0;e>this.exp,i=a[e]-this.minY>>this.exp,r=c[e]-this.minZ>>this.exp,s=(t*this.boundY+i)*this.boundZ+r;1===(h[s]+=1)&&(l+=1),u[e]=s}const d=new Uint16Array(l);for(let e=0,t=0;e0&&(h[e]=t+1,d[t]=i,t+=1)}const m=new Uint32Array(l);for(let e=1;e0){const i=t-1;f[m[i]+p[i]]=e,p[i]+=1}}this.grid=h,this.bucketCount=d,this.bucketOffset=m,this.bucketArray=f,this.xArray=o,this.yArray=a,this.zArray=c}within(e,t,i,r){const s=[];return this.eachWithin(e,t,i,r,(e=>s.push(e))),s}eachWithin(e,t,i,r,s){const n=r*r,o=Math.max(0,e-r-this.minX>>this.exp),a=Math.max(0,t-r-this.minY>>this.exp),c=Math.max(0,i-r-this.minZ>>this.exp),l=Math.min(this.boundX,1+(e+r-this.minX>>this.exp)),h=Math.min(this.boundY,1+(t+r-this.minY>>this.exp)),u=Math.min(this.boundZ,1+(i+r-this.minZ>>this.exp));for(let r=o;r0){const r=l-1,o=this.bucketOffset[r],a=o+this.bucketCount[r];for(let r=o;rr?s.set(this[t].subarray(0,r)):s.set(this[t]),this[t]=s}}growIfFull(){if(this.count>=this.length){const e=Math.round(1.5*this.length);this.resize(Math.max(256,e))}}copyFrom(e,t,i,r){for(let s=0,n=this._fields.length;s0;)h-=1;l<=h&&(l===c?c=h:h===c&&(c=l),(o=l)!==(a=h)&&(i.copyFrom(t,0,o,1),t.copyWithin(o,a,1),t.copyFrom(i,a,0,1)),l+=1,h-=1)}while(l<=h);r(s,h),r(l,n)}var o,a}(0,this.count-1),Be.timeEnd("Store.sort")}clear(){this.count=0}dispose(){for(let e=0,t=this._fields.length;e>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24}class Sr{constructor(e,t){this.length=e,this._words=new Uint32Array(e+32>>>5),!0===t&&this.setAll()}get(e){return 0!=(this._words[e>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,o=t>>>5;for(let e=n+1;e>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>i,this}_isRangeValue(e,t,i){if(t>>5,o=t>>>5;for(let e=n+1;e>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<0){const{types:r,groups:s,centers:n,atomSets:o}=e;r.push(t.type),s.push(t.group),n.x.push(t.x/i),n.y.push(t.y/i),n.z.push(t.z/i),o.push(t.atomSet)}}const Mr=0,Dr=["D-BETA-PEPTIDE, C-GAMMA LINKING","D-GAMMA-PEPTIDE, C-DELTA LINKING","D-PEPTIDE COOH CARBOXY TERMINUS","D-PEPTIDE NH3 AMINO TERMINUS","D-PEPTIDE LINKING","L-BETA-PEPTIDE, C-GAMMA LINKING","L-GAMMA-PEPTIDE, C-DELTA LINKING","L-PEPTIDE COOH CARBOXY TERMINUS","L-PEPTIDE NH3 AMINO TERMINUS","L-PEPTIDE LINKING","PEPTIDE LINKING","PEPTIDE-LIKE"],Tr=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],Br=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],Rr=["D-SACCHARIDE","D-SACCHARIDE 1,4 AND 1,4 LINKING","D-SACCHARIDE 1,4 AND 1,6 LINKING","L-SACCHARIDE","L-SACCHARIDE 1,4 AND 1,4 LINKING","L-SACCHARIDE 1,4 AND 1,6 LINKING","SACCHARIDE"],Or=["NON-POLYMER"].concat(["OTHER"],Rr),$r=["h","g","i"],Fr=["e","b"],Er=["s","t","l",""],Lr={H:1,D:1,T:1,HE:2,LI:3,BE:4,B:5,C:6,N:7,O:8,F:9,NE:10,NA:11,MG:12,AL:13,SI:14,P:15,S:16,CL:17,AR:18,K:19,CA:20,SC:21,TI:22,V:23,CR:24,MN:25,FE:26,CO:27,NI:28,CU:29,ZN:30,GA:31,GE:32,AS:33,SE:34,BR:35,KR:36,RB:37,SR:38,Y:39,ZR:40,NB:41,MO:42,TC:43,RU:44,RH:45,PD:46,AG:47,CD:48,IN:49,SN:50,SB:51,TE:52,I:53,XE:54,CS:55,BA:56,LA:57,CE:58,PR:59,ND:60,PM:61,SM:62,EU:63,GD:64,TB:65,DY:66,HO:67,ER:68,TM:69,YB:70,LU:71,HF:72,TA:73,W:74,RE:75,OS:76,IR:77,PT:78,AU:79,HG:80,TL:81,PB:82,BI:83,PO:84,AT:85,RN:86,FR:87,RA:88,AC:89,TH:90,PA:91,U:92,NP:93,PU:94,AM:95,CM:96,BK:97,CF:98,ES:99,FM:100,MD:101,NO:102,LR:103,RF:104,DB:105,SG:106,BH:107,HS:108,MT:109,DS:110,RG:111,CN:112,NH:113,FL:114,MC:115,LV:116,TS:117,OG:118},Nr={1:1.1,2:1.4,3:1.81,4:1.53,5:1.92,6:1.7,7:1.55,8:1.52,9:1.47,10:1.54,11:2.27,12:1.73,13:1.84,14:2.1,15:1.8,16:1.8,17:1.75,18:1.88,19:2.75,20:2.31,21:2.3,22:2.15,23:2.05,24:2.05,25:2.05,26:2.05,27:2,28:2,29:2,30:2.1,31:1.87,32:2.11,33:1.85,34:1.9,35:1.83,36:2.02,37:3.03,38:2.49,39:2.4,40:2.3,41:2.15,42:2.1,43:2.05,44:2.05,45:2,46:2.05,47:2.1,48:2.2,49:2.2,50:1.93,51:2.17,52:2.06,53:1.98,54:2.16,55:3.43,56:2.68,57:2.5,58:2.48,59:2.47,60:2.45,61:2.43,62:2.42,63:2.4,64:2.38,65:2.37,66:2.35,67:2.33,68:2.32,69:2.3,70:2.28,71:2.27,72:2.25,73:2.2,74:2.1,75:2.05,76:2,77:2,78:2.05,79:2.1,80:2.05,81:1.96,82:2.02,83:2.07,84:1.97,85:2.02,86:2.2,87:3.48,88:2.83,89:2,90:2.4,91:2,92:2.3,93:2,94:2,95:2,96:2,97:2,98:2,99:2,100:2,101:2,102:2,103:2,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:2,114:2,115:2,116:2,117:2,118:2},zr={1:.31,2:.28,3:1.28,4:.96,5:.84,6:.76,7:.71,8:.66,9:.57,10:.58,11:1.66,12:1.41,13:1.21,14:1.11,15:1.07,16:1.05,17:1.02,18:1.06,19:2.03,20:1.76,21:1.7,22:1.6,23:1.53,24:1.39,25:1.39,26:1.32,27:1.26,28:1.24,29:1.32,30:1.22,31:1.22,32:1.2,33:1.19,34:1.2,35:1.2,36:1.16,37:2.2,38:1.95,39:1.9,40:1.75,41:1.64,42:1.54,43:1.47,44:1.46,45:1.42,46:1.39,47:1.45,48:1.44,49:1.42,50:1.39,51:1.39,52:1.38,53:1.39,54:1.4,55:2.44,56:2.15,57:2.07,58:2.04,59:2.03,60:2.01,61:1.99,62:1.98,63:1.98,64:1.96,65:1.94,66:1.92,67:1.92,68:1.89,69:1.9,70:1.87,71:1.87,72:1.75,73:1.7,74:1.62,75:1.51,76:1.44,77:1.41,78:1.36,79:1.36,80:1.32,81:1.45,82:1.46,83:1.48,84:1.4,85:1.5,86:1.5,87:2.6,88:2.21,89:2.15,90:2.06,91:2,92:1.96,93:1.9,94:1.87,95:1.8,96:1.69,97:1.6,98:1.6,99:1.6,100:1.6,101:1.6,102:1.6,103:1.6,104:1.6,105:1.6,106:1.6,107:1.6,108:1.6,109:1.6,110:1.6,111:1.6,112:1.6,113:1.6,114:1.6,115:1.6,116:1.6,117:1.6,118:1.6},Vr={1:[1],2:[0],3:[1],4:[2],5:[3],6:[4],7:[3],8:[2],9:[1],10:[0],11:[1],12:[2],13:[6],14:[6],15:[3,5,7],16:[2,4,6],17:[1],18:[0],19:[1],20:[2],31:[3],32:[4],33:[3,5],34:[2,4,6],35:[1],36:[0],37:[1],38:[2],49:[3],50:[4],51:[3,5],52:[2],53:[1,2,5],54:[0,2],55:[1],56:[2],81:[3],82:[4],83:[3],84:[2],85:[1],86:[0],87:[1],88:[2]},Gr={1:1,2:2,3:1,4:2,5:3,6:4,7:5,8:6,9:7,10:8,11:1,12:2,13:3,14:4,15:5,16:6,17:7,18:8,19:1,20:2,21:3,22:4,23:5,24:6,25:7,26:8,27:9,28:10,29:11,30:2,31:3,32:4,33:5,34:6,35:7,36:8,37:1,38:2,39:3,40:4,41:5,42:6,43:7,44:8,45:9,46:10,47:11,48:2,49:3,50:4,51:5,52:6,53:7,54:8,55:1,56:2,57:3,58:4,59:3,60:4,61:5,62:6,63:7,64:8,65:9,66:10,67:11,68:12,69:13,70:14,71:15,72:4,73:5,74:6,75:7,76:8,77:9,78:10,79:11,80:2,81:3,82:4,83:5,84:6,85:7,86:8,87:1,88:2,89:3,90:4,91:3,92:4,93:5,94:6,95:7,96:8,97:9,98:10,99:11,100:12,101:13,102:14,103:15,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:3,114:4,115:5,116:6,117:7,118:8},Ur={ALA:[.17,.5,.33],ARG:[.81,1.81,1],ASN:[.42,.85,.43],ASP:[1.23,3.64,2.41],ASH:[-.07,.43,.5],CYS:[-.24,-.02,.22],GLN:[.58,.77,.19],GLU:[2.02,3.63,1.61],GLH:[-.01,.11,.12],GLY:[.01,1.15,1.14],HIS:[.17,.11,-.06],ILE:[-.31,-1.12,-.81],LEU:[-.56,-1.25,-.69],LYS:[.99,2.8,1.81],MET:[-.23,-.67,-.44],PHE:[-1.13,-1.71,-.58],PRO:[.45,.14,-.31],SER:[.13,.46,.33],THR:[.14,.25,.11],TRP:[-1.85,-2.09,-.24],TYR:[-.94,-.71,.23],VAL:[.07,-.46,-.53]},jr=[0,0,0],Hr={HIS:"H",ARG:"R",LYS:"K",ILE:"I",PHE:"F",LEU:"L",TRP:"W",ALA:"A",MET:"M",PRO:"P",CYS:"C",ASN:"N",VAL:"V",GLY:"G",SER:"S",GLN:"Q",TYR:"Y",ASP:"D",GLU:"E",THR:"T",SEC:"U",PYL:"O"},Wr=Object.keys(Hr),qr=["A","C","T","G","U","I"],Xr=["DA","DC","DT","DG","DU","DI"],Yr=["A","G","I","DA","DG","DI"],Kr=qr.concat(Xr),Zr=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4","SPC"],Qr=["118","119","1AL","1CU","2FK","2HP","2OF","3CO","3MT","3NI","3OF","3P8","4MO","4PU","543","6MO","ACT","AG","AL","ALF","AM","ATH","AU","AU3","AUC","AZI","BA","BCT","BEF","BF4","BO4","BR","BS3","BSY","CA","CAC","CD","CD1","CD3","CD5","CE","CHT","CL","CO","CO3","CO5","CON","CR","CS","CSB","CU","CU1","CU3","CUA","CUZ","CYN","DME","DMI","DSC","DTI","DY","E4N","EDR","EMC","ER3","EU","EU3","F","FE","FE2","FPO","GA","GD3","GEP","HAI","HG","HGC","IN","IOD","IR","IR3","IRI","IUM","K","KO4","LA","LCO","LCP","LI","LU","MAC","MG","MH2","MH3","MLI","MLT","MMC","MN","MN3","MN5","MN6","MO1","MO2","MO3","MO4","MO5","MO6","MOO","MOS","MOW","MW1","MW2","MW3","NA","NA2","NA5","NA6","NAO","NAW","NCO","NET","NH4","NI","NI1","NI2","NI3","NO2","NO3","NRU","O4M","OAA","OC1","OC2","OC3","OC4","OC5","OC6","OC7","OC8","OCL","OCM","OCN","OCO","OF1","OF2","OF3","OH","OS","OS4","OXL","PB","PBM","PD","PDV","PER","PI","PO3","PO4","PR","PT","PT4","PTN","RB","RH3","RHD","RU","SB","SCN","SE4","SEK","SM","SMO","SO3","SO4","SR","T1A","TB","TBA","TCN","TEA","TH","THE","TL","TMA","TRA","UNX","V","VN3","VO4","W","WO5","Y1","YB","YB2","YH","YT3","ZCM","ZN","ZN2","ZN3","ZNO","ZO3","OHX"],Jr=["045","0AT","0BD","0MK","0NZ","0TS","0V4","0XY","0YT","10M","147","149","14T","15L","16G","18T","18Y","1AR","1BW","1GL","1GN","1JB","1LL","1NA","1S3","26M","26Q","26R","26V","26W","26Y","27C","289","291","293","2DG","2F8","2FG","2FL","2FP","2GL","2M4","2M5","32O","34V","3CM","3DO","3DY","3FM","3LR","3MF","3MG","3SA","3ZW","46D","46M","46Z","48Z","4CQ","4GC","4NN","50A","5DI","5GF","5MM","5RP","5SA","5SP","64K","6PG","6SA","7JZ","7SA","A1Q","A2G","AAB","AAL","AAO","ABC","ABD","ABE","ABF","ABL","ACG","ACI","ACR","ACX","ADA","ADG","ADR","AF1","AFD","AFL","AFO","AFP","AFR","AGC","AGH","AGL","AHR","AIG","ALL","ALX","AMU","AOG","AOS","ARA","ARB","ARE","ARI","ASG","ASO","AXP","AXR","B0D","B16","B2G","B4G","B6D","B8D","B9D","BBK","BCD","BDG","BDP","BDR","BEM","BFP","BGC","BGL","BGP","BGS","BHG","BMA","BMX","BNG","BNX","BOG","BRI","BXF","BXP","BXX","BXY","C3X","C4X","C5X","CAP","CBI","CBK","CBS","CDR","CEG","CGF","CHO","CR1","CR6","CRA","CT3","CTO","CTR","CTT","D6G","DAF","DAG","DDA","DDB","DDL","DEL","DFR","DFX","DG0","DGC","DGD","DGM","DGS","DIG","DLF","DLG","DMU","DNO","DOM","DP5","DQQ","DQR","DR2","DR3","DR4","DRI","DSR","DT6","DVC","E4P","E5G","EAG","EBG","EBQ","EGA","EJT","EPG","ERE","ERI","F1P","F1X","F6P","FBP","FCA","FCB","FCT","FDP","FDQ","FFC","FIX","FMO","FRU","FSI","FU4","FUB","FUC","FUD","FUL","FXP","G16","G1P","G2F","G3I","G4D","G4S","G6D","G6P","G6S","GAC","GAD","GAL","GC1","GC4","GCD","GCN","GCO","GCS","GCT","GCU","GCV","GCW","GCX","GE1","GFG","GFP","GIV","GL0","GL2","GL5","GL6","GL7","GL9","GLA","GLB","GLC","GLD","GLF","GLG","GLO","GLP","GLS","GLT","GLW","GMH","GN1","GNX","GP1","GP4","GPH","GPM","GQ1","GQ2","GQ4","GS1","GS4","GSA","GSD","GTE","GTH","GTK","GTR","GTZ","GU0","GU1","GU2","GU3","GU4","GU5","GU6","GU8","GU9","GUF","GUP","GUZ","GYP","GYV","H2P","HDL","HMS","HS2","HSD","HSG","HSH","HSJ","HSQ","HSR","HSU","HSX","HSY","HSZ","IAB","IDG","IDR","IDS","IDT","IDU","IDX","IDY","IMK","IN1","IPT","ISL","KBG","KD2","KDA","KDM","KDO","KFN","KO1","KO2","KTU","L6S","LAG","LAI","LAK","LAO","LAT","LB2","LBT","LCN","LDY","LGC","LGU","LM2","LMT","LMU","LOG","LOX","LPK","LSM","LTM","LVZ","LXB","LXZ","M1F","M3M","M6P","M8C","MA1","MA2","MA3","MAB","MAG","MAL","MAN","MAT","MAV","MAW","MBG","MCU","MDA","MDM","MDP","MFA","MFB","MFU","MG5","MGA","MGL","MLB","MMA","MMN","MN0","MRP","MTT","MUG","MVP","MXY","N1L","N9S","NAA","NAG","NBG","NDG","NED","NG1","NG6","NGA","NGB","NGC","NGE","NGF","NGL","NGS","NGY","NHF","NM6","NM9","NTF","NTO","NTP","NXD","NYT","OPG","OPM","ORP","OX2","P3M","P53","P6P","PA5","PNA","PNG","PNW","PRP","PSJ","PSV","PTQ","QDK","QPS","QV4","R1P","R1X","R2B","R5P","RAA","RAE","RAF","RAM","RAO","RAT","RB5","RBL","RCD","RDP","REL","RER","RF5","RG1","RGG","RHA","RIB","RIP","RNS","RNT","ROB","ROR","RPA","RST","RUB","RUU","RZM","S6P","S7P","SA0","SCR","SDD","SF6","SF9","SG4","SG5","SG6","SG7","SGA","SGC","SGD","SGN","SGS","SHB","SHG","SI3","SIO","SOE","SOL","SSG","SUC","SUP","SUS","T6P","T6T","TAG","TCB","TDG","TGK","TGY","TH1","TIA","TM5","TM6","TM9","TMR","TMX","TOA","TOC","TRE","TYV","UCD","UDC","VG1","X0X","X1X","X2F","X4S","X5S","X6X","XBP","XDN","XDP","XIF","XIM","XLF","XLS","XMM","XUL","XXR","XYP","XYS","YO5","Z3Q","Z6J","Z9M","ZDC","ZDM"],es=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","OT1","OT2","H","H1","H2","H3","HA","HN","BB"],ts=["P","OP1","OP2","HOP2","HOP3","O2'","O3'","O4'","O5'","C1'","C2'","C3'","C4'","C5'","H1'","H2'","H2''","HO2'","H3'","H4'","H5'","H5''","HO3'","HO5'","O2*","O3*","O4*","O5*","C1*","C2*","C3*","C4*","C5*"],is={1:{trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT","OT1","OT2"],backboneStart:"N",backboneEnd:"C"},2:{trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},3:{trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},4:{trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},5:{trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},6:{trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]}};is[Mr]={};const rs={HD:"H",HS:"H",A:"C",NA:"N",NS:"N",OA:"O",OS:"O",SA:"S",G0:"C",G1:"C",G2:"C",G3:"C",CG0:"C",CG1:"C",CG2:"C",CG3:"C",W:"O"};function ss(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;default:return 8}}const ns=new Map([[2,T(180)],[3,T(120)],[4,T(109.4721)],[6,T(90)]]);function os(e,i){let r=[];const s=new t.Vector3,n=new t.Vector3;return s.subVectors(i,e),e.eachBondedAtom((t=>{1!==t.number&&(n.subVectors(t,e),r.push(s.angleTo(n)))})),r}function as(e,i){const r=e.clone(),s=new t.Vector3;s.subVectors(i,e);const n=[new t.Vector3,new t.Vector3];let o=0;if(e.eachBondedAtom((t=>{o>1||1!==t.number&&(r.index=t.index,n[o++].subVectors(t,e))})),1===o&&r.eachBondedAtom((t=>{o>1||1!==t.number&&t.index!==e.index&&n[o++].subVectors(t,e)})),2!==o)return;const a=n[0].cross(n[1]);return Math.abs(Math.PI/2-a.angleTo(s))}function cs(e,t){const i=e.structure,r=i.atomCount,s=new Int8Array(r),n=new Int8Array(r),o=new Int8Array(r),a=new Int8Array(r);return i.eachAtom((e=>{const i=e.index,[r,c,l,h]=function(e,t){const i=e.bondToElementCount(1);let r=e.formalCharge||0;const s="always"===t.assignCharge||"auto"===t.assignCharge&&0===r,n="always"===t.assignH||"auto"===t.assignH&&0===i,o=e.bondCount,a=function(e){let t=0;return e.eachBond((e=>t+=e.bondOrder)),t}(e),c=function(e){const t=e.structure.getBondProxy(),i=e.number,r=8===i||7===i;if(r&&4===e.bondCount)return!1;let s=!1;return e.eachBond((i=>{if(i.bondOrder>1)s=!0;else if(r){const r=i.getOtherAtom(e);r.eachBond((e=>{if(e.bondOrder>1){const t=r.number;if((15===t||16===t)&&8===e.getOtherAtom(r).number)return;s=!0}}),t)}})),s}(e),l=a-o>0;let h=0,u=8;switch(e.number){case 1:s&&(0===o?(r=1,u=0):1===o&&(r=0,u=1));break;case 6:s&&(r=0),n&&(h=Math.max(0,4-a-Math.abs(r))),u=ss(o+h+Math.max(0,-r));break;case 7:if(s)if(n)if(c&&a<4)r=o-i==1&&a-i==2?1:0;else{let t=!1;e.eachBondedAtom((e=>{(16===e.number||e.isMetal())&&(t=!0)})),r=t?0:1}else r=a-3;n&&(h=Math.max(0,3-a+r)),u=ss(c&&!l?o+h-r:o+h+1-r);break;case 8:s&&(n||(r=a-2),1===a&&e.eachBondedAtom((t=>{t.eachBond((i=>{const s=i.getOtherAtom(t);s.index!==e.index&&8===s.number&&2===i.bondOrder&&(r=-1)}))}))),n&&(h=Math.max(0,2-a+r)),u=ss(c&&!l?o+h-r+1:o+h-r+2);break;case 16:s&&(n||(r=a<=3&&!e.bondToElementCount(8)?a-2:0)),n&&a<2&&(h=Math.max(0,2-a+r)),a<=3&&(u=ss(o+h-r+2));break;case 9:case 17:case 35:case 53:case 85:s&&(r=a-1);break;case 3:case 11:case 19:case 37:case 55:case 87:s&&(r=1-a);break;case 4:case 12:case 20:case 38:case 56:case 88:s&&(r=2-a);break;default:console.warn("Requested charge, protonation for an unhandled element",e.element)}return[r,h,h+i,u]}(e,t);s[i]=r,n[i]=c,o[i]=l,a[i]=h})),{charge:s,implicitH:n,totalH:o,idealGeometry:a}}function ls(e){if(e["@valenceModel"])return e["@valenceModel"];const t=cs(e,{assignCharge:"auto",assignH:"auto"});return e["@valenceModel"]=t,t}function hs(e){return 15===e.number&&e.bondToElementCount(8)===e.bondCount}const us=["ARG","HIS","LYS"],ds=["GLU","ASP"];function ms(e,t){return 2===e&&1===t||1===e&&2===t}function ps(e,t){return 3===e&&3===t}function fs(e,t){return 3===e&&1===t||1===e&&3===t}function gs(e){return"HIS"===e.resname&&7==e.number&&e.isRing()}function ys(e,t){return 5===e&&4===t||4===e&&5===t}function bs(e,t){return 9===e&&5===t||5===e&&9===t}const xs=[3,11,19,37,55,12,20,38,56,13,31,49,81,21,50,82,83,51,80];function vs(e,t){return 12===e?11===t||12===t:13===e?10===t:void 0}const ws=[17,35,53,85];const As=[7,8,16],_s=[6,7,15,16];const Ss=T(180),Cs=T(120);function Ps(e,t,i){return!ks(e,t,i)&&(e.modelIndex!==t.modelIndex||e.altloc&&t.altloc&&e.altloc!==t.altloc)}const Is={maxHydrophobicDist:4,maxHbondDist:3.5,maxHbondSulfurDist:4.1,maxHbondAccAngle:45,maxHbondDonAngle:45,maxHbondAccPlaneAngle:90,maxHbondDonPlaneAngle:30,maxPiStackingDist:5.5,maxPiStackingOffset:2,maxPiStackingAngle:30,maxCationPiDist:6,maxCationPiOffset:2,maxIonicDist:5,maxHalogenBondDist:4,maxHalogenBondAngle:30,maxMetalDist:3,refineSaltBridges:!0,masterModelIndex:-1,lineOfSightDistFactor:1};function ks(e,t,i){return e.modelIndex===i&&t.modelIndex!==i||t.modelIndex===i&&e.modelIndex!==i}function Ms(e,t,i){return!ks(e,t,i)&&(e.modelIndex!==t.modelIndex||e.residueIndex===t.residueIndex||e.altloc&&t.altloc&&e.altloc!==t.altloc)}function Ds(t){const i={types:[],groups:[],centers:{x:[],y:[],z:[]},atomSets:[]};return e.Debug&&Be.time("calculateFeatures"),function(e,t){const{charge:i}=ls(e.data),r={};e.eachResidue((e=>{if(us.includes(e.resname)){const i=Pr(1);e.eachAtom((e=>{7===e.number&&e.isSidechain()&&Ir(i,e)})),kr(t,i)}else Wr.includes(e.resname)||e.isNucleic()||(e.eachAtom((e=>{let i=!1;const s=Pr(1);!function(e){let t=0;return 6===e.number&&3===e.bondCount&&3===e.bondToElementCount(7)&&e.eachBondedAtom((e=>{e.bondCount-e.bondToElementCount(1)==1&&++t})),2===t}(e)?function(e){let t=0;return 6===e.number&&3===e.bondCount&&2===e.bondToElementCount(7)&&1===e.bondToElementCount(6)&&e.eachBondedAtom((e=>{e.bondCount-e.bondToElementCount(1)==1&&++t})),2===t}(e)&&(s.group=9,i=!0):(s.group=8,i=!0),i&&(e.eachBondedAtom((e=>{7===e.number&&(r[e.index]=!0,Ir(s,e))})),kr(t,s))})),e.eachAtom((e=>{const s=Pr(1);i[e.index]>0&&(r[e.index]||(Ir(s,e),kr(t,s)))})))}))}(t,i),function(e,t){const{charge:i}=ls(e.data),r={};e.eachResidue((e=>{if(ds.includes(e.resname)){const i=Pr(2);e.eachAtom((e=>{8===e.number&&e.isSidechain()&&Ir(i,e)})),kr(t,i)}else if(Kr.includes(e.resname)){const i=Pr(2);e.eachAtom((e=>{hs(e)&&(i.group=6,e.eachBondedAtom((e=>{8===e.number&&Ir(i,e)})),kr(t,i))}))}else Wr.includes(e.resname)||Kr.includes(e.resname)||(e.eachAtom((e=>{let i=!1;const s=Pr(2);!function(e){return 16===e.number&&3===e.bondToElementCount(8)}(e)?hs(e)?(s.group=6,i=!0):function(e){return 16===e.number&&4===e.bondToElementCount(8)}(e)?(s.group=5,i=!0):function(e){let t=0;return 6===e.number&&2===e.bondToElementCount(8)&&1===e.bondToElementCount(6)&&e.eachBondedAtom((e=>{8===e.number&&e.bondCount-e.bondToElementCount(1)==1&&++t})),2===t}(e)&&(s.group=10,i=!0):(s.group=4,i=!0),i&&(e.eachBondedAtom((e=>{8===e.number&&(r[e.index]=!0,Ir(s,e))})),kr(t,s))})),e.eachAtom((e=>{const s=Pr(2);i[e.index]<0&&(r[e.index]||(Ir(s,e),kr(t,s)))})))}))}(t,i),function(e,t){const i=e.getAtomProxy();e.eachResidue((e=>{const r=e.getAromaticRings();if(r){const s=e.atomOffset;r.forEach((e=>{const r=Pr(3);e.forEach((e=>{i.index=e+s,Ir(r,i)})),kr(t,r)}))}}))}(t,i),function(e,t){const{charge:i,implicitH:r,idealGeometry:s}=ls(e.data);e.eachAtom((e=>{const n=Pr(5),o=e.number;if(8===o)Ir(n,e),kr(t,n);else if(7===o){if(gs(e))Ir(n,e),kr(t,n);else if(i[e.index]<1){const i=e.bondCount+r[e.index],o=s[e.index];(4===o&&i<4||3===o&&i<3||2===o&&i<2)&&(Ir(n,e),kr(t,n))}}else 16===o&&("CYS"!==e.resname&&"MET"!==e.resname&&-1!==e.formalCharge||(Ir(n,e),kr(t,n)))}))}(t,i),function(e,t){const{totalH:i}=ls(e.data);e.eachAtom((e=>{const r=Pr(4),s=e.number;(gs(e)||i[e.index]>0&&(7===s||8===s||16===s))&&(Ir(r,e),kr(t,r))}))}(t,i),function(e,t){const{totalH:i}=ls(e.data);e.eachAtom((e=>{if(6===e.number&&i[e.index]>0&&(e.bondToElementCount(7)>0||e.bondToElementCount(8)>0||function(e){if(!e.isAromatic())return!1;const t=e.residueType.getRings();if(!t)return!1;let i=!1;return t.rings.forEach((t=>{i||t.some((t=>e.index-e.residueAtomOffset===t))&&(i=t.some((t=>{const i=e.residueType.atomTypeIdList[t],r=e.atomMap.get(i).number;return 7===r||8===r})))})),i}(e))){const i=Pr(9);Ir(i,e),kr(t,i)}}))}(t,i),function(e,t){e.eachAtom((e=>{let i=!1,r=!1;const s=Wr.includes(e.resname),n=Kr.includes(e.resname);if(s||n?s?8===e.number?(["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(e.resname)&&e.isSidechain()||e.isBackbone())&&(i=!0,r=!0):16===e.number&&"CYS"===e.resname?(i=!0,r=!0):7===e.number&&"HIS"===e.resname&&e.isSidechain()&&(i=!0):n&&(8===e.number&&e.isBackbone()?(i=!0,r=!0):["N3","N4","N7"].includes(e.atomname)?i=!0:["O2","O4","O6"].includes(e.atomname)&&(i=!0,r=!0)):e.isHalogen()||8===e.number||16===e.number?(i=!0,r=!0):7===e.number&&(i=!0),i){const i=Pr(11);Ir(i,e),kr(t,i)}if(r){const i=Pr(10);Ir(i,e),kr(t,i)}}))}(t,i),function(e,t){e.eachAtom((e=>{if(e.isTransitionMetal()||30===e.number||48===e.number){const i=Pr(12);Ir(i,e),kr(t,i)}else if(xs.includes(e.number)){const i=Pr(13);Ir(i,e),kr(t,i)}}))}(t,i),function(e,t){e.eachAtom((e=>{const i=Pr(8);let r=!1;6===e.number?(r=!0,e.eachBondedAtom((e=>{const t=e.number;6!==t&&1!==t&&(r=!1)}))):9===e.number&&(r=!0),r&&(Ir(i,e),kr(t,i))}))}(t,i),function(e,t){e.eachAtom((e=>{if(As.includes(e.number)){let i=!1;if(e.eachBondedAtom((e=>{_s.includes(e.number)&&(i=!0)})),i){const i=Pr(7);Ir(i,e),kr(t,i)}}}))}(t,i),function(e,t){e.eachAtom((e=>{if(ws.includes(e.number)&&1===e.bondToElementCount(6)){const i=Pr(6);Ir(i,e),kr(t,i)}}))}(t,i),e.Debug&&Be.timeEnd("calculateFeatures"),i}function Ts(i,r=Is){const s=function(e){const{types:t,centers:i}=e;return{features:e,spatialHash:new vr(i),contactStore:new Ar,featureSet:new Sr(t.length,!1)}}(Ds(i));e.Debug&&Be.time("calculateContacts"),function(e,i,r={}){const s=l(r.maxIonicDist,Is.maxIonicDist),n=l(r.maxPiStackingDist,Is.maxPiStackingDist),o=l(r.maxPiStackingOffset,Is.maxPiStackingOffset),a=l(r.maxPiStackingAngle,Is.maxPiStackingAngle),c=l(r.maxCationPiDist,Is.maxCationPiDist),h=l(r.maxCationPiOffset,Is.maxCationPiOffset),u=l(r.masterModelIndex,Is.masterModelIndex),d=Math.max(s+2,n,c),m=n*n,p=c*c,{features:f,spatialHash:g,contactStore:y,featureSet:b}=i,{types:x,centers:v,atomSets:w}=f,{x:A,y:_,z:S}=v,C=x.length,P=e.atomStore.x,I=e.atomStore.y,k=e.atomStore.z,M=e.getAtomProxy(),D=e.getAtomProxy(),T=function(e,t,i){const r=e.length,s=t.length;for(let n=0;n{if(t<=e)return;if(M.index=w[e][0],D.index=w[t][0],Ms(M,D,u))return;const r=x[e],n=x[t];if(ms(r,n))T(w[e],w[t],s)&&V(e,t,1);else if(ps(r,n)){if(i<=m){N(w[e],E),N(w[t],L);const i=57.29578*E.angleTo(L);Math.min(z(e,t,L),z(t,e,E))<=o&&(i<=a||i>=180-a||i<=a+90&&i>=90-a)&&V(e,t,3)}}else if(fs(r,n)&&i<=p){const[i,s]=3===r?[e,t]:[t,e];N(w[i],E),z(s,i,E)<=h&&V(i,s,2)}}))}(i,s,r),function(e,t,i={}){const r=l(i.maxHbondDist,Is.maxHbondDist),s=l(i.maxHbondSulfurDist,Is.maxHbondSulfurDist),n=T(l(i.maxHbondAccAngle,Is.maxHbondAccAngle)),o=T(l(i.maxHbondDonAngle,Is.maxHbondDonAngle)),a=T(l(i.maxHbondAccPlaneAngle,Is.maxHbondAccPlaneAngle)),c=T(l(i.maxHbondDonPlaneAngle,Is.maxHbondDonPlaneAngle)),h=l(i.masterModelIndex,Is.masterModelIndex),u=Math.max(r,s),d=r*r,{features:m,spatialHash:p,contactStore:f,featureSet:g}=t,{types:y,centers:b,atomSets:x}=m,{x:v,y:w,z:A}=b,_=y.length,{idealGeometry:S}=ls(e.data),C=e.getAtomProxy(),P=e.getAtomProxy();for(let e=0;e<_;++e)p.eachWithin(v[e],w[e],A[e],u,((t,i)=>{if(t<=e)return;const r=y[e],s=y[t],l=bs(r,s);if(!l&&!ys(r,s))return;const[u,m]=5===s?[e,t]:[t,e];if(C.index=x[u][0],P.index=x[m][0],P.index===C.index)return;if(Ms(C,P,h))return;if(16!==C.number&&16!==P.number&&i>d)return;if(C.connectedTo(P))return;const p=os(C,P),b=ns.get(S[C.index])||T(120);if(p.some((e=>Math.abs(b-e)>o)))return;if(3===S[C.index]){const e=as(C,P);if(void 0!==e&&e>c)return}const v=os(P,C),w=ns.get(S[P.index])||T(120);if(v.some((e=>w-e>n)))return;if(3===S[P.index]){const e=as(P,C);if(void 0!==e&&e>a)return}g.setBits(u,m);const A=l?8:function(e,t){return e.isWater()&&t.isWater()}(_=C,I=P)?9:function(e,t){return e.isBackbone()&&t.isBackbone()}(_,I)?10:4;var _,I;f.addContact(u,m,A)}))}(i,s,r),function(e,t,i={}){const r=l(i.maxMetalDist,Is.maxMetalDist),s=l(i.masterModelIndex,Is.masterModelIndex),{features:n,spatialHash:o,contactStore:a,featureSet:c}=t,{types:h,centers:u,atomSets:d}=n,{x:m,y:p,z:f}=u,g=h.length,y=e.getAtomProxy(),b=e.getAtomProxy();for(let e=0;e{if(t<=e)return;if(y.index=d[e][0],b.index=d[t][0],Ms(y,b,s))return;const r=y.isMetal(),n=b.isMetal();if(!r&&!n)return;const[o,l]=r?[h[e],h[t]]:[h[t],h[e]];vs(o,l)&&(c.setBits(e,t),a.addContact(e,t,7))}))}(i,s,r),function(e,t,i={}){const r=l(i.maxHydrophobicDist,Is.maxHydrophobicDist),s=l(i.masterModelIndex,Is.masterModelIndex),{features:n,spatialHash:o,contactStore:a,featureSet:c}=t,{types:h,centers:u,atomSets:d}=n,{x:m,y:p,z:f}=u,g=h.length,y=e.getAtomProxy(),b=e.getAtomProxy();for(let e=0;e{var r,n;t<=e||(y.index=d[e][0],b.index=d[t][0],Ms(y,b,s)||9===y.number&&9===b.number||y.connectedTo(b)||(r=h[e],n=h[t],8===r&&8===n&&(c.setBits(e,t),a.addContact(e,t,6))))}))}(i,s,r),function(e,t,i={}){const r=l(i.maxHalogenBondDist,Is.maxHalogenBondDist),s=T(l(i.maxHalogenBondAngle,Is.maxHalogenBondAngle)),n=l(i.masterModelIndex,Is.masterModelIndex),{features:o,spatialHash:a,contactStore:c,featureSet:h}=t,{types:u,centers:d,atomSets:m}=o,{x:p,y:f,z:g}=d,y=u.length,b=e.getAtomProxy(),x=e.getAtomProxy();for(let e=0;e{if(t<=e)return;if(b.index=m[e][0],x.index=m[t][0],Ms(b,x,n))return;if(r=u[e],o=u[t],!(7===r&&6===o||6===r&&7===o))return;var r,o;const[a,l]=6===u[e]?[b,x]:[x,b],d=os(a,l);if(1!==d.length)return;if(Ss-d[0]>s)return;const p=os(l,a);0!==p.length&&(p.some((e=>Cs-e>s))||(h.setBits(e,t),c.addContact(e,t,5)))}))}(i,s,r);const n=function(e){const{index1:t,index2:i,count:r}=e.contactStore,s=Cr({nodeArray1:t,nodeArray2:i,edgeCount:r,nodeCount:e.featureSet.length}),n=new Sr(e.contactStore.count,!0);return Object.assign({adjacencyList:s,contactSet:n},e)}(s);return function(i,r,s={}){e.Debug&&Be.time("refineLineOfSight");const n=l(s.lineOfSightDistFactor,Is.lineOfSightDistFactor),o=l(s.masterModelIndex,Is.masterModelIndex),a=i.spatialHash,{contactSet:c,contactStore:h,features:u}=r,{index1:d,index2:m}=h,{centers:p,atomSets:f}=u,{x:g,y:y,z:b}=p,x=i.getAtomProxy(),v=i.getAtomProxy(),w=i.getAtomProxy(),A=new t.Vector3,_=new t.Vector3,S=3*n,C=n*n;c.forEach((t=>{A.set(g[d[t]],y[d[t]],b[d[t]]),_.set(g[m[t]],y[m[t]],b[m[t]]);const i=(A.x+_.x)/2,r=(A.y+_.y)/2,s=(A.z+_.z)/2,n=f[d[t]],l=f[m[t]];x.index=n[0],v.index=l[0],a.eachWithin(i,r,s,S,((i,r)=>{w.index=i,1!==w.number&&w.vdw*w.vdw*C>r&&!Ps(x,w,o)&&!Ps(v,w,o)&&!n.includes(i)&&!l.includes(i)&&A.distanceToSquared(w)>1&&_.distanceToSquared(w)>1&&(c.clear(t),e.Debug&&Be.log("removing",x.qualifiedName(),v.qualifiedName(),"because",w.qualifiedName()))}))})),e.Debug&&Be.timeEnd("refineLineOfSight")}(i,n,r),function(e,t){const{contactSet:i,contactStore:r,features:s}=t,{type:n,index1:o,index2:a}=r,{atomSets:c}=s,l=e.getAtomProxy(),h=e.getAtomProxy(),u={},d=function(e,t,r){const[s,n]=u[r]||[1/0,-1];e{if(6!==n[e])return;l.index=c[o[e]][0],h.index=c[a[e]][0];const t=l.distanceTo(h);d(t,e,`${l.index}|${h.residueIndex}`),d(t,e,`${h.index}|${l.residueIndex}`)}))}(i,n),r.refineSaltBridges&&function(e,t){const{contactSet:i,contactStore:r,features:s}=t,{type:n,index1:o,index2:a}=r,{atomSets:c}=s,l={},h=function(e,t){l[e]||(l[e]=[]),l[e].push(t)};i.forEach((e=>{1===n[e]&&(c[o[e]].forEach((t=>h(t,e))),c[a[e]].forEach((t=>h(t,e))))})),i.forEach((e=>{if(!function(e){return 4===e||9===e||10===e}(n[e]))return;const t=l[c[o[e]][0]],r=l[c[a[e]][0]];if(!t||!r)return;const s=t.length;for(let n=0;n{3===n[e]&&(c[o[e]].forEach((t=>h(t,e))),c[a[e]].forEach((t=>h(t,e))))})),i.forEach((e=>{if(6!==n[e]&&2!==n[e])return;const t=l[c[o[e]][0]],r=l[c[a[e]][0]];if(!t||!r)return;const s=t.length;for(let n=0;n{1===n[e]&&(c[o[e]].forEach((t=>h(t,e))),c[a[e]].forEach((t=>h(t,e))))})),i.forEach((e=>{if(7!==n[e])return;const t=l[c[o[e]][0]],r=l[c[a[e]][0]];if(!t||!r)return;const s=t.length;for(let e=0;et.getAtomSet(new ye(e)))):t.getAtomSet(new ye(r.filterSele))),o.forEach((e=>{const t=g[e];if(!s.includes(t))return;if(A){const t=l[p[e]][0],i=l[f[e]][0];if(Array.isArray(A)){if(!(A[0].isSet(t)&&A[1].isSet(i)||A[1].isSet(t)&&A[0].isSet(i)))return}else if(!A.isSet(t)&&!A.isSet(i))return}const i=p[e],n=f[e];y.push(u[i],d[i],m[i]),b.push(u[n],d[n],m[n]),x.push(...function(e){switch(e){case 4:case 9:case 10:return Os.setHex(2851770).toArray();case 6:return Os.setHex(8421504).toArray();case 5:return Os.setHex(4259775).toArray();case 1:return Os.setHex(15779860).toArray();case 7:return Os.setHex(9191577).toArray();case 2:return Os.setHex(16744448).toArray();case 3:return Os.setHex(9220966).toArray();case 8:return Os.setHex(12967404).toArray();default:return Os.setHex(13421772).toArray()}}(t)),v.push(r.radius),w.push(e)})),{position1:new Float32Array(y),position2:new Float32Array(b),color:new Float32Array(x),color2:new Float32Array(x),radius:new Float32Array(v),picking:new Vs(w,e,t)}}class Fs{constructor(e){this.array=e}get type(){return""}get data(){return{}}getIndex(e){return this.array?this.array[e]:e}getObject(e){return{}}_applyTransformations(e,t,i){return t&&e.applyMatrix4(t.matrix),i&&e.applyMatrix4(i.matrix),e}_getPosition(e){return new t.Vector3}getPosition(e,t,i){return this._applyTransformations(this._getPosition(e),t,i)}}class Es extends Fs{constructor(e){super(),this.shape=e}get primitive(){}get data(){return this.shape}get type(){return this.primitive.type}getObject(e){return this.primitive.objectFromShape(this.shape,this.getIndex(e))}_getPosition(e){return this.primitive.positionFromShape(this.shape,this.getIndex(e))}}class Ls extends Fs{constructor(e,t){super(e),this.structure=t}get type(){return"atom"}get data(){return this.structure}getObject(e){return this.structure.getAtomProxy(this.getIndex(e))}_getPosition(e){return(new t.Vector3).copy(this.getObject(e))}}class Ns extends Fs{constructor(e){super(),this.axes=e}get type(){return"axes"}get data(){return this.axes}getObject(){return{axes:this.axes}}_getPosition(){return this.axes.center.clone()}}class zs extends Fs{constructor(e,t,i){super(e),this.structure=t,this.bondStore=i||t.bondStore}get type(){return"bond"}get data(){return this.structure}getObject(e){const t=this.structure.getBondProxy(this.getIndex(e));return t.bondStore=this.bondStore,t}_getPosition(e){const i=this.getObject(e);return(new t.Vector3).copy(i.atom1).add(i.atom2).multiplyScalar(.5)}}class Vs extends Fs{constructor(e,t,i){super(e),this.contacts=t,this.structure=i}get type(){return"contact"}get data(){return this.contacts}getObject(e){const i=this.getIndex(e),{features:r,contactStore:s}=this.contacts,{centers:n,atomSets:o}=r,{x:a,y:c,z:l}=n,{index1:h,index2:u,type:d}=s,m=h[i],p=u[i];return{center1:new t.Vector3(a[m],c[m],l[m]),center2:new t.Vector3(a[p],c[p],l[p]),atom1:this.structure.getAtomProxy(o[m][0]),atom2:this.structure.getAtomProxy(o[p][0]),type:Bs(d[i])}}_getPosition(e){const{center1:i,center2:r}=this.getObject(e);return(new t.Vector3).addVectors(i,r).multiplyScalar(.5)}}class Gs extends Fs{constructor(e,t,i){super(e),this.validation=t,this.structure=i}get type(){return"clash"}get data(){return this.validation}getObject(e){const t=this.validation,i=this.getIndex(e);return{validation:t,index:i,clash:t.clashArray[i]}}_getAtomProxyFromSele(e){const t=new ye(e),i=this.structure.getAtomIndices(t)[0];return this.structure.getAtomProxy(i)}_getPosition(e){const i=this.getObject(e).clash,r=this._getAtomProxyFromSele(i.sele1),s=this._getAtomProxyFromSele(i.sele2);return(new t.Vector3).copy(r).add(s).multiplyScalar(.5)}}class Us extends zs{get type(){return"distance"}}class js extends Fs{get type(){return"ignore"}}class Hs extends Es{constructor(e,t){super(e),this.mesh=t}get type(){return"mesh"}getObject(){const e=this.mesh;return{shape:this.shape,name:e.name,serial:e.serial}}_getPosition(){return this.__position||(this.__position=Ri(this.mesh.position)),this.__position}}class Ws extends Fs{constructor(e,t){super(e),this.surface=t}get type(){return"surface"}get data(){return this.surface}getObject(e){return{surface:this.surface,index:this.getIndex(e)}}_getPosition(){return this.surface.center.clone()}}class qs extends Fs{constructor(e,t){super(),this.unitcell=e,this.structure=t}get type(){return"unitcell"}get data(){return this.unitcell}getObject(){return{unitcell:this.unitcell,structure:this.structure}}_getPosition(){return this.unitcell.getCenter(this.structure)}}class Xs extends Fs{constructor(e,t){super(e),this.volume=t}get type(){return"volume"}get data(){return this.volume}getObject(e){const t=this.volume,i=this.getIndex(e);return{volume:t,index:i,value:t.data[i]}}_getPosition(e){const i=this.volume.position,r=this.getIndex(e);return new t.Vector3(i[3*r],i[3*r+1],i[3*r+2])}}class Ys extends Xs{get type(){return"slice"}}function Ks(){return new Uint32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0])}function Zs(){return new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1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8,2,2,0,0],[0,8,0,0,8,0,8,8,0,8,8,0],[0,0,8,0,8,8,0,8,0,0,8,8],[0,0,0,1,8,8,8,0,1,0,0,1],[2,0,0,1,2,0,0,1,0,2,0,1],[2,8,0,0,2,8,0,0,2,0,8,0],[0,8,8,0,0,8,8,0,0,8,0,8],[0,0,8,1,0,0,8,1,1,0,8,0]],m=0,p=!1,f=!1,g=!1,y=!1,b=-1,x=t*i*r,v=t,w=t*i,_=new Int32Array(12),S=[],C=[],P=[],I=[],k=Ks(),M=Zs();function D(e,t,i){return e+(t-e)*i}function T(e,s,n){return w*(n=(n+u)%r)+v*(s=(s+h)%i)+(e=(e+l)%t)}function B(e,t,i,r,c,l,h){var u=3*e;if(o[u]<0){var d=(m-l)/(h-l),f=n,g=3*a;if(S[g]=i+d,S[g+1]=r,S[g+2]=c,!p){var y=3*e;C[g]=b*D(f[y],f[y+3],d),C[g+1]=b*D(f[y+1],f[y+4],d),C[g+2]=b*D(f[y+2],f[y+5],d)}s&&(I[a]=s[e+Math.round(d)]),o[u]=a,_[t]=a,a+=1}else _[t]=o[u]}function R(e,t,i,r,c,l,h){var u=3*e+1;if(o[u]<0){var d=(m-l)/(h-l),f=n,g=3*a;if(S[g]=i,S[g+1]=r+d,S[g+2]=c,!p){var y=3*e,x=y+3*v;C[g]=b*D(f[y],f[x],d),C[g+1]=b*D(f[y+1],f[x+1],d),C[g+2]=b*D(f[y+2],f[x+2],d)}s&&(I[a]=s[e+Math.round(d)*v]),o[u]=a,_[t]=a,a+=1}else _[t]=o[u]}function O(e,t,i,r,c,l,h){var u=3*e+2;if(o[u]<0){var d=(m-l)/(h-l),f=n,g=3*a;if(S[g]=i,S[g+1]=r,S[g+2]=c+d,!p){var y=3*e,x=y+3*w;C[g]=b*D(f[y],f[x],d),C[g+1]=b*D(f[y+1],f[x+1],d),C[g+2]=b*D(f[y+2],f[x+2],d)}s&&(I[a]=s[e+Math.round(d)*w]),o[u]=a,_[t]=a,a+=1}else _[t]=o[u]}function $(t){var i=3*t;0===n[i]&&(n[i]=e[(t-1+x)%x]-e[(t+1)%x],n[i+1]=e[(t-v+x)%x]-e[(t+v)%x],n[i+2]=e[(t-w+x)%x]-e[(t+w)%x])}function F(t,i,r,s,n){var o,a,l,h,u,b,x;g?(s=T(t,i,r),o=T(t+1,i,r),a=T(t,i+1,r),l=T(t,i,r+1),h=T(t+1,i+1,r),u=T(t+1,i,r+1),b=T(t,i+1,r+1),x=T(t+1,i+1,r+1)):(o=s+1,h=(a=s+v)+1,u=(l=s+w)+1,x=(b=a+w)+1);var A=0,S=e[s],C=e[o],I=e[a],D=e[h],F=e[l],E=e[u],L=e[b],N=e[x];S=m){R=b,M=!0;break}if(M)break}if(M)break}for(M=!1,y=n;y=m){B=y,M=!0;break}if(M)break}if(M)break}for(M=!1,f=s;f=m){D=f,M=!0;break}if(M)break}if(M)break}for(M=!1,b=h;b>=a;--b){for(y=l;y>=n;--y){for(f=c;f>=s;--f)if(u=t*i*b+t*y+f,e[u]>=m){E=b,M=!0;break}if(M)break}if(M)break}for(M=!1,y=l;y>=n;--y){for(b=E;b>=a;--b){for(f=c;f>=s;--f)if(u=t*i*b+t*y+f,e[u]>=m){$=y,M=!0;break}if(M)break}if(M)break}for(M=!1,f=c;f>=s;--f){for(y=$;y>=n;--y){for(b=E;b>=a;--b)if(u=t*i*b+t*y+f,e[u]>=m){O=f,M=!0;break}if(M)break}if(M)break}p?(s=Math.max(0,D-1),n=Math.max(0,B-1),a=Math.max(0,R-1),c=Math.min(t-1,O+1),l=Math.min(i-1,$+1),h=Math.min(r-1,E+1)):(s=Math.max(1,D-1),n=Math.max(1,B-1),a=Math.max(1,R-1),c=Math.min(t-2,O+1),l=Math.min(i-2,$+1),h=Math.min(r-2,E+1))}var L=15;for(b=a;b0?-1:1,n||(n=new Float32Array(3*x)));var k=3*x;if(o&&o.length===k||(o=new Int32Array(k)),a=0,c=0,void 0!==v){var M=v[0].map(Math.round),D=v[1].map(Math.round);l=t*Math.ceil(Math.abs(M[0])/t),h=i*Math.ceil(Math.abs(M[1])/i),u=r*Math.ceil(Math.abs(M[2])/r),E(M[0],M[1],M[2],D[0],D[1],D[2])}else l=h=u=0,E();return S.length=3*a,p||(C.length=3*a),P.length=c,s&&(I.length=a),{position:new Float32Array(S),normal:p?void 0:new Float32Array(C),index:A(P,S.length/3),atomindex:s?new Int32Array(I):void 0,contour:f}}}He.add("arrow",class extends Es{get primitive(){return mr}}),He.add("box",class extends Es{get primitive(){return lr}}),He.add("cone",class extends Es{get primitive(){return pr}}),He.add("cylinder",class extends Es{get primitive(){return dr}}),He.add("ellipsoid",class extends Es{get primitive(){return fr}}),He.add("octahedron",class extends Es{get primitive(){return hr}}),He.add("sphere",class extends Es{get primitive(){return cr}}),He.add("tetrahedron",class extends Es{get primitive(){return ur}}),He.add("torus",class extends Es{get primitive(){return gr}}),He.add("point",class extends Es{get primitive(){return br}}),He.add("wideline",class extends Es{get primitive(){return xr}}),Object.assign(Qs,{__deps:[Ks,Zs,A]});class Js{constructor(e,t){this.cols=e,this.rows=t,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}copyTo(e){e.data.set(this.data)}}function en(e,t){let i=0,r=0;const s=t.rows,n=t.cols;let o=0,a=0,c=0;const l=t.data,h=e.data;for(;i(t=Math.abs(t))?(t/=e,e*Math.sqrt(1+t*t)):t>0?(e/=t,t*Math.sqrt(1+e*e)):0}const cn=1.192092896e-7,ln=1e-37;function hn(e,t,i,r){let s=0,n=0;const o=e.rows,a=e.cols;let c=o,l=a;c>16)?O:-O,e[h*t+d]=R;for(m=0;m<2;m++)for(u=0;u{const t=e.data.sd,i=e.data.p;o(this._makeSurface(t,i.isolevel,i.smooth))}),(a=>{console.warn("Volume.getSurfaceWorker error - trying without worker",a);const c=this.getSurface(e,t,i,r,s,n);o(c)}))}else{const a=this.getSurface(e,t,i,r,s,n);o(a)}}getValueForSigma(e){return this.mean+l(e,2)*this.rms}getSigmaForValue(e){return(l(e,0)-this.mean)/this.rms}get position(){if(!this._position){const e=this.nz,t=this.ny,i=this.nx,r=new Float32Array(i*t*e*3);let s=0;for(let n=0;ni){const e=t;t=i,i=e}const r=e[t];return void 0===r?(e[t]=[i],!0):!r.includes(i)&&(r.push(i),!0)}const i=this.geometry,r=i.index;if(this.parameters.wireframe)if(r){const s=r.array;let n,o=s.length;if(i.drawRange.count!==1/0&&(o=i.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*o)n=this.wireframeIndex;else{n=A(2*o,i.attributes.position.count)}let a=0;e.length=0;for(let e=0;e2*e?this.wireframeIndex:A(2*e,e);for(let i=0,r=0;ithis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new t.BufferAttribute(this.wireframeIndex,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0));else{const e=this.wireframeGeometry.getIndex();if(!e)return void Be.error("Index is null");e.set(this.wireframeIndex),e.needsUpdate=this.wireframeIndexCount>0,e.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}}getRenderOrder(){let e=0;return this.isText?e=1:this.transparent&&(e=this.isSurface?3:2),e}_getMesh(e){this.material||this.makeMaterial();const i=this.geometry,r=this[e];let s;return s=this.isLine?new t.LineSegments(i,r):this.isPoint?new t.Points(i,r):new t.Mesh(i,r),s.frustumCulled=!1,s.renderOrder=this.getRenderOrder(),s}getMesh(){return this._getMesh("material")}getWireframeMesh(){let e;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),e=new t.LineSegments(this.wireframeGeometry,this.wireframeMaterial),e.frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e}getPickingMesh(){return this._getMesh("pickingMaterial")}getShader(e,t){return lt(e,this.getDefines(t))}getVertexShader(e){return this.getShader(this.vertexShader,e)}getFragmentShader(e){return this.getShader(this.fragmentShader,e)}getDefines(e){const t={};return this.parameters.clipNear&&(t.NEAR_CLIP=1),this.parameters.clipRadius&&(t.RADIUS_CLIP=1),"picking"===e?t.PICKING=1:(("background"===e||this.parameters.background)&&(t.NOLIGHT=1),this.parameters.flatShaded&&(t.FLAT_SHADED=1),this.parameters.opaqueBack&&(t.OPAQUE_BACK=1),this.parameters.diffuseInterior&&(t.DIFFUSE_INTERIOR=1),this.parameters.useInteriorColor&&(t.USE_INTERIOR_COLOR=1)),t}getParameters(){return this.parameters}addUniforms(e){this.uniforms=t.UniformsUtils.merge([this.uniforms,e]),this.pickingUniforms=t.UniformsUtils.merge([this.pickingUniforms,e])}addAttributes(e){for(let i in e){let r;const s=e[i],n=this.attributeSize*In[s.type];s.value?(n!==s.value.length&&Be.error("attribute value has wrong length",i),r=s.value):r=w("float32",n),this.geometry.setAttribute(i,new t.BufferAttribute(r,In[s.type]).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0))}}updateRenderOrder(){const e=this.getRenderOrder();function t(t){t.renderOrder=e}this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)}updateShader(){const e=this.material,t=this.wireframeMaterial,i=this.pickingMaterial;e.vertexShader=this.getVertexShader(),e.fragmentShader=this.getFragmentShader(),e.needsUpdate=!0,t.vertexShader=this.getShader("Line.vert"),t.fragmentShader=this.getShader("Line.frag"),t.needsUpdate=!0,i.vertexShader=this.getVertexShader("picking"),i.fragmentShader=this.getFragmentShader("picking"),i.needsUpdate=!0}setParameters(e){const t=e,i=this.parameterTypes,r=this.parameters,s={},n={};let o=!1,a=!1;for(const e in t){const c=t[e];void 0!==c&&(r[e]=c,void 0!==i[e]&&(i[e].property&&(!0!==i[e].property?s[i[e].property]=c:s[e]=c),i[e].uniform&&(!0!==i[e].uniform?n[i[e].uniform]=c:n[e]=c),i[e].updateShader&&(o=!0),i[e].updateVisibility&&(a=!0),this.dynamic&&"wireframe"===e&&!0===c&&this.updateWireframeIndex(),"forceTransparent"===e&&(s.transparent=this.transparent),"matrix"===e&&(this.matrix=c)))}this.setProperties(s),this.setUniforms(n),o&&this.updateShader(),a&&this.setVisibility(this.visible)}setAttributes(e){const i=this.geometry,r=i.attributes;for(const s in e){if("picking"===s)continue;const n=e[s],o=n.length;if("index"===s){const e=i.getIndex();if(!e){Be.error("Index is null");continue}i.setDrawRange(0,1/0),o>e.array.length?i.setIndex(new t.BufferAttribute(n,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(e.set(n),e.count=o,e.needsUpdate=o>0,e.updateRange.count=o,i.setDrawRange(0,o)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{const e=r[s];o>e.array.length?i.setAttribute(s,new t.BufferAttribute(n,e.itemSize).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(r[s].set(n),r[s].needsUpdate=o>0,r[s].updateRange.count=o)}}}setUniforms(e){if(!e)return;const t=this.material.uniforms,i=this.wireframeMaterial.uniforms,r=this.pickingMaterial.uniforms;for(let s in e)"opacity"===s&&this.setProperties({transparent:this.transparent}),void 0!==t[s]&&(t[s].value.isVector3?t[s].value.copy(e[s]):t[s].value.set?t[s].value.set(e[s]):t[s].value=e[s]),void 0!==i[s]&&(i[s].value.isVector3?i[s].value.copy(e[s]):i[s].value.set?i[s].value.set(e[s]):i[s].value=e[s]),void 0!==r[s]&&(r[s].value.isVector3?r[s].value.copy(e[s]):r[s].value.set?r[s].value.set(e[s]):r[s].value=e[s])}setProperties(e){if(!e)return;const t=this.material,i=this.wireframeMaterial,r=this.pickingMaterial;for(const s in e){const n=s;let o=e[n];"transparent"===n?this.updateRenderOrder():"side"===n&&(o=Pn(o)),t[n]=o,i[n]=o,r[n]=o}t.needsUpdate=!0,i.needsUpdate=!0,r.needsUpdate=!0}setVisibility(e){this.visible=e,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=e,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=e,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=e))}dispose(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()}toJSON(){var e={};for(var t in this)"group"!==t&&"wireframeGroup"!==t&&"pickingGroup"!=t&&"picking"!==t&&(e[t]=this[t]);return e}}class Bn extends Tn{constructor(e,t={}){super(e,t),this.vertexShader="Mesh.vert",this.fragmentShader="Mesh.frag",this.addAttributes({normal:{type:"v3",value:e.normal}}),void 0===e.normal&&this.geometry.computeVertexNormals()}}class Rn extends Bn{constructor(){super(...arguments),this.isSurface=!0}}function On(e){e.visible=!0}function $n(e){e.visible=!1}class Fn{constructor(e){this.group=new t.Group,this.wireframeGroup=new t.Group,this.pickingGroup=new t.Group,this.frontMeshes=[],this.backMeshes=[],this.size=e.size,this.side=e.parameters.side,this.visible=e.visible,this.geometry=e.geometry,this.picking=e.picking,this.group=new t.Group,this.wireframeGroup=new t.Group,this.pickingGroup=new t.Group,this.matrix=e.matrix;const i=e,r=new e.constructor({position:new Float32Array(0)});i.makeMaterial(),r.makeMaterial(),r.picking=e.picking,r.geometry=e.geometry,r.wireframeGeometry=e.wireframeGeometry,r.setParameters(e.getParameters()),r.updateShader(),i.setParameters({side:"front"}),r.setParameters({side:"back",opacity:r.parameters.opacity}),this.buffer=e,this.frontBuffer=i,this.backBuffer=r}set matrix(e){Tn.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking&&!this.parameters.disablePicking}get parameters(){return this.buffer.parameters}getParameters(){const e=Object.assign({},this.buffer.parameters);return e.side=this.side,e}getMesh(e){let i,r;return e?(r=this.backBuffer.getPickingMesh(),i=this.frontBuffer.getPickingMesh()):(r=this.backBuffer.getMesh(),i=this.frontBuffer.getMesh()),this.frontMeshes.push(i),this.backMeshes.push(r),this.setParameters({side:this.side}),(new t.Group).add(r,i)}getWireframeMesh(){return this.buffer.getWireframeMesh()}getPickingMesh(){return this.getMesh(!0)}setAttributes(e){this.buffer.setAttributes(e)}setParameters(e){"front"===(e=Object.assign({},e)).side?(this.frontMeshes.forEach(On),this.backMeshes.forEach($n)):"back"===e.side?(this.frontMeshes.forEach($n),this.backMeshes.forEach(On)):"double"===e.side&&(this.frontMeshes.forEach(On),this.backMeshes.forEach(On)),void 0!==e.side&&(this.side=e.side),delete e.side,void 0!==e.matrix&&(this.matrix=e.matrix),delete e.matrix,this.frontBuffer.setParameters(e),void 0!==e.wireframe&&(this.wireframe=e.wireframe,this.setVisibility(this.visible)),delete e.wireframe,this.backBuffer.setParameters(e)}setVisibility(e){this.visible=e,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=e,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=e,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=e))}dispose(){this.frontBuffer.dispose(),this.backBuffer.dispose()}toJSON(){var e={};for(var t in this)["side","size","visible","matrix","parameters"].includes(t)&&(e[t]=this[t]);return e}}Ve.add("shader/Line.vert","uniform float clipNear;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/Line.frag","uniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");class En extends Tn{constructor(){super(...arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}}class Ln extends Di{constructor(e,i,r){super(e,i,r),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},isolevelScroll:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),e instanceof Cn?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new t.Vector3,this.__boxCenter=new t.Vector3,this.box=new t.Box3,this.__box=new t.Box3,this._position=new t.Vector3,this.inverseMatrix=new t.Matrix4,this.setBox=function(){this._position.copy(i.translationGroup.position).negate(),this._position.applyMatrix4(this.inverseMatrix),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(r)}init(e){const t=e||{};t.colorScheme=l(t.colorScheme,"uniform"),t.colorValue=l(t.colorValue,14540253),this.isolevelType=l(t.isolevelType,"sigma"),this.isolevel=l(t.isolevel,2),this.negateIsolevel=l(t.negateIsolevel,!1),this.isolevelScroll=l(t.isolevelScroll,!1),this.smooth=l(t.smooth,0),this.background=l(t.background,!1),this.opaqueBack=l(t.opaqueBack,!0),this.boxSize=l(t.boxSize,0),this.colorVolume=l(t.colorVolume,void 0),this.contour=l(t.contour,!1),this.useWorker=l(t.useWorker,!0),this.wrap=l(t.wrap,!1),super.init(t),this.inverseMatrix.getInverse(this.matrix),this.build()}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e)})),this.setVisibility(this.visible),e()}prepare(e){if(this.volume){let t;if(t="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(t*=-1),!this.surface||this.__isolevel!==t||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=t,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);const i=t=>{this.surface=t,e()};this.useWorker?this.volume.getSurfaceWorker(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else e()}else e()}create(){const e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};let t;if(this.contour)t=new En(e,this.getBufferParams({wireframe:!1}));else{Object.assign(e,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});const i=new Rn(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new Fn(i)}this.bufferList.push(t)}update(e){if(0===this.bufferList.length)return;const t={};(e=e||{}).position&&(t.position=this.surface.getPosition()),e.color&&(t.color=this.surface.getColor(this.getColorParams())),e.index&&(t.index=this.surface.getIndex()),e.normal&&(t.normal=this.surface.getNormal()),this.bufferList.forEach((function(e){e.setAttributes(t)}))}setParameters(e,t,i){return e&&void 0!==e.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===e.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===e.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=e.isolevelType),e&&e.boxCenter&&(this.boxCenter.copy(e.boxCenter),delete e.boxCenter),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),e.matrix&&this.inverseMatrix.getInverse(e.matrix),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&void 0!==e.colorVolume&&t&&(t.color=!0),this.surface&&(void 0!==e.isolevel||void 0!==e.negateIsolevel||void 0!==e.smooth||void 0!==e.wrap||void 0!==e.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this}getColorParams(){const e=super.getColorParams();return e.volume=this.colorVolume,e}dispose(){this.viewer.signals.ticked.remove(this.setBox,this),super.dispose()}}class Nn{static zoomScroll(e,t){e.trackballControls.zoom(t)}static clipNearScroll(e,t){const i=e.getParameters();e.setParameters({clipNear:i.clipNear+t/10})}static focusScroll(e,t){const i=e.getFocus(),r=Math.sign(t)*function(e,t,i){if(e>t)return e;const r=e/t;return((2*i-t)*r+(2*t-3*i))*r*r+i}((100-i)/10,5,.2);e.setFocus(i+r)}static zoomFocusScroll(e,t){e.trackballControls.zoom(t);const i=e.viewer.camera.position.z;e.setFocus(100-Math.abs(i/8))}static isolevelScroll(e,t){const i=Math.sign(t)/10;e.eachRepresentation(((e,t)=>{if(e.repr instanceof Ln){const t=e.getParameters();t.isolevelScroll&&e.setParameters({isolevel:t.isolevel+i})}}))}static panDrag(e,t,i){e.trackballControls.pan(t,i)}static rotateDrag(e,t,i){e.trackballControls.rotate(t,i)}static zRotateDrag(e,t,i){e.trackballControls.zRotate(t,i)}static zoomDrag(e,t,i){e.trackballControls.zoom((t+i)/-2)}static zoomFocusDrag(e,t,i){e.trackballControls.zoom((t+i)/-2);const r=e.viewer.camera.position.z;e.setFocus(100-Math.abs(r/8))}static panComponentDrag(e,t,i){e.trackballControls.panComponent(t,i)}static panAtomDrag(e,t,i){e.trackballControls.panAtom(t,i)}static rotateComponentDrag(e,t,i){e.trackballControls.rotateComponent(t,i)}static movePick(e,t){t&&e.animationControls.move(t.position.clone())}static tooltipPick(e,t){const i=e.tooltip;if(e.getParameters().tooltip&&t){const e=t.mouse.position;i.innerText=t.getLabel(),i.style.bottom=window.innerHeight-e.y+3+"px",i.style.left=e.x+3+"px",i.style.display="block"}else i.style.display="none"}static measurePick(e,t){if(t&&(t.atom||t.bond)){const e=t.atom||t.closestBondAtom;t.component.measurePick(e)}else e.measureClear()}}const zn={default:[["scroll",Nn.zoomScroll],["scroll-shift",Nn.focusScroll],["scroll-ctrl",Nn.isolevelScroll],["scroll-shift-ctrl",Nn.zoomFocusScroll],["drag-left",Nn.rotateDrag],["drag-right",Nn.panDrag],["drag-ctrl-left",Nn.panDrag],["drag-ctrl-right",Nn.zRotateDrag],["drag-shift-left",Nn.zoomDrag],["drag-middle",Nn.zoomFocusDrag],["drag-ctrl-shift-right",Nn.panComponentDrag],["drag-ctrl-shift-left",Nn.rotateComponentDrag],["clickPick-right",Nn.measurePick],["clickPick-ctrl-left",Nn.measurePick],["clickPick-middle",Nn.movePick],["clickPick-left",Nn.movePick],["hoverPick",Nn.tooltipPick]],pymol:[["drag-left",Nn.rotateDrag],["drag-middle",Nn.panDrag],["drag-right",Nn.zoomDrag],["scroll",Nn.focusScroll],["drag-shift-right",Nn.focusScroll],["clickPick-ctrl+shift-middle",Nn.movePick],["hoverPick",Nn.tooltipPick]],coot:[["scroll",Nn.isolevelScroll],["drag-left",Nn.rotateDrag],["drag-middle",Nn.panDrag],["drag-ctrl-left",Nn.panDrag],["drag-right",Nn.zoomFocusDrag],["drag-ctrl-right",Nn.focusScroll],["clickPick-middle",Nn.movePick],["hoverPick",Nn.tooltipPick]],astexviewer:[["drag-left",Nn.rotateDrag],["drag-ctrl-left",Nn.panDrag],["drag-shift-left",Nn.zoomDrag],["scroll",Nn.focusScroll],["clickPick-middle",Nn.movePick],["hoverPick",Nn.tooltipPick]]};function Vn(e){const t=e.split(/[-+]/);let i="";t.includes("scroll")&&(i="scroll"),t.includes("drag")&&(i="drag"),t.includes("click")&&(i="click"),t.includes("doubleClick")&&(i="doubleClick"),t.includes("hover")&&(i="hover"),t.includes("clickPick")&&(i="clickPick"),t.includes("hoverPick")&&(i="hoverPick");let r=0;t.includes("alt")&&(r+=1),t.includes("ctrl")&&(r+=2),t.includes("meta")&&(r+=4),t.includes("shift")&&(r+=8);let s=0;return t.includes("left")&&(s+=1),t.includes("right")&&(s+=2),t.includes("middle")&&(s+=4),[i,r,s]}class Gn{constructor(e,t={}){this.stage=e,this.actionList=[],this.mouse=e.mouseObserver,this.disabled=t.disabled||!1,this.preset(t.preset||"default")}run(e,...t){if(this.disabled)return;const i=this.mouse.key||0,r=this.mouse.buttons||0;this.actionList.forEach((s=>{s.type===e&&s.key===i&&s.button===r&&s.callback(this.stage,...t)}))}add(e,t){const[i,r,s]=Vn(e);this.actionList.push({type:i,key:r,button:s,callback:t})}remove(e,t){const i=e.includes("*"),[r,s,n]=Vn(e),o=this.actionList.filter((function(e){return!((e.type===r||i&&""===r)&&(e.key===s||i&&0===s)&&(e.button===n||i&&0===n)&&(e.callback===t||void 0===t))}));this.actionList=o}preset(e){this.clear();(zn[e]||[]).forEach((e=>this.add(e[0],e[1])))}clear(){this.actionList.length=0}}class Un{static autoView(e){e.autoView(1e3)}static toggleAnimations(e){e.animationControls.toggle()}static toggleRock(e){e.toggleRock()}static toggleSpin(e){e.toggleSpin()}static toggleAntialiasing(e){const t=e.getParameters();e.setParameters({sampleLevel:-1===t.sampleLevel?0:-1})}}const jn={default:[["i",Un.toggleSpin],["k",Un.toggleRock],["p",Un.toggleAnimations],["a",Un.toggleAntialiasing],["r",Un.autoView]]};class Hn{constructor(e,t={}){this.stage=e,this.actionList=[],this.disabled=t.disabled||!1,this.preset(t.preset||"default")}run(e){this.disabled||this.actionList.forEach((t=>{t.key===e&&t.callback(this.stage)}))}add(e,t){this.actionList.push({key:e,callback:t})}remove(e,t){const i=this.actionList.filter((function(i){return!(i.key===e&&(i.callback===t||void 0===t))}));this.actionList=i}preset(e){this.clear();(jn[e]||[]).forEach((e=>this.add(e[0],e[1])))}clear(){this.actionList.length=0}}class Wn{constructor(e){this.stage=e,this.stage=e,this.mouse=e.mouseObserver,this.controls=e.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)}_onClick(e,t){const i=this.stage.pickingControls.pick(e,t);this.stage.signals.clicked.dispatch(i),this.controls.run("clickPick",i)}_onHover(e,t){const i=this.stage.pickingControls.pick(e,t);i&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=i.component,this.stage.transformAtom=i.atom),this.stage.signals.hovered.dispatch(i),this.controls.run("hoverPick",i)}dispose(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}}class qn{constructor(e){this.stage=e,this.stage=e,this.mouse=e.mouseObserver,this.controls=e.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)}_onMove(){this.stage.tooltip.style.display="none"}_onScroll(e){this.controls.run("scroll",e)}_onDrag(e,t){this.controls.run("drag",e,t)}_onClick(e,t){this.controls.run("click",e,t)}_onDblclick(e,t){this.controls.run("doubleClick",e,t)}_onHover(e,t){this.controls.run("hover",e,t)}dispose(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}}class Xn{constructor(e){this.stage=e,this.viewer=e.viewer,this.animationControls=e.animationControls,this.viewer.signals.ticked.add(this._onTick,this)}_onTick(e){this.animationControls.run(e)}dispose(){this.viewer.signals.ticked.remove(this._onTick,this)}}const Yn=!!Pe&&{passive:!0};class Kn{constructor(e){this.stage=e,this.stage=e,this.controls=e.keyControls,this.domElement=e.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,Yn),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)}_onKeydown(){}_onKeyup(){}_onKeypress(e){let t;t="key"in KeyboardEvent.prototype?e.key:String.fromCharCode(e.which||e.keyCode),this.controls.run(t)}_focusDomElement(){this.domElement.focus()}dispose(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,Yn),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)}}class Zn{constructor(e,i,r,s={}){this.component=e,this.position=i,this.offsetX=l(s.offsetX,0),this.offsetY=l(s.offsetY,0),this.visible=l(s.visible,!0),this.stage=e.stage,this.viewer=e.stage.viewer,this._viewerPosition=new t.Vector3,this._updateViewerPosition(),this._canvasPosition=new t.Vector2,this._cameraPosition=new t.Vector3,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",left:"-10000px"}),this.viewer.wrapper.appendChild(this.element),this.setContent(r),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)}setContent(e){const t=this.element.style.display;if("none"===t&&(this.element.style.left="-10000px",this.element.style.display="block"),e instanceof HTMLElement)this.element.appendChild(e);else{const t=document.createElement("div");t.innerText=e,Object.assign(t.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(t)}this._clientRect=this.element.getBoundingClientRect(),"none"===t&&(this.element.style.display=t)}setVisibility(e){this.visible=e,this.updateVisibility()}getVisibility(){return this.visible&&this.component.parameters.visible}updateVisibility(){this.element.style.display=this.getVisibility()?"block":"none"}_updateViewerPosition(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)}_update(){if(!this.getVisibility())return;const e=this.element.style,t=this._canvasPosition,i=this._viewerPosition,r=this._clientRect;if(this._cameraPosition.copy(i).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)return void(e.display="none");e.display="block";const s=this._cameraPosition.length(),n=this.viewer.scene.fog;e.opacity=(1-L(n.near,n.far,s)).toString(),e.zIndex=Math.round(100*(n.far-s)).toString(),this.stage.viewerControls.getPositionOnCanvas(i,t),e.bottom=this.offsetX+t.y+r.height/2+"px",e.left=this.offsetY+t.x-r.width/2+"px"}dispose(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)}}const Qn=new t.Matrix4,Jn=new t.Vector3,eo=new t.Quaternion;class to{constructor(e){this.component=e,this.signals={changed:new a.Signal},this.stage=e.stage,this.viewer=e.stage.viewer}get position(){return this.component.position}get rotation(){return this.component.quaternion}changed(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()}spin(e,t){Qn.getInverse(this.viewer.rotationGroup.matrix),Jn.copy(C(e)).applyMatrix4(Qn),Qn.extractRotation(this.component.transform),Qn.premultiply(this.viewer.rotationGroup.matrix),Qn.getInverse(Qn),Jn.copy(C(e)),Jn.applyMatrix4(Qn),Qn.makeRotationAxis(Jn,t),eo.setFromRotationMatrix(Qn),this.component.quaternion.premultiply(eo),this.changed()}}const io={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"};class ro{constructor(e={}){this.max=10,this.type=l(e.type,"size"),this.scale=l(e.scale,1),this.size=l(e.size,1),this.data=l(e.data,{})}atomRadius(e){let t;switch(this.type){case"vdw":t=e.vdw;break;case"covalent":t=e.covalent;break;case"bfactor":t=e.bfactor||1;break;case"sstruc":const i=e.sstruc;t="h"===i||"g"===i||"i"===i||"e"===i||"b"===i?.25:ts.includes(e.atomname)?.4:.1;break;case"data":t=l(this.data[e.index],1);break;case"explicit":t=e.radius,null===t&&(t=this.size);break;default:t=this.size}return Math.min(t*this.scale,this.max)}}ro.types=io;const so=new t.Vector3(-1,-1,-1),no=new t.Matrix4;class oo{constructor(e){const i=e.rows,r=i/3,s=new Js(i,3),n=new Js(3,3),o=new Js(1,3),a=new Js(3,3),c=new Js(3,3),l=sn(e);nn(e,l),en(s,e),tn(n,s,s),hn(n,o,a,c);const h=new t.Vector3(l[0],l[1],l[2]),u=new t.Vector3(a.data[0],a.data[3],a.data[6]),d=new t.Vector3(a.data[1],a.data[4],a.data[7]),m=new t.Vector3(a.data[2],a.data[5],a.data[8]),p=u.clone().multiplyScalar(Math.sqrt(o.data[0]/r)),f=d.clone().multiplyScalar(Math.sqrt(o.data[1]/r)),g=m.clone().multiplyScalar(Math.sqrt(o.data[2]/r));this.begA=h.clone().sub(p),this.endA=h.clone().add(p),this.begB=h.clone().sub(f),this.endB=h.clone().add(f),this.begC=h.clone().sub(g),this.endC=h.clone().add(g),this.center=h,this.vecA=p,this.vecB=f,this.vecC=g,this.normVecA=u,this.normVecB=d,this.normVecC=m}getBasisMatrix(e=new t.Matrix4){const i=e;return i.makeBasis(this.normVecB,this.normVecA,this.normVecC),i.determinant()<0&&i.scale(so),i}getRotationQuaternion(e=new t.Quaternion){const i=e;return i.setFromRotationMatrix(this.getBasisMatrix(no)),i.inverse()}getProjectedScaleForAtoms(e){let i=-1/0,r=-1/0,s=-1/0,n=-1/0,o=-1/0,a=-1/0;const c=new t.Vector3,l=new t.Vector3,h=this.center,u=this.normVecA,d=this.normVecB,m=this.normVecC;return e.eachAtom((function(e){Oi(c.copy(e),u,h);const t=l.subVectors(c,h).normalize().dot(u),p=c.distanceTo(h);t>0?p>i&&(i=p):p>r&&(r=p),Oi(c.copy(e),d,h);const f=l.subVectors(c,h).normalize().dot(d),g=c.distanceTo(h);f>0?g>s&&(s=g):g>n&&(n=g),Oi(c.copy(e),m,h);const y=l.subVectors(c,h).normalize().dot(m),b=c.distanceTo(h);y>0?b>o&&(o=b):b>a&&(a=b)})),{d1a:i,d2a:s,d3a:o,d1b:-r,d2b:-n,d3b:-a}}}class ao{constructor(e,t,i,r){this.volume=e,this.setFilter(t,i,r)}get header(){return this.volume.header}get matrix(){return this.volume.matrix}get normalMatrix(){return this.volume.normalMatrix}get inverseMatrix(){return this.volume.inverseMatrix}get center(){return this.volume.center}get boundingBox(){return this.volume.boundingBox}get min(){return this.volume.min}get max(){return this.volume.max}get mean(){return this.volume.mean}get rms(){return this.volume.rms}_getFilterHash(e,t,i){return JSON.stringify([e,t,i])}setFilter(e,t,i){isNaN(e)&&this.header&&(e=this.header.DMEAN+2*this.header.ARMS),e=void 0===e||isNaN(e)?-1/0:e,t=l(t,1/0),i=l(i,!1);const r=this.volume.data,s=this.volume.position,n=this.volume.atomindex,o=this._getFilterHash(e,t,i);if(o!==this._filterHash){if(e===-1/0&&t===1/0)this.data=r,this.position=s,this.atomindex=n;else{const o=r.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*o),this._positionBuffer=new ArrayBuffer(3*o*4),n&&(this._atomindexBuffer=new ArrayBuffer(4*o)));const a=new Float32Array(this._dataBuffer),c=new Float32Array(this._positionBuffer);let l;n&&(l=new Uint32Array(this._atomindexBuffer));let h=0;for(let u=0;u=e&&d<=t||i&&(dt)){const e=3*h;a[h]=d,c[e+0]=s[o+0],c[e+1]=s[o+1],c[e+2]=s[o+2],n&&l&&(l[h]=n[u]),h+=1}}this.data=new Float32Array(this._dataBuffer,0,h),this.position=new Float32Array(this._positionBuffer,0,3*h),n&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,h))}this._filterHash=o}}}ao.prototype.getValueForSigma=Cn.prototype.getValueForSigma,ao.prototype.getSigmaForValue=Cn.prototype.getSigmaForValue,ao.prototype.getDataAtomindex=Cn.prototype.getDataAtomindex,ao.prototype.getDataPosition=Cn.prototype.getDataPosition,ao.prototype.getDataColor=Cn.prototype.getDataColor,ao.prototype.getDataPicking=Cn.prototype.getDataPicking,ao.prototype.getDataSize=Cn.prototype.getDataSize;class co{constructor(e,t){const i=Cr({nodeArray1:e.atomIndex1,nodeArray2:e.atomIndex2,edgeCount:e.count,nodeCount:t});this.countArray=i.countArray,this.offsetArray=i.offsetArray,this.indexArray=i.indexArray}}class lo extends wr{get _defaultFields(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]}addBond(e,t,i){this.growIfFull();const r=this.count,s=e.index,n=t.index;s0&&(a[t]=v.angleTo(w));const r=Math.cos(f.angleTo(g));h[t]=180/Math.PI*Math.acos(r);const s=f.length(),x=g.length();c[t]=Math.sqrt(x*s)/Math.max(2,2*(1-r)),l[t]=Math.abs(m.dot(v)),y.copy(f).multiplyScalar(c[t]/s),b.copy(g).multiplyScalar(c[t]/x),y.subVectors(P,y),b.subVectors(I,b),y.toArray(n,i+3),b.toArray(n,i+6),A.subVectors(C,_),A.toArray(u,i),w.copy(v),_.copy(y)}y.fromArray(n,3),b.fromArray(n,6),v.subVectors(y,b).normalize(),C.index=e.getAtomIndexByType(0,S),_.copy(C),x.copy(C),Oi(x,v,y),x.toArray(n,0),A.subVectors(_,y),A.toArray(u,0),y.fromArray(n,3*r-6),b.fromArray(n,3*r-9),v.subVectors(y,b).normalize(),C.index=e.getAtomIndexByType(r-1,S),_.copy(C),x.copy(C),Oi(x,v,y),x.toArray(n,3*r-3);for(let t=r-3;ti||h.bending[t]>e)&&(F=!0)),F){if(t-p<4){p=t,F=!1;continue}R.index=T.traceAtomIndex,I=h.axis.subarray(3*p+3,3*t),k=h.center.subarray(3*p,3*t+3),C=Ri(I).normalize(),P=Ri(k),M.fromArray(k),Oi(M,C,P),D.fromArray(k,k.length-3),Oi(D,C,P),C.subVectors(D,M),C.toArray(g,f),P.toArray(y,f),M.toArray(b,f),D.toArray(x,f),d.atomColorToArray(R,v,f),w.push(R.index),A.push(m.atomRadius(R)),_.push(l+p),S.push(l+t+1-p),f+=3,p=t,F=!1}const E=new Float32Array(w);return{axis:new Float32Array(g),center:new Float32Array(y),begin:new Float32Array(b),end:new Float32Array(x),color:new Float32Array(v),picking:new Ls(E,a),size:new Float32Array(A),residueOffset:_,residueCount:S}}}class yo{constructor(e){this.scoreFunction=e,this.content=[],this.scoreFunction=e}push(e){this.content.push(e),this.bubbleUp(this.content.length-1)}pop(){const e=this.content[0],t=this.content.pop();return t&&this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e}peek(){return this.content[0]}remove(e){const t=this.content.length;for(let i=0;i0;){const i=Math.floor((e+1)/2)-1,r=this.content[i];if(!(this.scoreFunction(t), 2016 - * @author Roman Bolzern , 2013 - * @author I4DS http://www.fhnw.ch/i4ds, 2013 - * @license MIT License - * @description - * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place - * provides fast nearest neighbour search - * - * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs - * - * Further information (including mathematical properties) - * http://en.wikipedia.org/wiki/Binary_tree - * http://en.wikipedia.org/wiki/K-d_tree - * - * @example - * points: [x, y, z, x, y, z, x, y, z, ...] - * metric: function(a, b){ - * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2); - * } - * - * @param {Float32Array} points - points - * @param {Function} metric - metric - */ -var ns=function(t,e){this.points=t,this.metric=e,this.maxDepth=0,this.currentNode=0;for(var r=t.length/3,i=new Uint32Array(r),o=0;othis.maxDepth&&(this.maxDepth=t);var o=i-r;if(0===o)return-1;var n=4*this.currentNode,a=this.nodes;if(this.currentNode+=1,1===o)return a[n]=r,a[n+1]=-1,a[n+2]=-1,a[n+3]=e,n;for(var s,c,u,l,h,p=this.indices,d=this.points,f=r+Math.floor(o/2),m=t%3,g=r,y=i-1;y>g;){for(l=d[3*p[u=g+y>>1]+m],c=p[u],p[u]=p[y],p[y]=c,h=g,s=g;se&&o.pop()}var y=n[u+1],v=n[u+2];if(-1!==v||-1!==y){l=-1===v?y:-1===y?v:t[p]<=a[d+p]?y:v,c(l),(o.size()n[3*a[o[t]]+i])throw new Error("left child is > parent!");r+=this.verify(s,e+1)}if(-1!==c){if(n[3*a[o[c]]+i]0},as.prototype.isBackbone=function(){var t=this.residueType.backboneIndexList;return t.length>0&&t.includes(this.index-this.residueAtomOffset)},as.prototype.isPolymer=function(){if(this.structure.entityList.length>0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},as.prototype.isSidechain=function(){return this.isPolymer()&&!this.isBackbone()},as.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},as.prototype.isTrace=function(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset},as.prototype.isHetero=function(){return 1===this.residueType.hetero},as.prototype.isProtein=function(){return 3===this.residueType.moleculeType},as.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},as.prototype.isRna=function(){return 4===this.residueType.moleculeType},as.prototype.isDna=function(){return 5===this.residueType.moleculeType},as.prototype.isWater=function(){return 1===this.residueType.moleculeType},as.prototype.isIon=function(){return 2===this.residueType.moleculeType},as.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},as.prototype.isHelix=function(){return ho.includes(this.sstruc)},as.prototype.isSheet=function(){return po.includes(this.sstruc)},as.prototype.isTurn=function(){return fo.includes(this.sstruc)&&this.isProtein()},as.prototype.isBonded=function(){return 0!==this.bondHash.countArray[this.index]},as.prototype.isRing=function(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]},as.prototype.isAromatic=function(){return 1===this.aromatic},as.prototype.isPolarHydrogen=function(){var t=!1;return 1!==this.number?t:t=!this.hasBondToElement(6)},as.prototype.isMetal=function(){return this.atomType.isMetal()},as.prototype.isNonmetal=function(){return this.atomType.isNonmetal()},as.prototype.isMetalloid=function(){return this.atomType.isMetalloid()},as.prototype.isHalogen=function(){return this.atomType.isHalogen()},as.prototype.isDiatomicNonmetal=function(){return this.atomType.isDiatomicNonmetal()},as.prototype.isPolyatomicNonmetal=function(){return this.atomType.isPolyatomicNonmetal()},as.prototype.isAlkaliMetal=function(){return this.atomType.isAlkaliMetal()},as.prototype.isAlkalineEarthMetal=function(){return this.atomType.isAlkalineEarthMetal()},as.prototype.isNobleGas=function(){return this.atomType.isNobleGas()},as.prototype.isTransitionMetal=function(){return this.atomType.isTransitionMetal()},as.prototype.isPostTransitionMetal=function(){return this.atomType.isPostTransitionMetal()},as.prototype.isLanthanide=function(){return this.atomType.isLanthanide()},as.prototype.isActinide=function(){return this.atomType.isActinide()},as.prototype.getDefaultValence=function(){return this.atomType.getDefaultValence()},as.prototype.getValenceList=function(){return this.atomType.getValenceList()},as.prototype.getOuterShellElectronCount=function(){return this.atomType.getOuterShellElectronCount()},as.prototype.distanceTo=function(t){var e=this.atomStore,r=t.atomStore,i=this.index,o=t.index,n=e.x[i]-r.x[o],a=e.y[i]-r.y[o],s=e.z[i]-r.z[o],c=n*n+a*a+s*s;return Math.sqrt(c)},as.prototype.connectedTo=function(t){var e=this.atomStore,r=t.atomStore,i=this.index,o=t.index;if(e.altloc&&r.altloc){var n=e.altloc[i],a=r.altloc[o];if(0!==n&&0!==a&&32!==n&&32!==a&&n!==a)return!1}var s=e.x[i]-r.x[o],c=e.y[i]-r.y[o],u=e.z[i]-r.z[o],l=s*s+c*c+u*u;if(l<48&&this.isCg())return!0;if(isNaN(l))return!1;var h=this.covalent+t.covalent,p=h+.3,d=h-.5;return ld*d},as.prototype.positionFromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this},as.prototype.positionToArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var r=this.index,i=this.atomStore;return t[e+0]=i.x[r],t[e+1]=i.y[r],t[e+2]=i.z[r],t},as.prototype.positionToVector3=function(t){return void 0===t&&(t=new r.Vector3),t.x=this.x,t.y=this.y,t.z=this.z,t},as.prototype.positionFromVector3=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},as.prototype.positionAdd=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},as.prototype.positionSub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},as.prototype.getResidueBonds=function(t){void 0===t&&(t=!1);var e,r,i,o,n=this.residueAtomOffset,a=this.index-this.residueAtomOffset,s=this.residueType.getBonds(),c=s.atomIndices1,u=s.atomIndices2;for(t||(o=[]),e=c.indexOf(a);-1!==e;){if(i=u[e]+n,!o)return i;o.push(i),e=c.indexOf(a,e+1)}for(r=u.indexOf(a);-1!==r;){if(i=c[r]+n,!o)return i;o.push(i),r=u.indexOf(a,r+1)}return o},as.prototype.qualifiedName=function(t){void 0===t&&(t=!1);var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chainname&&(e+=":"+this.chainname),this.atomname&&(e+="."+this.atomname),this.altloc&&(e+="%"+this.altloc),this.structure.modelStore.count>1&&(e+="/"+this.modelIndex),e},as.prototype.clone=function(){return new as(this.structure,this.index)},as.prototype.toObject=function(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}},Object.defineProperties(as.prototype,ss);var ls=new Float32Array(3),hs=function(e,r){void 0===r&&(r=!1),t.Debug&&qt.time("Kdtree build");var i=r?cs:us,o=new Float32Array(3*e.atomCount),n=new Uint32Array(e.atomCount),a=0;e.eachAtom((function(t){o[a+0]=t.x,o[a+1]=t.y,o[a+2]=t.z,n[a/3]=t.index,a+=3})),this.atomIndices=n,this.points=o,this.kdtree=new ns(o,i),t.Debug&&qt.timeEnd("Kdtree build")};hs.prototype.nearest=function(t,e,i){t instanceof r.Vector3?t.toArray(ls):t instanceof as&&t.positionToArray(ls);for(var o=this.kdtree.nearest(ls,e,i),n=this.kdtree.indices,a=this.kdtree.nodes,s=this.atomIndices,c=[],u=0,l=o.length;u":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},ds={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 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*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},fs=/^[1-9]$/;function ms(t){var e="";return t.length>0&&(e=":"+I(t).join(" OR :")),new Pt(e)}var gs=function(t){void 0===t&&(t=""),this.name=t,this.partList=[]},ys={type:{configurable:!0}};ys.type.get=function(){return"Assembly"},gs.prototype.addPart=function(t,e){var r=new vs(t,e);return this.partList.push(r),r},gs.prototype.getAtomCount=function(t){return this.partList.reduce((function(e,r){return e+r.getAtomCount(t)}),0)},gs.prototype.getResidueCount=function(t){return this.partList.reduce((function(e,r){return e+r.getResidueCount(t)}),0)},gs.prototype.getInstanceCount=function(){var t=0;return this.partList.forEach((function(e){t+=e.matrixList.length})),t},gs.prototype.isIdentity=function(t){if(1!==this.partList.length)return!1;var e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new r.Matrix4).equals(e.matrixList[0]))return!1;var i=[];return t.eachChain((function(t){i.push(t.chainname)})),i=I(i),e.chainList.length===i.length},gs.prototype.getBoundingBox=function(t){var e=new r.Box3;return this.partList.forEach((function(r){var i=r.getBoundingBox(t);e.expandByPoint(i.min),e.expandByPoint(i.max)})),e},gs.prototype.getCenter=function(t){return this.getBoundingBox(t).getCenter(new r.Vector3)},gs.prototype.getSelection=function(){var t=[];return this.partList.forEach((function(e){t=t.concat(e.chainList)})),ms(t)},Object.defineProperties(gs.prototype,ys);var vs=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=[]),this.matrixList=t,this.chainList=e},bs={type:{configurable:!0}};bs.type.get=function(){return"AssemblyPart"},vs.prototype._getCount=function(t,e){var r=this,i=0;return t.eachChain((function(t){(0===r.chainList.length||r.chainList.includes(t.chainname))&&(i+=t[e])})),this.matrixList.length*i},vs.prototype.getAtomCount=function(t){return this._getCount(t,"atomCount")},vs.prototype.getResidueCount=function(t){return this._getCount(t,"residueCount")},vs.prototype.getBoundingBox=function(t){var e=new r.Box3,i=new r.Box3,o=this.getSelection(),n=t.getBoundingBox(o);return this.matrixList.forEach((function(t){i.copy(n).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)})),e},vs.prototype.getSelection=function(){return ms(this.chainList)},vs.prototype.getView=function(t){var e=this.getSelection();return e?t.getView(e):t},vs.prototype.getInstanceList=function(){for(var t=[],e=0,r=this.matrixList.length;e=0}));a.sort((function(t,e){var r=t[0],i=e[0],a=t[1],s=e[1];if(r===i)return a===s?0:a=0}));c.sort((function(t,e){var r=t[0],i=e[0];if(r===i)return 0;var a=C(o,r),s=C(o,i);return n[a]0&&this.addResidueType(this.ri-1),u.growIfFull(),u.resno[this.ri]=o,void 0!==a&&(u.sstruc[this.ri]=a.charCodeAt(0)),void 0!==s&&(u.inscode[this.ri]=s.charCodeAt(0)),u.atomOffset[this.ri]=this.ai,u.atomCount[this.ri]=0,u.count+=1,u.chainIndex[this.ri]=this.ci,l.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,u.atomCount[this.ri]+=1,this.currentModelindex=t,this.currentChainid=r,this.currentResname=i,this.currentResno=o,this.currentInscode=s,this.currentHetero=n},xs.prototype.finalize=function(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)};var ws,As,Ss,Cs=(ws=function(t,e,r,i){for(var o=t.structure,n=t.residueIndexStart,a=o.getResidueProxy(),s=o.getResidueProxy(),c=o.getAtomProxy(),u=o.getAtomProxy(),l=Math.max(0,e-2);l<=e;++l)for(var h=2;h<5;++h)if(!(l+h>=t.residueCount)){a.index=n+l,s.index=n+l+h,c.index=a.traceAtomIndex,u.index=s.traceAtomIndex;var p=c.distanceTo(u);if(Math.abs(p-r[h-2])>i)return!1}return!0},As=function(t,e){return ws(t,e,[5.45,5.18,6.37],2.1)},Ss=function(t,e){return ws(t,e,[6.1,10.4,13],1.42)},function(e){t.Debug&&qt.time("calculateSecondaryStructure"),e.eachPolymer((function(t){if(!(t.residueCount<4)){if(t.isCg())!function(t){for(var e=t.residueStore,i=t.residueIndexStart,o=new is(t).position,n=new r.Vector3,a=new r.Vector3,s=0,c=t.residueCount;s1&&o.bending[s]<20&&(e.sstruc[i+s]="h".charCodeAt(0),e.sstruc[i+s+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;!function(t){for(var e=t.residueStore,r=t.residueIndexStart,i=0,o=t.residueCount;i=e;)r=Math.floor(r/e),o+=Ps[r%e],i+=1;return i>=5&&qt.warn("chainname overflow"),o}function Os(e,r){void 0===r&&(r=!1),t.Debug&&qt.time("calculateChainnames");var i=!0;if(e.eachChain((function(t){t.chainname&&(i=!1)})),i){var o=e.modelStore,n=e.chainStore,a=e.residueStore,s=e.getAtomProxy(),c=e.getAtomProxy(),u=0,l=0,h=0,p=0,d=[];1===a.count?d.push({mIndex:0,chainname:"A",rStart:0,rCount:1}):e.eachResidueN(2,(function(t,e){var i=!1,o=t.backboneType,n=e.backboneType;p=t.index,t.modelIndex!==e.modelIndex||t.moleculeType!==e.moleculeType?i=!0:0!==o&&o===n&&(s.index=t.backboneEndAtomIndex,c.index=e.backboneStartAtomIndex,i=r?!s.hasBondTo(c):!s.connectedTo(c)),i||e.index!==a.count-1||(i=!0,p=e.index),i&&(d.push({mIndex:l,chainname:Is(u),rStart:h,rCount:p-h+1}),u+=1,t.modelIndex!==e.modelIndex&&(u=0,l+=1),e.index===a.count-1&&p!==e.index&&d.push({mIndex:l,chainname:Is(u),rStart:a.count-1,rCount:1}),h=e.index,p=e.index)})),n.count=0,o.chainCount.fill(0,0,o.count),o.chainOffset.fill(0,0,o.count),d.forEach((function(t){!function(t,e,r,i){for(var s=n.count,c=0;c500)return void qt.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());for(var h=t.getBonds(),p=h.atomIndices1,d=h.atomIndices2,f=h.bondOrders,m=p.length,g=0;g0)break;++r}else i=o+1;(r>0||i=3&&-1!==Fs.indexOf(e[0])?e[0]:""}function Ls(t){var e=t.bondHash,r=e.countArray,i=e.offsetArray,o=e.indexArray,n=t.getBondProxy();t.eachResidue((function(t){var e=t.residueType;if(void 0===e.bonds){var a=t.atomOffset,s=[],c=[],u=[],l={},h=a+t.atomCount;t.eachAtom((function(t){for(var e=t.index,p=i[e],d=0,f=r[e];d=h)){var g=n.atomIndex2;if(!(g=h)){if(m>g){var y=g;g=m,m=y}var v=m+"|"+g;void 0===l[v]&&(l[v]=!0,s.push(m-a),c.push(g-a),u.push(n.bondOrder))}}}})),e.bonds={atomIndices1:s,atomIndices2:c,bondOrders:u}}}))}var Ns=[3,11,19,37,55,87],zs=[4,12,20,38,56,88],js=[6,15,16,34],Vs=[1,7,8,9,17,35,53],Gs=[2,10,18,36,54,86],Us=[13,30,31,48,49,50,80,81,82,83,84,85,112],Hs=[5,14,32,33,51,52,85],Ws=[9,17,35,53,85],qs=function(t,e,r){this.structure=t,this.atomname=e,r=r||$s(e),this.element=r,this.number=mo[r]||0,this.vdw=go[this.number]||2,this.covalent=yo[this.number]||1.6};qs.prototype.getDefaultValence=function(){var t=vo[this.number];return t?t[0]:-1},qs.prototype.getValenceList=function(){return vo[this.number]||[]},qs.prototype.getOuterShellElectronCount=function(){return bo[this.number]||2},qs.prototype.isMetal=function(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()},qs.prototype.isNonmetal=function(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()},qs.prototype.isMetalloid=function(){return Hs.includes(this.number)},qs.prototype.isHalogen=function(){return Ws.includes(this.number)},qs.prototype.isDiatomicNonmetal=function(){return Vs.includes(this.number)},qs.prototype.isPolyatomicNonmetal=function(){return js.includes(this.number)},qs.prototype.isAlkaliMetal=function(){return Ns.includes(this.number)},qs.prototype.isAlkalineEarthMetal=function(){return zs.includes(this.number)},qs.prototype.isNobleGas=function(){return Gs.includes(this.number)},qs.prototype.isTransitionMetal=function(){var t=this.number;return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108},qs.prototype.isPostTransitionMetal=function(){return Us.includes(this.number)},qs.prototype.isLanthanide=function(){return this.number>=57&&this.number<=71},qs.prototype.isActinide=function(){return this.number>=89&&this.number<=103};var Xs=function(t){this.structure=t,this.dict={},this.list=[],this.structure=t};Xs.prototype.add=function(t,e){var r=function(t,e){return t+"|"+e}(t=t.toUpperCase(),e=e?e.toUpperCase():$s(t)),i=this.dict[r];if(void 0===i){var o=new qs(this.structure,t,e);i=this.list.length,this.dict[r]=i,this.list.push(o)}return i},Xs.prototype.get=function(t){return this.list[t]};var Ys=function(t,e,r,i,o,n){this.structure=t,this.bondReferenceAtomIndices=[],this.resname=e,this.atomTypeIdList=r,this.hetero=i?1:0,this.chemCompType=o,this.bonds=n,this.atomCount=r.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();var a=Bo[this.backboneType],s=Bo[this.backboneStartType],c=Bo[this.backboneEndType],u=this.getAtomIndexByName(a.trace);this.traceAtomIndex=y(u,-1);var l=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=y(l,-1);var h=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=y(h,-1);var p=this.getAtomIndexByName(s.backboneStart);this.backboneStartAtomIndex=y(p,-1);var d,f=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=y(f,-1),d=Po.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=y(d,-1)};Ys.prototype.getBackboneIndexList=function(){var t,e=[];switch(this.moleculeType){case 3:t=Do;break;case 4:case 5:t=To;break;default:return e}for(var r=this.structure.atomMap,i=this.atomTypeIdList,o=0,n=this.atomCount;o500)t.Debug&&qt.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName());else if(n>50)for(var h=new hs(e,!0),p=e.isCg()?1.2:2.3,d=a;d=0||Qs(t,e);this.rings={atomRings:t.atomRings,rings:t.rings}},Ys.prototype.isAromatic=function(t){return this.aromaticAtoms=this.getAromatic(t),1===this.aromaticAtoms[t.index-t.residueAtomOffset]},Ys.prototype.calculateAromatic=function(t){var e=this,r=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,o=i.map((function(r){return function(t){if(t.some((function(t){return!Ks.includes(t.number)})))return!1;var e=0,r=new Ln(3,t.length),i=r.data;return t.forEach((function(t){i[e+0]=t.x,i[e+1]=t.y,i[e+2]=t.z,e+=3})),new qa(r).vecC.length()<.05}(r.map((function(r){return e.structure.getAtomProxy(r+t.atomOffset)})))})),n=this.aromaticRings=[];i.forEach((function(t,e){o[e]&&(n.push(t),t.forEach((function(t){return r[t]=1})))}))},Ys.prototype.assignBondReferenceAtomIndices=function(){var t=this.getBondGraph(),e=this.getRings(),r=e.atomRings,i=e.rings,o=this.bonds,n=o.atomIndices1,a=o.atomIndices2,s=o.bondOrders,c=this.bondReferenceAtomIndices,u=o.atomIndices1.length;c.length=0;for(var l=0;l1)for(var y=0;y1)for(var b=0;b=0;x--)y[v++]=a[x];for(var _=t.rings.length,w=0;w0?n[h]!==c&&n[c]!==h&&Zs(t,c,h):(i[h]=1,o[s++]=h,n[h]=c)}}}var Js=4;var tc=function(t){this.structure=t,this.dict={},this.list=[]};tc.prototype.add=function(t,e,r,i,o){void 0===i&&(i="");var n=function(t,e,r,i){return void 0===i&&(i=""),t+"|"+e.join(",")+"|"+(r?1:0)+"|"+i}(t=t.toUpperCase(),e,r,i),a=this.dict[n];if(void 0===a){var s=new Ys(this.structure,t,e,r,i,o);a=this.list.length,this.dict[n]=a,this.list.push(s)}return a},tc.prototype.get=function(t){return this.list[t]};var ec=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.bondStore=t.bondStore,this._v12=new r.Vector3,this._v13=new r.Vector3,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()},rc={atom1:{configurable:!0},atom2:{configurable:!0},atomIndex1:{configurable:!0},atomIndex2:{configurable:!0},bondOrder:{configurable:!0}};rc.atom1.get=function(){return this.structure.getAtomProxy(this.atomIndex1)},rc.atom2.get=function(){return this.structure.getAtomProxy(this.atomIndex2)},rc.atomIndex1.get=function(){return this.bondStore.atomIndex1[this.index]},rc.atomIndex1.set=function(t){this.bondStore.atomIndex1[this.index]=t},rc.atomIndex2.get=function(){return this.bondStore.atomIndex2[this.index]},rc.atomIndex2.set=function(t){this.bondStore.atomIndex2[this.index]=t},rc.bondOrder.get=function(){return this.bondStore.bondOrder[this.index]},rc.bondOrder.set=function(t){this.bondStore.bondOrder[this.index]=t},ec.prototype.getOtherAtomIndex=function(t){return t===this.atomIndex1?this.atomIndex2:this.atomIndex1},ec.prototype.getOtherAtom=function(t){return this.structure.getAtomProxy(this.getOtherAtomIndex(t.index))},ec.prototype.getReferenceAtomIndex=function(){var t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex===e.residueIndex){var r=t.index-t.residueAtomOffset,i=e.index-e.residueAtomOffset,o=t.residueType.getBondReferenceAtomIndex(r,i);if(void 0!==o)return o+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}},ec.prototype.calculateShiftDir=function(t){void 0===t&&(t=new r.Vector3);var e=this._ap1,i=this._ap2,o=this._ap3,n=this._v12,a=this._v13;e.index=this.atomIndex1,i.index=this.atomIndex2;var s=this.getReferenceAtomIndex();n.subVectors(e,i).normalize(),void 0!==s?(o.index=s,a.subVectors(e,o)):a.copy(e),a.normalize();var c=n.dot(a);return 1-Math.abs(c)<1e-5&&(a.set(1,0,0),c=n.dot(a),1-Math.abs(c)<1e-5&&(a.set(0,1,0),c=n.dot(a))),t.copy(a.sub(n.multiplyScalar(c))).normalize()},ec.prototype.qualifiedName=function(){return this.atomIndex1+"="+this.atomIndex2},ec.prototype.clone=function(){return new ec(this.structure,this.index)},ec.prototype.toObject=function(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}},Object.defineProperties(ec.prototype,rc);var ic=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap},oc={entity:{configurable:!0},entityIndex:{configurable:!0},chain:{configurable:!0},chainIndex:{configurable:!0},atomOffset:{configurable:!0},atomCount:{configurable:!0},atomEnd:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0},chainid:{configurable:!0},resno:{configurable:!0},sstruc:{configurable:!0},inscode:{configurable:!0},residueType:{configurable:!0},resname:{configurable:!0},hetero:{configurable:!0},moleculeType:{configurable:!0},backboneType:{configurable:!0},backboneStartType:{configurable:!0},backboneEndType:{configurable:!0},traceAtomIndex:{configurable:!0},direction1AtomIndex:{configurable:!0},direction2AtomIndex:{configurable:!0},backboneStartAtomIndex:{configurable:!0},backboneEndAtomIndex:{configurable:!0},rungEndAtomIndex:{configurable:!0},x:{configurable:!0},y:{configurable:!0},z:{configurable:!0}};oc.entity.get=function(){return this.structure.entityList[this.entityIndex]},oc.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},oc.chain.get=function(){return this.structure.getChainProxy(this.chainIndex)},oc.chainIndex.get=function(){return this.residueStore.chainIndex[this.index]},oc.chainIndex.set=function(t){this.residueStore.chainIndex[this.index]=t},oc.atomOffset.get=function(){return this.residueStore.atomOffset[this.index]},oc.atomOffset.set=function(t){this.residueStore.atomOffset[this.index]=t},oc.atomCount.get=function(){return this.residueStore.atomCount[this.index]},oc.atomCount.set=function(t){this.residueStore.atomCount[this.index]=t},oc.atomEnd.get=function(){return this.atomOffset+this.atomCount-1},oc.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},oc.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},oc.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},oc.resno.get=function(){return this.residueStore.resno[this.index]},oc.resno.set=function(t){this.residueStore.resno[this.index]=t},oc.sstruc.get=function(){return this.residueStore.getSstruc(this.index)},oc.sstruc.set=function(t){this.residueStore.setSstruc(this.index,t)},oc.inscode.get=function(){return this.residueStore.getInscode(this.index)},oc.inscode.set=function(t){this.residueStore.setInscode(this.index,t)},oc.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},oc.resname.get=function(){return this.residueType.resname},oc.hetero.get=function(){return this.residueType.hetero},oc.moleculeType.get=function(){return this.residueType.moleculeType},oc.backboneType.get=function(){return this.residueType.backboneType},oc.backboneStartType.get=function(){return this.residueType.backboneStartType},oc.backboneEndType.get=function(){return this.residueType.backboneEndType},oc.traceAtomIndex.get=function(){return this.residueType.traceAtomIndex+this.atomOffset},oc.direction1AtomIndex.get=function(){return this.residueType.direction1AtomIndex+this.atomOffset},oc.direction2AtomIndex.get=function(){return this.residueType.direction2AtomIndex+this.atomOffset},oc.backboneStartAtomIndex.get=function(){return this.residueType.backboneStartAtomIndex+this.atomOffset},oc.backboneEndAtomIndex.get=function(){return this.residueType.backboneEndAtomIndex+this.atomOffset},oc.rungEndAtomIndex.get=function(){return this.residueType.rungEndAtomIndex+this.atomOffset},oc.x.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.x[e];return t/this.atomCount},oc.y.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.y[e];return t/this.atomCount},oc.z.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.z[e];return t/this.atomCount},ic.prototype.eachAtom=function(t,e){var r=this.atomCount,i=this.atomOffset,o=this.structure._ap,n=i+r;if(e&&e.atomOnlyTest)for(var a=e.atomOnlyTest,s=i;s0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},ic.prototype.isHetero=function(){return 1===this.residueType.hetero},ic.prototype.isWater=function(){return 1===this.residueType.moleculeType},ic.prototype.isIon=function(){return 2===this.residueType.moleculeType},ic.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},ic.prototype.isStandardAminoacid=function(){return this.residueType.isStandardAminoacid()},ic.prototype.isStandardBase=function(){return this.residueType.isStandardBase()},ic.prototype.isHelix=function(){return ho.includes(this.sstruc)},ic.prototype.isSheet=function(){return po.includes(this.sstruc)},ic.prototype.isTurn=function(){return fo.includes(this.sstruc)&&this.isProtein()},ic.prototype.getAtomType=function(t){return this.atomMap.get(this.atomStore.atomTypeId[t])},ic.prototype.getResname1=function(){return wo[this.resname.toUpperCase()]||"X"},ic.prototype.getBackboneType=function(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},ic.prototype.getAtomIndexByName=function(t){var e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e},ic.prototype.hasAtomWithName=function(t){return this.residueType.hasAtomWithName(t)},ic.prototype.getAtomnameList=function(){console.warn("getAtomnameList - might be expensive");for(var t=this.atomCount,e=this.atomOffset,r=new Array(t),i=0;i=e){var i=y(t,this.structure.getResidueProxy());if(i.index=r,i.connectedTo(this))return i}else if(r===e-1){var o=this.chainStore.residueCount[this.chainIndex],n=y(t,this.structure.getResidueProxy());if(n.index=e+o-1,n.connectedTo(this))return n}},ic.prototype.getBonds=function(){return this.residueType.getBonds(this)},ic.prototype.getRings=function(){return this.residueType.getRings()},ic.prototype.getAromaticRings=function(){return this.residueType.getAromaticRings(this)},ic.prototype.qualifiedName=function(t){void 0===t&&(t=!1);var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chain&&(e+=":"+this.chainname),e+="/"+this.modelIndex},ic.prototype.clone=function(){return new ic(this.structure,this.index)},ic.prototype.toObject=function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}},Object.defineProperties(ic.prototype,oc);var nc=function(t,e,r){this.structure=t,this.residueIndexStart=e,this.residueIndexEnd=r,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueCount=r-e+1;var i=this.structure.getResidueProxy(this.residueIndexStart),o=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==i.getPreviousConnectedResidue();var n=o.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=o.connectedTo(i),this.__residueProxy=this.structure.getResidueProxy()},ac={chainIndex:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0}};ac.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndexStart]},ac.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},ac.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},nc.prototype.isProtein=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},nc.prototype.isCg=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},nc.prototype.isNucleic=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},nc.prototype.getMoleculeType=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},nc.prototype.getBackboneType=function(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)},nc.prototype.getAtomIndexByType=function(t,e){this.isCyclic?-1===t?t=this.residueCount-1:t===this.residueCount&&(t=0):(-1!==t||this.isPrevConnected||(t+=1),t!==this.residueCount||this.isNextNextConnected||(t-=1));var r,i=this.__residueProxy;switch(i.index=this.residueIndexStart+t,e){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(e)}return r},nc.prototype.eachAtom=function(t,e){this.eachResidue((function(r){r.eachAtom(t,e)}))},nc.prototype.eachAtomN=function(t,e,r){for(var i=this.residueCount,o=new Array(t),n=0;n1&&t(new nc(n,r,u.index)),r=i)):(0!==m&&u.index-r>1&&t(new nc(n,r,u.index)),r=i)}i-r>1&&this.structure.getResidueProxy(r).backboneEndType&&t(new nc(n,r,i))},sc.prototype.qualifiedName=function(){return":"+this.chainname+"/"+this.modelIndex},sc.prototype.clone=function(){return new sc(this.structure,this.index)},sc.prototype.toObject=function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}},Object.defineProperties(sc.prototype,cc);var uc=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore},lc={chainOffset:{configurable:!0},chainCount:{configurable:!0},residueOffset:{configurable:!0},atomOffset:{configurable:!0},chainEnd:{configurable:!0},residueEnd:{configurable:!0},atomEnd:{configurable:!0},residueCount:{configurable:!0},atomCount:{configurable:!0}};lc.chainOffset.get=function(){return this.modelStore.chainOffset[this.index]},lc.chainOffset.set=function(t){this.modelStore.chainOffset[this.index]=t},lc.chainCount.get=function(){return this.modelStore.chainCount[this.index]},lc.chainCount.set=function(t){this.modelStore.chainCount[this.index]=t},lc.residueOffset.get=function(){return this.chainStore.residueOffset[this.chainOffset]},lc.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},lc.chainEnd.get=function(){return this.chainOffset+this.chainCount-1},lc.residueEnd.get=function(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},lc.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},lc.residueCount.get=function(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},lc.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},uc.prototype.eachAtom=function(t,e){this.eachChain((function(r){r.eachAtom(t,e)}),e)},uc.prototype.eachResidue=function(t,e){this.eachChain((function(r){r.eachResidue(t,e)}),e)},uc.prototype.eachPolymer=function(t,e){if(e&&e.chainOnlyTest){var r=e.chainOnlyTest;this.eachChain((function(i){r(i)&&i.eachPolymer(t,e)}))}else this.eachChain((function(r){r.eachPolymer(t,e)}))},uc.prototype.eachChain=function(t,e){var r=this.chainCount,i=this.chainOffset,o=this.structure._cp,n=i+r;if(e&&e.test){var a=e.chainOnlyTest;if(a)for(var s=i;s1){var e=i.atomRadius(m);S=e*l/(.5*w),d.calculateShiftDir(F),u?(A=2*h*e,F.multiplyScalar(A),F.negate(),R.subVectors(g,m).multiplyScalar(Math.max(.1,A/1.88)),m.positionToArray(C,x),g.positionToArray(P,x),w>=2&&(B.addVectors(m,F).add(R).toArray(C,x+3),B.addVectors(g,F).sub(R).toArray(P,x+3),w>=3&&(B.subVectors(m,F).add(R).toArray(C,x+6),B.subVectors(g,F).sub(R).toArray(P,x+6)))):(A=(h-l)*e,F.multiplyScalar(A),2===w?(B.addVectors(m,F).toArray(C,x),B.subVectors(m,F).toArray(C,x+3),B.addVectors(g,F).toArray(P,x),B.subVectors(g,F).toArray(P,x+3)):3===w?(m.positionToArray(C,x),B.addVectors(m,F).toArray(C,x+3),B.subVectors(m,F).toArray(C,x+6),g.positionToArray(P,x),B.addVectors(g,F).toArray(P,x+3),B.subVectors(g,F).toArray(P,x+6)):(m.positionToArray(C,x),g.positionToArray(P,x)))}else m.positionToArray(C,x),g.positionToArray(P,x);if(I&&O&&(o.bondColorToArray(d,1,I,x),o.bondColorToArray(d,0,O,x),c&&w>1))for(b=1;b1))for(b=1;b1))for(S=k[T]*l/(u?1:.5*w),b=u?1:0;b1))for(S=D[T]*l/(u?1:.5*w),b=u?1:0;bs&&(s=e),r>c&&(c=r),i>u&&(u=i)}),e),i.min.set(o,n,a),i.max.set(s,c,u),t.Debug&&qt.timeEnd("getBoundingBox"),i},hc.prototype.getPrincipalAxes=function(e){t.Debug&&qt.time("getPrincipalAxes");var r=0,i=new Ln(3,this.atomCount),o=i.data;return this.eachAtom((function(t){o[r+0]=t.x,o[r+1]=t.y,o[r+2]=t.z,r+=3}),e),t.Debug&&qt.timeEnd("getPrincipalAxes"),new qa(i)},hc.prototype.atomCenter=function(t){return t?this.getBoundingBox(t).getCenter(new r.Vector3):this.center.clone()},hc.prototype.hasCoords=function(){if(void 0===this._hasCoords){var t=this.atomStore;this._hasCoords=0!==qe(t.x)||0!==We(t.x)||0!==qe(t.y)||0!==We(t.y)||0!==qe(t.z)||0!==We(t.z)||t.count/this.modelStore.count==1}return this._hasCoords},hc.prototype.getSequence=function(t){var e=[],r=this.getResidueProxy();return this.eachAtom((function(t){r.index=t.residueIndex,t.index===r.traceAtomIndex&&e.push(r.getResname1())}),t),e},hc.prototype.getAtomIndices=function(t){if(t&&t.string){var e=[];return this.eachAtom((function(t){e.push(t.index)}),t),new Uint32Array(e)}return this.getAtomData({what:{index:!0}}).index},hc.prototype.getChainnameCount=function(t){var e=new Set;return this.eachChain((function(t){t.residueCount&&e.add(t.chainname)}),t),e.size},hc.prototype.updatePosition=function(t,e){void 0===e&&(e=!0);var r=0;this.eachAtom((function(e){e.positionFromArray(t,r),r+=3}),void 0),this._hasCoords=void 0,e&&this.refreshPosition()},hc.prototype.refreshPosition=function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new Ki(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)},hc.prototype.dispose=function(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet},Object.defineProperties(hc.prototype,pc);var dc=new r.Box3,fc=[Gi,Ni,Ui,Vi,Hi,zi,Li,ji,qi,Wi,Xi,Yi],mc={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2},gc=function(t,e){var i=this;void 0===t&&(t="shape"),void 0===e&&(e={}),this.boundingBox=new r.Box3,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=t,this.parameters=v(e,mc),fc.forEach((function(t){Object.keys(t.fields).forEach((function(e){i._primitiveData[t.getShapeKey(e)]=[]})),i._primitiveData[t.getShapeKey("name")]=[]}))},yc={center:{configurable:!0},type:{configurable:!0}};gc.prototype.addBuffer=function(t){this.bufferList.push(t);var e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this},gc.prototype.addMesh=function(t,e,r,i,o){var n;t=E(t),e=E(e),Array.isArray(r)&&(r=k(r,t.length)),i&&(i=E(i)),n=void 0===i||0==i.length?{position:t,color:e,index:r}:{position:t,color:e,index:r,normal:i};var a=new Cn(this,Object.assign({serial:this.meshCount,name:o},n)),s=new ya(Object.assign({picking:a},n));return this.bufferList.push(s),dc.setFromArray(t),this.boundingBox.union(dc),this.meshCount+=1,this},gc.prototype.addSphere=function(t,e,r,i){return Li.objectToShape(this,{position:t,color:e,radius:r,name:i}),this},gc.prototype.addEllipsoid=function(t,e,r,i,o,n){return Hi.objectToShape(this,{position:t,color:e,radius:r,majorAxis:i,minorAxis:o,name:n}),this},gc.prototype.addTorus=function(t,e,r,i,o,n){return Wi.objectToShape(this,{position:t,color:e,radius:r,majorAxis:i,minorAxis:o,name:n}),this},gc.prototype.addCylinder=function(t,e,r,i,o){return Vi.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:o}),this},gc.prototype.addCone=function(t,e,r,i,o){return Ui.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:o}),this},gc.prototype.addArrow=function(t,e,r,i,o){return Gi.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:o}),this},gc.prototype.addBox=function(t,e,r,i,o,n){return Ni.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:o,name:n}),this},gc.prototype.addOctahedron=function(t,e,r,i,o,n){return zi.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:o,name:n}),this},gc.prototype.addTetrahedron=function(t,e,r,i,o,n){return ji.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:o,name:n}),this},gc.prototype.addText=function(t,e,r,i){return qi.objectToShape(this,{position:t,color:e,size:r,text:i}),this},gc.prototype.addPoint=function(t,e,r){return Xi.objectToShape(this,{position:t,color:e,name:r}),this},gc.prototype.addWideline=function(t,e,r,i,o){return this.parameters.linewidth=i,Yi.objectToShape(this,{position1:t,position2:e,color:r,name:o}),this},gc.prototype.addLabel=function(t,e,r,i){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,r,i)},gc.prototype.getBufferList=function(){var t=this,e=[];return fc.forEach((function(r){t._primitiveData[r.getShapeKey("color")].length&&e.push(r.bufferFromShape(t,t.parameters))})),this.bufferList.concat(e)},gc.prototype.dispose=function(){var t=this;this.bufferList.forEach((function(t){t.dispose()})),this.bufferList.length=0,fc.forEach((function(e){Object.keys(e.fields).forEach((function(r){t._primitiveData[e.getShapeKey(r)].length=0})),t._primitiveData[e.getShapeKey("name")].length=0}))},yc.center.get=function(){return this._center||(this._center=this.boundingBox.getCenter(new r.Vector3)),this._center},yc.type.get=function(){return"Shape"},Object.defineProperties(gc.prototype,yc);var vc=function(t){function e(e,r,i){Array.isArray(e)||(e=[e]),t.call(this,e,r,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){t.prototype.init.call(this,e),this.build()},e.prototype.create=function(){this.bufferList.push.apply(this.bufferList,this.buffer)},e.prototype.attach=function(t){var e=this;this.bufferList.forEach((function(t){e.viewer.add(t),t.setParameters(e.getBufferParams())})),this.setVisibility(this.visible),t()},e}(ai),bc=new r.Matrix4,xc=new r.Matrix3;var _c=function(t){function e(e,r,i){void 0===r&&(r={}),t.call(this,function(t,e){var r,i=e.attributes.position.array,o=e.index?e.index.array:void 0,n=t.position.length/3,a=i.length/3,s=n*a,c=new Float32Array(3*s),u=new Float32Array(3*s),l=new Float32Array(3*s);return o&&(r=k(n*o.length,s)),{position:c,color:l,index:r,normal:u,primitiveId:t.primitiveId||Ve(n,a),picking:t.picking}}(e,i),r),this.updateNormals=!1;var o=i.attributes.position.array,n=i.attributes.normal.array,a=i.index?i.index.array:void 0;this.geoPosition=o,this.geoNormal=n,this.geoIndex=a,this.positionCount=e.position.length/3,this.geoPositionCount=o.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);var s=this.geometry.attributes;if(this.meshPosition=s.position.array,this.meshColor=s.color.array,this.meshNormal=s.normal.array,this.setAttributes(e),a){var c=this.geometry.getIndex();if(!c)return void qt.error("Index is null");this.meshIndex=c.array,this.makeIndex()}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setAttributes=function(t,e){void 0===t&&(t={}),void 0===e&&(e=!1);var r,i,o,n,a,s,c,u,l,h=this.geometry.attributes,p=this.updateNormals;t.position&&(r=t.position,o=this.geoPosition,c=this.meshPosition,a=this.transformedGeoPosition,h.position.needsUpdate=!0,(p||e)&&(n=this.geoNormal,l=this.meshNormal,s=this.transformedGeoNormal,h.normal.needsUpdate=!0)),t.color&&(i=t.color,u=this.meshColor,h.color.needsUpdate=!0);for(var d=this.positionCount,f=this.geoPositionCount,m=0;m 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Cc=function(t){function e(e,r,i){void 0===i&&(i={}),t.call(this,r,i),this.index=k(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:je(this.size)})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={attributeSize:{configurable:!0},indexSize:{configurable:!0}};return r.attributeSize.get=function(){return this.size*this.mappingSize},r.indexSize.get=function(){return this.size*this.mappingIndicesSize},e.prototype.addAttributes=function(e){var r={};for(var i in e){var o=e[i];r[i]={type:o.type,value:null}}t.prototype.addAttributes.call(this,r)},e.prototype.getAttributeIndex=function(t){return 3*t*this.mappingSize},e.prototype.setAttributes=function(t){t&&!t.position&&t.position1&&t.position2&&(t.position=$e(t.position1,t.position2));var e,r,i,o,n,a,s,c=this.size,u=this.mappingSize,l=this.geometry.attributes;for(var h in t)if("index"!==h&&"picking"!==h){r=t[h],i=(e=l[h]).itemSize,o=e.array;for(var p=0;p0&&this.parameters.alphaTest<=1&&(r.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),r},e.prototype.setUniforms=function(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.tex&&this.tex.dispose()},Object.defineProperties(e.prototype,i),e}(ma);oe.add("point",Bc);var Rc=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof ca?(this.surface=void 0,this.volume=new Xa(e)):(this.surface=e,this.volume=void 0),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.colorScheme=y(r.colorScheme,"uniform"),r.colorValue=y(r.colorValue,14540253),this.thresholdType=y(r.thresholdType,"sigma"),this.thresholdMin=y(r.thresholdMin,2),this.thresholdMax=y(r.thresholdMax,1/0),this.thresholdOut=y(r.thresholdOut,!1),this.dotType=y(r.dotType,"point"),this.radius=y(r.radius,.1),this.scale=y(r.scale,1),this.pointSize=y(r.pointSize,1),this.sizeAttenuation=y(r.sizeAttenuation,!0),this.sortParticles=y(r.sortParticles,!1),this.useTexture=y(r.useTexture,!1),this.alphaTest=y(r.alphaTest,.5),this.forceTransparent=y(r.forceTransparent,!1),this.edgeBleach=y(r.edgeBleach,0),t.prototype.init.call(this,r),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach((function(t){e.viewer.add(t)})),this.setVisibility(this.visible),t()},e.prototype.create=function(){var t={};if(this.volume){var e,r,i=this.volume;"sigma"===this.thresholdType?(e=i.getValueForSigma(this.thresholdMin),r=i.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,r=this.thresholdMax),i.setFilter(e,r,this.thresholdOut),Object.assign(t,{position:i.getDataPosition(),color:i.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:i.getDataSize(this.radius,this.scale),picking:i.getDataPicking()})}else{var o=this.surface;Object.assign(t,{position:o.getPosition(),color:o.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:o.getSize(this.radius,this.scale),picking:o.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new kc(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Bc(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)},e.prototype.update=function(t){if(void 0===t&&(t={}),0!==this.bufferList.length){var e={};t.color&&(this.volume?Object.assign(e,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(e,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?Object.assign(e,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(e,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(e)}},e.prototype.setParameters=function(e,r,i){return void 0===r&&(r={}),e&&void 0!==e.thresholdType&&this.volume instanceof ca&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=parseFloat(e.radiusType),r.radius=!0,"sphere"!==this.dotType||Ut&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(r.radius=!0,"sphere"!==this.dotType||Ut&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(r.scale=!0,"sphere"!==this.dotType||Ut&&!this.disableImpostor||(i=!0)),t.prototype.setParameters.call(this,e,r,i),this},e}(ai);ee.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),ee.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");var Fc=new Uint16Array([0,1,2,1,3,2]),Ec=new Float32Array([0,1,0,0,1,1,1,0]),$c=Object.assign({filter:"nearest",forceTransparent:!0},da),Lc=Object.assign({filter:{updateShader:!0,uniform:!0}},fa),Nc=function(t){function e(e,i){t.call(this,{position:e.position,index:Fc,picking:e.picking},i),this.parameterTypes=Lc,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";var o=e.imageData,n=e.width,a=e.height,s=new r.DataTexture(o,n,a);s.flipY=!0,this.tex=s;for(var c=o.length,u=new Uint8Array(c),l=0;l>16&255,u[l+1]=h>>8&255,u[l+2]=255&h}var p=new r.DataTexture(u,n,a);p.flipY=!0,p.minFilter=r.NearestFilter,p.magFilter=r.NearestFilter,this.pickingTex=p,this.addUniforms({map:{value:s},pickingMap:{value:p},mapSize:{value:new r.Vector2(n,a)}}),this.geometry.setAttribute("uv",new r.BufferAttribute(Ec,2))}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={defaultParameters:{configurable:!0}};return i.defaultParameters.get=function(){return $c},e.prototype.getDefines=function(e){var r=t.prototype.getDefines.call(this,e),i=this.parameters.filter;return i.startsWith("cubic")&&(r.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?r.BSPLINE_FILTER=1:i.endsWith("catmulrom")?r.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(r.MITCHELL_FILTER=1)),r},e.prototype.updateTexture=function(){var t=this.tex,e=this.parameters.filter;e.startsWith("cubic")?(t.minFilter=r.NearestFilter,t.magFilter=r.NearestFilter):"linear"===e?(t.minFilter=r.LinearFilter,t.magFilter=r.LinearFilter):(t.minFilter=r.NearestFilter,t.magFilter=r.NearestFilter),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this),this.updateTexture();var e=this.material;e.uniforms.map.value=this.tex,e.blending=r.NormalBlending,e.needsUpdate=!0;var i=this.wireframeMaterial;i.uniforms.map.value=this.tex,i.blending=r.NormalBlending,i.needsUpdate=!0;var o=this.pickingMaterial;o.uniforms.map.value=this.tex,o.uniforms.pickingMap.value=this.pickingTex,o.blending=r.NormalBlending,o.needsUpdate=!0},e.prototype.setUniforms=function(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},Object.defineProperties(e.prototype,i),e}(ma),zc=function(t,e){var r=e||{};this.dimension=y(r.dimension,"x"),this.positionType=y(r.positionType,"percent"),this.position=y(r.position,30),this.thresholdType=y(r.thresholdType,"sigma"),this.thresholdMin=y(r.thresholdMin,-1/0),this.thresholdMax=y(r.thresholdMax,1/0),this.normalize=y(r.normalize,!1),this.volume=t};zc.prototype.getPositionFromCoordinate=function(t){var e,i=this.dimension,o=this.volume,n=o.matrix,a=(new r.Vector3).setFromMatrixPosition(n)[i],s=(new r.Vector3).setFromMatrixScale(n)[i];return e="x"===i?o.nx:"y"===i?o.ny:o.nz,Math.round(((t-a)/(e/100)+1)/s)},zc.prototype.getData=function(t){t=t||{};var e,i=this.volume,o=i.data,n=i.matrix;function a(t){return Math.round(t/100*(e-1))}function s(t,e,r,o){return 3*(r*i.ny*i.nx+e*i.nx+t)+o}e="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;var c,u,l,h,p,d=new Float32Array(12),f=new r.Vector3,m=0,g=0,y=0,v=i.nx,b=i.ny,x=i.nz;function _(t,e,r,i){f.set(t,e,r).applyMatrix4(n).toArray(d,i)}"x"===this.dimension?(l=a(i.nx),h=i.ny-1,p=i.nz-1,c=i.nz,u=i.ny,v=(m=l)+1,_(l,0,0,0),_(l,h,0,3),_(l,0,p,6),_(l,h,p,9)):"y"===this.dimension?(l=i.nx-1,h=a(i.ny),p=i.nz-1,c=i.nz,u=i.nx,b=(g=h)+1,_(0,h,0,0),_(l,h,0,3),_(0,h,p,6),_(l,h,p,9)):"z"===this.dimension&&(l=i.nx-1,h=i.ny-1,p=a(i.nz),c=i.nx,u=i.ny,x=(y=p)+1,_(0,0,p,0),_(0,h,p,3),_(l,0,p,6),_(l,h,p,9));var w,A,S=0,C=0,P=new Uint8Array(c*u*4),I=new Float32Array(c*u);"sigma"===this.thresholdType?(w=i.getValueForSigma(this.thresholdMin),A=i.getValueForSigma(this.thresholdMax)):(w=this.thresholdMin,A=this.thresholdMax);var O=Object.assign({},t.colorParams,{volume:i});this.normalize&&(O.domain=[0,1]);var M,k=Zt.getScheme(O),D=new Float32Array(3),T=k.getScale(),B=0,R=0;if(this.normalize){B=1/0,M=-1/0;for(var F=g;FM&&(M=L)}R=M-B}for(var N=g;Nw&&G0?this.list[0]:void 0},Jc.prototype.forEach=function(t){return this.list.forEach(t),this},Jc.prototype.dispose=function(){return this.forEach((function(t){return t.dispose()}))},Object.defineProperties(Jc.prototype,tu);var eu=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setParameters=function(t){return this.forEach((function(e){return e.setParameters(t)}))},e.prototype.setVisibility=function(t){return this.forEach((function(e){return e.setVisibility(t)}))},e.prototype.setSelection=function(t){return this.forEach((function(e){return e.setSelection(t)}))},e.prototype.setColor=function(t){return this.forEach((function(e){return e.setColor(t)}))},e.prototype.update=function(t){return this.forEach((function(e){return e.update(t)}))},e.prototype.build=function(t){return this.forEach((function(e){return e.build(t)}))},e.prototype.dispose=function(t){return this.forEach((function(t){return t.dispose()}))},e}(Jc),ru=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},Gc),iu=function(t){function e(e,r,i){var n=this;void 0===i&&(i={}),t.call(this,e,Object.assign({name:r.name},i)),this.trajectory=r,this.signals=Object.assign(this.signals,{frameChanged:new o.Signal,playerChanged:new o.Signal,countChanged:new o.Signal,parametersChanged:new o.Signal}),r.signals.frameChanged.add((function(t){n.signals.frameChanged.dispatch(t)})),r.signals.playerChanged.add((function(t){n.signals.playerChanged.dispatch(t)})),r.signals.countChanged.add((function(t){n.signals.countChanged.dispatch(t)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultParameters:{configurable:!0},type:{configurable:!0}};return r.defaultParameters.get=function(){return ru},r.type.get=function(){return"trajectory"},e.prototype.setFrame=function(t){this.trajectory.setFrame(t)},e.prototype.setParameters=function(t){void 0===t&&(t={}),this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)},e.prototype.dispose=function(){this.trajectory.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(Uc),ou=function(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1},nu={type:{configurable:!0}};nu.type.get=function(){return"Frames"},Object.defineProperties(ou.prototype,nu);var au=function(t,e){var i,o;if(this.A=new Ln(3,3),this.W=new Ln(1,3),this.U=new Ln(3,3),this.V=new Ln(3,3),this.VH=new Ln(3,3),this.R=new Ln(3,3),this.tmp=new Ln(3,3),this.c=new Ln(3,3),t instanceof hc)i=t.atomCount;else{if(!(t instanceof Float32Array))return;i=t.length/3}if(e instanceof hc)o=e.atomCount;else{if(!(e instanceof Float32Array))return;o=e.length/3}var n=Math.min(i,o),a=new Ln(3,n),s=new Ln(3,n);this.coords1t=new Ln(n,3),this.coords2t=new Ln(n,3),this.transformationMatrix=new r.Matrix4,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,a,n,!1),this.prepCoords(e,s,n,!1),this._superpose(a,s)};au.prototype._superpose=function(e,r){var i,o,n,a,s,c,u,l,h,p,d,f,m,g,y,v,b,x,_,w,A,S;this.mean1=Vn(e),this.mean2=Vn(r),Gn(e,this.mean1),Gn(r,this.mean2),Nn(this.coords1t,e),Nn(this.coords2t,r),zn(this.A,this.coords2t,this.coords1t),Wn(this.A,this.W,this.U,this.V),i=this.V,o=this.VH,n=i.data,a=o.data,s=n[4],c=n[8],u=n[5],l=n[7],h=n[0],p=h*s,d=h*u,f=n[3],m=n[1],g=f*m,y=n[2],v=f*y,b=n[6],w=1/(p*c-d*l-g*c+v*l+(x=b*m)*u-(_=b*y)*s),a[0]=(s*c-u*l)*w,a[1]=-(m*c-y*l)*w,a[2]=-(-m*u+y*s)*w,a[3]=-(f*c-u*b)*w,a[4]=(h*c-_)*w,a[5]=-(d-v)*w,a[6]=-(-f*l+s*b)*w,a[7]=-(h*l-x)*w,a[8]=(p-g)*w,jn(this.R,this.U,this.VH),A=this.R,(S=A.data)[0]*S[4]*S[8]-S[0]*S[5]*S[7]-S[3]*S[1]*S[8]+S[3]*S[2]*S[7]+S[6]*S[1]*S[5]-S[6]*S[2]*S[4]<0&&(t.Debug&&qt.log("R not a right handed system"),jn(this.tmp,this.c,this.VH),jn(this.R,this.U,this.tmp));var C=new Ln(4,4),P=new Ln(4,4),I=new Ln(4,4),O=new Ln(4,4),M=new Ln(4,4),k=new Ln(4,4),D=this.R.data,T=this.mean1,B=this.mean2;O.data.set([1,0,0,-T[0],0,1,0,-T[1],0,0,1,-T[2],0,0,0,1]),M.data.set([D[0],D[1],D[2],0,D[3],D[4],D[5],0,D[6],D[7],D[8],0,0,0,0,1]),k.data.set([1,0,0,B[0],0,1,0,B[1],0,0,1,B[2],0,0,0,1]),Nn(P,O),zn(C,M,P),Nn(I,C),zn(P,k,I),Nn(C,P),this.transformationMatrix.elements=C.data},au.prototype.prepCoords=function(t,e,r,i){var o=0,n=e.data,a=3,s=3*r;if(i&&(s=4*r,a=4),t instanceof hc)t.eachAtom((function(t){o=r)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),i.hasFrame(this._currentFrame)){this._currentStep+=1;var o=this._currentStep/(this.parameters.interpolateStep+1),n=this._currentFrame,a=n[0],s=n[1],c=n[2],u=n[3];i.setFrameInterpolated(a,s,c,u,o,this.parameters.interpolateType),this._previousTime=this._currentTime}else i.loadFrame(this._currentFrame);else{var l=this._next();i.hasFrame(l)?(i.setFrame(l),this._previousTime=this._currentTime):i.loadFrame(l)}window.requestAnimationFrame(this._animate)}},cu.prototype._next=function(){var t,e=this.parameters;return((t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step)>e.end||t=t.end?r=t.start:"backward"===t.direction&&e<=t.start&&(r=t.end),this.traj.setFrame(r),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}},cu.prototype.pause=function(){this._run=!1,this.signals.haltedRunning.dispatch()},cu.prototype.stop=function(){this.pause(),this.traj.setFrame(this.parameters.start)},Object.defineProperties(cu.prototype,uu);var lu=function(t,e,r){var i=this;void 0===r&&(r={}),this.signals={countChanged:new o.Signal,frameChanged:new o.Signal,playerChanged:new o.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=y(r.deltaTime,0),this.timeOffset=y(r.timeOffset,0),this.centerPbc=y(r.centerPbc,!1),this.removePbc=y(r.removePbc,!1),this.removePeriodicity=y(r.removePeriodicity,!1),this.superpose=y(r.superpose,!1),this.name=t.replace(/^.*[\\/]/,""),this.trajPath=t,this.selection=new Pt(y(r.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((function(){i.selectionIndices=i.structure.getAtomIndices(i.selection),i._resetCache(),i._saveInitialCoords(),i.setFrame(i._currentFrame)}))},hu={frameCount:{configurable:!0},currentFrame:{configurable:!0}};hu.frameCount.get=function(){return this._frameCount},hu.currentFrame.get=function(){return this._currentFrame},lu.prototype._init=function(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new cu(this))},lu.prototype._loadFrameCount=function(){},lu.prototype.setStructure=function(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new Pt("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)},lu.prototype._saveInitialCoords=function(){var t=this;this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(function(){return t._saveInitialCoords()}))},lu.prototype._saveStructureCoords=function(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position},lu.prototype.setSelection=function(t){return this.selection.setString(t),this},lu.prototype._getIndices=function(t){var e=0,r=t.test,i=[];return r&&this.structure.eachAtom((function(t){r(t)&&i.push(e),e+=1})),i},lu.prototype._makeSuperposeCoords=function(){var t=3*this.selectionIndices.length;this.coords1=new Float32Array(t),this.coords2=new Float32Array(t);for(var e=this.initialCoords,r=this.coords2,i=0;i0&&this.centerPbc){var o=[e[0],e[4],e[8]],n=function(t,e,r){return[Ee(e,r[0],3,0,t),Ee(e,r[1],3,1,t),Ee(e,r[2],3,2,t)]}(this.backboneIndices,r,o);!function(t,e,r){if(0!==r[0]&&0!==r[8]&&0!==r[4])for(var i=t.length,o=r[0],n=r[1],a=r[2],s=-e[0]+o+o/2,c=-e[1]+n+n/2,u=-e[2]+a+a/2,l=0;l.5&&(t[o+n]-=e[3*n+n]*Math.round(a))}}}(r,e,a)}this.removePbc&&function(t,e){if(0!==e[0]&&0!==e[8]&&0!==e[4]){for(var r=t.length,i=3;i.9*e[3*o+o])if(n>0)for(var a=0;a<3;++a)t[i+a]-=e[3*o+a];else for(var s=0;s<3;++s)t[i+s]+=e[3*o+s]}}}(r,e)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(r),this.frameCache[t]=r,this.boxCache[t]=e,this.frameCacheSize+=1},lu.prototype._setFrameCount=function(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))},lu.prototype.dispose=function(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()},lu.prototype.setPlayer=function(t){this.player=t,this.signals.playerChanged.dispatch(t)},lu.prototype.getFrameTime=function(t){return this.timeOffset+t*this.deltaTime},Object.defineProperties(lu.prototype,hu);var pu=function(t){function e(e,r,i){var o=i||{};o.timeOffset=y(o.timeOffset,e.timeOffset),o.deltaTime=y(o.deltaTime,e.deltaTime),t.call(this,"",r,o),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"frames"},e.prototype._makeAtomIndices=function(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0},e.prototype._loadFrame=function(t,e){var r,i=this.frames[t];if(this.atomIndices){var o=this.atomIndices,n=o.length;r=new Float32Array(3*n);for(var a=0;a0&&(i="( "+e.join(" ) AND ( ")+" )"),new Pt(i)},i.prototype.getStructure=function(){return this.structure.getStructure()},i.prototype.eachBond=function(t,e){this.structure.eachBond(t,this.getSelection(e))},i.prototype.eachAtom=function(t,e){var r=this.getAtomProxy(),i=this.getAtomSet(e),o=this.atomStore.count;if(i.getSize()=this.V[i][o]?(e="S",this.score=this.S[i][o]):this.V[i][o]>=this.H[i][o]?(e="V",this.score=this.V[i][o]):(e="H",this.score=this.H[i][o]),t.Debug&&qt.log("Alignment: SCORE",this.score),t.Debug&&qt.log("Alignment: S, V, H",this.S[i][o],this.V[i][o],this.H[i][o]);i>0&&o>0;)"S"===e?this.S[i][o]===this.S[i-1][o-1]+r(i-1,o-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[o-1]+this.ali2,--i,--o,e="S"):this.S[i][o]===this.V[i][o]?e="V":this.S[i][o]===this.H[i][o]?e="H":(--i,--o):"V"===e?this.V[i][o]===this.V[i-1][o]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="V"):this.V[i][o]===this.S[i-1][o]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="S"):--i:"H"===e?this.H[i][o]===this.H[i][o-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[o-1]+this.ali2,--o,e="H"):this.H[i][o]===this.S[i][o-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[o-1]+this.ali2,--o,e="S"):--o:qt.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;o>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[o-1]+this.ali2,--o;t.Debug&&qt.timeEnd("Alignment.trace"),t.Debug&&qt.log([this.ali1,this.ali2])};var wu=Object.assign({sele:"",defaultAssembly:""},Kc),Au=function(t){function e(e,r,i){var n,a,s,c,u,l=this;void 0===i&&(i={}),t.call(this,e,r,Object.assign({name:r.name},i)),this.structure=r,this.trajList=[],this.signals=Object.assign(this.signals,{trajectoryAdded:new o.Signal,trajectoryRemoved:new o.Signal,defaultAssemblyChanged:new o.Signal}),this.initSelection(this.parameters.sele),this.pickBuffer=(n=4,a=0,s=0,c=[],{has:function(t){return-1!==c.indexOf(t)},get:function(t){return c[t]},push:function(t){c[a]=t,a=(n+a+1)%n,++s},get count(){return s},get data(){return c.slice(0,Math.min(s,n))},clear:function(){s=0,a=0,c.length=0}}),this.pickDict=(u={},{has:function(t){return void 0!==u[JSON.stringify(t)]},add:function(t,e){u[JSON.stringify(t)]=e},del:function(t){delete u[JSON.stringify(t)]},get values(){return Object.keys(u).map((function(t){return u[t]}))}}),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Xt.opacity,color:Xt.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Xt,!0),this.angleRepresentation=this.addRepresentation("angle",Xt,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Xt,!0),this.measureRepresentations=new eu([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((function(){l.updateRepresentations({position:!0})}))}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultParameters:{configurable:!0},type:{configurable:!0}};return r.defaultParameters.get=function(){return wu},r.type.get=function(){return"structure"},e.prototype.initSelection=function(t){var e=this;this.selection=new Pt(t),this.structureView=new gu(this.structure,this.selection),this.selection.signals.stringChanged.add((function(){e.structureView.setSelection(e.selection),e.rebuildRepresentations(),e.rebuildTrajectories()}))},e.prototype.setSelection=function(t){return this.parameters.sele=t,this.selection.setString(t),this},e.prototype.setDefaultAssembly=function(t){if(void 0===this.structure.biomolDict[t]&&(t=""),this.parameters.defaultAssembly!==t){var e={defaultAssembly:t};this.reprList.forEach((function(t){return t.setParameters(e)})),this.measureRepresentations.setParameters(e),this.parameters.defaultAssembly=t,this.signals.defaultAssemblyChanged.dispatch(t)}return this},e.prototype.rebuildRepresentations=function(){this.reprList.forEach((function(t){t.build()})),this.measureRepresentations.build()},e.prototype.rebuildTrajectories=function(){var t=this;this.trajList.forEach((function(e){e.trajectory.setStructure(t.structureView)}))},e.prototype.updateRepresentations=function(e){t.prototype.updateRepresentations.call(this,e),this.measureRepresentations.update(e)},e.prototype.updateRepresentationMatrices=function(){t.prototype.updateRepresentationMatrices.call(this),this.measureRepresentations.setParameters({matrix:this.matrix})},e.prototype.addRepresentation=function(t,e,r){var i=this;void 0===e&&(e={}),void 0===r&&(r=!1),e.defaultAssembly=this.parameters.defaultAssembly;var o=this._addRepresentation(t,this.structureView,e,r);return r||o.signals.parametersChanged.add((function(){return i.measureUpdate()})),o},e.prototype.addTrajectory=function(t,e){void 0===t&&(t=""),void 0===e&&(e={});var r=function(t,e,r){return t&&t instanceof ou?new pu(t,e,r):!t&&e.frames?new du(t,e,r):t&&"function"==typeof t?new mu(t,e,r):new fu(t,e,r)}(t,this.structureView,e),i=new iu(this.stage,r,e);return this.trajList.push(i),this.signals.trajectoryAdded.dispatch(i),i},e.prototype.removeTrajectory=function(t){var e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)},e.prototype.dispose=function(){this.trajList.slice().forEach((function(t){return t.dispose()})),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),t.prototype.dispose.call(this)},e.prototype.autoView=function(t,e){"number"==typeof t&&(e=t,t=""),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),y(e,0))},e.prototype.getBoxUntransformed=function(t){return t?this.structureView.getBoundingBox(new Pt(t)):this.structureView.boundingBox},e.prototype.getCenterUntransformed=function(t){return t&&"string"==typeof t?this.structure.atomCenter(new Pt(t)):this.structure.center},e.prototype.superpose=function(t,e,r,i){return _u(this.structureView,t.structureView,e,r,i),this.updateRepresentations({position:!0}),this},e.prototype.getMaxRepresentationRadius=function(t){var e=0,r=this.structure.getAtomProxy(t);return this.eachRepresentation((function(t){if(t.getVisibility()){var i=t.repr;e=Math.max(i.getAtomRadius(r),e)}})),e},e.prototype.measurePick=function(t){var e=this.pickBuffer.count;if(this.lastPick===t.index&&e>=1){if(e>1){var r=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,r),2===e?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((function(t){return 2===t.length}))}):3===e?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((function(t){return 3===t.length}))}):4===e&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((function(t){return 4===t.length}))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(t.index)||this.pickBuffer.push(t.index),this.lastPick=t.index;this.measureUpdate()},e.prototype.measureClear=function(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")},e.prototype.measureBuild=function(){var t=this.measureData();this.distanceRepresentation.setParameters({atomPair:t.distance}),this.angleRepresentation.setParameters({atomTriple:t.angle}),this.dihedralRepresentation.setParameters({atomQuad:t.dihedral})},e.prototype.measureUpdate=function(){var t=this,e=this.pickBuffer.data,r={};e.forEach((function(e){var i=Math.max(.1,t.getMaxRepresentationRadius(e));r[e]=i*(2.3-q(.1,2,i))})),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:r})},e.prototype.measureData=function(){var t=this.pickDict.values;return{distance:t.filter((function(t){return 2===t.length})),angle:t.filter((function(t){return 3===t.length})),dihedral:t.filter((function(t){return 4===t.length}))}},e.prototype.removeAllMeasurements=function(t){var e=this.pickDict,r=e.values,i=function(t){r.filter((function(e){return e.length===t})).forEach((function(t){return e.del(t.slice().sort())}))};(!t||1&t)&&i(2),(!t||2&t)&&i(3),(!t||4&t)&&i(4),this.measureBuild()},e.prototype.removeMeasurement=function(t){this.pickDict.del(t.slice().sort()),this.measureBuild()},e.prototype.addMeasurement=function(t){if(!(t.length<2||t.length>4)){var e=t.slice().sort();this.pickDict.has(e)||this.pickDict.add(e,t),this.measureBuild()}},Object.defineProperties(e.prototype,r),e}(Zc);ie.add("structure",Au),ie.add("structureview",Au);var Su=function(t){function e(e,r,i){void 0===i&&(i={}),t.call(this,e,r,Object.assign({name:r.name},i)),this.surface=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"surface"},e.prototype.addRepresentation=function(t,e){return void 0===e&&(e={}),this._addRepresentation(t,this.surface,e)},e.prototype.getBoxUntransformed=function(){return this.surface.boundingBox},e.prototype.getCenterUntransformed=function(){return this.surface.center},e.prototype.dispose=function(){this.surface.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(Zc);ie.add("surface",Su);var Cu=function(t){function e(e,r,i){void 0===i&&(i={}),t.call(this,e,r,Object.assign({name:r.name},i)),this.volume=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"volume"},e.prototype.addRepresentation=function(t,e){return void 0===e&&(e={}),this._addRepresentation(t,this.volume,e)},e.prototype.getBoxUntransformed=function(){return this.volume.boundingBox},e.prototype.getCenterUntransformed=function(){return this.volume.center},e.prototype.dispose=function(){this.volume.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(Zc);ie.add("volume",Cu);var Pu=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.addRepresentation=function(t,e){return this.forEach((function(r){return r.addRepresentation(t,e)}))},e.prototype.autoView=function(t){return this.forEach((function(e){return e.autoView(t)}))},e}(Jc);function Iu(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}var Ou=new r.Vector3,Mu={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"},ku=function(t,e){void 0===e&&(e={}),this.signals={parametersChanged:new o.Signal,fullscreenChanged:new o.Signal,componentAdded:new o.Signal,componentRemoved:new o.Signal,clicked:new o.Signal,hovered:new o.Signal},this.tasks=new we,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new fr(t),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new yr(this.viewer.renderer.domElement),this.viewerControls=new Ur(this),this.trackballControls=new kr(this),this.pickingControls=new Fr(this),this.animationControls=new ii(this),this.mouseControls=new Oa(this),this.keyControls=new Da(this),this.pickingBehavior=new Ta(this),this.mouseBehavior=new Ba(this),this.animationBehavior=new Ra(this),this.keyBehavior=new Ea(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=v(e,Mu),this.setParameters(this.parameters),this.viewer.animate())};ku.prototype.setParameters=function(t){void 0===t&&(t={}),b(this.parameters,t);var e=t,r=this.parameters,i=this.viewer,o=this.trackballControls;return void 0!==e.quality&&this.setQuality(r.quality),void 0!==e.impostor&&this.setImpostor(r.impostor),void 0!==e.rotateSpeed&&(o.rotateSpeed=r.rotateSpeed),void 0!==e.zoomSpeed&&(o.zoomSpeed=r.zoomSpeed),void 0!==e.panSpeed&&(o.panSpeed=r.panSpeed),void 0!==e.mousePreset&&this.mouseControls.preset(r.mousePreset),this.mouseObserver.setParameters({hoverTimeout:r.hoverTimeout}),i.setClip(r.clipNear,r.clipFar,r.clipDist,r.clipMode,r.clipScale),i.setFog(void 0,r.fogNear,r.fogFar),i.setCamera(r.cameraType,r.cameraFov,r.cameraEyeSep),i.setSampling(r.sampleLevel),i.setBackground(r.backgroundColor),i.setLight(r.lightColor,r.lightIntensity,r.ambientColor,r.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this},ku.prototype.log=function(t){console.log("STAGE LOG",t),this.logList.push(t)},ku.prototype.getParameters=function(){return Object.assign({},this.parameters)},ku.prototype.defaultFileRepresentation=function(e){if(e instanceof Au){var r,i,o;e.setSelection("/0");var n=e.structure;if(n.biomolDict.BU1){var a=n.biomolDict.BU1;r=a.getAtomCount(n),i=a.getResidueCount(n),o=a.getInstanceCount(),e.setDefaultAssembly("BU1")}else r=n.getModelProxy(0).atomCount,i=n.getModelProxy(0).residueCount,o=1;var s=r;jt&&(s*=4);var c=n.atomStore.count/n.residueStore.count<2;c&&(s*=10);var u="chainname",l="RdYlBu",h=!1;if(1===n.getChainnameCount(new Pt("polymer and /0"))&&(u="residueindex",l="Spectral",h=!0),t.Debug&&console.log(s,r,o,c),i/o<4)e.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(o>5&&s>15e3||s>7e5){var p=Math.min(2,Math.max(.1,6e3/(s/o)));c&&(p=Math.min(p,.5)),e.addRepresentation("surface",{colorScheme:u,colorScale:l,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:p,useWorker:!1})}else s>25e4?e.addRepresentation("backbone",{colorScheme:u,colorScale:l,colorReverse:h,lineOnly:!0}):s>1e5?e.addRepresentation("backbone",{colorScheme:u,colorScale:l,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):s>8e4?e.addRepresentation("backbone",{colorScheme:u,colorScale:l,colorReverse:h,radiusScale:2}):(e.addRepresentation("cartoon",{colorScheme:u,colorScale:l,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),s<5e4&&e.addRepresentation("base",{colorScheme:u,colorScale:l,colorReverse:h,quality:"auto"}),e.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));e.structure.frames.length&&e.addTrajectory()}else(e instanceof Su||e instanceof Cu)&&e.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)},ku.prototype.loadFile=function(t,e){var r=this;void 0===e&&(e={});var i=Object.assign({},this.defaultFileParams,e),o=de(t).name;this.tasks.increment(),this.log("loading file '"+o+"'");var n=y(i.ext,de(t).ext);return(te.isTrajectory(n)?Promise.reject(new Error("loadFile: ext '"+n+"' is a trajectory and must be loaded into a structure component")):me(t,i)).then((function(t){r.log("loaded '"+o+"'");var e=r.addComponentFromObject(t,i);return i.defaultRepresentation&&r.defaultFileRepresentation(e),r.tasks.decrement(),e}),(function(t){r.tasks.decrement();var e="error loading file: '"+t+"'";throw r.log(e),e}))},ku.prototype.loadScript=function(t){var e=this,r=de(t).name;return this.log("loading script '"+r+"'"),me(t).then((function(t){e.tasks.increment(),e.log("running script '"+r+"'"),t.run(e).then((function(){e.tasks.decrement(),e.log("finished script '"+r+"'")})),e.log("called script '"+r+"'")}),(function(t){e.tasks.decrement();var i="errored script '"+r+"' \""+t+'"';throw e.log(i),i}))},ku.prototype.addComponent=function(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):qt.warn("Stage.addComponent: no component given")},ku.prototype.addComponentFromObject=function(t,e){void 0===e&&(e={});var r=ie.get(t.type);if(r){var i=new r(this,t,e);return this.addComponent(i),i}qt.warn("no component for object type",t.type)},ku.prototype.removeComponent=function(t){var e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))},ku.prototype.removeAllComponents=function(){var t=this;this.compList.slice().forEach((function(e){return t.removeComponent(e)}))},ku.prototype.handleResize=function(){this.viewer.handleResize()},ku.prototype.setSize=function(t,e){var r=this.viewer.container;r!==document.body&&(void 0!==t&&(r.style.width=t),void 0!==e&&(r.style.height=e),this.handleResize())},ku.prototype.toggleFullscreen=function(t){if(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled){var e=this;t=t||this.viewer.container,this.lastFullscreenElement=t,r()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(t.dataset.normalWidth=t.style.width||"",t.dataset.normalHeight=t.style.height||"",t.style.width=window.screen.width+"px",t.style.height=window.screen.height+"px",t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){e.handleResize()}),100))}else qt.log("fullscreen mode (currently) not possible");function r(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function i(){if(!r()&&e.lastFullscreenElement){var t=e.lastFullscreenElement;t.style.width=t.dataset.normalWidth||"",t.style.height=t.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i),e.handleResize(),e.signals.fullscreenChanged.dispatch(!1)}}},ku.prototype.setSpin=function(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)},ku.prototype.setRock=function(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)},ku.prototype.toggleSpin=function(){this.setSpin(this.spinAnimation.paused)},ku.prototype.toggleRock=function(){this.setRock(this.rockAnimation.paused)},ku.prototype.getFocus=function(){var t=this.parameters;if("scene"!==t.clipMode)return 0;var e=t.clipNear;return"absolute"===t.clipScale&&(e=this.viewer.absoluteToRelative(e)),2*e},ku.prototype.setFocus=function(t){var e,r,i,o;"scene"===this.parameters.clipMode&&("relative"===this.parameters.clipScale?(i=50,o=function(t){return U(t,0,100)}(2*(r=100-(e=U(t/2,0,49.9)))-50)):(i=0,o=2*(r=e=this.viewer.relativeToAbsolute(t/2))),this.setParameters({clipNear:e,clipFar:r,fogNear:i,fogFar:o}))},ku.prototype.getZoomForBox=function(t){var e=t.getSize(Ou),r=Math.max(e.x,e.y,e.z),i=Math.min(e.x,e.y,e.z),o=r+Math.sqrt(i),n=z(this.viewer.perspectiveCamera.fov),a=this.viewer.width,s=this.viewer.height,c=s=0;s--)(o=t[s])&&(a=(n<3?o(a):n>3?o(e,r,a):o(e,r))||a);return n>3&&a&&Object.defineProperty(e,r,a),a}ie.add("shape",Du);var Bu=function(t){function e(e){var r=this;t.call(this,e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=y(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel((function(t){r.parameters.domain=[t.atomOffset,t.atomEnd],r.scalePerModel[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.index)},e}(J);Tu([Z],Bu.prototype,"atomColor",null),Zt.add("atomindex",Bu);var Ru=function(t){function e(e){if(t.call(this,e),e.scale||(this.parameters.scale="OrRd"),!e.domain){var r,i=1/0,o=-1/0;e.sele&&(r=new Pt(e.sele)),e.structure.eachAtom((function(t){var e=t.bfactor;i=Math.min(i,e),o=Math.max(o,e)}),r),this.parameters.domain=[i,o]}this.bfactorScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.bfactorScale(t.bfactor)},e}(J);Tu([Z],Ru.prototype,"atomColor",null),Zt.add("bfactor",Ru);var Fu=function(t){function e(e){var r=this;t.call(this,e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((function(t){var e=0,i={};t.eachChain((function(t){void 0===i[t.chainid]&&(i[t.chainid]=e,e+=1)})),r.parameters.domain=[0,e-1],r.chainidDictPerModel[t.index]=i,r.scalePerModel[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=this.chainidDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainid])},e}(J);Tu([Z],Fu.prototype,"atomColor",null),Zt.add("chainid",Fu);var Eu=function(t){function e(e){var r=this;t.call(this,e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((function(t){r.parameters.domain=[t.chainOffset,t.chainEnd],r.scalePerModel[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.chainIndex)},e}(J);Tu([Z],Eu.prototype,"atomColor",null),Zt.add("chainindex",Eu);var $u=function(t){function e(e){var r=this;t.call(this,e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((function(t){var e=0,i={};t.eachChain((function(t){void 0===i[t.chainname]&&(i[t.chainname]=e,e+=1)})),r.parameters.domain=[0,e-1],r.chainnameDictPerModel[t.index]=i,r.scalePerModel[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=this.chainnameDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainname])},e}(J);Tu([Z],$u.prototype,"atomColor",null),Zt.add("chainname",$u);var Lu=function(t){function e(e){t.call(this,e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});var r=e.structure.validation;r&&(this.rsrzDict=r.rsrzDict,this.rsccDict=r.rsccDict)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.resno+"";t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;var r=this.rsrzDict[e];if(void 0!==r)return this.rsrzScale(r);var i=this.rsccDict[e];return void 0!==i?this.rsccScale(i):9474192},e}(J);Tu([Z],Lu.prototype,"atomColor",null),Zt.add("densityfit",Lu);var Nu={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};var zu=function(t){function e(e){var i=this;t.call(this,e),this.delta=new r.Vector3,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);var o=[];e.structure.eachAtom((function(t){var e;if(i.charges[t.index]=(null!==(e=t).partialCharge?e.partialCharge:e.isProtein()&&(Nu[e.resname]&&Nu[e.resname][e.atomname]||Nu.backbone[e.atomname])||0)*t.occupancy,"N"===t.atomname){if(t.bondCount>=3)return;if(t.bondToElementCount(1))return;var n=function(t,e){void 0===e&&(e=new r.Vector3);var i=!1,o=!1,n=!1;return e.set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom((function(t){if(!i)return"H"===t.atomname?(e.set(t.x,t.y,t.z),void(i=!0)):void(o||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,e.sub(t)):(e.sub(t),o=!0))})),i?e:o&&n?(e.normalize(),e.multiplyScalar(1.04),e.add(t),e):void 0}(t);void 0!==n&&(o.push(n),i.hCharges.push(.25*t.occupancy))}}));var n=e.structure.getBoundingBox();n.expandByScalar(1.04),this.hStore=function(t){for(var e=t.length,r=new Float32Array(e),i=new Float32Array(e),o=new Float32Array(e),n=0;n>1&1431655765))+(i>>2&858993459))+(i>>4)&252645135)>>24}else e=this.geoDict[r]||0;return 0===e?2188972:1===e?16703627:2===e?16018755:e>=3?10813478:9474192},e}(J);Tu([Z],Hu.prototype,"atomColor",null),Zt.add("geoquality",Hu);var Wu=function(t){function e(e){t.call(this,e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(var r in xo)this.resHF[r]=xo[r][0];if(this.defaultResidueHydrophobicity=_o[0],!e.domain){var i=1/0,o=-1/0;for(var n in this.resHF){var a=this.resHF[n];i=Math.min(i,a),o=Math.max(o,a)}this.parameters.domain=[i,0,o]}this.hfScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.hfScale(this.resHF[t.resname]||this.defaultResidueHydrophobicity)},e}(J);Tu([Z],Wu.prototype,"atomColor",null),Zt.add("hydrophobicity",Wu);var qu=function(t){function e(e){t.call(this,e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.modelindexScale(t.modelIndex)},e}(J);Tu([Z],qu.prototype,"atomColor",null),Zt.add("modelindex",qu);var Xu=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){switch(t.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}},e}(J);Tu([Z],Xu.prototype,"atomColor",null),Zt.add("moleculetype",Xu);var Yu=function(t){function e(e){t.call(this,e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.occupancyScale(t.occupancy)},e}(J);Tu([Z],Yu.prototype,"atomColor",null),Zt.add("occupancy",Yu);var Ku=function(t){function e(e){t.call(this,e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.partialchargeScale(t.partialCharge||0)},e}(J);function Zu(){return 16777215*Math.random()}Tu([Z],Ku.prototype,"atomColor",null),Zt.add("partialcharge",Ku);var Qu=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return Zu()},e.prototype.volumeColor=function(){return Zu()},e.prototype.positionColor=function(){return Zu()},e}(J);Tu([Z],Qu.prototype,"atomColor",null),Tu([Z],Qu.prototype,"volumeColor",null),Tu([Z],Qu.prototype,"positionColor",null),Zt.add("random",Qu);var Ju=function(t){function e(e){t.call(this,e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});var r=e.structure.validation;r&&(this.rciDict=r.rciDict)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e="["+t.resname+"]"+t.resno;t.chainname&&(e+=":"+t.chainname);var r=this.rciDict[e];return void 0!==r?this.rciScale(r):9474192},e}(J);Tu([Z],Ju.prototype,"atomColor",null),Zt.add("randomcoilindex",Ju);var tl=function(t){function e(e){var r=this;t.call(this,e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=y(e.reverse,!0)),e.structure.eachChain((function(t){r.parameters.domain=[t.residueOffset,t.residueEnd],r.scalePerChain[t.index]=r.getScale()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerChain[t.chainIndex](t.residueIndex)},e}(J);Tu([Z],tl.prototype,"atomColor",null),Zt.add("residueindex",tl);var el={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723},rl=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return el[t.resname]||16711935},e}(J);Tu([Z],rl.prototype,"atomColor",null),Zt.add("resname",rl);var il=16711808,ol=10485888,nl=6291584,al=16762880,sl=6324479,cl=16777215,ul=11403518,ll=16580962,hl=10921722,pl=function(t){function e(e){t.call(this,e),this.residueProxy=e.structure.getResidueProxy()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.sstruc,r=this.residueProxy;return"h"===e?il:"g"===e?ol:"i"===e?nl:"e"===e||"b"===e?al:"t"===e?sl:(r.index=t.residueIndex,r.isDna()?ul:r.isRna()?ll:r.isSaccharide()?hl:r.isProtein()||"s"===e||"l"===e?cl:8421504)},e}(J);Tu([Z],pl.prototype,"atomColor",null),Zt.add("sstruc",pl);var dl=function(t){function e(e){var r,i;t.call(this,e),e.scale||(this.parameters.scale="rwb"),this.atomData=null===(r=this.parameters.data)||void 0===r?void 0:r.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e,r=null===(e=this.atomData)||void 0===e?void 0:e[t.index];return void 0!==r?this.scale(r):this.parameters.value},e.prototype.bondColor=function(t,e){var r,i=null===(r=this.bondData)||void 0===r?void 0:r[t.index];return void 0!==i?this.scale(i):this.atomProxy?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value},e}(J);Tu([Z],dl.prototype,"atomColor",null),Tu([Z],dl.prototype,"bondColor",null),Zt.add("structuredata",dl);var fl=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return this.parameters.value},e.prototype.bondColor=function(){return this.parameters.value},e.prototype.valueColor=function(){return this.parameters.value},e.prototype.volumeColor=function(){return this.parameters.value},e}(J);Tu([Z],fl.prototype,"atomColor",null),Tu([Z],fl.prototype,"bondColor",null),Tu([Z],fl.prototype,"valueColor",null),Tu([Z],fl.prototype,"volumeColor",null),Zt.add("uniform",fl);var ml=function(t){function e(e){t.call(this,e),this.valueScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.volumeColor=function(t){return this.valueScale(this.parameters.volume.data[t])},e}(J);Tu([Z],ml.prototype,"volumeColor",null),Zt.add("value",ml);var gl=function(t){function e(e){t.call(this,e),this.vec=new r.Vector3,this.valueScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.positionColor=function(t){var e=this.parameters.volume;if(!e||!e.inverseMatrix)return this.parameters.value;var r=this.vec,i=e.data,o=e.nx,n=e.ny,a=o*n;r.copy(t),r.applyMatrix4(e.inverseMatrix);var s=Math.floor(r.x),c=Math.floor(r.y),u=Math.floor(r.z),l=(u*n+c)*o+s,h=l+1,p=l+o,d=l+a,f=p+1,m=d+1,g=p+a,y=g+1,v=i[l],b=i[h],x=i[p],_=i[d],w=i[f],A=i[m],S=i[g],C=i[y],P=r.x-s,I=r.y-c,O=r.z-u,M=H(v,b,P),k=H(_,A,P),D=H(x,w,P),T=H(S,C,P),B=H(M,D,I),R=H(k,T,I),F=H(B,R,O);return this.valueScale(F)},e}(J);Tu([Z],gl.prototype,"positionColor",null),Zt.add("volume",gl);var yl=function(t){function e(e,r,i){var o=i||{};if(t.call(this,e,r,o),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:Ua.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new Pt(o.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){var n={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach((function(t){n[t]=t})),this.parameters.assembly={type:"select",options:n,rebuild:!0}}else this.parameters.assembly=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultScale:{configurable:!0}};return r.defaultScale.get=function(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}},e.prototype.init=function(e){var r=this,i=e||{};i.colorScheme=y(i.colorScheme,"element"),this.setRadius(i.radius,i),this.radiusType=y(i.radiusType,"vdw"),this.radiusData=y(i.radiusData,{}),this.radiusSize=y(i.radiusSize,1),this.radiusScale=y(i.radiusScale,1),this.assembly=y(i.assembly,"default"),this.defaultAssembly=y(i.defaultAssembly,""),"auto"===i.quality&&(i.quality=this.getQuality()),t.prototype.init.call(this,i),this.selection.signals.stringChanged.add((function(){r.build()})),this.build()},e.prototype.setRadius=function(t,e){var r=Object.keys(Ga);return"string"==typeof t&&r.includes(t.toLowerCase())?e.radiusType=t:void 0!==t&&(e.radiusType="size",e.radiusSize=t),this},e.prototype.getAssembly=function(){var t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]},e.prototype.getQuality=function(){var t,e=this.structureView,r=this.getAssembly();return t=r?r.getAtomCount(e):e.atomCount,jt&&(t*=4),e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"},e.prototype.create=function(){var t=this;if(0!==this.structureView.atomCount)if(this.structureView.hasCoords()){this.needsBuild=!1;var e=this.getAssembly();if(e)e.partList.forEach((function(e,r){var i=e.getView(t.structureView);if(0!==i.atomCount){var o=t.createData(i,r);o&&(o.sview=i,o.instanceList=e.getInstanceList(),t.dataList.push(o))}}));else{var r=this.createData(this.structureView,0);r&&(r.sview=this.structureView,this.dataList.push(r))}}else this.needsBuild=!0},e.prototype.update=function(t){var e=this;!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((function(r){r.bufferList.length>0&&e.updateData(t,r)}),this):Object.assign(this.lazyProps.what,t)},e.prototype.updateData=function(t,e){this.build()},e.prototype.getColorParams=function(){return Object.assign(Object.assign({},t.prototype.getColorParams.call(this)),{structure:this.structure})},e.prototype.getRadiusParams=function(t){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}},e.prototype.getAtomParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)},e.prototype.getBondParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)},e.prototype.getAtomRadius=function(t){return this.structureView.atomSet.isSet(t.index)?new Ua(this.getRadiusParams()).atomRadius(t):0},e.prototype.setSelection=function(t,e){return this.selection.setString(t,e),this},e.prototype.setParameters=function(e,r,i){void 0===r&&(r={}),void 0===i&&(i=!1);var o=e||{};return this.setRadius(o.radius,o),void 0===o.radiusType&&void 0===o.radiusData&&void 0===o.radiusSize&&void 0===o.radiusScale||(r.radius=!0,Ut&&!this.disableImpostor||(i=!0)),void 0!==o.defaultAssembly&&o.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===o.assembly||"default"===o.assembly)&&(i=!0),t.prototype.setParameters.call(this,o,r,i),this},e.prototype.getParameters=function(){return Object.assign(t.prototype.getParameters.call(this),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})},e.prototype.attach=function(t){var e=this.viewer,r=this.bufferList;this.dataList.forEach((function(t){t.bufferList.forEach((function(i){r.push(i),e.add(i,t.instanceList)}))})),this.setVisibility(this.visible),t()},e.prototype.clear=function(){this.dataList.length=0,t.prototype.clear.call(this)},e.prototype.dispose=function(){this.structureView.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(ai),vl=function(t){function e(e,r,i){t.call(this,e,r,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};this.labelVisible=y(r.labelVisible,!0),this.labelSize=y(r.labelSize,2),this.labelColor=y(r.labelColor,16777215),this.labelFontFamily=y(r.labelFontFamily,"sans-serif"),this.labelFontStyle=y(r.labelFontstyle,"normal"),this.labelFontWeight=y(r.labelFontWeight,"bold"),this.labelsdf=y(r.labelsdf,"Chrome"===Lt),this.labelXOffset=y(r.labelXOffset,0),this.labelYOffset=y(r.labelYOffset,0),this.labelZOffset=y(r.labelZOffset,.5),this.labelAttachment=y(r.labelAttachment,"bottom-left"),this.labelBorder=y(r.labelBorder,!1),this.labelBorderColor=y(r.labelBorderColor,"lightgrey"),this.labelBorderWidth=y(r.labelBorderWidth,.15),this.labelBackground=y(r.labelBackground,!1),this.labelBackgroundColor=y(r.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=y(r.labelBackgroundMargin,.5),this.labelBackgroundOpacity=y(r.labelBackgroundOpacity,1),this.labelFixedSize=y(r.labelFixedSize,!1),this.lineOpacity=y(r.lineOpacity,1),this.linewidth=y(r.linewidth,2),t.prototype.init.call(this,r)},e.prototype.update=function(e){e.position?this.build():t.prototype.update.call(this,e)},e.prototype.updateData=function(t,e){var i={};if(t&&!t.labelSize||Object.assign(i,{size:Ne(this.n,this.labelSize)}),!t||t.labelColor){var o=new r.Color(this.labelColor);Object.assign(i,{color:ze(this.n,o.r,o.g,o.b)})}this.textBuffer.setAttributes(i)},e.prototype.setParameters=function(e,r,i){return void 0===r&&(r={}),void 0===i&&(i=!1),e&&e.labelSize&&(r.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(r.labelColor=!0,i=!0),t.prototype.setParameters.call(this,e,r,i),e&&void 0!==e.opacity&&this.textBuffer.setParameters({opacity:1}),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this},e.prototype.setVisibility=function(e,r){return t.prototype.setVisibility.call(this,e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),r||this.viewer.requestRender(),this},e.prototype.getLabelBufferParams=function(e){return void 0===e&&(e={}),t.prototype.getBufferParams.call(this,Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))},e.prototype.getAtomRadius=function(){return 0},e}(yl);function bl(t,e){var r=t.getAtomProxy(),i=new Pt,o=e.length;if(0===o)return new Float32Array(0);var n=e[0].length,a=t.getAtomSet(),s=new Float32Array(o*n*3),c=0;return e.forEach((function(e){for(var o=!1,u=0;u 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Al={};var Sl={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024},Cl=function(t){void 0===t&&(t={}),this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=v(t,Sl);var e=this.parameters;this.radius=e.size/8,this.padding=e.size/3;var i=this.lineHeight=e.size+2*e.outline+Math.round(e.size/4),o=this.maxWidth=e.width/4,n=this.canvas=document.createElement("canvas");n.width=o,n.height=i;var a=this.context=this.canvas.getContext("2d");a.font=e.style+" "+e.variant+" "+e.weight+" "+e.size+"px "+e.font,a.fillStyle="black",a.textAlign="left",a.textBaseline="bottom",a.lineJoin="round",this.gridOuter=new Float64Array(i*o),this.gridInner=new Float64Array(i*o),this.f=new Float64Array(Math.max(i,o)),this.d=new Float64Array(Math.max(i,o)),this.z=new Float64Array(Math.max(i,o)+1),this.v=new Int16Array(Math.max(i,o)),this.data=new Uint8Array(e.width*e.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=e.width,this.canvas2.height=e.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(var s=32;s<=126;++s)this.map(String.fromCharCode(s));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new r.CanvasTexture(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0};Cl.prototype.map=function(t){var e=this.parameters;return void 0===this.mapped[t]&&(this.draw(t),this.currentX+this.scratchW>e.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>e.height&&console.warn("canvas to small"),this.mapped[t]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[t]},Cl.prototype.get=function(t){return this.mapped[t]||this.placeholder},Cl.prototype.draw=function(t){var e=this.parameters,r=this.lineHeight,i=e.outline,o=this.context,n=this.maxWidth,a=i,s=r-e.outline,c=o.measureText(t),u=Math.min(n,Math.ceil(c.width+2*a+1)),l=u*r;o.clearRect(0,0,u,r),o.fillText(t,a,s);for(var h=o.getImageData(0,0,u,r),p=h.data,d=0;d= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),ee.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var kl=Object.assign({linewidth:2},da),Dl=Object.assign({linewidth:{uniform:!0}},fa),Tl=function(t){function e(e,i){void 0===i&&(i={}),t.call(this,e,i),this.parameterTypes=Dl,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new r.Vector2},projectionMatrixInverse:{value:new r.Matrix4}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={defaultParameters:{configurable:!0}};return i.defaultParameters.get=function(){return kl},e.prototype.setParameters=function(e){t.prototype.setParameters.call(this,e)},Object.defineProperties(e.prototype,i),e}(Oc);oe.add("wideline",Tl);var Bl=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.side=y(r.side,"double"),r.opacity=y(r.opacity,.5),this.atomTriple=y(r.atomTriple,[]),this.arcVisible=y(r.arcVisible,!0),this.sectorVisible=y(r.sectorVisible,!0),this.vectorVisible=y(r.vectorVisible,!0),t.prototype.init.call(this,r)},e.prototype.createData=function(t){if(t.atomCount&&this.atomTriple.length){var e=function(t,e){return function(t){for(var e=[],r=t.length/9,i=0;i radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var jl=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Vl=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),Gl=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,"v3",e,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.mapping.get=function(){return jl},r.mappingIndices.get=function(){return Vl},r.mappingIndicesSize.get=function(){return 12},r.mappingSize.get=function(){return 6},r.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,r),e}(Cc),Ul=Object.assign({openEnded:!1},da),Hl=Object.assign({openEnded:{updateShader:!0}},fa),Wl=function(t){function e(e,i){void 0===i&&(i={}),t.call(this,e,i),this.parameterTypes=Hl,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new r.Matrix4},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={defaultParameters:{configurable:!0}};return i.defaultParameters.get=function(){return Ul},e.prototype.getDefines=function(e){var r=t.prototype.getDefines.call(this,e);return this.parameters.openEnded||(r.CAP=1),r},Object.defineProperties(e.prototype,i),e}(Gl);Object.assign({disableImpostor:!1},Ll,Ul);var ql=function(t,e){return void 0===e&&(e={}),!t.color2&&t.color&&(t.color2=t.color),!Ut||e&&e.disableImpostor?new zl(t,e):new Wl(t,e)};oe.add("cylinder",ql);var Xl=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radiusSize=y(r.radiusSize,.5),r.colorValue=y(r.colorValue,"lightgreen"),r.useInteriorColor=y(r.useInteriorColor,!0),this.showAxes=y(r.showAxes,!0),this.showBox=y(r.showBox,!1),t.prototype.init.call(this,r)},e.prototype.getPrincipalAxes=function(){var t,e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)},e.prototype.getAxesData=function(t){var e=this.getPrincipalAxes(),i=new r.Color(this.colorValue),o=0,n=0;this.showAxes&&(o+=6,n+=3),this.showBox&&(o+=8,n+=12);var a=new Float32Array(3*o),s=ze(o,i.r,i.g,i.b),c=Ne(o,this.radiusSize),u=new Float32Array(3*n),l=new Float32Array(3*n),h=ze(n,i.r,i.g,i.b),p=Ne(n,this.radiusSize),d=0;if(this.showAxes){var f=function(t,e){t.toArray(a,2*d),e.toArray(a,2*d+3),t.toArray(u,d),e.toArray(l,d),d+=3};f(e.begA,e.endA),f(e.begB,e.endB),f(e.begC,e.endC)}if(this.showBox){var m=new r.Vector3,g=e.getProjectedScaleForAtoms(t),y=g.d1a,v=g.d2a,b=g.d3a,x=g.d1b,_=g.d2b,w=g.d3b,A=2*d,S=function(t,r,i){m.copy(e.center).addScaledVector(e.normVecA,t).addScaledVector(e.normVecB,r).addScaledVector(e.normVecC,i),m.toArray(a,A),A+=3};S(y,v,b),S(y,v,w),S(y,_,w),S(y,_,b),S(x,_,w),S(x,_,b),S(x,v,b),S(x,v,w);var C=d,P=function(t,e){m.fromArray(a,2*d+3*t).toArray(u,C),m.fromArray(a,2*d+3*e).toArray(l,C),C+=3};P(0,1),P(0,3),P(0,6),P(1,2),P(1,7),P(2,3),P(2,4),P(3,5),P(4,5),P(4,7),P(5,6),P(6,7)}var I=new mn(e);return{vertex:{position:a,color:s,radius:c,picking:I},edge:{position1:u,position2:l,color:h,color2:h,radius:p,picking:I}}},e.prototype.create=function(){var t=this.getAxesData(this.structureView);this.sphereBuffer=new kc(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new ql(t.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})},e.prototype.createData=function(t){},e.prototype.updateData=function(t,e){var r=this.getAxesData(e.sview),i={},o={};t&&!t.position||(Object.assign(i,{position:r.vertex.position}),Object.assign(o,{position1:r.edge.position1,position2:r.edge.position2})),t&&!t.color||(Object.assign(i,{color:r.vertex.color}),Object.assign(o,{color:r.edge.color,color2:r.edge.color})),t&&!t.radius||(Object.assign(i,{radius:r.vertex.radius}),Object.assign(o,{radius:r.edge.radius})),this.sphereBuffer.setAttributes(i),this.cylinderBuffer.setAttributes(o)},e}(yl);Jt.add("axes",Xl);var Yl=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radiusType=y(r.radiusType,"size"),r.radiusSize=y(r.radiusSize,.15),r.useInteriorColor=y(r.useInteriorColor,!0),this.aspectRatio=y(r.aspectRatio,2),this.lineOnly=y(r.lineOnly,!1),this.cylinderOnly=y(r.cylinderOnly,!1),this.multipleBond=y(r.multipleBond,"off"),this.bondSpacing=y(r.bondSpacing,1),this.bondScale=y(r.bondScale,.4),this.linewidth=y(r.linewidth,2),t.prototype.init.call(this,r)},e.prototype.getAtomRadius=function(e){return this.aspectRatio*t.prototype.getAtomRadius.call(this,e)},e.prototype.getAtomParams=function(e,r){var i=t.prototype.getAtomParams.call(this,e,r);return i.radiusParams.scale*=this.aspectRatio,i},e.prototype.getAtomData=function(t,e,r){return t.getAtomData(this.getAtomParams(e,r))},e.prototype.getBondParams=function(e,r){return r=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},r),t.prototype.getBondParams.call(this,e,r)},e.prototype.getBondData=function(t,e,r){return t.getBondData(this.getBondParams(e,r))},e.prototype.createData=function(t){var e=[];if(this.lineOnly)this.lineBuffer=new Tl(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{var r=new ql(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(r),!this.cylinderOnly){var i=new kc(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(i)}}return{bufferList:e}},e.prototype.updateData=function(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);var r=this.getBondData(e.sview,t);if(this.lineOnly){var i={};t&&!t.position||Object.assign(i,{position1:r.position1,position2:r.position2}),t&&!t.color||Object.assign(i,{color:r.color,color2:r.color2}),e.bufferList[0].setAttributes(i)}else{var o={};if(t&&!t.position||Object.assign(o,{position1:r.position1,position2:r.position2}),t&&!t.color||Object.assign(o,{color:r.color,color2:r.color2}),t&&!t.radius||Object.assign(o,{radius:r.radius}),e.bufferList[0].setAttributes(o),!this.cylinderOnly){var n=this.getAtomData(e.sview,t),a={};t&&!t.position||Object.assign(a,{position:n.position}),t&&!t.color||Object.assign(a,{color:n.color}),t&&!t.radius||Object.assign(a,{radius:n.radius}),e.bufferList[1].setAttributes(a)}}},e.prototype.setParameters=function(e){void 0===e&&(e={});var r=!1,i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),Ut&&!this.disableImpostor||(r=!0)),t.prototype.setParameters.call(this,e,i,r),this},e}(yl);Jt.add("ball+stick",Yl);var Kl=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.aspectRatio=y(r.aspectRatio,1),r.radiusSize=y(r.radiusSize,.25),t.prototype.init.call(this,r)},e.prototype.getAtomRadius=function(e){return e.isTrace()?t.prototype.getAtomRadius.call(this,e):0},e.prototype.getAtomData=function(t,e,r){return t.getBackboneAtomData(this.getAtomParams(e,r))},e.prototype.getBondData=function(t,e,r){return t.getBackboneBondData(this.getBondParams(e,r))},e}(Yl);Jt.add("backbone",Kl);var Zl=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.aspectRatio=y(r.aspectRatio,1),r.radiusSize=y(r.radiusSize,.3),t.prototype.init.call(this,r)},e.prototype.getAtomData=function(t,e,r){return t.getRungAtomData(this.getAtomParams(e,r))},e.prototype.getBondData=function(t,e,r){var i=this.getBondParams(e,r);return Object.assign(i.colorParams,{rung:!0}),t.getRungBondData(i)},e}(Yl);Jt.add("base",Zl);var Ql=function(t,e){this.m=t,this.tension=e,this.dt=1/this.m,this.delta=1e-4,this.vec1=new r.Vector3,this.vec2=new r.Vector3,this.vDir=new r.Vector3,this.vTan=new r.Vector3,this.vNorm=new r.Vector3,this.vBin=new r.Vector3,this.m2=Math.ceil(this.m/2)};Ql.prototype.interpolateToArr=function(t,e,r,i,o,n,a){n[a+0]=W(t.x,e.x,r.x,i.x,o,this.tension),n[a+1]=W(t.y,e.y,r.y,i.y,o,this.tension),n[a+2]=W(t.z,e.z,r.z,i.z,o,this.tension)},Ql.prototype.interpolateToVec=function(t,e,r,i,o,n){n.x=W(t.x,e.x,r.x,i.x,o,this.tension),n.y=W(t.y,e.y,r.y,i.y,o,this.tension),n.z=W(t.z,e.z,r.z,i.z,o,this.tension)},Ql.prototype.interpolatePosition=function(t,e,r,i,o,n){for(var a=0;a1&&(u=1),this.interpolateToVec(t,e,r,i,c,this.vec1),this.interpolateToVec(t,e,r,i,u,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(o,l)}},Ql.prototype.vectorSubdivide=function(t,e,r,i,o){for(var n,a=e.next(),s=e.next(),c=e.next(),u=e.size,l=u-1,h=i||0,p=0;p0&&r0;vi(A,b,S);var y=yi(A,_)<0;if(Ci(A,_,yi(_,x)),vi(C,x,A),Ci(A,_,yi(_,w)),vi(P,w,A),0!==Ai(C)&&0!==Ai(P)){Pi(C,C),Pi(P,P);var T=n[D]=function(t,e){var r=t[0],i=t[1],o=t[2],n=e[0],a=e[1],s=e[2],c=i*s-o*a,u=o*n-r*s,l=r*a-i*n,h=Math.sqrt(c*c+u*u+l*l),p=r*n+i*a+o*s;return Math.atan2(h,p)}(C,P);s[D]=(Fe*T).toFixed(1)+String.fromCharCode(176),gi(M,C,_),Pi(M,M),yi(M,P)<0&&Di(M,M),xl(A,S,C,M,T/2),_i(A,a,3*D);var B=Math.ceil(T/r),R=B+(e.extendLine?4:2),F=e.extendLine?36:0,E=new Float32Array(3*R),$=new Float32Array(3*R),L=new Float32Array(9*B),N=new Float32Array(F);c[D]=E,u[D]=$,l[D]=L,h[D]=N,e.extendLine&&(o?(vi(A,m,v),Pi(A,A),Ci(I,A,1/yi(C,A)),bi(I,I,v)):(Ci(I,x,1/yi(C,x)),bi(I,I,g)),y?(vi(A,b,g),Pi(A,A),Ci(O,A,1/yi(P,A)),bi(O,O,g)):(Ci(O,w,1/yi(P,w)),bi(O,O,v))),bi(k,S,C);var z=0;e.extendLine?(_i(m,E,z),_i(I,$,z),_i(I,E,z+=3),_i(k,$,z),z+=3,_i(I,N,0),_i(k,N,3),_i(o?v:g,N,6),_i(o?v:g,N,9),_i(k,N,12),_i(S,N,15)):(_i(S,E,z),_i(k,$,z),z+=3);for(var j=function(t,e){var r=9*e;_i(S,L,r),_i(k,L,r+3),_i(k,E,z),xl(k,S,C,M,t),_i(k,L,r+6),_i(k,$,z),z+=3},V=0,G=r;G=3&&(o=lh(n)),void 0!==o&&r.push(o)}return this.frontHistogramBinBordersBuffer=s(r.map((function(t){return t.frontHistogramBinBorders})),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=s(r.map((function(t){return t.backHistogramBinBorders})),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=s(r.map((function(t){return t.adjacentBondArrows})),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=s(r.map((function(t){return t.distantBondArrows})),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=c(r.map((function(t){return t.opaqueMiddleDisc})),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=c(r.map((function(t){return t.frontHistogram})),this.getHistogramBufferParameters()),this.backHistogramBuffer=c(r.map((function(t){return t.backHistogram})),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}function a(t){for(var e=t.map((function(t){return t.length})),r=new Float32Array(Xe(e)),i=0,o=0;o0&&(i-=h,n=n.subarray(0,3*i));var d=new eo(c.count,!0);return{text:o,position:n,bondSet:d,bondStore:c}},e.prototype.getBondData=function(t,e,r){var i=t.getBondData(this.getBondParams(e,r));return i.picking&&(i.picking=new xn(i.picking.array,i.picking.structure,r.bondStore)),i},e.prototype.createData=function(t){if(t.atomCount&&this.atomPair.length){var e=this.atomPair.length,i=new r.Color(this.labelColor),o=this.getDistanceData(t,this.atomPair);this.textBuffer=new Ml({position:o.position,size:Ne(e,this.labelSize),color:ze(e,i.r,i.g,i.b),text:o.text},this.getLabelBufferParams());var n={bondSet:o.bondSet,bondStore:o.bondStore},a=this.getBondData(t,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new ql(a,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Tl(Bi(a),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:o.bondSet,bondStore:o.bondStore,position:o.position,bufferList:[this.textBuffer,this.distanceBuffer]}}},e.prototype.updateData=function(e,r){t.prototype.updateData.call(this,e,r);var i={bondSet:r.bondSet,bondStore:r.bondStore},o=this.getBondData(r.sview,e,i),n={};e&&!e.color||Object.assign(n,{color:o.color,color2:o.color2}),e&&!e.radius||Object.assign(n,{radius:o.radius}),this.distanceBuffer.setAttributes(n)},e.prototype.setParameters=function(e){return t.prototype.setParameters.call(this,e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this},e}(vl);function ph(t){return 2*(t.position.length/3)*3}Jt.add("distance",hh);var dh=Object.assign({scale:1,color:"grey"},da),fh=function(t){function e(e,i){void 0===i&&(i={}),t.call(this,{position:new Float32Array(ph(e)),color:new Float32Array(ph(e))},i),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";var o=new r.Color(this.parameters.color),n=this.geometry.attributes;ze(ph(e)/3,o.r,o.g,o.b,n.color.array),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={defaultParameters:{configurable:!0}};return i.defaultParameters.get=function(){return dh},e.prototype.setAttributes=function(t){void 0===t&&(t={});var e,r,i,o=this.geometry.attributes;t.position&&t.vector&&(e=t.position,r=t.vector,i=o.position.array,o.position.needsUpdate=!0);var n=this.size/2,a=this.parameters.scale;if(e&&r)for(var s=0;s radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),ee.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var yh=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),vh=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]),bh=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,"v3",e,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.mapping.get=function(){return yh},r.mappingIndices.get=function(){return vh},r.mappingIndicesSize.get=function(){return 36},r.mappingSize.get=function(){return 8},r.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,r),e}(Cc),xh=Object.assign({shrink:.14},da),_h=Object.assign({shrink:{uniform:!0}},fa),wh=function(t){function e(e,i){void 0===i&&(i={}),t.call(this,e,i),this.parameterTypes=_h,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new r.Matrix4},modelViewProjectionMatrixInverse:{value:new r.Matrix4},modelViewMatrixInverseTranspose:{value:new r.Matrix4},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={defaultParameters:{configurable:!0}};return i.defaultParameters.get=function(){return xh},Object.defineProperties(e.prototype,i),e}(bh);Object.assign({disableImpostor:!1},Ll,xh);var Ah=function(t,e){return void 0===e&&(e={}),!Ut||e&&e.disableImpostor?(t.radius=function(t,e){for(var r=t.length,i=new Float32Array(r),o=0;o0;)i[s]=arguments[s+3];for(var c=a(t,e,r),u=0;uu?p[m]=-1:(c=Math.sqrt(u-s),p[m]=Math.floor(c)),++m;f[g]=h,d[g]=p}}function C(r){var i,o,n,s,h,m,v,x,_,w,A,S,C,P,I,O,M,k,D=3*r,T=r;i=Math.floor(.5+a*(t[D]+p[0])),o=Math.floor(.5+a*(t[D+1]+p[1])),n=Math.floor(.5+a*(t[D+2]+p[2]));var B,R=e[T],F=d[R],E=0,$=u*l,L=f[R];for(w=0;w=c||P>=u||I>=l)){var N=C*$+P*l+I;if(g)if(1&y[N]){if(1&y[N]){var z=b[N];z!==D&&v*v+x*x+_*_<(s=i+v-Math.floor(.5+a*(t[z]+p[0])))*s+(h=o+x-Math.floor(.5+a*(t[z+1]+p[1])))*h+(m=n+_-Math.floor(.5+a*(t[z+2]+p[2])))*m&&(b[N]=r)}}else y[N]|=1,b[N]=r;else y[N]|=1}E++}}function P(e){var r,i;for(console.time("EDTSurface fillvoxels"),r=0,i=y.length;r=c||A>=u||S>=l)){var $=w*E+A*l+S;if(2&y[$]){if(g){var L=b[$];v*v+x*x+_*_<(s=Math.floor(.5+a*(t[L]+p[0])))*s+(h=Math.floor(.5+a*(t[L+1]+p[1])))*h+(m=Math.floor(.5+a*(t[L+2]+p[2])))*m&&(b[$]=r)}}else y[$]|=2,g&&(b[$]=r)}R++}}function O(){var t,e,r,i;console.time("EDTSurface fastdistancemap");var o,n=Oh(c,u,l,Uint16Array,3),a=u*l,h=m*m,p=0;for(t=0;t0);var w,A=s*s,S=new Uint16Array(3);for(t=0;t=A)||(y[o]|=4,g&&2&y[o]&&(n.toArray(t,e,r,S),w=S[0]*a+S[1]*l+S[2],b[o]=b[w])));console.timeEnd("EDTSurface fastdistancemap")}function M(t,e,r,i){var o,n,a,s,h,p,d,f,m,g,b,x,_=new Uint16Array(3),w=0;if(0===r)return w;var S=-1,C=-1,P=-1,I=u*l;for(d=0,m=r;d-1&&C-1&&P-1&&(1&y[b=S*I+l*C+P]&&!(2&y[b])?(e.fromArray(S,C,P,_),g=(s=S-_[0])*s+(h=C-_[1])*h+(p=P-_[2])*p,v[b]=g,y[b]|=2,y[b]|=4,i[w]=S,i[w+1]=C,i[w+2]=P,w+=3):1&y[b]&&2&y[b]&&(g=(s=S-_[0])*s+(h=C-_[1])*h+(p=P-_[2])*p)-1&&C-1&&P-1&&(1&y[b=S*I+l*C+P]&&!(2&y[b])?(e.fromArray(S,C,P,_),g=(s=S-_[0])*s+(h=C-_[1])*h+(p=P-_[2])*p,v[b]=g,y[b]|=2,y[b]|=4,i[w]=S,i[w+1]=C,i[w+2]=P,w+=3):1&y[b]&&2&y[b]&&(g=(s=S-_[0])*s+(h=C-_[1])*h+(p=P-_[2])*p)-1&&C-1&&P-1&&(1&y[b=S*I+l*C+P]&&!(2&y[b])?(e.fromArray(S,C,P,_),g=(s=S-_[0])*s+(h=C-_[1])*h+(p=P-_[2])*p,v[b]=g,y[b]|=2,y[b]|=4,i[w]=S,i[w+1]=C,i[w+2]=P,w+=3):1&y[b]&&2&y[b]&&(g=(s=S-_[0])*s+(h=C-_[1])*h+(p=P-_[2])*p)-1&&a-1&&h-1&&sk&&(k=R)}return{neighbourListLength:27*k+1,withinRadii:function(o,n,a,s,h){for(var p=0,d=f(o,c),m=f(n,u),g=f(a,l),y=Math.max(0,d-1),_=Math.max(0,m-1),A=Math.max(0,g-1),S=Math.min(v,d+2),C=Math.min(b,m+2),M=Math.min(x,g+2),k=y;kp&&(p=l[R]);var F;F=oa(k,D,p,f,0),f=F.scaleFactor,v=F.dim,b=F.matrix,M=Math.max(5,2+Math.floor(d*f)),x=Ne(v[0]*v[1]*v[2],-1001),_=new Int32Array(x.length),w=new Float32Array(v[0]),A=new Float32Array(v[1]),S=new Float32Array(v[2]),L(w,k[0],1/f),L(A,k[1],1/f),L(S,k[2],1/f),function(){var t=0,e=2*Math.PI/g;P=new Float32Array(g),C=new Float32Array(g);for(var r=0;r=0;){if(n!==i&&n!==o&&z(n,t,e,r))return T=n,n;n=O[++a]}return T=-1,-1}function z(e,r,i,o){var n=3*e,a=h[e],s=t[n]-r,c=t[n+1]-i,u=t[n+2]-o;return s*s+c*c+u*u0&&h=0;)t0)continue;var vt=void 0,bt=void 0,xt=void 0,_t=void 0,wt=0;if(z){if(wt=10===(_t=h.split(jp)).length?1:0,b=_t[2],Y&&"CA"!==b)continue;vt=parseFloat(_t[6-wt]),bt=parseFloat(_t[7-wt]),xt=parseFloat(_t[8-wt])}else{if(b=h.substr(12,4).trim(),Y&&"CA"!==b)continue;vt=parseFloat(h.substr(30,8)),bt=parseFloat(h.substr(38,8)),xt=parseFloat(h.substr(46,8))}if(X){var At=3*s;if(a[At+0]=vt,a[At+1]=bt,a[At+2]=xt,s+=1,Q)continue}var St=void 0;z?(d=parseInt(_t[1]),St="",x="H"===h[0]?1:0,f=wt?"":_t[4],m=parseInt(_t[5-wt]),v="",g=_t[3],w="",y=1):(d=parseInt(h.substr(6,5),H),U&&99999===d&&(H=16),x="H"===h[0]?1:0,f=h[21].trim(),m=parseInt(h.substr(22,4),W),U&&9999===m&&(W=16),v=h[26].trim(),g=h.substr(17,4).trim()||"MOL",_=parseFloat(h.substr(60,6)),w=h[16].trim(),y=parseFloat(h.substr(54,6)),e||(j?(St=h.substr(76,3).trim())in Ro&&(St=Ro[St]):(St=h.substr(76,2).trim(),f||(f=h.substr(72,4).trim())),A=parseInt((h.substr(79,1)+h.substr(78,1)).trim()))),pt.growIfFull(),pt.atomTypeId[mt]=ht.add(b,St),pt.x[mt]=vt,pt.y[mt]=bt,pt.z[mt]=xt,pt.serial[mt]=d,pt.altloc[mt]=w.charCodeAt(0),pt.occupancy[mt]=isNaN(y)?0:y,z?(pt.partialCharge[mt]=parseFloat(_t[9-wt]),pt.radius[mt]=parseFloat(_t[10-wt])):(pt.bfactor[mt]=isNaN(_)?0:_,j&&(pt.partialCharge[mt]=parseFloat(h.substr(70,6))),isFinite(A)&&(pt.formalCharge||pt.addField("formalCharge",1,"int8"),pt.formalCharge[mt]=A));var Ct=Vp(m,f,v);!x||nt[Ct]||Np.includes(g)?R||F===f||(B=(T+=1).toString()):F===f&&$===g&&(Oo.includes(g)||E===m&&L===v)||(B=(T+=1).toString(),E=m,$=g,L=v),G.addAtom(gt,f,B,g,m,x,void 0,v),tt[d]=mt,mt+=1,R=!1,F=f}else if("CONECT"===p){var Pt=tt[parseInt(h.substr(6,5))],It=[11,16,21,26],Ot={};if(void 0===Pt)continue;for(var Mt=0;Mt<4;++Mt){var kt=parseInt(h.substr(It[Mt],5));if(!Number.isNaN(kt)&&void 0!==(kt=tt[kt]))if(Pt0)continue;var at=ot[u].replace(Wp,"");if(O&&"CA"!==at)continue;var st=parseFloat(ot[b]),ct=parseFloat(ot[x]),ut=parseFloat(ot[_]);if(I){var lt=3*i;if(e[lt+0]=st,e[lt+1]=ct,e[lt+2]=ut,i+=1,X>0)continue}var ht=ot[l],pt=parseInt(ot[-1!==s?s:c]),dt=ot[v];dt="?"===dt?"":dt;var ft=ot[a],mt=ot[h],gt="H"===ot[f][0]?1:0,yt=ot[g],vt=parseFloat(ot[w]),bt=parseFloat(ot[A]),xt=ot[d];if(xt="."===xt?"":xt,H.growIfFull(),H.atomTypeId[q]=U.add(at,yt),H.x[q]=st,H.y[q]=ct,H.z[q]=ut,H.serial[q]=parseInt(ot[m]),H.bfactor[q]=isNaN(vt)?0:vt,H.occupancy[q]=isNaN(bt)?0:bt,H.altloc[q]=xt.charCodeAt(0),C.addAtom(X,ft,mt,ht,pt,gt,void 0,dt),t.Debug){var _t=D[mt];void 0!==_t&&_t!==ft&&t.Debug&&qt.warn(_t,ft)}D[mt]=ft;var wt=ot[p];T[wt]||(T[wt]=new Set),T[wt].add(S.chainStore.count-1),q+=1}else{var At=n.match(Hp),St=At.length;N===L.length&&(N=0);for(var Ct=0;Cth*h)return o.growIfFull(),o.atomTypeId[m]=o.atomTypeId[t],o.x[m]=p.x,o.y[m]=p.y,o.z[m]=p.z,o.occupancy[m]=o.occupancy[t],o.serial[m]=m,o.altloc[m]="A".charCodeAt(0),i.addAtom(0,"","","HET",1,!0),void(m+=1)}}}))},b=0;b0){a=a.split("(");var u=c(a[0]),l=c(a[1]);Object.keys(u).forEach((function(t){Object.keys(l).forEach((function(e){var i=new r.Matrix4;i.multiplyMatrices(u[t],l[e]),o[t+"x"+e]=i}))}))}else o=c(a);var h=[];for(var p in o)h.push(o[p]);var d=t;/^(0|[1-9][0-9]*)$/.test(d)&&(d="BU"+d);for(var f=s.asym_id_list[e].split(","),m=0,g=f.length;mA){var S=w;w=A,A=S;var C=m;m=x,x=C}if(0!==w&&0!==A)for(var P=0;Pb)continue}p=I.substr(5,5).trim(),d=parseInt(I.substr(0,5)),f=parseInt(I.substr(15,5)),_.growIfFull(),_.atomTypeId[w]=x.add(h),_.x[w]=k,_.y[w]=D,_.z[w]=T,_.serial[w]=f,o.addAtom(A,"","",p,d,0,"l"),w+=1}}}(0,t.length,t)})),o.finalize(),i.finalizeAtoms(),Os(i),Ms(i),i.finalizeBonds(),Cs(i),t.Debug&&qt.timeEnd("GroParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Bp);te.add("gro",td);var ed=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function rd(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function id(t){return rd(DataView,t)}function od(t){return rd(Int8Array,t)}function nd(t){return rd(Int32Array,t,4)}function ad(t,e){var r=t.length/2;e||(e=new Int16Array(r));for(var i=0,o=0;in&&++s;e=new Int32Array(s)}for(r=0,i=0;ro){for(var n=[],a=0;a0&&(d.biomolDict.NCS=ct)}var lt=f.unitCell;lt&&Array.isArray(lt)&<[0]?d.unitcell=new $p({a:lt[0],b:lt[1],c:lt[2],alpha:lt[3],beta:lt[4],gamma:lt[5],spacegroup:f.spaceGroup}):d.unitcell=void 0,Bs(d,!0),Ts(d,!0),d.finalizeAtoms(),d.finalizeBonds(),Rs(d),t.Debug&&qt.timeEnd("MmtfParser._parse "+this.name)},Object.defineProperties(i.prototype,o),i}(Bp);te.add("mmtf",vd);var bd=/\s+/,xd={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0},_d=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"mol2"},r.prototype._parse=function(){t.Debug&&qt.time("Mol2Parser._parse "+this.name);var e,r,i=this.structure,o=this.structureBuilder,n=this.firstModelOnly,a=this.asTrajectory,s=i.frames,c=!1,u=i.atomMap,l=i.atomStore;l.resize(Math.round(this.streamer.data.length/60)),l.addField("partialCharge",1,"float32");var h=0,p=0,d=0,f=-1,m=0,g=0,y=i.getAtomProxy(),v=i.getAtomProxy();this.streamer.eachChunkOfLines((function(t){!function(t,b,x){for(var _=t;_MOLECULE"===w?(g=1,p=0,++f):"@ATOM"===w?(g=2,d=l.count,a&&(r=0,e=new Float32Array(3*m),s.push(e),f>0&&(c=!0))):g="@BOND"===w?3:0;else if(1===g){if(0===p)i.title=w,i.id=w;else if(1===p){var A=w.split(bd);m=parseInt(A[0])}++p}else if(2===g){var S=w.split(bd);if(n&&f>0)continue;var C=parseFloat(S[2]),P=parseFloat(S[3]),I=parseFloat(S[4]);if(a){var O=3*r;if(e[O+0]=C,e[O+1]=P,e[O+2]=I,r+=1,c)continue}var M=S[0],k=S[1],D=S[5].split(".")[0],T=S[6]?parseInt(S[6]):1,B=S[7]?S[7]:"",R=S[8]?parseFloat(S[8]):0;l.growIfFull(),l.atomTypeId[h]=u.add(k,D),l.x[h]=C,l.y[h]=P,l.z[h]=I,l.serial[h]=M,l.partialCharge[h]=R,o.addAtom(f,"","",B,T,1),h+=1}else if(3===g){if(n&&f>0)continue;if(a&&f>0)continue;var F=w.split(bd);y.index=parseInt(F[1])-1+d,v.index=parseInt(F[2])-1+d;var E=xd[F[3]];i.bondStore.addBond(y,v,E)}}}(0,t.length,t)})),o.finalize(),i.finalizeAtoms(),Os(i),Ts(i,!0),Bs(i,!0),i.finalizeBonds(),Ls(i),Cs(i),t.Debug&&qt.timeEnd("Mol2Parser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Bp);te.add("mol2",_d);var wd=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"pdbqt"},Object.defineProperties(e.prototype,r),e}(Gp);te.add("pdbqt",wd);var Ad=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"pqr"},Object.defineProperties(e.prototype,r),e}(Gp);te.add("pqr",Ad);var Sd=/> +<(.+)>/,Cd=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"sdf"},r.prototype._parse=function(){t.Debug&&qt.time("SdfParser._parse "+this.name);var e=this.structure,r=this.structureBuilder,i=this.firstModelOnly,o=this.asTrajectory,n=this.streamer.peekLines(2);e.id=n[0].trim(),e.title=n[1].trim();var a,s,c=e.frames,u=!1,l=e.atomMap,h=e.atomStore;h.resize(Math.round(this.streamer.data.length/50)),h.addField("formalCharge",1,"int8");var p,d,f,m,g,y,v,b,x,_,w,A,S,C,P=e.getAtomProxy(),I=e.getAtomProxy(),O=0,M=0,k=0,D=0,T=[],B=!1,R={};e.extraData.sdf=T;var F=!1,E=!1,$=!1,L=[],N=[],z=new Map;this.streamer.eachChunkOfLines((function(t){!function(t,n,j){for(var V=t;V-1)?z.clear():(d=parseInt(G.substr(0,3)),f=parseInt(G.substr(3,3)),v=(y=g=(m=4)+d)+f,o&&(s=0,a=new Float32Array(3*d),c.push(a),k>0&&(u=!0)));else if(F&&"COUNTS"===L[0])d=parseInt(L[1]),o&&(s=0,a=new Float32Array(3*d),c.push(a),k>0&&(u=!0));else if(F&&2==L.length)"ATOM"===L[1]?"BEGIN"===L[0]?E=!0:"END"===L[0]&&(E=!1):"BOND"===L[1]&&("BEGIN"===L[0]?$=!0:"END"===L[0]&&($=!1));else if(E||!F&&M>=m&&M0)continue;var U=0;if(F){if(b=parseFloat(L[2]),x=parseFloat(L[3]),_=parseFloat(L[4]),A=L[1],S=parseInt(L[0]),z.set(S,O),w=A+S,L.length>6){var H=L.slice(6).find((function(t){return 0===t.indexOf("CHG=")}));H&&(U=parseInt(H.substring(4)))}}else b=parseFloat(G.substr(0,10)),x=parseFloat(G.substr(10,10)),_=parseFloat(G.substr(20,10)),A=G.substr(31,3).trim(),w=A+(O-D+1);if(o){var W=3*s;if(a[W+0]=b,a[W+1]=x,a[W+2]=_,s+=1,u)continue}h.growIfFull(),h.atomTypeId[O]=l.add(w,A),h.x[O]=b,h.y[O]=x,h.z[O]=_,h.serial[O]=F?S:O,h.formalCharge[O]=U,r.addAtom(k,"","","HET",1,1),O+=1}else if($||!F&&M>=y&&M0)continue;if(o&&k>0)continue;F?(P.index=z.get(parseInt(L[2])),I.index=z.get(parseInt(L[3])),C=parseInt(L[1])):(P.index=parseInt(G.substr(0,3))-1+D,I.index=parseInt(G.substr(3,3))-1+D,C=parseInt(G.substr(6,3))),e.bondStore.addBond(P,I,C)}else if("M CHG"===G.substr(0,6))for(var q=parseInt(G.substr(6,3)),X=0,Y=10;X"===G.charAt(0)&&(p=G.match(Sd))?(B=p[1],R[B]=[]):!1!==B&&G&&R[B].push(G);++M}}}(0,t.length,t)})),r.finalize(),e.finalizeAtoms(),e.finalizeBonds(),Ls(e),t.Debug&&qt.timeEnd("SdfParser._parse "+this.name)},r.prototype._postProcess=function(){Ls(this.structure)},Object.defineProperties(r.prototype,i),r}(Bp);te.add("sdf",Cd),te.add("sd",Cd),te.add("mol",Cd);function Pd(t,e,r){return parseInt(t.substr(e,r).trim())}var Id=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"prmtop"},r.prototype._parse=function(){t.Debug&&qt.time("PrmtopParser._parse "+this.name);var e=this.structure,r=this.structureBuilder,i=e.atomMap,o=e.atomStore;o.addField("partialCharge",1,"float32"),o.addField("radius",1,"float32");var n,a,s,c,u,l=[],h={},p=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];p.forEach((function(t){h[t]=0}));var d,f,m,g,y,v=new Uint8Array(0);this.streamer.eachChunkOfLines((function(t){!function(t,e,r){for(var i=t;i0)qt.error("dcd format with fixed atoms unsupported, aborting");else{for(var y=a.NATOM,v=4*y,b=0,x=a.NSET;b=1&&(i.timeOffset=(a.ISTART-1)*i.deltaTime),t.Debug&&qt.timeEnd("DcdParser._parse "+this.name)}},Object.defineProperties(r.prototype,i),r}(Rd);function Ed(t,e){if(t)throw new TypeError("Not a valid NetCDF v3.x file: "+e)}function $d(t){t.offset%4!=0&&t.skip(4-t.offset%4)}function Ld(t){var e=t.readUint32(),r=t.readChars(e);return $d(t),r}te.add("dcd",Fd);var Nd=1,zd=2,jd=3,Vd=4,Gd=5,Ud=6;function Hd(t){switch(Number(t)){case Nd:return"byte";case zd:return"char";case jd:return"short";case Vd:return"int";case Gd:return"float";case Ud:return"double";default:return"undefined"}}function Wd(t){switch(Number(t)){case Nd:case zd:return 1;case jd:return 2;case Vd:case Gd:return 4;case Ud:return 8;default:return-1}}function qd(t){switch(String(t)){case"byte":return Nd;case"char":return zd;case"short":return jd;case"int":return Vd;case"float":return Gd;case"double":return Ud;default:return-1}}function Xd(t,e){if(1!==t){for(var r=new Array(t),i=0;i6,"non valid type "+d);var f=t.readUint32(),m=t.readUint32();2===r&&(Ed(m>0,"offsets larger than 4GB not supported"),m=t.readUint32()),l[0]===e&&(n+=f),i[s]={name:c,dimensions:l,attributes:p,type:Hd(d),size:f,offset:m,record:l[0]===e}}return{variables:i,recordStep:n}}(t,i.recordId,e);return r.variables=o.variables,r.recordDimension.recordStep=o.recordStep,r}function Zd(t){var e,r=t.readUint32();if(0===r)return Ed(0!==t.readUint32(),"wrong empty tag for list of attributes"),[];Ed(12!==r,"wrong tag for list of attributes");var i=t.readUint32();e=new Array(i);for(var o=0;o6,"non valid type "+a);var s=t.readUint32(),c=Yd(t,a,s);$d(t),e[o]={name:n,type:Hd(a),value:c}}return e}var Qd=function(t){var e=new xe(t);e.setBigEndian(),Ed("CDF"!==e.readChars(3),"should start with CDF");var r=e.readByte();Ed(r>2,"unknown version"),this.header=Kd(e,r),this.buffer=e},Jd={version:{configurable:!0},recordDimension:{configurable:!0},dimensions:{configurable:!0},globalAttributes:{configurable:!0},variables:{configurable:!0}};Jd.version.get=function(){return 1===this.header.version?"classic format":"64-bit offset format"},Jd.recordDimension.get=function(){return this.header.recordDimension},Jd.dimensions.get=function(){return this.header.dimensions},Jd.globalAttributes.get=function(){return this.header.globalAttributes},Jd.variables.get=function(){return this.header.variables},Qd.prototype.hasDataVariable=function(t){return-1!==this.header.variables.findIndex((function(e){return e.name===t}))},Qd.prototype.getDataVariable=function(t){var e;return Ed(void 0===(e="string"==typeof t?this.header.variables.find((function(e){return e.name===t})):t),"variable not found"),this.buffer.seek(e.offset),e.record?function(t,e,r){for(var i=qd(e.type),o=e.size?e.size/Wd(i):1,n=r.length,a=new Array(n),s=r.recordStep,c=0;c=1&&(r.timeOffset=n[0]),n.length>=2&&(r.deltaTime=n[1]-n[0]),t.Debug&&qt.timeEnd("NctrajParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Rd);te.add("nctraj",tf),te.add("ncdf",tf),te.add("nc",tf);var ef=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"trr"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&qt.time("TrrParser._parse "+this.name);for(var e=D(this.streamer.data),r=new DataView(e),i=this.frames,o=i.coordinates,n=i.boxes,a=i.times,s=0;;){s+=8;var c=r.getInt32(s);s+=4,s+=c;var u=r.getInt32(s+8),l=r.getInt32(s+12),h=r.getInt32(s+16),p=r.getInt32(s+28),d=r.getInt32(s+32),f=r.getInt32(s+36),m=r.getInt32(s+40);s+=52;var g=u/9,y=3*m;if(8===g?a.push(r.getFloat64(s)):a.push(r.getFloat32(s)),s+=2*g,u){var v=new Float32Array(9);if(8===g)for(var b=0;b<9;++b)v[b]=10*r.getFloat64(s),s+=8;else for(var x=0;x<9;++x)v[x]=10*r.getFloat32(s),s+=4;n.push(v)}if(s+=l,s+=h,p){var _=void 0;if(8===g){_=new Float32Array(y);for(var w=0;w>8&65280|C>>24&255}_=new Float32Array(e,s,y);for(var P=0;P=e.byteLength)break}a.length>=1&&(i.timeOffset=a[0]),a.length>=2&&(i.deltaTime=a[1]-a[0]),t.Debug&&qt.timeEnd("TrrParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Rd);te.add("trr",ef);var rf=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function of(t){for(var e=1,r=0;t>=e&&r<32;)r++,e<<=1;return r}var nf=new Uint8Array(32);function af(t,e){var r=1,i=0;nf[0]=1;for(var o=0;o>=8;for(;0!==a;)nf[n++]=255&a,a>>=8;r=n}var s=1;for(r--;nf[r]>=s;)i++,s*=2;return i+8*r}function sf(t,e,r,i){for(var o=(1<=8;)c|=(a=a<<8|e[s++])>>n<0&&(n>(n-=r)&(1<8;)cf[s++]=sf(t,e,8,a),i-=8;i>0&&(cf[s++]=sf(t,e,i,a));for(var c=r-1;c>0;c--){for(var u=0,l=s-1;l>=0;l--){var h=(u=u<<8|cf[l])/o[c]|0;cf[l]=h,u-=h*o[c]}n[c]=u}n[0]=cf[0]|cf[1]<<8|cf[2]<<16|cf[3]<<24}var lf=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"xtc"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&qt.time("XtcParser._parse "+this.name);for(var e=D(this.streamer.data),r=new DataView(e),i=this.frames,o=i.coordinates,n=i.boxes,a=i.times,s=new Int32Array(6),c=new Int32Array(3),u=new Int32Array(3),l=new Uint32Array(3),h=new Float32Array(3),p=new Float32Array(3),d=0,f=new Int32Array(3),m=new Uint32Array(f.buffer);;){var g=void 0,y=r.getInt32(d+4);d+=12;var v=3*y;a.push(r.getFloat32(d)),d+=4;for(var b=new Float32Array(9),x=0;x<9;++x)b[x]=10*r.getFloat32(d),d+=4;if(n.push(b),y<=9){g=new Float32Array(y);for(var _=0;_16777215?(u[0]=of(c[0]),u[1]=of(c[1]),u[2]=of(c[2]),C=0):C=af(3,c);var P=r.getInt32(d);d+=4;var I=P-1,O=rf[I=9>I?9:I]/2|0,M=rf[P]/2|0;l[0]=l[1]=l[2]=rf[P];var k=4*Math.ceil(r.getInt32(d)/4);d+=4;var T=1/S,B=0,R=0,F=new Uint8Array(e,d);for(h[0]=h[1]=h[2]=0;R0){h[0]=h[1]=h[2]=0;for(var $=0;$9?rf[P-1]/2|0:0):E>0&&(O=M,M=rf[P]/2|0),l[0]=l[1]=l[2]=rf[P],0===l[0]||0===l[1]||0===l[2])return void console.error("(xdrfile error) Undefined error.")}d+=k}for(var N=0;N=e.byteLength)break}a.length>=1&&(i.timeOffset=a[0]),a.length>=2&&(i.deltaTime=a[1]-a[0]),t.Debug&&qt.timeEnd("XtcParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Rd);te.add("xtc",lf);var hf=function(t){function e(e,r){var i=r||{};t.call(this,e,i),this.volume=new ca(this.name,this.path),this.voxelSize=y(i.voxelSize,1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{configurable:!0},__objName:{configurable:!0}};return i.type.get=function(){return"volume"},i.__objName.get=function(){return"volume"},e.prototype._afterParse=function(){this.volume.setMatrix(this.getMatrix()),t.prototype._afterParse.call(this)},e.prototype.getMatrix=function(){return new r.Matrix4},Object.defineProperties(e.prototype,i),e}(Dp),pf=/\s+/,df=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,ff=.529177210859,mf=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var o={type:{configurable:!0}};return o.type.get=function(){return"cube"},i.prototype._parse=function(){t.Debug&&qt.time("CubeParser._parse "+this.name);var e=this.volume,i=this.streamer.peekLines(6),o={},n=ff*this.voxelSize;function a(t,e){var r=i[t].trim().split(pf)[e];return parseFloat(r)}o.atomCount=Math.abs(a(2,0)),o.originX=a(2,1)*ff,o.originY=a(2,2)*ff,o.originZ=a(2,3)*ff,o.NVX=a(3,0),o.NVY=a(4,0),o.NVZ=a(5,0),o.basisX=new r.Vector3(a(3,1),a(3,2),a(3,3)).multiplyScalar(n),o.basisY=new r.Vector3(a(4,1),a(4,2),a(4,3)).multiplyScalar(n),o.basisZ=new r.Vector3(a(5,1),a(5,2),a(5,3)).multiplyScalar(n);var s=new Float32Array(o.NVX*o.NVY*o.NVZ),c=0,u=0,l=a(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(t){!function(t,e,r){for(var i=t;i=o.atomCount+6+l)for(var a=n.match(df),h=0,p=a.length;h>8&255}o.xStart=a[0],o.yStart=a[1],o.zStart=a[2],o.xExtent=a[3],o.yExtent=a[4],o.zExtent=a[5],o.xRate=a[6],o.yRate=a[7],o.zRate=a[8];var p=1/a[17],d=p*this.voxelSize;o.xlen=a[9]*d,o.ylen=a[10]*d,o.zlen=a[11]*d,o.alpha=a[12]*p,o.beta=a[13]*p,o.gamma=a[14]*p,e=a[15]/100,r=a[16],o.gamma=a[14]*p}i.header=o,t.Debug&&qt.log(o,e,r);for(var f=new Float32Array(o.xExtent*o.yExtent*o.zExtent),m=512,g=Math.ceil(o.xExtent/8),y=Math.ceil(o.yExtent/8),v=Math.ceil(o.zExtent/8),b=0;bn){var o=r[i].trim();if(""!==o)for(var l=o.split(yf),h=0,p=l.length;h=n&&(m-n)%d!=0&&f=0?r-1:r+e/3)},parseNormalIndex:function(t,e){var r=parseInt(t,10);return 3*(r>=0?r-1:r+e/3)},addVertex:function(t,e,r){var i=this.vertices,o=this.object.geometry.vertices;o.push(i[t+0]),o.push(i[t+1]),o.push(i[t+2]),o.push(i[e+0]),o.push(i[e+1]),o.push(i[e+2]),o.push(i[r+0]),o.push(i[r+1]),o.push(i[r+2])},addVertexLine:function(t){var e=this.vertices,r=this.object.geometry.vertices;r.push(e[t+0]),r.push(e[t+1]),r.push(e[t+2])},addNormal:function(t,e,r){var i=this.normals,o=this.object.geometry.normals;o.push(i[t+0]),o.push(i[t+1]),o.push(i[t+2]),o.push(i[e+0]),o.push(i[e+1]),o.push(i[e+2]),o.push(i[r+0]),o.push(i[r+1]),o.push(i[r+2])},addFace:function(t,e,r,i,o,n,a,s){var c,u=this.vertices.length,l=this.parseVertexIndex(t,u),h=this.parseVertexIndex(e,u),p=this.parseVertexIndex(r,u);if(void 0===i?this.addVertex(l,h,p):(c=this.parseVertexIndex(i,u),this.addVertex(l,h,c),this.addVertex(h,p,c)),void 0!==o){var d=this.normals.length;l=this.parseNormalIndex(o,d),h=o===n?l:this.parseNormalIndex(n,d),p=o===a?l:this.parseNormalIndex(a,d),void 0===i?this.addNormal(l,h,p):(c=this.parseNormalIndex(s,d),this.addNormal(l,h,c),this.addNormal(h,p,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,r=0,i=t.length;r0?x.setAttribute("normal",new r.BufferAttribute(new Float32Array(b.normals),3)):x.computeVertexNormals(),v.push(x)}}return v}};var Nf=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"obj"},e.prototype.getLoader=function(){return new Lf},Object.defineProperties(e.prototype,r),e}($f);te.add("obj",Nf);var zf=function(){this.propertyNameMapping={}};zf.prototype={constructor:zf,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),r="",i=0;i=o.elements[s].count&&(s++,c=0);var h=this.parseASCIIElement(o.elements[s].properties,l);this.handleElement(i,o.elements[s].name,h),c++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e/g,""),{declaration:e(),root:r()};function e(){if(o(/^<\?xml\s*/)){for(var t={attributes:{}};!n()&&!a("?>");){var e=i();if(!e)return t;t.attributes[e.name]=e.value}return o(/\?>\s*/),t}}function r(){var t=o(Xf);if(t){for(var e,s={name:t[1],attributes:{},children:[]};!(n()||a(">")||a("?>")||a("/>"));){var c=i();if(!c)return s;s.attributes[c.name]=c.value}if(o(/^\s*\/>\s*/))return s;for(o(/\??>\s*/),s.content=function(){var t=o(Yf);if(t)return t[1];return""}();e=r();)s.children.push(e);return o(/^<\/[\w-:.]+>\s*/),s}}function i(){var t,e=o(Kf);if(e)return{name:e[1],value:(t=e[2],t.replace(qf,""))}}function o(e){var r=t.match(e);if(r)return t=t.slice(r[0].length),r}function n(){return 0===t.length}function a(e){return 0===t.indexOf(e)}}var Qf=function(e){function r(t,r){var i=r||{};e.call(this,t,i),this.useDomParser=y(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},__objName:{configurable:!0},isXml:{configurable:!0}};return i.type.get=function(){return"xml"},i.__objName.get=function(){return"xml"},i.isXml.get=function(){return!0},r.prototype.__xmlParser=function(t){return Zf(t)},r.prototype.__domParser=function(t){return(new window.DOMParser).parseFromString(t,"text/xml")},r.prototype._parse=function(){t.Debug&&qt.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),t.Debug&&qt.timeEnd("XmlParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Dp);function Jf(t,e){var r=t.getNamedItem(e);return null!==r?r.value:""}function tm(t,e,r){void 0===r&&(r=!1);var i=Jf(t,"icode").trim(),o=Jf(t,"chain").trim(),n=Jf(t,"altcode"),a=Jf(t,"resnum");return i&&(a+="^"+i),o&&(a+=":"+o),e&&(a+="."+e),r&&n.trim()&&(a+="%"+n),a+="/"+(parseInt(Jf(t,"model"))-1)}function em(t){var e=Jf(t,"chain").trim(),r="["+Jf(t,"rescode")+"]"+Jf(t,"resnum");return e&&(r+=":"+e),r}function rm(t,e,r){void 0===t[e]?t[e]=r:t[e]|=r}function im(t,e){return null!==t&&t.value===e}function om(t,e,r){for(var i=0,o=e.getElementsByTagName("clash"),n=0,a=o.length;n0&&(i+=1),e.getElementsByTagName("bond-outlier").length>0&&(i+=1),e.getElementsByTagName("plane-outlier").length>0&&(i+=1),im(r.getNamedItem("rota"),"OUTLIER")&&(i+=1),im(r.getNamedItem("rama"),"OUTLIER")&&(i+=1),im(r.getNamedItem("RNApucker"),"outlier")&&(i+=1),i}te.add("xml",Qf);var nm=function(t,e){this.name=t,this.path=e,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"},am={type:{configurable:!0}};am.type.get=function(){return"validation"},nm.prototype.fromXml=function(e){t.Debug&&qt.time("Validation.fromXml");var r=this.rsrzDict,i=this.rsccDict,o=this.rciDict,n=this.clashDict,a=this.clashArray,s=this.geoDict,c=this.geoAtomDict,u=this.atomDict,l=e.getElementsByTagName("Entry");if(1===l.length){var h=l[0].getElementsByTagName("chemical_shift_list");if(1===h.length)for(var p=h[0].getElementsByTagName("random_coil_index"),d=0,f=p.length;d0&&(s[$]=L)}else{var N=F.getElementsByTagName("clash"),z=F.getElementsByTagName("mog-bond-outlier"),j=F.getElementsByTagName("mog-angle-outlier");if(z.length>0||j.length>0||N.length>0){var V={};c[$]=V;for(var G=0,U=N.length;G>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{n=n+(o=o+e[i++]|0)|0}while(--a);o%=65521,n%=65521}return o|n<<16|0}te.add("validation",sm);var hm=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();function pm(t,e,r,i){var o=hm,n=i+r;t^=-1;for(var a=i;a>>8^o[255&(t^e[a])];return-1^t}function dm(t,e){var r,i,o,n,a,s,c,u,l,h,p,d,f,m,g,y,v,b,x,_,w,A,S,C,P;r=t.state,i=t.next_in,C=t.input,o=i+(t.avail_in-5),n=t.next_out,P=t.output,a=n-(e-t.avail_out),s=n+(t.avail_out-257),c=r.dmax,u=r.wsize,l=r.whave,h=r.wnext,p=r.window,d=r.hold,f=r.bits,m=r.lencode,g=r.distcode,y=(1<>>=x=b>>>24,f-=x,0===(x=b>>>16&255))P[n++]=65535&b;else{if(!(16&x)){if(0==(64&x)){b=m[(65535&b)+(d&(1<>>=x,f-=x),f<15&&(d+=C[i++]<>>=x=b>>>24,f-=x,!(16&(x=b>>>16&255))){if(0==(64&x)){b=g[(65535&b)+(d&(1<c){t.msg="invalid distance too far back",r.mode=30;break t}if(d>>>=x,f-=x,w>(x=n-a)){if((x=w-x)>l&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(A=0,S=p,0===h){if(A+=u-x,x<_){_-=x;do{P[n++]=p[A++]}while(--x);A=n-w,S=P}}else if(h2;)P[n++]=S[A++],P[n++]=S[A++],P[n++]=S[A++],_-=3;_&&(P[n++]=S[A++],_>1&&(P[n++]=S[A++]))}else{A=n-w;do{P[n++]=P[A++],P[n++]=P[A++],P[n++]=P[A++],_-=3}while(_>2);_&&(P[n++]=P[A++],_>1&&(P[n++]=P[A++]))}break}}break}}while(i>3,d&=(1<<(f-=_<<3))-1,t.next_in=i,t.next_out=n,t.avail_in=i=1&&0===k[_];_--);if(w>_&&(w=_),0===_)return o[n++]=20971520,o[n++]=20971520,s.bits=1,0;for(x=1;x<_&&0===k[x];x++);for(w0&&(0===t||1!==_))return-1;for(D[1]=0,v=1;v852||2===t&&P>592)return 1;for(;;){f=v-S,a[b]d?(m=T[B+a[b]],g=O[M+a[b]]):(m=96,g=0),c=1<>S)+(u-=c)]=f<<24|m<<16|g|0}while(0!==u);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,b++,0==--k[v]){if(v===_)break;v=e[r+a[b]]}if(v>w&&(I&h)!==l){for(0===S&&(S=w),p+=x,C=1<<(A=v-S);A+S<_&&!((C-=k[A+S])<=0);)A++,C<<=1;if(P+=1<852||2===t&&P>592)return 1;o[l=I&h]=w<<24|A<<16|p-n|0}}return 0!==I&&(o[p+I]=v-S<<24|64<<16|0),s.bits=w,0}var xm=-2,_m=12,wm=30;function Am(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function Sm(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Cm(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,0):xm}(t)):xm}function Pm(t,e){var r,i;return t?(i=new Sm,t.state=i,i.window=null,r=function(t,e){var r,i;return t&&t.state?(i=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?xm:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,Cm(t))):xm}(t,e),0!==r&&(t.state=null),r):xm}var Im,Om,Mm=!0;function km(t){if(Mm){var e;for(Im=new Int32Array(512),Om=new Int32Array(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(bm(1,t.lens,0,288,Im,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;bm(2,t.lens,0,32,Om,0,t.work,{bits:5}),Mm=!1}t.lencode=Im,t.lenbits=9,t.distcode=Om,t.distbits=5}function Dm(t,e,r,i){var o,n=t.state;return null===n.window&&(n.wsize=1<=n.wsize?(um(n.window,e,r-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((o=n.wsize-n.wnext)>i&&(o=i),um(n.window,e,r-i,o,n.wnext),(i-=o)?(um(n.window,e,r-i,i,0),n.wnext=i,n.whave=n.wsize):(n.wnext+=o,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,r.check=pm(r.check,I,2,0),u=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",r.mode=wm;break}if(8!=(15&u)){t.msg="unknown compression method",r.mode=wm;break}if(l-=4,w=8+(15&(u>>>=4)),0===r.wbits)r.wbits=w;else if(w>r.wbits){t.msg="invalid window size",r.mode=wm;break}r.dmax=1<>8&1),512&r.flags&&(I[0]=255&u,I[1]=u>>>8&255,r.check=pm(r.check,I,2,0)),u=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===s)break t;s--,u+=i[n++]<>>8&255,I[2]=u>>>16&255,I[3]=u>>>24&255,r.check=pm(r.check,I,4,0)),u=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===s)break t;s--,u+=i[n++]<>8),512&r.flags&&(I[0]=255&u,I[1]=u>>>8&255,r.check=pm(r.check,I,2,0)),u=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===s)break t;s--,u+=i[n++]<>>8&255,r.check=pm(r.check,I,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>s&&(d=s),d&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),um(r.head.extra,i,n,d,w)),512&r.flags&&(r.check=pm(r.check,i,d,n)),s-=d,n+=d,r.length-=d),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break t;d=0;do{w=i[n+d++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w))}while(w&&d>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=_m;break;case 10:for(;l<32;){if(0===s)break t;s--,u+=i[n++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===s)break t;s--,u+=i[n++]<>>=1)){case 0:r.mode=14;break;case 1:if(km(r),r.mode=20,6===e){u>>>=2,l-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=wm}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break t;s--,u+=i[n++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=wm;break}if(r.length=65535&u,u=0,l=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(d=r.length){if(d>s&&(d=s),d>c&&(d=c),0===d)break t;um(o,i,n,d,a),s-=d,n+=d,c-=d,a+=d,r.length-=d;break}r.mode=_m;break;case 17:for(;l<14;){if(0===s)break t;s--,u+=i[n++]<>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=wm;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,l-=3}for(;r.have<19;)r.lens[O[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},A=bm(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,A){t.msg="invalid code lengths set",r.mode=wm;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,v=65535&P,!((g=P>>>24)<=l);){if(0===s)break t;s--,u+=i[n++]<>>=g,l-=g,r.lens[r.have++]=v;else{if(16===v){for(C=g+2;l>>=g,l-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=wm;break}w=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===v){for(C=g+3;l>>=g)),u>>>=3,l-=3}else{for(C=g+7;l>>=g)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=wm;break}for(;d--;)r.lens[r.have++]=w}}if(r.mode===wm)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=wm;break}if(r.lenbits=9,S={bits:r.lenbits},A=bm(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,A){t.msg="invalid literal/lengths set",r.mode=wm;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},A=bm(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,A){t.msg="invalid distances set",r.mode=wm;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(s>=6&&c>=258){t.next_out=a,t.avail_out=c,t.next_in=n,t.avail_in=s,r.hold=u,r.bits=l,dm(t,p),a=t.next_out,o=t.output,c=t.avail_out,n=t.next_in,i=t.input,s=t.avail_in,u=r.hold,l=r.bits,r.mode===_m&&(r.back=-1);break}for(r.back=0;y=(P=r.lencode[u&(1<>>16&255,v=65535&P,!((g=P>>>24)<=l);){if(0===s)break t;s--,u+=i[n++]<>b)])>>>16&255,v=65535&P,!(b+(g=P>>>24)<=l);){if(0===s)break t;s--,u+=i[n++]<>>=b,l-=b,r.back+=b}if(u>>>=g,l-=g,r.back+=g,r.length=v,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=_m;break}if(64&y){t.msg="invalid literal/length code",r.mode=wm;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(C=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;y=(P=r.distcode[u&(1<>>16&255,v=65535&P,!((g=P>>>24)<=l);){if(0===s)break t;s--,u+=i[n++]<>b)])>>>16&255,v=65535&P,!(b+(g=P>>>24)<=l);){if(0===s)break t;s--,u+=i[n++]<>>=b,l-=b,r.back+=b}if(u>>>=g,l-=g,r.back+=g,64&y){t.msg="invalid distance code",r.mode=wm;break}r.offset=v,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(C=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=wm;break}r.mode=25;case 25:if(0===c)break t;if(d=p-c,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=wm;break}d>r.wnext?(d-=r.wnext,f=r.wsize-d):f=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=o,f=a-r.offset,d=r.length;d>c&&(d=c),c-=d,r.length-=d;do{o[a++]=m[f++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===c)break t;o[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===s)break t;s--,u|=i[n++]<=252?6:$m>=248?5:$m>=240?4:$m>=224?3:$m>=192?2:1;function Lm(t){var e,r,i,o,n,a=t.length,s=0;for(o=0;o>>6,e[n++]=128|63&r):r<65536?(e[n++]=224|r>>>12,e[n++]=128|r>>>6&63,e[n++]=128|63&r):(e[n++]=240|r>>>18,e[n++]=128|r>>>12&63,e[n++]=128|r>>>6&63,e[n++]=128|63&r);return e}function Nm(t,e){var r,i,o,n,a=e||t.length,s=new Array(2*a);for(i=0,r=0;r4)s[i++]=65533,r+=n-1;else{for(o&=2===n?31:3===n?15:7;n>1&&r1?s[i++]=65533:o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|1023&o)}return function(t,e){if(e<65537&&(t.subarray&&Fm||!t.subarray&&Rm))return String.fromCharCode.apply(null,cm(t,e));for(var r="",i=0;it.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+Em[t[r]]>e?r:e}Em[254]=Em[254]=1;var jm={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Vm(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Gm(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Um=Object.prototype.toString;function Hm(t){if(!(this instanceof Hm))return new Hm(t);this.options=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i])}}return t}({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Vm,this.strm.avail_out=0;var r,i,o,n=Pm(this.strm,e.windowBits);if(0!==n)throw new Error(jm[n]);this.header=new Gm,r=this.strm,i=this.header,r&&r.state&&(0==(2&(o=r.state).wrap)||(o.head=i,i.done=!1))}Hm.prototype.push=function(t,e){var r,i,o,n,a,s,c=this.strm,u=this.options.chunkSize,l=this.options.dictionary,h=!1;if(this.ended)return!1;i=e===~~e?e:!0===e?4:0,"string"==typeof t?c.input=function(t){for(var e=new Uint8Array(t.length),r=0,i=e.length;r0||0===c.avail_out)&&1!==r);return 1===r&&(i=4),4===i?(r=function(t){if(!t||!t.state)return xm;var e=t.state;return e.window&&(e.window=null),t.state=null,0}(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==i||(this.onEnd(0),c.avail_out=0,!0)},Hm.prototype.onData=function(t){this.chunks.push(t)},Hm.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,r,i,o,n,a;for(i=0,e=0,r=t.length;e0;)r[i]=arguments[i+1];t.Debug&&qt.time("concatStructures");var o=new hc(e,""),n=new xs(o),a=o.atomStore,s=o.atomMap;a.addField("formalCharge",1,"int8"),a.addField("partialCharge",1,"float32");var c={},u=0,l=0,h=0;r.forEach((function(t){t.eachAtom((function(t){a.growIfFull(),a.atomTypeId[u]=s.add(t.atomname,t.element),a.x[u]=t.x,a.y[u]=t.y,a.z[u]=t.z,a.serial[u]=t.serial,a.formalCharge[u]=t.formalCharge,a.partialCharge[u]=t.partialCharge,a.altloc[u]=t.altloc,a.occupancy[u]=t.occupancy,a.bfactor[u]=t.bfactor,n.addAtom(t.modelIndex+h,t.chainname,t.chainid,t.resname,t.resno,1===t.hetero,t.sstruc,t.inscode),c[t.index+l]=u,u+=1})),l+=t.atomStore.count,h+=t.modelStore.count}));var p=o.bondStore,d=o.getAtomProxy(),f=o.getAtomProxy();return l=0,r.forEach((function(t){t.eachBond((function(t){d.index=c[t.atomIndex1+l],f.index=c[t.atomIndex2+l],p.addBond(d,f,t.bondOrder)})),l+=t.atomStore.count})),n.finalize(),Bs(o,!0),Ts(o,!0),o.finalizeAtoms(),o.finalizeBonds(),Ls(o),t.Debug&&qt.timeEnd("concatStructures"),o},t.download=A,t.flatten=function t(e,r){r=y(r,[]);for(var i=0;ie?(a&&(clearTimeout(a),a=null),s=u,n=t.apply(i,o),a||(i=o=null)):a||!1===r.trailing||(a=setTimeout(c,l)),n}},t.uniqueArray=I,Object.defineProperty(t,"__esModule",{value:!0})})); + * Kdtree + * @class + * @author Alexander Rose , 2016 + * @author Roman Bolzern , 2013 + * @author I4DS http://www.fhnw.ch/i4ds, 2013 + * @license MIT License + * @description + * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place + * provides fast nearest neighbour search + * + * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs + * + * Further information (including mathematical properties) + * http://en.wikipedia.org/wiki/Binary_tree + * http://en.wikipedia.org/wiki/K-d_tree + * + * @example + * points: [x, y, z, x, y, z, x, y, z, ...] + * metric: function(a, b){ + * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2); + * } + * + * @param {Float32Array} points - points + * @param {Function} metric - metric + */class bo{constructor(e,t){this.points=e,this.metric=t,this.maxDepth=0,this.currentNode=0;const i=e.length/3,r=new Uint32Array(i);for(let e=0;ethis.maxDepth&&(this.maxDepth=e);const s=r-i;if(0===s)return-1;const n=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===s)return o[n]=i,o[n+1]=-1,o[n+2]=-1,o[n+3]=t,n;const a=this.indices,c=this.points,l=i+Math.floor(s/2),h=e%3;let u,d,m,p,f,g=i,y=r-1;for(;y>g;){for(m=g+y>>1,p=c[3*a[m]+h],d=a[m],a[m]=a[y],a[y]=d,f=g,u=g;u-e[1])),s=this.nodes,n=this.points,o=this.indices,a=c=>{let l,h;const u=this.getNodeDepth(c)%3,d=3*o[s[c]],m=[n[d+0],n[d+1],n[d+2]],p=this.metric(e,m);function f(e,i){r.push([e,i]),r.size()>t&&r.pop()}const g=s[c+1],y=s[c+2];if(-1===y&&-1===g)return void((r.size()n[3*o[s[e]]+r])throw new Error("left child is > parent!");i+=this.verify(a,t+1)}if(-1!==c){if(n[3*o[s[c]]+r]0}isBackbone(){const e=this.residueType.backboneIndexList;return e.length>0&&e.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const e=this.residueType.backboneType;return 4===e||5===e||6===e}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const e=this.residueType.moleculeType;return 4===e||5===e}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return $r.includes(this.sstruc)}isSheet(){return Fr.includes(this.sstruc)}isTurn(){return Er.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let e=!1;return 1!==this.number||(e=!this.hasBondToElement(6)),e}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(e){const t=this.atomStore,i=e.atomStore,r=this.index,s=e.index,n=t.x[r]-i.x[s],o=t.y[r]-i.y[s],a=t.z[r]-i.z[s],c=n*n+o*o+a*a;return Math.sqrt(c)}connectedTo(e){const t=this.atomStore,i=e.atomStore,r=this.index,s=e.index;if(t.altloc&&i.altloc){const e=t.altloc[r],n=i.altloc[s];if(0!==e&&0!==n&&32!==e&&32!==n&&e!==n)return!1}const n=t.x[r]-i.x[s],o=t.y[r]-i.y[s],a=t.z[r]-i.z[s],c=n*n+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+e.covalent,h=l+.3,u=l-.5;return cu*u}positionFromArray(e,t=0){return this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this}positionToArray(e=[],t=0){const i=this.index,r=this.atomStore;return e[t+0]=r.x[i],e[t+1]=r.y[i],e[t+2]=r.z[i],e}positionToVector3(e){return void 0===e&&(e=new t.Vector3),e.x=this.x,e.y=this.y,e.z=this.z,e}positionFromVector3(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}positionAdd(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}positionSub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}getResidueBonds(e=!1){const t=this.residueAtomOffset,i=this.index-this.residueAtomOffset,r=this.residueType.getBonds(),s=r.atomIndices1,n=r.atomIndices2;let o,a,c,l;for(e||(l=[]),o=s.indexOf(i);-1!==o;){if(c=n[o]+t,!l)return c;l.push(c),o=s.indexOf(i,o+1)}for(a=n.indexOf(i);-1!==a;){if(c=s[a]+t,!l)return c;l.push(c),a=n.indexOf(i,a+1)}return l}qualifiedName(e=!1){var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chainname&&(t+=":"+this.chainname),this.atomname&&(t+="."+this.atomname),this.altloc&&(t+="%"+this.altloc),this.structure.modelStore.count>1&&(t+="/"+this.modelIndex),t}clone(){return new xo(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function vo(e,t){const i=e[0]-t[0],r=e[1]-t[1],s=e[2]-t[2];return i*i+r*r+s*s}function wo(e,t){return Math.sqrt(vo(e,t))}const Ao=new Float32Array(3);class _o{constructor(t,i=!1){e.Debug&&Be.time("Kdtree build");const r=i?vo:wo,s=new Float32Array(3*t.atomCount),n=new Uint32Array(t.atomCount);let o=0;t.eachAtom((function(e){s[o+0]=e.x,s[o+1]=e.y,s[o+2]=e.z,n[o/3]=e.index,o+=3})),this.atomIndices=n,this.points=s,this.kdtree=new bo(s,r),e.Debug&&Be.timeEnd("Kdtree build")}nearest(e,i,r){e instanceof t.Vector3?e.toArray(Ao):e instanceof xo&&e.positionToArray(Ao);const s=this.kdtree.nearest(Ao,i,r),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,c=[];for(let e=0,t=s.length;e":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Co={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","F 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ","F 4/m -3 2/c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Po=/^[1-9]$/;function Io(e){let t="";return e.length>0&&(t=":"+x(e).join(" OR :")),new ye(t)}class ko{constructor(e=""){this.name=e,this.partList=[]}get type(){return"Assembly"}addPart(e,t){const i=new Mo(e,t);return this.partList.push(i),i}getAtomCount(e){return this.partList.reduce(((t,i)=>t+i.getAtomCount(e)),0)}getResidueCount(e){return this.partList.reduce(((t,i)=>t+i.getResidueCount(e)),0)}getInstanceCount(){let e=0;return this.partList.forEach((function(t){e+=t.matrixList.length})),e}isIdentity(e){if(1!==this.partList.length)return!1;const i=this.partList[0];if(1!==i.matrixList.length)return!1;if(!(new t.Matrix4).equals(i.matrixList[0]))return!1;let r=[];return e.eachChain((function(e){r.push(e.chainname)})),r=x(r),i.chainList.length===r.length}getBoundingBox(e){const i=new t.Box3;return this.partList.forEach((function(t){const r=t.getBoundingBox(e);i.expandByPoint(r.min),i.expandByPoint(r.max)})),i}getCenter(e){return this.getBoundingBox(e).getCenter(new t.Vector3)}getSelection(){let e=[];return this.partList.forEach((function(t){e=e.concat(t.chainList)})),Io(e)}}class Mo{constructor(e=[],t=[]){this.matrixList=e,this.chainList=t}get type(){return"AssemblyPart"}_getCount(e,t){let i=0;return e.eachChain((e=>{(0===this.chainList.length||this.chainList.includes(e.chainname))&&(i+=e[t])})),this.matrixList.length*i}getAtomCount(e){return this._getCount(e,"atomCount")}getResidueCount(e){return this._getCount(e,"residueCount")}getBoundingBox(e){const i=new t.Box3,r=new t.Box3,s=this.getSelection(),n=e.getBoundingBox(s);return this.matrixList.forEach((function(e){r.copy(n).applyMatrix4(e),i.expandByPoint(r.min),i.expandByPoint(r.max)})),i}getSelection(){return Io(this.chainList)}getView(e){const t=this.getSelection();return t?e.getView(t):e}getInstanceList(){const e=[];for(let t=0,i=this.matrixList.length;t0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=s,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=e,this.currentChainid=i,this.currentResname=r,this.currentResno=s,this.currentInscode=a,this.currentHetero=n}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function To(t,i){if(!i)return;e.Debug&&Be.time("assignSecondaryStructure");const r=[];t.eachModel((function(e){e.eachChain((function(e){r.push(e.chainname)}))}));const s=r.slice().sort(),n=[];s.forEach((function(e){n.push(r.indexOf(e))}));const o=i.helices.filter((function(e){return y(s,e[0])>=0}));o.sort((function(e,t){const i=e[0],r=t[0],o=e[1],a=t[1];if(i===r)return o===a?0:o=0}));c.sort((function(e,t){const i=e[0],r=t[0];if(i===r)return 0;const o=y(s,i),a=y(s,r);return n[o]=e.residueCount)continue;o.index=n+s,a.index=n+s+t,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[t-2])>r)return!1}return!0},r=function(e,t){return i(e,t,[5.45,5.18,6.37],2.1)},s=function(e,t){return i(e,t,[6.1,10.4,13],1.42)};return function(i){e.Debug&&Be.time("calculateSecondaryStructure"),i.eachPolymer((function(e){if(e.residueCount<4)return;if(e.isCg())!function(e){const i=e.residueStore,r=e.residueIndexStart,s=new go(e).position,n=new t.Vector3,o=new t.Vector3;for(let t=0,a=e.residueCount;t1&&s.bending[t]<20&&(i.sstruc[r+t]="h".charCodeAt(0),i.sstruc[r+t+1]="h".charCodeAt(0))}}(e);else{if(!e.isProtein())return;!function(e){const t=e.residueStore,i=e.residueIndexStart;for(let n=0,o=e.residueCount;n=t;)i=Math.floor(i/t),s+=Ro[i%t],r+=1;return r>=5&&Be.warn("chainname overflow"),s}function $o(t,i=!1){e.Debug&&Be.time("calculateChainnames");let r=!0;if(t.eachChain((function(e){e.chainname&&(r=!1)})),r){const e=t.modelStore,r=t.chainStore,s=t.residueStore,n=function(t,i,n,o){const a=r.count;for(let e=0;e500)return void Be.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName());const s=e.getBonds(),n=s.atomIndices1,h=s.atomIndices2,u=s.bondOrders,d=n.length;for(let t=0;t{d.forEach((i=>{e.push(t.clone().multiply(i))}))})),h.addPart(e)}else h.addPart(u);const m=new t.Vector3,p=new ko("SUPERCELL"),f=Array.prototype.concat.call(l(m.set(1,0,0)),l(m.set(0,1,0)),l(m.set(0,0,1)),l(m.set(-1,0,0)),l(m.set(0,-1,0)),l(m.set(0,0,-1)),l(m.set(1,1,0)),l(m.set(1,0,1)),l(m.set(0,1,1)),l(m.set(-1,-1,0)),l(m.set(-1,0,-1)),l(m.set(0,-1,-1)),l(m.set(1,-1,-1)),l(m.set(1,1,-1)),l(m.set(1,-1,1)),l(m.set(-1,1,1)),l(m.set(-1,-1,1)),l(m.set(-1,1,-1)),l(m.set(0,1,-1)),l(m.set(0,-1,1)),l(m.set(1,0,-1)),l(m.set(-1,0,1)),l(m.set(1,-1,0)),l(m.set(-1,1,0)),l(),l(m.set(1,1,1)),l(m.set(-1,-1,-1)));if(i.biomolDict.NCS){const e=[];f.forEach((function(t){d.forEach((function(i){e.push(t.clone().multiply(i))}))})),p.addPart(e)}else p.addPart(f);i.biomolDict.UNITCELL=h,i.biomolDict.SUPERCELL=p,e.Debug&&Be.timeEnd("buildUnitcellAssembly")}const Go=["H","C","O","N","S","P"],Uo=["NA","CL","FE"];function jo(e){let t=e.toUpperCase(),i=0,r=0;for(let e=0;e0)break;++i}else r=e+1;(i>0||r=3&&-1!==Go.indexOf(t[0])?t[0]:""}function Ho(e){const t=e.bondHash,i=t.countArray,r=t.offsetArray,s=t.indexArray,n=e.getBondProxy();e.eachResidue((function(e){const t=e.residueType;if(void 0!==t.bonds)return;var o=e.atomOffset,a=[],c=[],l=[],h={};const u=o+e.atomCount;e.eachAtom((function(e){const t=e.index,d=r[t];for(let e=0,r=i[t];e=u)continue;let i=n.atomIndex2;if(i=u)continue;if(t>i){const e=i;i=t,t=e}const r=t+"|"+i;void 0===h[r]&&(h[r]=!0,a.push(t-o),c.push(i-o),l.push(n.bondOrder))}})),t.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}const Wo=[3,11,19,37,55,87],qo=[4,12,20,38,56,88],Xo=[6,15,16,34],Yo=[1,7,8,9,17,35,53],Ko=[2,10,18,36,54,86],Zo=[13,30,31,48,49,50,80,81,82,83,84,85,112],Qo=[5,14,32,33,51,52,85],Jo=[9,17,35,53,85];class ea{constructor(e,t,i){this.structure=e,this.atomname=t,i=i||jo(t),this.element=i,this.number=Lr[i]||0,this.vdw=Nr[this.number]||2,this.covalent=zr[this.number]||1.6}getDefaultValence(){const e=Vr[this.number];return e?e[0]:-1}getValenceList(){return Vr[this.number]||[]}getOuterShellElectronCount(){return Gr[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return Qo.includes(this.number)}isHalogen(){return Jo.includes(this.number)}isDiatomicNonmetal(){return Yo.includes(this.number)}isPolyatomicNonmetal(){return Xo.includes(this.number)}isAlkaliMetal(){return Wo.includes(this.number)}isAlkalineEarthMetal(){return qo.includes(this.number)}isNobleGas(){return Ko.includes(this.number)}isTransitionMetal(){const e=this.number;return e>=21&&e<=29||e>=39&&e<=47||e>=72&&e<=79||e>=104&&e<=108}isPostTransitionMetal(){return Zo.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class ta{constructor(e){this.structure=e,this.dict={},this.list=[],this.structure=e}add(e,t){const i=function(e,t){return e+"|"+t}(e=e.toUpperCase(),t=t?t.toUpperCase():jo(e));let r=this.dict[i];if(void 0===r){const s=new ea(this.structure,e,t);r=this.list.length,this.dict[i]=r,this.list.push(s)}return r}get(e){return this.list[e]}}class ia{constructor(e,t,i,r,s,n){this.structure=e,this.bondReferenceAtomIndices=[],this.resname=t,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=s,this.bonds=n,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=is[this.backboneType],a=is[this.backboneStartType],c=is[this.backboneEndType],h=this.getAtomIndexByName(o.trace);this.traceAtomIndex=l(h,-1);const u=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=l(u,-1);const d=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=l(d,-1);const m=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=l(m,-1);const p=this.getAtomIndexByName(c.backboneEnd);let f;this.backboneEndAtomIndex=l(p,-1),f=Yr.includes(t)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=l(f,-1)}getBackboneIndexList(){const e=[];let t;switch(this.moleculeType){case 3:t=es;break;case 4:case 5:t=ts;break;default:return e}const i=this.structure.atomMap,r=this.atomTypeIdList;for(let s=0,n=this.atomCount;s500)e.Debug&&Be.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(n>50){const e=new _o(t,!0),i=t.isCg()?1.2:2.3;for(let t=o;t=0||oa(e,t);this.rings={atomRings:e.atomRings,rings:e.rings}}isAromatic(e){return this.aromaticAtoms=this.getAromatic(e),1===this.aromaticAtoms[e.index-e.residueAtomOffset]}calculateAromatic(e){const t=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,r=i.map((t=>function(e){if(e.some((e=>!ra.includes(e.number))))return!1;let t=0;const i=new Js(3,e.length),r=i.data;e.forEach((e=>{r[t+0]=e.x,r[t+1]=e.y,r[t+2]=e.z,t+=3}));return new oo(i).vecC.length()this.structure.getAtomProxy(t+e.atomOffset)))))),s=this.aromaticRings=[];i.forEach(((e,i)=>{r[i]&&(s.push(e),e.forEach((e=>t[e]=1)))}))}assignBondReferenceAtomIndices(){const e=this.getBondGraph(),t=this.getRings(),i=t.atomRings,r=t.rings,s=this.bonds,n=s.atomIndices1,o=s.atomIndices2,a=s.bondOrders,c=this.bondReferenceAtomIndices,l=s.atomIndices1.length;c.length=0;for(let t=0;t1)for(let i=0;i1)for(let i=0;i=0;e--)p[f++]=o[e];const g=e.rings.length;for(let t=0;t0?n[c]!==t&&n[t]!==c&&na(e,t,c):(r[c]=1,s[a++]=c,n[c]=t)}}}const aa=4;class ca{constructor(e){this.structure=e,this.dict={},this.list=[]}add(e,t,i,r="",s){const n=function(e,t,i,r=""){return e+"|"+t.join(",")+"|"+(i?1:0)+"|"+r}(e=e.toUpperCase(),t,i,r);let o=this.dict[n];if(void 0===o){const a=new ia(this.structure,e,t,i,r,s);o=this.list.length,this.dict[n]=o,this.list.push(a)}return o}get(e){return this.list[e]}}class la{constructor(e,i=0){this.structure=e,this.index=i,this.bondStore=e.bondStore,this._v12=new t.Vector3,this._v13=new t.Vector3,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(e){this.bondStore.atomIndex1[this.index]=e}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(e){this.bondStore.atomIndex2[this.index]=e}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(e){this.bondStore.bondOrder[this.index]=e}getOtherAtomIndex(e){return e===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(e){return this.structure.getAtomProxy(this.getOtherAtomIndex(e.index))}getReferenceAtomIndex(){const e=this._ap1,t=this._ap2;if(e.index=this.atomIndex1,t.index=this.atomIndex2,e.residueIndex!==t.residueIndex)return;const i=e.index-e.residueAtomOffset,r=t.index-t.residueAtomOffset,s=e.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==s)return s+e.residueAtomOffset;console.warn("No reference atom found",e.index,t.index)}calculateShiftDir(e=new t.Vector3){const i=this._ap1,r=this._ap2,s=this._ap3,n=this._v12,o=this._v13;i.index=this.atomIndex1,r.index=this.atomIndex2;const a=this.getReferenceAtomIndex();n.subVectors(i,r).normalize(),void 0!==a?(s.index=a,o.subVectors(i,s)):o.copy(i),o.normalize();let c=n.dot(o);return 1-Math.abs(c)<1e-5&&(o.set(1,0,0),c=n.dot(o),1-Math.abs(c)<1e-5&&(o.set(0,1,0),c=n.dot(o))),e.copy(o.sub(n.multiplyScalar(c))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new la(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class ha{constructor(e,t=0){this.structure=e,this.index=t,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueMap=e.residueMap,this.atomMap=e.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(e){this.residueStore.chainIndex[this.index]=e}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(e){this.residueStore.atomOffset[this.index]=e}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(e){this.residueStore.atomCount[this.index]=e}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(e){this.residueStore.resno[this.index]=e}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(e){this.residueStore.setSstruc(this.index,e)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(e){this.residueStore.setInscode(this.index,e)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.x[t];return e/this.atomCount}get y(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.y[t];return e/this.atomCount}get z(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.z[t];return e/this.atomCount}eachAtom(e,t){const i=this.atomCount,r=this.atomOffset,s=this.structure._ap,n=r+i;if(t&&t.atomOnlyTest){const i=t.atomOnlyTest;for(let t=r;t0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return $r.includes(this.sstruc)}isSheet(){return Fr.includes(this.sstruc)}isTurn(){return Er.includes(this.sstruc)&&this.isProtein()}getAtomType(e){return this.atomMap.get(this.atomStore.atomTypeId[e])}getResname1(){return Hr[this.resname.toUpperCase()]||"X"}getBackboneType(e){switch(e){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(e){let t=this.residueType.getAtomIndexByName(e);return void 0!==t&&(t+=this.atomOffset),t}hasAtomWithName(e){return this.residueType.hasAtomWithName(e)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const e=this.atomCount,t=this.atomOffset,i=new Array(e);for(let r=0;r=t){const t=l(e,this.structure.getResidueProxy());if(t.index=i,t.connectedTo(this))return t}else if(i===t-1){const i=this.chainStore.residueCount[this.chainIndex],r=l(e,this.structure.getResidueProxy());if(r.index=t+i-1,r.connectedTo(this))return r}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(e=!1){let t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chain&&(t+=":"+this.chainname),t+="/"+this.modelIndex,t}clone(){return new ha(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class ua{constructor(e,t,i){this.structure=e,this.residueIndexStart=t,this.residueIndexEnd=i,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueCount=i-t+1;const r=this.structure.getResidueProxy(this.residueIndexStart),s=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();const n=s.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=s.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(e){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(e)}getAtomIndexByType(e,t){this.isCyclic?-1===e?e=this.residueCount-1:e===this.residueCount&&(e=0):(-1!==e||this.isPrevConnected||(e+=1),e!==this.residueCount||this.isNextNextConnected||(e-=1));const i=this.__residueProxy;let r;switch(i.index=this.residueIndexStart+e,t){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(t)}return r}eachAtom(e,t){this.eachResidue((function(i){i.eachAtom(e,t)}))}eachAtomN(e,t,i){const r=this.residueCount,s=new Array(e);for(let t=0;t1&&e(new ua(n,i,l.index)),i=r)):(o!==Mr&&l.index-i>1&&e(new ua(n,i,l.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneEndType&&e(new ua(n,i,r))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new da(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class ma{constructor(e,t=0){this.structure=e,this.index=t,this.modelStore=e.modelStore,this.chainStore=e.chainStore,this.residueStore=e.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(e){this.modelStore.chainOffset[this.index]=e}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(e){this.modelStore.chainCount[this.index]=e}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(e,t){this.eachChain((function(i){i.eachAtom(e,t)}),t)}eachResidue(e,t){this.eachChain((function(i){i.eachResidue(e,t)}),t)}eachPolymer(e,t){if(t&&t.chainOnlyTest){const i=t.chainOnlyTest;this.eachChain((function(r){i(r)&&r.eachPolymer(e,t)}))}else this.eachChain((function(i){i.eachPolymer(e,t)}))}eachChain(e,t){const i=this.chainCount,r=this.chainOffset,s=this.structure._cp,n=r+i;if(t&&t.test){const i=t.chainOnlyTest;if(i)for(let t=r;t{const i=3*t;a.index=e,h&&a.positionToArray(h,i),u&&n.atomColorToArray(a,u,i),d&&(d.array[t]=e),m&&(m[t]=s.atomRadius(a)),p&&(p[t]=e)})),o}getBondData(e){const i=Object.assign({},e);i.colorParams&&(i.colorParams.structure=this.getStructure());const r=i.what,s=l(i.bondSet,this.bondSet),n=l(i.multipleBond,"off"),o="off"!==n,a="offset"===n,c=l(i.bondScale,.4),h=l(i.bondSpacing,1);let u,d;const m={},p=this.getBondProxy();i.bondStore&&(p.bondStore=i.bondStore);const f=this.getAtomProxy(),g=this.getAtomProxy();let y;if(o){const e=p.bondStore.bondOrder;y=0,s.forEach((function(t){y+=e[t]}))}else y=s.getSize();r&&!r.position||(m.position1=new Float32Array(3*y),m.position2=new Float32Array(3*y)),r&&!r.color||!i.colorParams||(m.color=new Float32Array(3*y),m.color2=new Float32Array(3*y),d=Ee.getScheme(i.colorParams)),r&&!r.picking||(m.picking=new zs(new Float32Array(y),this.getStructure(),i.bondStore)),(!r||r.radius||o&&r.position)&&(u=new ro(i.radiusParams)),r&&!r.radius||(m.radius=new Float32Array(y),i.radius2&&(m.radius2=new Float32Array(y)));const{position1:b,position2:x,color:v,color2:w,picking:A,radius:_,radius2:S}=m;let C,P,I,k,M,D,T=0;const B=new t.Vector3,R=new t.Vector3,O=new t.Vector3;return s.forEach((e=>{if(P=3*T,p.index=e,f.index=p.atomIndex1,g.index=p.atomIndex2,k=p.bondOrder,b)if(o&&k>1){const e=u.atomRadius(f);D=e*c/(.5*k),p.calculateShiftDir(O),a?(M=2*h*e,O.multiplyScalar(M),O.negate(),R.subVectors(g,f).multiplyScalar(Math.max(.1,M/1.88)),f.positionToArray(b,P),g.positionToArray(x,P),k>=2&&(B.addVectors(f,O).add(R).toArray(b,P+3),B.addVectors(g,O).sub(R).toArray(x,P+3),k>=3&&(B.subVectors(f,O).add(R).toArray(b,P+6),B.subVectors(g,O).sub(R).toArray(x,P+6)))):(M=(h-c)*e,O.multiplyScalar(M),2===k?(B.addVectors(f,O).toArray(b,P),B.subVectors(f,O).toArray(b,P+3),B.addVectors(g,O).toArray(x,P),B.subVectors(g,O).toArray(x,P+3)):3===k?(f.positionToArray(b,P),B.addVectors(f,O).toArray(b,P+3),B.subVectors(f,O).toArray(b,P+6),g.positionToArray(x,P),B.addVectors(g,O).toArray(x,P+3),B.subVectors(g,O).toArray(x,P+6)):(f.positionToArray(b,P),g.positionToArray(x,P)))}else f.positionToArray(b,P),g.positionToArray(x,P);if(v&&w&&(d.bondColorToArray(p,1,v,P),d.bondColorToArray(p,0,w,P),o&&k>1))for(C=1;C1))for(C=1;C1))for(D=_[T]*c/(a?1:.5*k),C=a?1:0;C1))for(D=S[T]*c/(a?1:.5*k),C=a?1:0;C{const t=e.x,i=e.y,r=e.z;ta&&(a=t),i>c&&(c=i),r>l&&(l=r)}),i),r.min.set(s,n,o),r.max.set(a,c,l),e.Debug&&Be.timeEnd("getBoundingBox"),r}getPrincipalAxes(t){e.Debug&&Be.time("getPrincipalAxes");let i=0;const r=new Js(3,this.atomCount),s=r.data;return this.eachAtom((e=>{s[i+0]=e.x,s[i+1]=e.y,s[i+2]=e.z,i+=3}),t),e.Debug&&Be.timeEnd("getPrincipalAxes"),new oo(r)}atomCenter(e){return e?this.getBoundingBox(e).getCenter(new t.Vector3):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const e=this.atomStore;this._hasCoords=0!==Ct(e.x)||0!==St(e.x)||0!==Ct(e.y)||0!==St(e.y)||0!==Ct(e.z)||0!==St(e.z)||e.count/this.modelStore.count==1}return this._hasCoords}getSequence(e){const t=[],i=this.getResidueProxy();return this.eachAtom((function(e){i.index=e.residueIndex,e.index===i.traceAtomIndex&&t.push(i.getResname1())}),e),t}getAtomIndices(e){if(e&&e.string){const t=[];return this.eachAtom((function(e){t.push(e.index)}),e),new Uint32Array(t)}{const e={what:{index:!0}};return this.getAtomData(e).index}}getChainnameCount(e){const t=new Set;return this.eachChain((function(e){e.residueCount&&t.add(e.chainname)}),e),t.size}updatePosition(e,t=!0){let i=0;this.eachAtom((function(t){t.positionFromArray(e,i),i+=3}),void 0),this._hasCoords=void 0,t&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new vr(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const fa=new t.Box3,ga=[mr,lr,pr,dr,fr,hr,cr,ur,yr,gr,br,xr],ya={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class ba{constructor(e="shape",i={}){this.boundingBox=new t.Box3,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=e,this.parameters=h(i,ya),ga.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)]=[]})),this._primitiveData[e.getShapeKey("name")]=[]}))}addBuffer(e){this.bufferList.push(e);const t=e.geometry;return t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox),this}addMesh(e,t,i,r,s){let n;e=k(e),t=k(t),Array.isArray(i)&&(i=A(i,e.length)),r&&(r=k(r)),n=void 0===r||0==r.length?{position:e,color:t,index:i}:{position:e,color:t,index:i,normal:r};const o=new Hs(this,Object.assign({serial:this.meshCount,name:s},n)),a=new Bn(Object.assign({picking:o},n));return this.bufferList.push(a),fa.setFromArray(e),this.boundingBox.union(fa),this.meshCount+=1,this}addSphere(e,t,i,r){return cr.objectToShape(this,{position:e,color:t,radius:i,name:r}),this}addEllipsoid(e,t,i,r,s,n){return fr.objectToShape(this,{position:e,color:t,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addTorus(e,t,i,r,s,n){return gr.objectToShape(this,{position:e,color:t,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addCylinder(e,t,i,r,s){return dr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addCone(e,t,i,r,s){return pr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addArrow(e,t,i,r,s){return mr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addBox(e,t,i,r,s,n){return lr.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addOctahedron(e,t,i,r,s,n){return hr.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addTetrahedron(e,t,i,r,s,n){return ur.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addText(e,t,i,r){return yr.objectToShape(this,{position:e,color:t,size:i,text:r}),this}addPoint(e,t,i){return br.objectToShape(this,{position:e,color:t,name:i}),this}addWideline(e,t,i,r,s){return this.parameters.linewidth=r,xr.objectToShape(this,{position1:e,position2:t,color:i,name:s}),this}addLabel(e,t,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(e,t,i,r)}getBufferList(){const e=[];return ga.forEach((t=>{this._primitiveData[t.getShapeKey("color")].length&&e.push(t.bufferFromShape(this,this.parameters))})),this.bufferList.concat(e)}dispose(){this.bufferList.forEach((function(e){e.dispose()})),this.bufferList.length=0,ga.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)].length=0})),this._primitiveData[e.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new t.Vector3)),this._center}get type(){return"Shape"}}class xa extends Di{constructor(e,t,i){Array.isArray(e)||(e=[e]),super(e,t,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}init(e){super.init(e),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e),e.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),e()}}const va=new t.Matrix4,wa=new t.Matrix3;class Aa extends Bn{constructor(e,t={},i){super(function(e,t){const i=t.attributes.position.array,r=t.index?t.index.array:void 0,s=e.position.length/3,n=i.length/3,o=s*n,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return r&&(h=A(s*r.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:e.primitiveId||vt(s,n),picking:e.picking}}(e,i),t),this.updateNormals=!1;const r=i.attributes.position.array,s=i.attributes.normal.array,n=i.index?i.index.array:void 0;this.geoPosition=r,this.geoNormal=s,this.geoIndex=n,this.positionCount=e.position.length/3,this.geoPositionCount=r.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(e),n){const e=this.geometry.getIndex();if(!e)return void Be.error("Index is null");this.meshIndex=e.array,this.makeIndex()}}setAttributes(e={},t=!1){const i=this.geometry.attributes;let r,s,n,o,a,c,l,h,u;const d=this.updateNormals;e.position&&(r=e.position,n=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(d||t)&&(o=this.geoNormal,u=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),e.color&&(s=e.color,h=this.meshColor,i.color.needsUpdate=!0);const m=this.positionCount,p=this.geoPositionCount;for(let e=0;e 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Pa extends Tn{constructor(e,t,i={}){super(t,i),this.index=A(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:xt(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(e){const t={};for(const i in e){const r=e[i];t[i]={type:r.type,value:null}}super.addAttributes(t)}getAttributeIndex(e){return 3*e*this.mappingSize}setAttributes(e){e&&!e.position&&e.position1&&e.position2&&(e.position=ft(e.position1,e.position2));const t=this.size,i=this.mappingSize,r=this.geometry.attributes;let s,n,o,a,c,l,h;for(const u in e)if("index"!==u&&"picking"!==u){n=e[u],s=r[u],o=s.itemSize,a=s.array;for(let e=0;e0&&this.parameters.alphaTest<=1&&(t.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),t}setUniforms(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),super.setUniforms(e)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}je.add("point",$a);class Fa extends Di{constructor(e,t,i){super(e,t,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Cn?(this.surface=void 0,this.volume=new ao(e)):(this.surface=e,this.volume=void 0),this.init(i)}init(e){var t=e||{};t.colorScheme=l(t.colorScheme,"uniform"),t.colorValue=l(t.colorValue,14540253),this.thresholdType=l(t.thresholdType,"sigma"),this.thresholdMin=l(t.thresholdMin,2),this.thresholdMax=l(t.thresholdMax,1/0),this.thresholdOut=l(t.thresholdOut,!1),this.dotType=l(t.dotType,"point"),this.radius=l(t.radius,.1),this.scale=l(t.scale,1),this.pointSize=l(t.pointSize,1),this.sizeAttenuation=l(t.sizeAttenuation,!0),this.sortParticles=l(t.sortParticles,!1),this.useTexture=l(t.useTexture,!1),this.alphaTest=l(t.alphaTest,.5),this.forceTransparent=l(t.forceTransparent,!1),this.edgeBleach=l(t.edgeBleach,0),super.init(t),this.build()}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){var e={};if(this.volume){var t,i,r=this.volume;"sigma"===this.thresholdType?(t=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(t=this.thresholdMin,i=this.thresholdMax),r.setFilter(t,i,this.thresholdOut),Object.assign(e,{position:r.getDataPosition(),color:r.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:r.getDataSize(this.radius,this.scale),picking:r.getDataPicking()})}else{var s=this.surface;Object.assign(e,{position:s.getPosition(),color:s.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:s.getSize(this.radius,this.scale),picking:s.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Ta(e,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new $a(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(e={}){if(0===this.bufferList.length)return;const t={};e.color&&(this.volume?Object.assign(t,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(t,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(e.radius||e.scale)&&(this.volume?Object.assign(t,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(t,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(t)}setParameters(e,t={},i){return e&&void 0!==e.thresholdType&&this.volume instanceof Cn&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=parseFloat(e.radiusType),t.radius=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(t.radius=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(t.scale=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),super.setParameters(e,t,i),this}}Ve.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),Ve.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const Ea=new Uint16Array([0,1,2,1,3,2]),La=new Float32Array([0,1,0,0,1,1,1,0]),Na=Object.assign({filter:"nearest",forceTransparent:!0},Mn),za=Object.assign({filter:{updateShader:!0,uniform:!0}},Dn);class Va extends Tn{constructor(e,i){super({position:e.position,index:Ea,picking:e.picking},i),this.parameterTypes=za,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:r,width:s,height:n}=e,o=new t.DataTexture(r,s,n);o.flipY=!0,this.tex=o;const a=r.length,c=new Uint8Array(a);for(let e=0;e>16&255,c[e+1]=t>>8&255,c[e+2]=255&t}const l=new t.DataTexture(c,s,n);l.flipY=!0,l.minFilter=t.NearestFilter,l.magFilter=t.NearestFilter,this.pickingTex=l,this.addUniforms({map:{value:o},pickingMap:{value:l},mapSize:{value:new t.Vector2(s,n)}}),this.geometry.setAttribute("uv",new t.BufferAttribute(La,2))}get defaultParameters(){return Na}getDefines(e){const t=super.getDefines(e),i=this.parameters.filter;return i.startsWith("cubic")&&(t.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?t.BSPLINE_FILTER=1:i.endsWith("catmulrom")?t.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(t.MITCHELL_FILTER=1)),t}updateTexture(){const e=this.tex,i=this.parameters.filter;i.startsWith("cubic")?(e.minFilter=t.NearestFilter,e.magFilter=t.NearestFilter):"linear"===i?(e.minFilter=t.LinearFilter,e.magFilter=t.LinearFilter):(e.minFilter=t.NearestFilter,e.magFilter=t.NearestFilter),e.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const e=this.material;e.uniforms.map.value=this.tex,e.blending=t.NormalBlending,e.needsUpdate=!0;const i=this.wireframeMaterial;i.uniforms.map.value=this.tex,i.blending=t.NormalBlending,i.needsUpdate=!0;const r=this.pickingMaterial;r.uniforms.map.value=this.tex,r.uniforms.pickingMap.value=this.pickingTex,r.blending=t.NormalBlending,r.needsUpdate=!0}setUniforms(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),super.setUniforms(e)}}class Ga{constructor(e,t){const i=t||{};this.dimension=l(i.dimension,"x"),this.positionType=l(i.positionType,"percent"),this.position=l(i.position,30),this.thresholdType=l(i.thresholdType,"sigma"),this.thresholdMin=l(i.thresholdMin,-1/0),this.thresholdMax=l(i.thresholdMax,1/0),this.normalize=l(i.normalize,!1),this.volume=e}getPositionFromCoordinate(e){const i=this.dimension,r=this.volume,s=r.matrix,n=(new t.Vector3).setFromMatrixPosition(s)[i],o=(new t.Vector3).setFromMatrixScale(s)[i];let a;return a="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((e-n)/(a/100)+1)/o)}getData(e){e=e||{};const i=this.volume,r=i.data,s=i.matrix;let n;function o(e){return Math.round(e/100*(n-1))}function a(e,t,r,s){return 3*(r*i.ny*i.nx+t*i.nx+e)+s}n="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const c=new Float32Array(12),l=new t.Vector3;let h,u,d,m,p,f=0,g=0,y=0,b=i.nx,x=i.ny,v=i.nz;function w(e,t,i,r){l.set(e,t,i).applyMatrix4(s).toArray(c,r)}"x"===this.dimension?(d=o(i.nx),m=i.ny-1,p=i.nz-1,h=i.nz,u=i.ny,f=d,b=f+1,w(d,0,0,0),w(d,m,0,3),w(d,0,p,6),w(d,m,p,9)):"y"===this.dimension?(d=i.nx-1,m=o(i.ny),p=i.nz-1,h=i.nz,u=i.nx,g=m,x=g+1,w(0,m,0,0),w(d,m,0,3),w(0,m,p,6),w(d,m,p,9)):"z"===this.dimension&&(d=i.nx-1,m=i.ny-1,p=o(i.nz),h=i.nx,u=i.ny,y=p,v=y+1,w(0,0,p,0),w(0,m,p,3),w(d,0,p,6),w(d,m,p,9));let A=0,_=0;const S=new Uint8Array(h*u*4),C=new Float32Array(h*u);let P,I;"sigma"===this.thresholdType?(P=i.getValueForSigma(this.thresholdMin),I=i.getValueForSigma(this.thresholdMax)):(P=this.thresholdMin,I=this.thresholdMax);const k=Object.assign({},e.colorParams,{volume:i});this.normalize&&(k.domain=[0,1]);const M=Ee.getScheme(k),D=new Float32Array(3),T=M.getScale();let B,R=0,O=0;if(this.normalize){R=1/0,B=-1/0;for(let e=g;eB&&(B=s)}O=B-R}for(let e=g;eP&&n{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){const e=new Ga(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),t=new Va(e.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(t)}}function ja(e){Be.error(`makeRepresentation: representation type ${e} unknown`)}const Ha={name:"some element",status:""};class Wa{constructor(e,t={}){this.stage=e,this.signals={statusChanged:new r.Signal,nameChanged:new r.Signal,disposed:new r.Signal},this.parameters=h(t,this.defaultParameters),this.uuid=O()}get defaultParameters(){return Ha}get name(){return this.parameters.name}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}dispose(){this.signals.disposed.dispatch()}}const qa=Object.assign({visible:!0},Ha);class Xa extends Wa{constructor(e,t,i={},s){super(e,Object.assign({name:t.type},i)),this.parent=s,this.signals=Object.assign({visibilityChanged:new r.Signal,parametersChanged:new r.Signal},this.signals),this.setRepresentation(t)}get defaultParameters(){return qa}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(e){this._disposeRepresentation(),this.repr=e,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(e){return this.parameters.visible=e,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(e){return this.repr.update(e),this}build(e){return this.repr.build(e),this}setSelection(e){const t=this.repr;return t.setSelection&&t.setSelection(e),this}setParameters(e){return this.repr.setParameters(e),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(e){return this.repr.setColor(e),this}}const Ya=new t.Matrix4,Ka=new t.Vector3,Za={name:"",status:"",visible:!0};class Qa{constructor(e,i,s={}){this.stage=e,this.object=i,this.signals={representationAdded:new r.Signal,representationRemoved:new r.Signal,visibilityChanged:new r.Signal,matrixChanged:new r.Signal,statusChanged:new r.Signal,nameChanged:new r.Signal,disposed:new r.Signal},this.reprList=[],this.annotationList=[],this.matrix=new t.Matrix4,this.position=new t.Vector3,this.quaternion=new t.Quaternion,this.scale=new t.Vector3(1,1,1),this.transform=new t.Matrix4,this.parameters=h(s,this.defaultParameters),this.uuid=O(),this.viewer=e.viewer,this.controls=new to(this)}get defaultParameters(){return Za}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(e){return Array.isArray(e)?this.position.fromArray(e):this.position.copy(e),this.updateMatrix(),this}setRotation(e){if(Array.isArray(e))if(3===e.length){const i=(new t.Euler).fromArray(e);this.quaternion.setFromEuler(i)}else this.quaternion.fromArray(e);else e instanceof t.Euler?this.quaternion.setFromEuler(e):this.quaternion.copy(e);return this.updateMatrix(),this}setScale(e){return this.scale.set(e,e,e),this.updateMatrix(),this}setTransform(e){return this.transform.copy(e),this.updateMatrix(),this}updateMatrix(){const e=this.getCenterUntransformed(Ka);this.matrix.makeTranslation(-e.x,-e.y,-e.z),Ya.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(Ya),Ya.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(Ya);const t=this.position;Ya.makeTranslation(t.x+e.x,t.y+e.y,t.z+e.z),this.matrix.premultiply(Ya),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((e=>{e.setParameters({matrix:this.matrix})}))}addAnnotation(e,t,i){const r=new Zn(this,e,t,i);return this.annotationList.push(r),r}eachAnnotation(e){this.annotationList.slice().forEach(e)}removeAnnotation(e){const t=this.annotationList.indexOf(e);-1!==t&&(this.annotationList.splice(t,1),e.dispose())}removeAllAnnotations(){this.eachAnnotation((e=>e.dispose())),this.annotationList.length=0}_addRepresentation(t,i,r,s=!1){const n=r||{},o=this.stage.getParameters();n.matrix=this.matrix.clone(),n.quality=n.quality||o.quality,n.disableImpostor=l(n.disableImpostor,!o.impostor),n.useWorker=l(n.useWorker,o.workerDefault),n.visible=l(n.visible,!0);const a=Object.assign({},n,{visible:this.parameters.visible&&n.visible}),c=function(t,i,r,s){var n;if(e.Debug&&Be.time("makeRepresentation "+t),i instanceof pa){if(!(n=Ne.get(t)))return void ja(t)}else if(i instanceof _n)if("surface"===t)n=Ln;else{if("dot"!==t)return void ja(t);n=Fa}else if(i instanceof Cn)if("surface"===t)n=Ln;else if("dot"===t)n=Fa;else{if("slice"!==t)return void ja(t);n=Ua}else if(i instanceof ba)n=xa,i=i.getBufferList();else{if("buffer"!==t)return void Be.error("makeRepresentation: object "+i+" unknown");n=xa}const o=new n(i,r,s);return e.Debug&&Be.timeEnd("makeRepresentation "+t),o}(t,i,this.viewer,a),h=new Xa(this.stage,c,n,this);return s||(this.reprList.push(h),this.signals.representationAdded.dispatch(h)),h}addBufferRepresentation(e,t){return this._addRepresentation.call(this,"buffer",e,t)}hasRepresentation(e){return-1!==this.reprList.indexOf(e)}eachRepresentation(e){this.reprList.slice().forEach(e)}removeRepresentation(e){const t=this.reprList.indexOf(e);-1!==t&&(this.reprList.splice(t,1),e.dispose(),this.signals.representationRemoved.dispatch(e))}updateRepresentations(e){this.reprList.forEach((t=>t.update(e))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((e=>e.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(e){return this.parameters.visible=e,this.eachRepresentation((e=>e.updateVisibility())),this.eachAnnotation((e=>e.updateVisibility())),this.signals.visibilityChanged.dispatch(e),this}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}getBox(...e){return this.getBoxUntransformed(...e).clone().applyMatrix4(this.matrix)}getCenter(...e){return this.getCenterUntransformed(...e).clone().applyMatrix4(this.matrix)}getZoom(...e){return this.stage.getZoomForBox(this.getBox(...e))}getBoxUntransformed(...e){return new t.Box3}getCenterUntransformed(...e){return this.getBoxUntransformed().getCenter(new t.Vector3)}autoView(e){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),l(e,0))}}class Ja{constructor(e=[]){this.list=e;const t=e.length;for(let i=0;i0?this.list[0]:void 0}forEach(e){return this.list.forEach(e),this}dispose(){return this.forEach((e=>e.dispose()))}}class ec extends Ja{setParameters(e){return this.forEach((t=>t.setParameters(e)))}setVisibility(e){return this.forEach((t=>t.setVisibility(e)))}setSelection(e){return this.forEach((t=>t.setSelection(e)))}setColor(e){return this.forEach((t=>t.setColor(e)))}update(e){return this.forEach((t=>t.update(e)))}build(e){return this.forEach((t=>t.build(e)))}dispose(e){return this.forEach((e=>e.dispose()))}}const tc=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},Ha);class ic extends Wa{constructor(e,t,i={}){super(e,Object.assign({name:t.name},i)),this.trajectory=t,this.signals=Object.assign(this.signals,{frameChanged:new r.Signal,playerChanged:new r.Signal,countChanged:new r.Signal,parametersChanged:new r.Signal}),t.signals.frameChanged.add((e=>{this.signals.frameChanged.dispatch(e)})),t.signals.playerChanged.add((e=>{this.signals.playerChanged.dispatch(e)})),t.signals.countChanged.add((e=>{this.signals.countChanged.dispatch(e)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return tc}get type(){return"trajectory"}setFrame(e){this.trajectory.setFrame(e)}setParameters(e={}){this.trajectory.setParameters(e),this.signals.parametersChanged.dispatch(e)}dispose(){this.trajectory.dispose(),super.dispose()}}class rc{constructor(e,t){this.name=e,this.path=t,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class sc{constructor(e,i){let r,s;if(this.A=new Js(3,3),this.W=new Js(1,3),this.U=new Js(3,3),this.V=new Js(3,3),this.VH=new Js(3,3),this.R=new Js(3,3),this.tmp=new Js(3,3),this.c=new Js(3,3),e instanceof pa)r=e.atomCount;else{if(!(e instanceof Float32Array))return;r=e.length/3}if(i instanceof pa)s=i.atomCount;else{if(!(i instanceof Float32Array))return;s=i.length/3}const n=Math.min(r,s),o=new Js(3,n),a=new Js(3,n);this.coords1t=new Js(n,3),this.coords2t=new Js(n,3),this.transformationMatrix=new t.Matrix4,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(e,o,n,!1),this.prepCoords(i,a,n,!1),this._superpose(o,a)}_superpose(t,i){this.mean1=sn(t),this.mean2=sn(i),nn(t,this.mean1),nn(i,this.mean2),en(this.coords1t,t),en(this.coords2t,i),tn(this.A,this.coords2t,this.coords1t),hn(this.A,this.W,this.U,this.V),function(e,t){const i=e.data,r=t.data,s=i[4],n=i[8],o=i[5],a=i[7],c=i[0],l=c*s,h=c*o,u=i[3],d=i[1],m=u*d,p=i[2],f=u*p,g=i[6],y=g*d,b=g*p,x=1/(l*n-h*a-m*n+f*a+y*o-b*s);r[0]=(s*n-o*a)*x,r[1]=-(d*n-p*a)*x,r[2]=-(-d*o+p*s)*x,r[3]=-(u*n-o*g)*x,r[4]=(c*n-b)*x,r[5]=-(h-f)*x,r[6]=-(-u*a+s*g)*x,r[7]=-(c*a-y)*x,r[8]=(l-m)*x}(this.V,this.VH),rn(this.R,this.U,this.VH),function(e){const t=e.data;return t[0]*t[4]*t[8]-t[0]*t[5]*t[7]-t[3]*t[1]*t[8]+t[3]*t[2]*t[7]+t[6]*t[1]*t[5]-t[6]*t[2]*t[4]}(this.R)<0&&(e.Debug&&Be.log("R not a right handed system"),rn(this.tmp,this.c,this.VH),rn(this.R,this.U,this.tmp));const r=new Js(4,4),s=new Js(4,4),n=new Js(4,4),o=new Js(4,4),a=new Js(4,4),c=new Js(4,4),l=this.R.data,h=this.mean1,u=this.mean2;o.data.set([1,0,0,-h[0],0,1,0,-h[1],0,0,1,-h[2],0,0,0,1]),a.data.set([l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]),c.data.set([1,0,0,u[0],0,1,0,u[1],0,0,1,u[2],0,0,0,1]),en(s,o),tn(r,a,s),en(n,r),tn(s,c,n),en(r,s),this.transformationMatrix.elements=r.data}prepCoords(e,t,i,r){let s=0;const n=t.data;let o=3,a=3*i;if(r&&(a=4*i,o=4),e instanceof pa)e.eachAtom((function(e){s{e!==this&&this.pause()}),this);const i=l(e.frameCount,1);this.traj=e,this.parameters=h(t,nc),this.parameters.end=Math.min(l(t.end,i-1),i-1),this.parameters.step=l(t.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,e.signals.countChanged.add((e=>{this.parameters.end=Math.min(l(this.parameters.end,e-1),e-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(e={}){u(this.parameters,e),void 0!==e.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const e=this._currentTime-this._previousTime,t=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/t,r=this.traj;if(r&&r.frameCount&&!r.inProgress&&e>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),r.hasFrame(this._currentFrame)){this._currentStep+=1;const e=this._currentStep/(this.parameters.interpolateStep+1),[t,i,s,n]=this._currentFrame;r.setFrameInterpolated(t,i,s,n,e,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{const e=this._next();r.hasFrame(e)?(r.setFrame(e),this._previousTime=this._currentTime):r.loadFrame(e)}window.requestAnimationFrame(this._animate)}_next(){const e=this.parameters;let t;return t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step,(t>e.end||t=e.end?i=e.start:"backward"===e.direction&&t<=e.start&&(i=e.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class ac{constructor(e,t,i={}){this.signals={countChanged:new r.Signal,frameChanged:new r.Signal,playerChanged:new r.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=l(i.deltaTime,0),this.timeOffset=l(i.timeOffset,0),this.centerPbc=l(i.centerPbc,!1),this.removePbc=l(i.removePbc,!1),this.removePeriodicity=l(i.removePeriodicity,!1),this.superpose=l(i.superpose,!1),this.name=e.replace(/^.*[\\/]/,""),this.trajPath=e,this.selection=new ye(l(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(e){this.setStructure(e),this._loadFrameCount(),this.setPlayer(new oc(this))}_loadFrameCount(){}setStructure(e){this.structure=e,this.atomCount=e.atomCount,this.backboneIndices=this._getIndices(new ye("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(e){return this.selection.setString(e),this}_getIndices(e){let t=0;const i=e.test,r=[];return i&&this.structure.eachAtom((e=>{i(e)&&r.push(t),t+=1})),r}_makeSuperposeCoords(){const e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);const t=this.initialCoords,i=this.coords2;for(let r=0;r!!this.frameCache[e])):!!this.frameCache[e]}setFrame(e,t){return void 0===e||(this.inProgress=!0,-1===e||this.frameCache[e]?(this._updateStructure(e),t&&t()):this.loadFrame(e,(()=>{this._updateStructure(e),t&&t()}))),this}_interpolate(e,t,i,r,s,n){const o=this.frameCache;let a;a="spline"===n?function(e,t,i,r,s){const n=e.length,o=new Float32Array(n);for(let a=0;a{this._interpolate(e,t,i,r,s,n),o&&o()})):(this._interpolate(e,t,i,r,s,n),o&&o()),this}loadFrame(e,t){Array.isArray(e)?e.forEach((e=>{this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e]})))})):this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e],t&&t()})))}_loadFrame(e,t){Be.error("Trajectory._loadFrame not implemented",e,t)}_updateStructure(e){this._disposed?console.error("updateStructure: traj disposed"):(-1===e?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[e]),this.structure.trajectory={name:this.trajPath,frame:e},this._currentFrame=e,this.inProgress=!1,this.signals.frameChanged.dispatch(e))}_doSuperpose(e){const t=3*this.selectionIndices.length,i=this.coords1,r=this.coords2;for(let r=0;r0&&this.centerPbc){const e=[t[0],t[4],t[8]],r=function(e,t,i){return[pt(t,i[0],3,0,e),pt(t,i[1],3,1,e),pt(t,i[2],3,2,e)]}(this.backboneIndices,i,e);!function(e,t,i){if(0===i[0]||0===i[8]||0===i[4])return;const r=e.length,s=i[0],n=i[1],o=i[2],a=-t[0]+s+s/2,c=-t[1]+n+n/2,l=-t[2]+o+o/2;for(let t=0;t.5&&(e[s+r]-=t[3*r+r]*Math.round(n))}}(i,t,e)}this.removePbc&&function(e,t){if(0===t[0]||0===t[8]||0===t[4])return;const i=e.length;for(let r=3;r.9*t[3*i+i])if(s>0)for(let s=0;s<3;++s)e[r+s]-=t[3*i+s];else for(let s=0;s<3;++s)e[r+s]+=t[3*i+s]}}(i,t)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[e]=i,this.boxCache[e]=t,this.frameCacheSize+=1}_setFrameCount(e){e!==this._frameCount&&(this._frameCount=e,this.signals.countChanged.dispatch(e))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(e){this.player=e,this.signals.playerChanged.dispatch(e)}getFrameTime(e){return this.timeOffset+e*this.deltaTime}}class cc extends ac{constructor(e,t,i){const r=i||{};r.timeOffset=l(r.timeOffset,e.timeOffset),r.deltaTime=l(r.deltaTime,e.deltaTime),super("",t,r),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(t)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(e,t){let i;const r=this.frames[e];if(this.atomIndices){const e=this.atomIndices,t=e.length;i=new Float32Array(3*t);for(let s=0;s{const e=r.response;if(!e)return void Be.error(`empty arrayBuffer for '${s}'`);const n=new Int32Array(e,0,1)[0],o=new Float32Array(e,8,9),a=new Float32Array(e,44);this._process(t,o,a,n),"function"==typeof i&&i()}),!1),r.send(n)}_loadFrameCount(){const t=new XMLHttpRequest,i=e.TrajectoryDatasource.getCountUrl(this.trajPath);t.open("GET",i,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class uc extends ac{constructor(e,t,i){super("",t,i),this.requestCallback=e,this._init(t)}get type(){return"callback"}_makeAtomIndices(){const e=[];if("StructureView"===this.structure.type){const t=this.structure.getAtomIndices(),i=t.length;let r=t[0],s=t[0];for(let n=1;n{this._process(e,i,r,s),"function"==typeof t&&t()}),e,this.atomIndices)}_loadFrameCount(){this.requestCallback((e=>this._setFrameCount(e)))}}pa.prototype.getView=function(e){return new dc(this,e)};class dc extends pa{constructor(e,i){super(),this.structure=e,this.selection=i,this.center=new t.Vector3,this.boundingBox=new t.Box3,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(e){this.structure._hasCoords=e}refresh(){e.Debug&&Be.time("StructureView.refresh"),this.atomSetCache={};const i=this.structure;if(this.selection.isAllSelection()&&i!==this&&i.atomSet&&i.bondSet){this.atomSet=i.atomSet.clone(),this.bondSet=i.bondSet.clone();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.clone()}this.atomCount=i.atomCount,this.bondCount=i.bondCount,this.boundingBox.copy(i.boundingBox),this.center.copy(i.center)}else if(this.selection.isNoneSelection()&&i!==this&&i.atomSet&&i.bondSet){this.atomSet=new Sr(i.atomCount),this.bondSet=new Sr(i.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Sr(i.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),i.atomSet&&(this.atomSet=this.atomSet.intersection(i.atomSet)),this.bondSet=this.getBondSet();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new t.Vector3)}e.Debug&&Be.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(e){this.selection=e,this.refresh()}getSelection(e){const t=[];e&&e.string&&t.push(e.string);const i=this.structure.getSelection();i&&i.string&&t.push(i.string),this.selection&&this.selection.string&&t.push(this.selection.string);let r="";return t.length>0&&(r=`( ${t.join(" ) AND ( ")} )`),new ye(r)}getStructure(){return this.structure.getStructure()}eachBond(e,t){this.structure.eachBond(e,this.getSelection(t))}eachAtom(e,t){const i=this.getAtomProxy(),r=this.getAtomSet(t),s=this.atomStore.count;if(r.getSize()=this.V[r][s]?(i="S",this.score=this.S[r][s]):this.V[r][s]>=this.H[r][s]?(i="V",this.score=this.V[r][s]):(i="H",this.score=this.H[r][s]),e.Debug&&Be.log("Alignment: SCORE",this.score),e.Debug&&Be.log("Alignment: S, V, H",this.S[r][s],this.V[r][s],this.H[r][s]);r>0&&s>0;)"S"===i?this.S[r][s]===this.S[r-1][s-1]+t(r-1,s-1)?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--r,--s,i="S"):this.S[r][s]===this.V[r][s]?i="V":this.S[r][s]===this.H[r][s]?i="H":(--r,--s):"V"===i?this.V[r][s]===this.V[r-1][s]+this.gapExtensionPenalty?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r,i="V"):this.V[r][s]===this.S[r-1][s]+this.gap(0)?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r,i="S"):--r:"H"===i?this.H[r][s]===this.H[r][s-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s,i="H"):this.H[r][s]===this.S[r][s-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s,i="S"):--s:Be.error("Alignment: no matrix");for(;r>0;)this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r;for(;s>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s;e.Debug&&Be.timeEnd("Alignment.trace"),e.Debug&&Be.log([this.ali1,this.ali2])}}function yc(e,t,i=!1,r="",s=""){let n,o,a,c,l;if(i){let i=e,h=t;r&&s&&(i=e.getView(new ye(r)),h=t.getView(new ye(s)));const u=i.getSequence(),d=h.getSequence(),m=new gc(u.join(""),d.join(""));let p,f;m.calc(),m.trace(),n=0,o=0,a=m.ali1.length;const g=[],y=[];for(let e=0;ee[t]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Re.opacity,color:Re.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Re,!0),this.angleRepresentation=this.addRepresentation("angle",Re,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Re,!0),this.measureRepresentations=new ec([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return bc}get type(){return"structure"}initSelection(e){this.selection=new ye(e),this.structureView=new dc(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(e){return this.parameters.sele=e,this.selection.setString(e),this}setDefaultAssembly(e){if(void 0===this.structure.biomolDict[e]&&(e=""),this.parameters.defaultAssembly!==e){const t={defaultAssembly:e};this.reprList.forEach((e=>e.setParameters(t))),this.measureRepresentations.setParameters(t),this.parameters.defaultAssembly=e,this.signals.defaultAssemblyChanged.dispatch(e)}return this}rebuildRepresentations(){this.reprList.forEach((e=>{e.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((e=>{e.trajectory.setStructure(this.structureView)}))}updateRepresentations(e){super.updateRepresentations(e),this.measureRepresentations.update(e)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(e,t={},i=!1){t.defaultAssembly=this.parameters.defaultAssembly;const r=this._addRepresentation(e,this.structureView,t,i);return i||r.signals.parametersChanged.add((()=>this.measureUpdate())),r}addTrajectory(e="",t={}){const i=function(e,t,i){let r;return r=e&&e instanceof rc?new cc(e,t,i):!e&&t.frames?new lc(e,t,i):e&&"function"==typeof e?new uc(e,t,i):new hc(e,t,i),r}(e,this.structureView,t),r=new ic(this.stage,i,t);return this.trajList.push(r),this.signals.trajectoryAdded.dispatch(r),r}removeTrajectory(e){const t=this.trajList.indexOf(e);-1!==t&&this.trajList.splice(t,1),e.dispose(),this.signals.trajectoryRemoved.dispatch(e)}dispose(){this.trajList.slice().forEach((e=>e.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(e,t){"number"==typeof e&&(t=e,e=""),this.stage.animationControls.zoomMove(this.getCenter(e),this.getZoom(e),l(t,0))}getBoxUntransformed(e){let t;return t=e?this.structureView.getBoundingBox(new ye(e)):this.structureView.boundingBox,t}getCenterUntransformed(e){return e&&"string"==typeof e?this.structure.atomCenter(new ye(e)):this.structure.center}superpose(e,t,i,r){return yc(this.structureView,e.structureView,t,i,r),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(e){let t=0;const i=this.structure.getAtomProxy(e);return this.eachRepresentation((e=>{if(e.getVisibility()){const r=e.repr;t=Math.max(r.getAtomRadius(i),t)}})),t}measurePick(e){const t=this.pickBuffer.count;if(this.lastPick===e.index&&t>=1){if(t>1){const e=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,e),2===t?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((e=>2===e.length))}):3===t?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((e=>3===e.length))}):4===t&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((e=>4===e.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(e.index)||this.pickBuffer.push(e.index),this.lastPick=e.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const e=this.measureData();this.distanceRepresentation.setParameters({atomPair:e.distance}),this.angleRepresentation.setParameters({atomTriple:e.angle}),this.dihedralRepresentation.setParameters({atomQuad:e.dihedral})}measureUpdate(){const e=this.pickBuffer.data,t={};e.forEach((e=>{const i=Math.max(.1,this.getMaxRepresentationRadius(e));t[e]=i*(2.3-L(.1,2,i))})),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:t})}measureData(){const e=this.pickDict.values;return{distance:e.filter((e=>2===e.length)),angle:e.filter((e=>3===e.length)),dihedral:e.filter((e=>4===e.length))}}removeAllMeasurements(e){const t=this.pickDict,i=t.values,r=function(e){i.filter((t=>t.length===e)).forEach((e=>t.del(e.slice().sort())))};(!e||1&e)&&r(2),(!e||2&e)&&r(3),(!e||4&e)&&r(4),this.measureBuild()}removeMeasurement(e){this.pickDict.del(e.slice().sort()),this.measureBuild()}addMeasurement(e){if(e.length<2||e.length>4)return;const t=e.slice().sort();this.pickDict.has(t)||this.pickDict.add(t,e),this.measureBuild()}}Ue.add("structure",xc),Ue.add("structureview",xc);class vc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.surface=t}get type(){return"surface"}addRepresentation(e,t={}){return this._addRepresentation(e,this.surface,t)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}Ue.add("surface",vc);class wc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.volume=t}get type(){return"volume"}addRepresentation(e,t={}){return this._addRepresentation(e,this.volume,t)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}Ue.add("volume",wc);class Ac extends Ja{addRepresentation(e,t){return this.forEach((i=>i.addRepresentation(e,t)))}autoView(e){return this.forEach((t=>t.autoView(e)))}}function _c(e,t){return e instanceof RegExp?null!==t.name.match(e):t.name===e}const Sc=new t.Vector3,Cc={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Pc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.shape=t}get type(){return"shape"}addRepresentation(e,t={}){return this._addRepresentation(e,this.shape,t)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Ic(e,t,i,r){var s,n=arguments.length,o=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,i,o):s(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o}Ue.add("shape",Pc);class kc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=l(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel((e=>{this.parameters.domain=[e.atomOffset,e.atomEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.index)}}Ic([G],kc.prototype,"atomColor",null),Ee.add("atomindex",kc);class Mc extends U{constructor(e){if(super(e),e.scale||(this.parameters.scale="OrRd"),!e.domain){let t,i=1/0,r=-1/0;e.sele&&(t=new ye(e.sele)),e.structure.eachAtom((function(e){const t=e.bfactor;i=Math.min(i,t),r=Math.max(r,t)}),t),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}atomColor(e){return this.bfactorScale(e.bfactor)}}Ic([G],Mc.prototype,"atomColor",null),Ee.add("bfactor",Mc);class Dc extends U{constructor(e){super(e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainid]&&(i[e.chainid]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainidDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainidDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainid])}}Ic([G],Dc.prototype,"atomColor",null),Ee.add("chainid",Dc);class Tc extends U{constructor(e){super(e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{this.parameters.domain=[e.chainOffset,e.chainEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.chainIndex)}}Ic([G],Tc.prototype,"atomColor",null),Ee.add("chainindex",Tc);class Bc extends U{constructor(e){super(e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainname]&&(i[e.chainname]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainnameDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainnameDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainname])}}Ic([G],Bc.prototype,"atomColor",null),Ee.add("chainname",Bc);class Rc extends U{constructor(e){super(e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const t=e.structure.validation;t&&(this.rsrzDict=t.rsrzDict,this.rsccDict=t.rsccDict)}atomColor(e){let t=e.resno+"";e.inscode&&(t+="^"+e.inscode),e.chainname&&(t+=":"+e.chainname),t+="/"+e.modelIndex;const i=this.rsrzDict[t];if(void 0!==i)return this.rsrzScale(i);const r=this.rsccDict[t];return void 0!==r?this.rsccScale(r):9474192}}Ic([G],Rc.prototype,"atomColor",null),Ee.add("densityfit",Rc);const Oc={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class $c extends U{constructor(e){super(e),this.delta=new t.Vector3,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);const i=[];e.structure.eachAtom((e=>{var r;if(this.charges[e.index]=(null!==(r=e).partialCharge?r.partialCharge:r.isProtein()&&(Oc[r.resname]&&Oc[r.resname][r.atomname]||Oc.backbone[r.atomname])||0)*e.occupancy,"N"===e.atomname){if(e.bondCount>=3)return;if(e.bondToElementCount(1))return;const r=function(e,i=new t.Vector3){let r=!1,s=!1,n=!1;return i.set(2*e.x,2*e.y,2*e.z),e.eachBondedAtom((function(e){if(!r)return"H"===e.atomname?(i.set(e.x,e.y,e.z),void(r=!0)):void(s||"CA"!==e.atomname?n||"C"!==e.atomname||(n=!0,i.sub(e)):(i.sub(e),s=!0))})),r?i:s&&n?(i.normalize(),i.multiplyScalar(1.04),i.add(e),i):void 0}(e);void 0!==r&&(i.push(r),this.hCharges.push(.25*e.occupancy))}}));const r=e.structure.getBoundingBox();r.expandByScalar(1.04),this.hStore=function(e){const t=e.length,i=new Float32Array(t),r=new Float32Array(t),s=new Float32Array(t);for(let t=0;t{const s=t[e];0!==s&&(r+=s/i)})),this.hHash.eachWithin(e.x,e.y,e.z,12,((e,t)=>{const s=i[e];0!==s&&(r+=s/t)})),this.scale(332*r)}}Ic([G],$c.prototype,"positionColor",null),Ee.add("electrostatic",$c);const Fc={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class Ec extends U{constructor(e){e.value=l(e.value,Fc.C),super(e)}atomColor(e){const t=e.element;return"C"===t?this.parameters.value:Fc[t]||16777215}}Ic([G],Ec.prototype,"atomColor",null),Ee.add("element",Ec);class Lc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="Spectral"),e.domain||(this.parameters.domain=[0,e.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(e){return this.entityindexScale(e.entityIndex)}}Ic([G],Lc.prototype,"atomColor",null),Ee.add("entityindex",Lc);class Nc extends U{atomColor(e){const t=e.entity;switch(t?t.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Ic([G],Nc.prototype,"atomColor",null),Ee.add("entitytype",Nc);class zc extends U{constructor(e){super(e),this.geoAtomDict={},this.geoDict={};const t=e.structure.validation;t&&(this.geoAtomDict=t.geoAtomDict,this.geoDict=t.geoDict)}atomColor(e){let t,i=e.resno+"";e.inscode&&(i+="^"+e.inscode),e.chainname&&(i+=":"+e.chainname),i+="/"+e.modelIndex;const r=this.geoAtomDict[i];if(void 0!==r){const i=r[e.atomname]||0;s=i,t=16843009*((s=(858993459&(s-=s>>1&1431655765))+(s>>2&858993459))+(s>>4)&252645135)>>24}else t=this.geoDict[i]||0;var s;return 0===t?2188972:1===t?16703627:2===t?16018755:t>=3?10813478:9474192}}Ic([G],zc.prototype,"atomColor",null),Ee.add("geoquality",zc);class Vc extends U{constructor(e){super(e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(const e in Ur)this.resHF[e]=Ur[e][0];if(this.defaultResidueHydrophobicity=jr[0],!e.domain){let e=1/0,t=-1/0;for(const i in this.resHF){const r=this.resHF[i];e=Math.min(e,r),t=Math.max(t,r)}this.parameters.domain=[e,0,t]}this.hfScale=this.getScale()}atomColor(e){return this.hfScale(this.resHF[e.resname]||this.defaultResidueHydrophobicity)}}Ic([G],Vc.prototype,"atomColor",null),Ee.add("hydrophobicity",Vc);class Gc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(e){return this.modelindexScale(e.modelIndex)}}Ic([G],Gc.prototype,"atomColor",null),Ee.add("modelindex",Gc);class Uc extends U{atomColor(e){switch(e.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Ic([G],Uc.prototype,"atomColor",null),Ee.add("moleculetype",Uc);class jc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(e){return this.occupancyScale(e.occupancy)}}Ic([G],jc.prototype,"atomColor",null),Ee.add("occupancy",jc);class Hc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(e){return this.partialchargeScale(e.partialCharge||0)}}function Wc(){return 16777215*Math.random()}Ic([G],Hc.prototype,"atomColor",null),Ee.add("partialcharge",Hc);class qc extends U{atomColor(){return Wc()}volumeColor(){return Wc()}positionColor(){return Wc()}}Ic([G],qc.prototype,"atomColor",null),Ic([G],qc.prototype,"volumeColor",null),Ic([G],qc.prototype,"positionColor",null),Ee.add("random",qc);class Xc extends U{constructor(e){super(e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const t=e.structure.validation;t&&(this.rciDict=t.rciDict)}atomColor(e){let t=`[${e.resname}]${e.resno}`;e.chainname&&(t+=":"+e.chainname);const i=this.rciDict[t];return void 0!==i?this.rciScale(i):9474192}}Ic([G],Xc.prototype,"atomColor",null),Ee.add("randomcoilindex",Xc);class Yc extends U{constructor(e){super(e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=l(e.reverse,!0)),e.structure.eachChain((e=>{this.parameters.domain=[e.residueOffset,e.residueEnd],this.scalePerChain[e.index]=this.getScale()}))}atomColor(e){return this.scalePerChain[e.chainIndex](e.residueIndex)}}Ic([G],Yc.prototype,"atomColor",null),Ee.add("residueindex",Yc);const Kc={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class Zc extends U{atomColor(e){return Kc[e.resname]||16711935}}Ic([G],Zc.prototype,"atomColor",null),Ee.add("resname",Zc);const Qc=16711808,Jc=10485888,el=6291584,tl=16762880,il=6324479,rl=16777215,sl=11403518,nl=16580962,ol=10921722;class al extends U{constructor(e){super(e),this.residueProxy=e.structure.getResidueProxy()}atomColor(e){const t=e.sstruc,i=this.residueProxy;return"h"===t?Qc:"g"===t?Jc:"i"===t?el:"e"===t||"b"===t?tl:"t"===t?il:(i.index=e.residueIndex,i.isDna()?sl:i.isRna()?nl:i.isSaccharide()?ol:i.isProtein()||"s"===t||"l"===t?rl:8421504)}}Ic([G],al.prototype,"atomColor",null),Ee.add("sstruc",al);class cl extends U{constructor(e){var t,i;super(e),e.scale||(this.parameters.scale="rwb"),this.atomData=null===(t=this.parameters.data)||void 0===t?void 0:t.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(e){var t;const i=null===(t=this.atomData)||void 0===t?void 0:t[e.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(e,t){var i;const r=null===(i=this.bondData)||void 0===i?void 0:i[e.index];return void 0!==r?this.scale(r):this.atomProxy?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Ic([G],cl.prototype,"atomColor",null),Ic([G],cl.prototype,"bondColor",null),Ee.add("structuredata",cl);class ll extends U{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Ic([G],ll.prototype,"atomColor",null),Ic([G],ll.prototype,"bondColor",null),Ic([G],ll.prototype,"valueColor",null),Ic([G],ll.prototype,"volumeColor",null),Ee.add("uniform",ll);class hl extends U{constructor(e){super(e),this.valueScale=this.getScale()}volumeColor(e){return this.valueScale(this.parameters.volume.data[e])}}Ic([G],hl.prototype,"volumeColor",null),Ee.add("value",hl);class ul extends U{constructor(e){super(e),this.vec=new t.Vector3,this.valueScale=this.getScale()}positionColor(e){const t=this.parameters.volume;if(!t||!t.inverseMatrix)return this.parameters.value;const i=this.vec,r=t.data,s=t.nx,n=t.ny,o=s*n;i.copy(e),i.applyMatrix4(t.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*n+c)*s+a,u=h+1,d=h+s,m=h+o,p=d+1,f=m+1,g=d+o,y=g+1,b=r[h],x=r[u],v=r[d],w=r[m],A=r[p],_=r[f],S=r[g],C=r[y],P=i.x-a,I=i.y-c,k=i.z-l,M=F(b,x,P),D=F(w,_,P),T=F(v,A,P),B=F(S,C,P),R=F(M,T,I),O=F(D,B,I),$=F(R,O,k);return this.valueScale($)}}Ic([G],ul.prototype,"positionColor",null),Ee.add("volume",ul);class dl extends Di{constructor(e,t,i){const r=i||{};if(super(e,t,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:ro.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new ye(r.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){const t={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach((function(e){t[e]=e})),this.parameters.assembly={type:"select",options:t,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(e){const t=e||{};t.colorScheme=l(t.colorScheme,"element"),this.setRadius(t.radius,t),this.radiusType=l(t.radiusType,"vdw"),this.radiusData=l(t.radiusData,{}),this.radiusSize=l(t.radiusSize,1),this.radiusScale=l(t.radiusScale,1),this.assembly=l(t.assembly,"default"),this.defaultAssembly=l(t.defaultAssembly,""),"auto"===t.quality&&(t.quality=this.getQuality()),super.init(t),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(e,t){const i=Object.keys(io);return"string"==typeof e&&i.includes(e.toLowerCase())?t.radiusType=e:void 0!==e&&(t.radiusType="size",t.radiusSize=e),this}getAssembly(){const e="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[e]}getQuality(){let e;const t=this.structureView,i=this.getAssembly();e=i?i.getAtomCount(t):t.atomCount,Ie&&(e*=4);return t.atomStore.count/t.residueStore.count<2&&(e*=10),e<15e3?"high":e<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const e=this.getAssembly();if(e)e.partList.forEach(((e,t)=>{const i=e.getView(this.structureView);if(0===i.atomCount)return;const r=this.createData(i,t);r&&(r.sview=i,r.instanceList=e.getInstanceList(),this.dataList.push(r))}));else{const e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}update(e){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((t=>{t.bufferList.length>0&&this.updateData(e,t)}),this):Object.assign(this.lazyProps.what,e)}updateData(e,t){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(e){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getBondParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getAtomRadius(e){if(this.structureView.atomSet.isSet(e.index)){return new ro(this.getRadiusParams()).atomRadius(e)}return 0}setSelection(e,t){return this.selection.setString(e,t),this}setParameters(e,t={},i=!1){const r=e||{};return this.setRadius(r.radius,r),void 0===r.radiusType&&void 0===r.radiusData&&void 0===r.radiusSize&&void 0===r.radiusScale||(t.radius=!0,De&&!this.disableImpostor||(i=!0)),void 0!==r.defaultAssembly&&r.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===r.assembly||"default"===r.assembly)&&(i=!0),super.setParameters(r,t,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(e){const t=this.viewer,i=this.bufferList;this.dataList.forEach((function(e){e.bufferList.forEach((function(r){i.push(r),t.add(r,e.instanceList)}))})),this.setVisibility(this.visible),e()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class ml extends dl{constructor(e,t,i){super(e,t,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(e){const t=e||{};this.labelVisible=l(t.labelVisible,!0),this.labelSize=l(t.labelSize,2),this.labelColor=l(t.labelColor,16777215),this.labelFontFamily=l(t.labelFontFamily,"sans-serif"),this.labelFontStyle=l(t.labelFontstyle,"normal"),this.labelFontWeight=l(t.labelFontWeight,"bold"),this.labelsdf=l(t.labelsdf,"Chrome"===Ce),this.labelXOffset=l(t.labelXOffset,0),this.labelYOffset=l(t.labelYOffset,0),this.labelZOffset=l(t.labelZOffset,.5),this.labelAttachment=l(t.labelAttachment,"bottom-left"),this.labelBorder=l(t.labelBorder,!1),this.labelBorderColor=l(t.labelBorderColor,"lightgrey"),this.labelBorderWidth=l(t.labelBorderWidth,.15),this.labelBackground=l(t.labelBackground,!1),this.labelBackgroundColor=l(t.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=l(t.labelBackgroundMargin,.5),this.labelBackgroundOpacity=l(t.labelBackgroundOpacity,1),this.labelFixedSize=l(t.labelFixedSize,!1),this.lineOpacity=l(t.lineOpacity,1),this.linewidth=l(t.linewidth,2),super.init(t)}update(e){e.position?this.build():super.update(e)}updateData(e,i){const r={};if(e&&!e.labelSize||Object.assign(r,{size:yt(this.n,this.labelSize)}),!e||e.labelColor){const e=new t.Color(this.labelColor);Object.assign(r,{color:bt(this.n,e.r,e.g,e.b)})}this.textBuffer.setAttributes(r)}setParameters(e,t={},i=!1){return e&&e.labelSize&&(t.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(t.labelColor=!0,i=!0),super.setParameters(e,t,i),e&&void 0!==e.opacity&&this.textBuffer.setParameters({opacity:1}),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),t||this.viewer.requestRender(),this}getLabelBufferParams(e={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))}getAtomRadius(){return 0}}function pl(e,t){const i=e.getAtomProxy(),r=new ye,s=t.length;if(0===s)return new Float32Array(0);const n=t[0].length,o=e.getAtomSet(),a=new Float32Array(s*n*3);let c=0;return t.forEach((function(t){let s=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const bl={};const xl={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class vl{constructor(e={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=h(e,xl);const i=this.parameters;this.radius=i.size/8,this.padding=i.size/3;const r=this.lineHeight=i.size+2*i.outline+Math.round(i.size/4),s=this.maxWidth=i.width/4,n=this.canvas=document.createElement("canvas");n.width=s,n.height=r;const o=this.context=this.canvas.getContext("2d");o.font=`${i.style} ${i.variant} ${i.weight} ${i.size}px ${i.font}`,o.fillStyle="black",o.textAlign="left",o.textBaseline="bottom",o.lineJoin="round",this.gridOuter=new Float64Array(r*s),this.gridInner=new Float64Array(r*s),this.f=new Float64Array(Math.max(r,s)),this.d=new Float64Array(Math.max(r,s)),this.z=new Float64Array(Math.max(r,s)+1),this.v=new Int16Array(Math.max(r,s)),this.data=new Uint8Array(i.width*i.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=i.width,this.canvas2.height=i.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let e=32;e<=126;++e)this.map(String.fromCharCode(e));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new t.CanvasTexture(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(e){const t=this.parameters;return void 0===this.mapped[e]&&(this.draw(e),this.currentX+this.scratchW>t.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>t.height&&console.warn("canvas to small"),this.mapped[e]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[e]}get(e){return this.mapped[e]||this.placeholder}draw(e){const t=this.parameters,i=this.lineHeight,r=t.outline,s=this.context,n=this.maxWidth,o=r,a=i-t.outline,c=s.measureText(e),l=Math.min(n,Math.ceil(c.width+2*o+1)),h=l*i;s.clearRect(0,0,l,i),s.fillText(e,o,a);const u=s.getImageData(0,0,l,i),d=u.data;for(let e=0;e= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Cl=Object.assign({linewidth:2},Mn),Pl=Object.assign({linewidth:{uniform:!0}},Dn);class Il extends Ma{constructor(e,i={}){super(e,i),this.parameterTypes=Pl,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new t.Vector2},projectionMatrixInverse:{value:new t.Matrix4}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Cl}setParameters(e){super.setParameters(e)}}je.add("wideline",Il);class kl extends ml{constructor(e,t,i){super(e,t,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(e){const t=e||{};t.side=l(t.side,"double"),t.opacity=l(t.opacity,.5),this.atomTriple=l(t.atomTriple,[]),this.arcVisible=l(t.arcVisible,!0),this.sectorVisible=l(t.sectorVisible,!0),this.vectorVisible=l(t.vectorVisible,!0),super.init(t)}createData(e){if(!e.atomCount||!this.atomTriple.length)return;const i=function(e,t){return function(e){const t=[],i=e.length/9;for(let r=0;r radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Fl=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),El=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class Ll extends Pa{constructor(e,t={}){super("v3",e,t)}get mapping(){return Fl}get mappingIndices(){return El}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const Nl=Object.assign({openEnded:!1},Mn),zl=Object.assign({openEnded:{updateShader:!0}},Dn);class Vl extends Ll{constructor(e,i={}){super(e,i),this.parameterTypes=zl,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new t.Matrix4},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Nl}getDefines(e){const t=Ll.prototype.getDefines.call(this,e);return this.parameters.openEnded||(t.CAP=1),t}}Object.assign({disableImpostor:!1},Rl,Nl);const Gl=class{constructor(e,t={}){return!e.color2&&e.color&&(e.color2=e.color),!De||t&&t.disableImpostor?new $l(e,t):new Vl(e,t)}};je.add("cylinder",Gl);class Ul extends dl{constructor(e,t,i){super(e,t,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(e){const t=e||{};t.radiusSize=l(t.radiusSize,.5),t.colorValue=l(t.colorValue,"lightgreen"),t.useInteriorColor=l(t.useInteriorColor,!0),this.showAxes=l(t.showAxes,!0),this.showBox=l(t.showBox,!1),super.init(t)}getPrincipalAxes(){let e;const t=this.getAssembly();return t&&(e=t.partList[0].getSelection()),this.structureView.getPrincipalAxes(e)}getAxesData(e){const i=this.getPrincipalAxes(),r=new t.Color(this.colorValue);let s=0,n=0;this.showAxes&&(s+=6,n+=3),this.showBox&&(s+=8,n+=12);const o=new Float32Array(3*s),a=bt(s,r.r,r.g,r.b),c=yt(s,this.radiusSize),l=new Float32Array(3*n),h=new Float32Array(3*n),u=bt(n,r.r,r.g,r.b),d=yt(n,this.radiusSize);let m=0;if(this.showAxes){const e=function(e,t){e.toArray(o,2*m),t.toArray(o,2*m+3),e.toArray(l,m),t.toArray(h,m),m+=3};e(i.begA,i.endA),e(i.begB,i.endB),e(i.begC,i.endC)}if(this.showBox){const r=new t.Vector3,{d1a:s,d2a:n,d3a:a,d1b:c,d2b:u,d3b:d}=i.getProjectedScaleForAtoms(e);let p=2*m;const f=function(e,t,s){r.copy(i.center).addScaledVector(i.normVecA,e).addScaledVector(i.normVecB,t).addScaledVector(i.normVecC,s),r.toArray(o,p),p+=3};f(s,n,a),f(s,n,d),f(s,u,d),f(s,u,a),f(c,u,d),f(c,u,a),f(c,n,a),f(c,n,d);let g=m;const y=function(e,t){r.fromArray(o,2*m+3*e).toArray(l,g),r.fromArray(o,2*m+3*t).toArray(h,g),g+=3};y(0,1),y(0,3),y(0,6),y(1,2),y(1,7),y(2,3),y(2,4),y(3,5),y(4,5),y(4,7),y(5,6),y(6,7)}const p=new Ns(i);return{vertex:{position:o,color:a,radius:c,picking:p},edge:{position1:l,position2:h,color:u,color2:u,radius:d,picking:p}}}create(){const e=this.getAxesData(this.structureView);this.sphereBuffer=new Ta(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new Gl(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(e){}updateData(e,t){const i=this.getAxesData(t.sview),r={},s={};e&&!e.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(s,{position1:i.edge.position1,position2:i.edge.position2})),e&&!e.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(s,{color:i.edge.color,color2:i.edge.color})),e&&!e.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(s,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(s)}}Ne.add("axes",Ul);class jl extends dl{constructor(e,t,i){super(e,t,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(e){var t=e||{};t.radiusType=l(t.radiusType,"size"),t.radiusSize=l(t.radiusSize,.15),t.useInteriorColor=l(t.useInteriorColor,!0),this.aspectRatio=l(t.aspectRatio,2),this.lineOnly=l(t.lineOnly,!1),this.cylinderOnly=l(t.cylinderOnly,!1),this.multipleBond=l(t.multipleBond,"off"),this.bondSpacing=l(t.bondSpacing,1),this.bondScale=l(t.bondScale,.4),this.linewidth=l(t.linewidth,2),super.init(t)}getAtomRadius(e){return this.aspectRatio*super.getAtomRadius(e)}getAtomParams(e,t){var i=super.getAtomParams(e,t);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(e,t,i){return e.getAtomData(this.getAtomParams(t,i))}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},t),super.getBondParams(e,t)}getBondData(e,t,i){return e.getBondData(this.getBondParams(t,i))}createData(e){const t=[];if(this.lineOnly)this.lineBuffer=new Il(this.getBondData(e,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),t.push(this.lineBuffer);else{const i=new Gl(this.getBondData(e),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(t.push(i),!this.cylinderOnly){const i=new Ta(this.getAtomData(e),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));t.push(i)}}return{bufferList:t}}updateData(e,t){"off"!==this.multipleBond&&e&&e.radius&&(e.position=!0);const i=this.getBondData(t.sview,e);if(this.lineOnly){const r={};e&&!e.position||Object.assign(r,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(r,{color:i.color,color2:i.color2}),t.bufferList[0].setAttributes(r)}else{var r={};if(e&&!e.position||Object.assign(r,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(r,{color:i.color,color2:i.color2}),e&&!e.radius||Object.assign(r,{radius:i.radius}),t.bufferList[0].setAttributes(r),!this.cylinderOnly){var s=this.getAtomData(t.sview,e),n={};e&&!e.position||Object.assign(n,{position:s.position}),e&&!e.color||Object.assign(n,{color:s.color}),e&&!e.radius||Object.assign(n,{radius:s.radius}),t.bufferList[1].setAttributes(n)}}}setParameters(e={}){let t=!1;const i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),De&&!this.disableImpostor||(t=!0)),super.setParameters(e,i,t),this}}Ne.add("ball+stick",jl);class Hl extends jl{constructor(e,t,i){super(e,t,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(e){var t=e||{};t.aspectRatio=l(t.aspectRatio,1),t.radiusSize=l(t.radiusSize,.25),super.init(t)}getAtomRadius(e){return e.isTrace()?super.getAtomRadius(e):0}getAtomData(e,t,i){return e.getBackboneAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){return e.getBackboneBondData(this.getBondParams(t,i))}}Ne.add("backbone",Hl);class Wl extends jl{constructor(e,t,i){super(e,t,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(e){let t=e||{};t.aspectRatio=l(t.aspectRatio,1),t.radiusSize=l(t.radiusSize,.3),super.init(t)}getAtomData(e,t,i){return e.getRungAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){let r=this.getBondParams(t,i);return Object.assign(r.colorParams,{rung:!0}),e.getRungBondData(r)}}Ne.add("base",Wl);class ql{constructor(e,i){this.m=e,this.tension=i,this.dt=1/this.m,this.delta=1e-4,this.vec1=new t.Vector3,this.vec2=new t.Vector3,this.vDir=new t.Vector3,this.vTan=new t.Vector3,this.vNorm=new t.Vector3,this.vBin=new t.Vector3,this.m2=Math.ceil(this.m/2)}interpolateToArr(e,t,i,r,s,n,o){n[o+0]=E(e.x,t.x,i.x,r.x,s,this.tension),n[o+1]=E(e.y,t.y,i.y,r.y,s,this.tension),n[o+2]=E(e.z,t.z,i.z,r.z,s,this.tension)}interpolateToVec(e,t,i,r,s,n){n.x=E(e.x,t.x,i.x,r.x,s,this.tension),n.y=E(e.y,t.y,i.y,r.y,s,this.tension),n.z=E(e.z,t.z,i.z,r.z,s,this.tension)}interpolatePosition(e,t,i,r,s,n){for(var o=0;o1&&(l=1),this.interpolateToVec(e,t,i,r,c,this.vec1),this.interpolateToVec(e,t,i,r,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(s,h)}}vectorSubdivide(e,t,i,r,s){let n,o=t.next(),a=t.next(),c=t.next();const l=t.size,h=l-1;let u=r||0;for(let r=0;r0&&t{if(e.residueCount<4)return;i.push(e);const r=this.getSpline(e),s=this.getAspectRatio(e),n=r.getSubdividedPosition(),o=r.getSubdividedOrientation(),a=r.getSubdividedColor(this.getColorParams()),c=r.getSubdividedPicking(),l=r.getSubdividedSize(this.getRadiusParams());t.push(new Ql(Object.assign({},n,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:s,capped:this.capped})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&Be.time(this.type+" repr update"),t=t||{};for(var r=0,s=i.polymerList.length;r0;Gi(_,x,S);const s=Vi(_,w)<0;if(Yi(_,w,Vi(w,v)),Gi(C,v,_),Yi(_,w,Vi(w,A)),Gi(P,A,_),0===qi(C)||0===qi(P))continue;Ki(C,C),Ki(P,P);const l=n[T]=ir(C,P);a[T]=(mt*l).toFixed(1)+String.fromCharCode(176),zi(M,C,w),Ki(M,M),Vi(M,P)<0&&tr(M,M),fl(_,S,C,M,l/2),Hi(_,o,3*T);const R=Math.ceil(l/i),O=R+(t.extendLine?4:2),$=t.extendLine?36:0,F=new Float32Array(3*O),E=new Float32Array(3*O),L=new Float32Array(9*R),N=new Float32Array($);c[T]=F,h[T]=E,u[T]=L,d[T]=N,t.extendLine&&(r?(Gi(_,g,b),Ki(_,_),Yi(I,_,1/Vi(C,_)),Ui(I,I,b)):(Yi(I,v,1/Vi(C,v)),Ui(I,I,y)),s?(Gi(_,x,y),Ki(_,_),Yi(k,_,1/Vi(P,_)),Ui(k,k,y)):(Yi(k,A,1/Vi(P,A)),Ui(k,k,b))),Ui(D,S,C);let z=0;t.extendLine?(Hi(g,F,z),Hi(I,E,z),z+=3,Hi(I,F,z),Hi(D,E,z),z+=3,Hi(I,N,0),Hi(D,N,3),Hi(r?b:y,N,6),Hi(r?b:y,N,9),Hi(D,N,12),Hi(S,N,15)):(Hi(S,F,z),Hi(D,E,z),z+=3);const V=function(e,t){const i=9*t;Hi(S,L,i),Hi(D,L,i+3),Hi(D,F,z),fl(D,S,C,M,e),Hi(D,L,i+6),Hi(D,E,z),z+=3};let G=0;for(let e=i;e{const t=ih(i,e);Object.assign(e,t)})),t.side=l(t.side,"double"),t.opacity=l(t.opacity,.5),t.radiusType=l(t.radiusType,"size"),t.radiusSize=l(t.radiusSize,.15),super.init(t)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(e){if(!e.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((t=>t.atomPositions=pl(e,[t.atomQuad])));const t=this.scaleBinToSectorArea?function(e){return Math.sqrt(e)}:function(e){return e};function i(e){const t=e.map((e=>e.length)),i=new Float32Array(Pt(t));let r=0;for(let t=0;te.startPoints))),position2:i(e.map((e=>e.endPoints))),color:i(e.map((e=>e.startColors))),color2:i(e.map((e=>e.endColors)))},t)}function s(e,t){return new Bn({position:i(e.map((e=>e.triangles))),color:i(e.map((e=>e.triangleColors)))},t)}this.histogramsData.forEach((e=>e.histogram360Scaled=e.histogram360.map(t)));const n=[];for(let e=0;e=3&&(t=nh(i)),void 0!==t&&n.push(t)}return this.frontHistogramBinBordersBuffer=r(n.map((e=>e.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=r(n.map((e=>e.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=r(n.map((e=>e.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=r(n.map((e=>e.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=s(n.map((e=>e.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=s(n.map((e=>e.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=s(n.map((e=>e.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(e){return super.setParameters(e,{},!1),e&&void 0!==e.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),t||this.viewer.requestRender(),this}}function nh(e){const t=e.atomPositions,i=e.histogram360Scaled,r=i.length<=180?360:2*i.length,s={triangles:new Float32Array(3*r*3),triangleColors:rh(e.opaqueMiddleDiscColor,3*r)},n={triangles:new Float32Array(3*i.length*3),triangleColors:rh(e.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:rh(e.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:rh(e.histogramBinBorderColor,i.length),endColors:rh(e.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:rh(e.histogramBinBorderColor,i.length),endColors:rh(e.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:rh(e.adjacentBondArrowColor,i.length),endColors:rh(e.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:rh(e.distantBondArrowColor,i.length),endColors:rh(e.distantBondArrowColor,i.length)},u=Ni(),d=Ni(),m=Ni(),p=Ni(),f=Ni(),g=Ni(),y=Ni(),b=Ni(),x=Ni(),v=Ni(),w=Ni(),A=Ni(),_=Ni(),S=Ni(),C=Ni(),P=Ni(),I=[u,d,m,p];for(let e=0;e{let d=t[0],m=t[1];if("number"==typeof d&&Number.isInteger(d)&&"number"==typeof m&&Number.isInteger(m)){if(!u.get(d)||!u.get(m))return void(h+=1);c.index=d,l.index=m}else{n.setString(d),o.setString(m);var p=e.getAtomIndices(n),f=e.getAtomIndices(o);if(!p.length||!f.length)return void(h+=1);c.index=p[0],l.index=f[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":r[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(g/10).toFixed(2)+" nm";break;default:r[i]=g.toFixed(2)}var y=3*i;s[y+0]=(c.x+l.x)/2,s[y+1]=(c.y+l.y)/2,s[y+2]=(c.z+l.z)/2})),h>0&&(i-=h,s=s.subarray(0,3*i));var d=new Sr(a.count,!0);return{text:r,position:s,bondSet:d,bondStore:a}}getBondData(e,t,i){const r=e.getBondData(this.getBondParams(t,i));return r.picking&&(r.picking=new Us(r.picking.array,r.picking.structure,i.bondStore)),r}createData(e){if(!e.atomCount||!this.atomPair.length)return;const i=this.atomPair.length,r=new t.Color(this.labelColor),s=this.getDistanceData(e,this.atomPair);this.textBuffer=new Sl({position:s.position,size:yt(i,this.labelSize),color:bt(i,r.r,r.g,r.b),text:s.text},this.getLabelBufferParams());const n={bondSet:s.bondSet,bondStore:s.bondStore},o=this.getBondData(e,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new Gl(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Il(sr(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:s.bondSet,bondStore:s.bondStore,position:s.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(e,t){super.updateData(e,t);const i={bondSet:t.bondSet,bondStore:t.bondStore},r=this.getBondData(t.sview,e,i),s={};e&&!e.color||Object.assign(s,{color:r.color,color2:r.color2}),e&&!e.radius||Object.assign(s,{radius:r.radius}),this.distanceBuffer.setAttributes(s)}setParameters(e){return super.setParameters(e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this}}function ah(e){return 2*(e.position.length/3)*3}Ne.add("distance",oh);const ch=Object.assign({scale:1,color:"grey"},Mn);class lh extends Tn{constructor(e,i={}){super({position:new Float32Array(ah(e)),color:new Float32Array(ah(e))},i),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const r=new t.Color(this.parameters.color),s=this.geometry.attributes;bt(ah(e)/3,r.r,r.g,r.b,s.color.array),this.setAttributes(e)}get defaultParameters(){return ch}setAttributes(e={}){const t=this.geometry.attributes;let i,r,s;e.position&&e.vector&&(i=e.position,r=e.vector,s=t.position.array,t.position.needsUpdate=!0);const n=this.size/2,o=this.parameters.scale;if(i&&r)for(let e=0;e{if(e.residueCount<4)return;i.push(e);const r=new fo(e),s=r.getPosition(),n=r.getColor(this.getColorParams()),o=r.getSize(this.getRadiusParams()),a=r.getPicking();t.push(new Ta({position:s.center,color:n.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new lh({position:s.center,vector:s.axis},this.getBufferParams({color:"skyblue",scale:1})),new lh({position:s.center,vector:s.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&Be.time(this.type+" repr update"),t=t||{};for(let e=0,r=i.polymerList.length;e radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),Ve.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const dh=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),mh=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class ph extends Pa{constructor(e,t={}){super("v3",e,t)}get mapping(){return dh}get mappingIndices(){return mh}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const fh=Object.assign({shrink:.14},Mn),gh=Object.assign({shrink:{uniform:!0}},Dn);class yh extends ph{constructor(e,i={}){super(e,i),this.parameterTypes=gh,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new t.Matrix4},modelViewProjectionMatrixInverse:{value:new t.Matrix4},modelViewMatrixInverseTranspose:{value:new t.Matrix4},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return fh}}Object.assign({disableImpostor:!1},Rl,fh);const bh=class{constructor(e,t={}){return!De||t&&t.disableImpostor?(e.radius=function(e,t){const i=e.length,r=new Float32Array(i);for(let s=0;sa.push(r.atomLabel(e)))))}else if("residue"===this.labelGrouping){t&&!t.position||(c=[]),t&&!t.color||(h=[]),t&&!t.radius||(l=[]),t&&!t.text||(a=[]),i.colorParams&&(i.colorParams.structure=e.getStructure());const u=Ee.getScheme(i.colorParams),d=new ro(i.radiusParams),m=e.getAtomProxy();let p=0;e.eachResidue((e=>{const i=3*p;e.isProtein()||e.isNucleic()?(m.index=e.traceAtomIndex,t&&!t.position||m.positionToArray(c,i)):(m.index=e.atomOffset,t&&!t.position||e.positionToArray(c,i)),t&&!t.color||u.atomColorToArray(m,h,i),t&&!t.radius||(l[p]=d.atomRadius(m)),t&&!t.text||a.push(r.atomLabel(m)),++p})),t&&!t.position||(s=new Float32Array(c)),t&&!t.color||(o=new Float32Array(h)),t&&!t.radius||(n=new Float32Array(l))}return{position:s,size:n,color:o,text:a}}createData(e){return{bufferList:[new Sl(this.getTextData(e,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(e,t){t.bufferList[0].setAttributes(this.getTextData(t.sview,e))}getAtomRadius(){return 0}}function Ah(e){const t=e.getAtomSet(),i=e.getBondSet(),r=e.getBondProxy();return i.forEach((function(e){r.index=e,t.clear(r.atomIndex1),t.clear(r.atomIndex2)})),t}Ne.add("label",wh);class _h extends dl{constructor(e,t,i){super(e,t,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.multipleBond=l(t.multipleBond,"off"),this.bondSpacing=l(t.bondSpacing,1),this.linewidth=l(t.linewidth,2),this.lines=l(t.lines,!0),this.crosses=l(t.crosses,"lone"),this.crossSize=l(t.crossSize,.4),super.init(t)}getAtomRadius(e){return.1}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},t),super.getBondParams(e,t)}_crossData(e,t){if(e&&!e.position&&!e.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Ah(t)});const r=t.getAtomData(this.getAtomParams(e,i)),s={},n=r.position,o=r.color,a=r.picking,c=(n||o).length,l=3*c;let h=new Float32Array(0),u=new Float32Array(0),d=new Float32Array(0),m=new Float32Array(0),p=0,f=new Float32Array(0);e&&!e.position||(h=s.position1=new Float32Array(l),u=s.position2=new Float32Array(l),p=this.crossSize/2),e&&!e.color||(d=s.color=new Float32Array(l),m=s.color2=new Float32Array(l)),e&&!e.picking||(f=new Float32Array(3*r.picking.array.length));for(let t=0;tl?d[f]=-1:(c=Math.sqrt(l-a),d[f]=Math.floor(c)),++f;p[g]=u,m[g]=d}}function k(i){var r,s,n,a,u,f,b,v,w,A,S,C,P,I,k,M,D,T,B=3*i,R=i;r=Math.floor(.5+o*(e[B]+d[0])),s=Math.floor(.5+o*(e[B+1]+d[1])),n=Math.floor(.5+o*(e[B+2]+d[2]));var O,$=t[R],F=m[$],E=0,L=l*h,N=p[$];for(A=0;A=c||I>=l||k>=h)){var z=P*L+I*h+k;if(g)if(y[z]&_){if(y[z]&_){var V=x[z];V!==B&&b*b+v*v+w*w<(a=r+b-Math.floor(.5+o*(e[V]+d[0])))*a+(u=s+v-Math.floor(.5+o*(e[V+1]+d[1])))*u+(f=n+w-Math.floor(.5+o*(e[V+2]+d[2])))*f&&(x[z]=i)}}else y[z]|=_,x[z]=i;else y[z]|=_}E++}}function M(t){var i,r;for(console.time("EDTSurface fillvoxels"),i=0,r=y.length;i=c||_>=l||C>=h)){var L=A*E+_*h+C;if(y[L]&S){if(g){var N=x[L];b*b+v*v+w*w<(a=Math.floor(.5+o*(e[N]+d[0])))*a+(u=Math.floor(.5+o*(e[N+1]+d[1])))*u+(f=Math.floor(.5+o*(e[N+2]+d[2])))*f&&(x[L]=i)}}else y[L]|=S,g&&(x[L]=i)}$++}}function T(){var e,t,i,r;console.time("EDTSurface fastdistancemap");var s,n=Sh(c,l,h,Uint16Array,3),o=l*h,u=f*f,d=0;for(e=0;e0);var A,P=a*a,I=new Uint16Array(3);for(e=0;e=P)||(y[s]|=C,g&&y[s]&S&&(n.toArray(e,t,i,I),A=I[0]*o+I[1]*h+I[2],x[s]=x[A])));console.timeEnd("EDTSurface fastdistancemap")}function B(e,t,i,r){var s,n,o,a,u,d,m,p,f,g,x,v,w=new Uint16Array(3),A=0;if(0===i)return A;var I=-1,k=-1,M=-1,D=l*h;for(m=0,f=i;m-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&o-1&&u-1&&aD&&(D=O)}return{neighbourListLength:27*D+1,withinRadii:function(s,n,o,a,u){for(var d=0,m=p(s,c),f=p(n,l),g=p(o,h),y=Math.max(0,m-1),w=Math.max(0,f-1),_=Math.max(0,g-1),S=Math.min(b,m+2),C=Math.min(x,f+2),M=Math.min(v,g+2),D=y;Dm&&(m=u[e]);!function(){const e=An(c,h,m,f,0);f=e.scaleFactor,b=e.dim,x=e.matrix,O=Math.max(5,2+Math.floor(p*f)),v=yt(b[0]*b[1]*b[2],-1001),w=new Int32Array(v.length),A=new Float32Array(b[0]),_=new Float32Array(b[1]),S=new Float32Array(b[2]),F(A,c[0],1/f),F(_,c[1],1/f),F(S,c[2],1/f)}(),function(){var e=0,t=2*Math.PI/y;P=new Float32Array(y),C=new Float32Array(y);for(var i=0;i=0;){if(n!==r&&n!==s&&L(n,e,t,i))return M=n,n;n=k[++o]}return M=-1,-1}function L(t,i,r,s){var n=3*t,o=d[t],a=e[n]-i,c=e[n+1]-r,l=e[n+2]-s;return a*a+c*c+l*l0&&d=0;)e{t(this._makeSurface(e.data.sd,i))}),(e=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",e),this.worker.terminate(),this.worker=void 0;const r=this.getSurface(i);t(r)}))}else{const e=this.getSurface(i);t(e)}}dispose(){this.worker&&this.worker.terminate()}}class Mh extends dl{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(e){const t=e||{};t.colorScheme=l(t.colorScheme,"uniform"),t.colorValue=l(t.colorValue,14540253),t.disablePicking=l(t.disablePicking,!0),this.surfaceType=l(t.surfaceType,"ms"),this.probeRadius=l(t.probeRadius,1.4),this.smooth=l(t.smooth,2),this.scaleFactor=l(t.scaleFactor,2),this.cutoff=l(t.cutoff,0),this.contour=l(t.contour,!1),this.background=l(t.background,!1),this.opaqueBack=l(t.opaqueBack,!0),this.filterSele=l(t.filterSele,""),this.colorVolume=l(t.colorVolume,void 0),this.useWorker=l(t.useWorker,!0),super.init(e)}prepareData(e,i,r){let s=this.__infoList[i];if(s||(s={},this.__infoList[i]=s),s.molsurf&&s.sele===e.selection.string)r(i);else{if(this.filterSele){const s=e.structure.getView(new ye(this.filterSele)),n=s.boundingBox.getSize(new t.Vector3),o=Math.max(n.x,n.y,n.z),a=e.getAtomSetWithinPoint(s.center,o/2+6);if(0===(e=e.getView(new ye(e.getAtomSetWithinSelection(a,3).toSeleString()))).atomCount)return void r(i)}s.sele=e.selection.string,s.molsurf=new kh(e);const n=this.getSurfaceParams(),o=e=>{s.surface=e,r(i)};this.useWorker?s.molsurf.getSurfaceWorker(n,o):o(s.molsurf.getSurface(n))}}prepare(e){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void e();const t=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,e()},i="default"===this.assembly?this.defaultAssembly:this.assembly,r=this.structure.biomolDict[i];r?r.partList.forEach(((e,i)=>{const s=e.getView(this.structureView);this.prepareData(s,i,(e=>{e===r.partList.length-1&&t()}))})):this.prepareData(this.structureView,0,t)}createData(e,t){const i=this.__infoList[t],r=i.surface;if(!r)return;const s={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,e)},n=[];if(r.contour){const e=new En(s,this.getBufferParams({wireframe:!1}));n.push(e)}else{Object.assign(s,{normal:r.getNormal(),picking:r.getPicking(e.getStructure())});const t=new Rn(s,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const e=new Fn(t);n.push(e)}else n.push(t)}return{bufferList:n,info:i}}updateData(e,t){const i={};if(e.position||e.radius)return this.__forceNewMolsurf=!0,void this.build();e.color&&(i.color=t.info.surface.getColor(this.getColorParams())),e.index&&(i.index=t.info.surface.getFilteredIndex(this.filterSele,t.sview)),t.bufferList[0].setAttributes(i)}setParameters(e,t={},i){return e&&e.filterSele&&(t.index=!0),e&&void 0!==e.colorVolume&&(t.color=!0),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),this}getSurfaceParams(e={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},e)}getColorParams(){const e=super.getColorParams();return e.volume=this.colorVolume,e}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}Ne.add("surface",Mh);class Dh extends dl{constructor(e,t,i){super(e,t,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.pointSize=l(t.pointSize,1),this.sizeAttenuation=l(t.sizeAttenuation,!0),this.sortParticles=l(t.sortParticles,!1),this.useTexture=l(t.useTexture,!1),this.alphaTest=l(t.alphaTest,.5),this.forceTransparent=l(t.forceTransparent,!1),this.edgeBleach=l(t.edgeBleach,0),super.init(t)}createData(e){var t=e.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new $a(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),r={};e&&!e.position||Object.assign(r,{position:i.position}),e&&!e.color||Object.assign(r,{color:i.color}),t.bufferList[0].setAttributes(r)}getAtomRadius(){return.1}}Ne.add("point",Dh),Ve.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const Th=new Uint16Array([0,1,2,1,3,2]);function Bh(e){return 3*(4*(e.position.length/3-1))}class Rh extends Bn{constructor(e,t={}){super({position:new Float32Array(Bh(e)),color:new Float32Array(Bh(e)),index:A(Bh(e),Bh(e)/3),normal:new Float32Array(Bh(e)),picking:e.picking},t),this.vertexShader="Ribbon.vert";const i=e.position.length/3-1,r=4*i,s=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(s)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),e.primitiveId=xt(i),this.setAttributes(e),this.makeIndex()}setAttributes(e={}){const t=this.size/4,i=this.geometry.attributes;let r,s,n,o,a,c,l,h,u,d,m,p,f,g,y,b,x,v,w;e.position&&(r=e.position,l=i.position.array,i.position.needsUpdate=!0),e.normal&&(s=e.normal,h=i.normal.array,i.normal.needsUpdate=!0),e.size&&(n=e.size,u=i.size.array,i.size.needsUpdate=!0),e.dir&&(o=e.dir,d=i.dir.array,i.dir.needsUpdate=!0),e.color&&(a=e.color,m=i.color.array,i.color.needsUpdate=!0),e.primitiveId&&(c=e.primitiveId,p=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let A=n?n[0]:null;for(f=0;f{if(!(e.residueCount<4)){i.push(e);var r=new Xl(e,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedOrientation(),o=r.getSubdividedColor(this.getColorParams()),a=r.getSubdividedPicking(),c=r.getSubdividedSize(this.getRadiusParams());t.push(new Rh({position:s.position,normal:n.binormal,dir:n.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,r=t.polymerList.length;for(i=0;i{if(e.residueCount<4||e.isNucleic())return;const s=new go(e),n=s.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t+=n.size.length,i.push(n),r.push(s)}),e.getSelection());const s={begin:new Float32Array(3*t),end:new Float32Array(3*t),size:new Float32Array(t),color:new Float32Array(3*t),picking:{}};let n=new Float32Array(t),o=0;i.forEach((function(e){s.begin.set(e.begin,3*o),s.end.set(e.end,3*o),s.size.set(e.size,o),s.color.set(e.color,3*o),n.set(e.picking.array,o),o+=e.size.length})),t&&(s.picking=new Ls(n,e.getStructure()));return{bufferList:[new Gl({position1:s.begin,position2:s.end,color:s.color,color2:s.color,radius:s.size,picking:s.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:r,axisData:s}}updateData(e,t){if((e=e||{}).position)this.build();else{var i={};if(e.color||e.radius){var r=0;t.helixbundleList.forEach((i=>{var s=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e.color&&t.axisData.color.set(s.color,3*r),(e.radius||e.scale)&&t.axisData.size.set(s.size,r),r+=s.size.length})),e.color&&Object.assign(i,{color:t.axisData.color,color2:t.axisData.color}),(e.radius||e.scale)&&Object.assign(i,{radius:t.axisData.size})}t.bufferList[0].setAttributes(i)}}}Ne.add("rocket",$h);class Fh extends Jl{constructor(e,t,i){super(e,t,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(e){var t=e||{};t.aspectRatio=1,t.tension=l(t.tension,.5),t.radiusScale=l(t.radiusScale,5),t.smoothSheet=!1,this.smooth=l(t.smooth,2),super.init(t)}getSpline(e){var t=new fo(e);return new Xl(e,this.getSplineParams({directional:!1,positionIterator:t.getCenterIterator(this.smooth)}))}}Ne.add("rope",Fh);class Eh extends dl{constructor(e,t,i){super(e,t,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(e){var t=e||{};t.useInteriorColor=l(t.useInteriorColor,!0),super.init(t)}createData(e){return{bufferList:[new Ta(e.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),r={};e&&!e.position||Object.assign(r,{position:i.position}),e&&!e.color||Object.assign(r,{color:i.color}),e&&!e.radius||Object.assign(r,{radius:i.radius}),t.bufferList[0].setAttributes(r)}}function Lh(e){return 3*(e.position.length/3-1)*2}Ne.add("spacefill",Eh);class Nh extends Tn{constructor(e,t={}){super({position:new Float32Array(Lh(e)),color:new Float32Array(Lh(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(e)}setAttributes(e){let t,i,r,s;const n=this.geometry.attributes;if(e.position&&(t=e.position,r=n.position.array,n.position.needsUpdate=!0),e.color&&(i=e.color,s=n.color.array,n.color.needsUpdate=!0),!t&&!i)return void Be.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let e=0;e{if(!(e.residueCount<4)){i.push(e);var r=new Xl(e,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedColor(this.getColorParams());t.push(new Nh(Object.assign({},s,n),this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,r=t.polymerList.length;for(i=0;i{e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox)}))}}const Zh=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},Mn);class Qh{constructor(e,i={}){this.group=new t.Group,this.wireframeGroup=new t.Group,this.pickingGroup=new t.Group,this.visible=!0,this.parameters=h(i,this.defaultParameters),this.splitPosition=new Float32Array(e.position1.length),this.cylinderRadius=new Float32Array(e.radius.length);const r=this.makeAttributes(e),s={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new Gl(r.cylinder,s),this.coneBuffer=new Yh(r.cone,s),this.geometry=new Kh([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=l(i.matrix,new t.Matrix4),this.picking=e.picking}get defaultParameters(){return Zh}set matrix(e){Tn.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(e={}){const i=this.splitPosition,r=this.cylinderRadius,s=this.parameters.aspectRatio;let n,o;const a={},c={};if(e.radius){for(n=0,o=r.length;n(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){e.Debug&&Be.log(this[this.__objName])}}class Iu extends Pu{constructor(e,t){var i=t||{};super(e,i),this.firstModelOnly=l(i.firstModelOnly,!1),this.asTrajectory=l(i.asTrajectory,!1),this.cAlphaOnly=l(i.cAlphaOnly,!1),this.structure=new pa(this.name,this.path),this.structureBuilder=new Do(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class ku{constructor(e,t,i="",r,s=[]){this.structure=e,this.index=t,this.description=i,this.entityType=function(e){switch(e=e.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(r||""),this.chainIndexList=s,s.forEach((function(i){e.chainStore.entityIndex[i]=t}))}get type(){return function(e){switch(e){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(e){const t=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){t.index=i,e(t)}))}}const Mu={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class Du{constructor(e=Mu){this.cartToFrac=new t.Matrix4,this.fracToCart=new t.Matrix4,this.a=e.a,this.b=e.b,this.c=e.c,this.alpha=e.alpha,this.beta=e.beta,this.gamma=e.gamma,this.spacegroup=e.spacegroup;const i=T(this.alpha),r=T(this.beta),s=T(this.gamma),n=Math.cos(i),o=Math.cos(r),a=Math.cos(s),c=Math.sin(r),l=Math.sin(s);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-n*n-o*o-a*a+2*n*o*a),void 0===e.cartToFrac){const e=this.a*this.b*l/this.volume,t=(o*a-n)/(c*l);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*l,0,0,this.c*o,-this.c*c*t,1/e,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(e.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(e){const i=new Float32Array(24);if(e.unitcell){const r=e.unitcell,s=e.center.clone().applyMatrix4(r.cartToFrac).floor(),n=new t.Vector3;let o=0;const a=function(e,t,a){n.set(e,t,a).add(s).applyMatrix4(r.fracToCart).toArray(i,o),o+=3};a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1)}return i}getCenter(e){return function(e,i=new t.Vector3){const r=e.length;for(let t=0;t0)continue;let e,t,r,s,n,c=0;if(o){if(s=C.split(Ou),c=10===s.length?1:0,R=s[2],f&&"CA"!==R)continue;e=parseFloat(s[6-c]),t=parseFloat(s[7-c]),r=parseFloat(s[8-c])}else{if(R=C.substr(12,4).trim(),f&&"CA"!==R)continue;e=parseFloat(C.substr(30,8)),t=parseFloat(C.substr(38,8)),r=parseFloat(C.substr(46,8))}if(p){const i=3*x;if(b[i+0]=e,b[i+1]=t,b[i+2]=r,x+=1,v)continue}o?(I=parseInt(s[1]),n="",O="H"===C[0]?1:0,k=c?"":s[4],M=parseInt(s[5-c]),B="",D=s[3],F="",T=1):(I=parseInt(C.substr(6,5),u),h&&99999===I&&(u=16),O="H"===C[0]?1:0,k=C[21].trim(),M=parseInt(C.substr(22,4),d),h&&9999===M&&(d=16),B=C[26].trim(),D=C.substr(17,4).trim()||"MOL",$=parseFloat(C.substr(60,6)),F=C[16].trim(),T=parseFloat(C.substr(54,6)),i||(a?(n=C.substr(76,3).trim(),n in rs&&(n=rs[n])):(n=C.substr(76,2).trim(),k||(k=C.substr(72,4).trim())),E=parseInt((C.substr(79,1)+C.substr(78,1)).trim()))),de.growIfFull(),de.atomTypeId[fe]=ue.add(R,n),de.x[fe]=e,de.y[fe]=t,de.z[fe]=r,de.serial[fe]=I,de.altloc[fe]=F.charCodeAt(0),de.occupancy[fe]=isNaN(T)?0:T,o?(de.partialCharge[fe]=parseFloat(s[9-c]),de.radius[fe]=parseFloat(s[10-c])):(de.bfactor[fe]=isNaN($)?0:$,a&&(de.partialCharge[fe]=parseFloat(C.substr(70,6))),isFinite(E)&&(de.formalCharge||de.addField("formalCharge",1,"int8"),de.formalCharge[fe]=E));const y=$u(M,k,B);!O||Z[y]||Bu.includes(D)?te||ie===k||(J+=1,ee=J.toString()):ie===k&&se===D&&(Zr.includes(D)||re===M&&ne===B)||(J+=1,ee=J.toString(),re=M,se=D,ne=B),l.addAtom(ge,k,ee,D,M,O,void 0,B),j[I]=fe,fe+=1,te=!1,ie=k}else if("CONECT"===P){const e=j[parseInt(C.substr(6,5))],t=[11,16,21,26],i={};if(void 0===e)continue;for(let r=0;r<4;++r){let s=parseInt(C.substr(t[r],5));if(!Number.isNaN(s)&&(s=j[s],void 0!==s))if(e0)continue;const D=t[l].replace(Nu,"");if(k&&"CA"!==D)continue;const R=parseFloat(t[x]),O=parseFloat(t[v]),$=parseFloat(t[w]);if(I){const e=3*r;if(i[e+0]=R,i[e+1]=O,i[e+2]=$,r+=1,X>0)continue}const F=t[h],E=parseInt(t[-1!==a?a:c]);let L=t[b];L="?"===L?"":L;const N=t[o],z=t[u],V="H"===t[p][0]?1:0,Y=t[g],K=parseFloat(t[A]),Z=parseFloat(t[_]);let Q=t[m];if(Q="."===Q?"":Q,H.growIfFull(),H.atomTypeId[q]=j.add(D,Y),H.x[q]=R,H.y[q]=O,H.z[q]=$,H.serial[q]=parseInt(t[f]),H.bfactor[q]=isNaN(K)?0:K,H.occupancy[q]=isNaN(Z)?0:Z,H.altloc[q]=Q.charCodeAt(0),C.addAtom(X,N,z,F,E,V,void 0,L),e.Debug){const t=T[z];void 0!==t&&t!==N&&e.Debug&&Be.warn(t,N)}T[z]=N;const J=t[d];B[J]||(B[J]=new Set),B[J].add(S.chainStore.count-1),q+=1}else{const e=n.match(Lu),t=e.length;N===L.length&&(N=0);for(let i=0;ic*c)return s.growIfFull(),s.atomTypeId[d]=s.atomTypeId[e],s.x[d]=l.x,s.y[d]=l.y,s.z[d]=l.z,s.occupancy[d]=s.occupancy[e],s.serial[d]=d,s.altloc[d]="A".charCodeAt(0),r.addAtom(0,"","","HET",1,!0),void(d+=1)}}}))}}(D,S,C),C.finalize(),S.finalizeAtoms(),Fo(S),S.finalizeBonds();else{var Y=function(e,t,i){var r,s,n,o,a=[],c=[],l=e.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(Gu(l,"id"),r=0,s=l.beg_auth_seq_id.length;r0){o=o.split("(");var l=c(o[0]),h=c(o[1]);Object.keys(l).forEach((function(e){Object.keys(h).forEach((function(i){var r=new t.Matrix4;r.multiplyMatrices(l[e],h[i]),s[e+"x"+i]=r}))}))}else s=c(o);var u=[];for(var d in s)u.push(s[d]);var m=e;/^(0|[1-9][0-9]*)$/.test(m)&&(m="BU"+m);for(var p=a.asym_id_list[i].split(","),f=0,g=p.length;f_){var S=A;A=_,_=S;var C=f;f=v,v=C}if(0!==A&&0!==_)for(var P=0;P<_;++P)o.index=f[P%A],a.index=v[P],o&&a?i.bondStore.addBond(o,a,Hu(s.pdbx_value_order[l])):Be.log("atoms for connection not found");else e.Debug&&Be.warn("no atoms found for",p,x)}}}}(D,S,T),function(e,t,i){if(e.entity){Gu(e.entity,"id");for(var r=e.entity,s=r.id.length,n=0;nx)continue}d=I.substr(5,5).trim(),m=parseInt(I.substr(0,5)),p=parseInt(I.substr(15,5)),w.growIfFull(),w.atomTypeId[A]=v.add(u),w.x[A]=D,w.y[A]=T,w.z[A]=B,w.serial[A]=p,s.addAtom(_,"","",d,m,0,"l"),A+=1}}}(0,e.length,e)})),s.finalize(),r.finalizeAtoms(),$o(r),Fo(r),r.finalizeBonds(),Bo(r),e.Debug&&Be.timeEnd("GroParser._parse "+this.name)}});var qu=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function Xu(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function Yu(e){return Xu(DataView,e)}function Ku(e){return Xu(Int8Array,e)}function Zu(e){return Xu(Int32Array,e,4)}function Qu(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var r=0,s=0;rn&&++a;t=new Int32Array(a)}for(i=0,r=0;is){for(var n=[],o=0;o0&&(a.biomolDict[e]=i)}const $=c.unitCell;$&&Array.isArray($)&&$[0]?a.unitcell=new Du({a:$[0],b:$[1],c:$[2],alpha:$[3],beta:$[4],gamma:$[5],spacegroup:c.spaceGroup}):a.unitcell=void 0,zo(a,!0),No(a,!0),a.finalizeAtoms(),a.finalizeBonds(),Vo(a),e.Debug&&Be.timeEnd("MmtfParser._parse "+this.name)}});const hd=/\s+/,ud={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};ze.add("mol2",class extends Iu{get type(){return"mol2"}_parse(){e.Debug&&Be.time("Mol2Parser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=this.firstModelOnly,s=this.asTrajectory,n=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/60)),h.addField("partialCharge",1,"float32");let u=0,d=0,m=0,p=-1,f=0,g=0;const y=t.getAtomProxy(),b=t.getAtomProxy();this.streamer.eachChunkOfLines((function(e){!function(e,x,v){for(let w=e;wMOLECULE"===e?(g=1,d=0,++p):"@ATOM"===e?(g=2,m=h.count,s&&(a=0,o=new Float32Array(3*f),n.push(o),p>0&&(c=!0))):g="@BOND"===e?3:0;else if(1===g){if(0===d)t.title=e,t.id=e;else if(1===d){const t=e.split(hd);f=parseInt(t[0])}++d}else if(2===g){const t=e.split(hd);if(r&&p>0)continue;const n=parseFloat(t[2]),d=parseFloat(t[3]),m=parseFloat(t[4]);if(s){const e=3*a;if(o[e+0]=n,o[e+1]=d,o[e+2]=m,a+=1,c)continue}const f=t[0],g=t[1],y=t[5].split(".")[0],b=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",v=t[8]?parseFloat(t[8]):0;h.growIfFull(),h.atomTypeId[u]=l.add(g,y),h.x[u]=n,h.y[u]=d,h.z[u]=m,h.serial[u]=f,h.partialCharge[u]=v,i.addAtom(p,"","",x,b,1),u+=1}else if(3===g){if(r&&p>0)continue;if(s&&p>0)continue;const i=e.split(hd);y.index=parseInt(i[1])-1+m,b.index=parseInt(i[2])-1+m;const n=ud[i[3]];t.bondStore.addBond(y,b,n)}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),$o(t),No(t,!0),zo(t,!0),t.finalizeBonds(),Ho(t),Bo(t),e.Debug&&Be.timeEnd("Mol2Parser._parse "+this.name)}});ze.add("pdbqt",class extends Fu{get type(){return"pdbqt"}});ze.add("pqr",class extends Fu{get type(){return"pqr"}});const dd=/> +<(.+)>/;class md extends Iu{get type(){return"sdf"}_parse(){e.Debug&&Be.time("SdfParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=this.firstModelOnly,s=this.asTrajectory,n=this.streamer.peekLines(2);t.id=n[0].trim(),t.title=n[1].trim();const o=t.frames;let a,c,l=!1;const h=t.atomMap,u=t.atomStore;u.resize(Math.round(this.streamer.data.length/50)),u.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),m=t.getAtomProxy();let p=0,f=0,g=0,y=0;const b=[];let x,v,w,A,_,S,C,P,I,k,M,D,T,B,R=!1,O={};t.extraData.sdf=b;let $=!1,F=!1,E=!1,L=[],N=[];const z=new Map;this.streamer.eachChunkOfLines((function(e){!function(e,n,V){for(let G=e;G-1,$?z.clear():(v=parseInt(e.substr(0,3)),w=parseInt(e.substr(3,3)),A=4,_=A+v,S=_,C=S+w,s&&(c=0,a=new Float32Array(3*v),o.push(a),g>0&&(l=!0)));else if($&&"COUNTS"===L[0])v=parseInt(L[1]),s&&(c=0,a=new Float32Array(3*v),o.push(a),g>0&&(l=!0));else if($&&2==L.length)"ATOM"===L[1]?"BEGIN"===L[0]?F=!0:"END"===L[0]&&(F=!1):"BOND"===L[1]&&("BEGIN"===L[0]?E=!0:"END"===L[0]&&(E=!1));else if(F||!$&&f>=A&&f<_){if(r&&g>0)continue;let t=0;if($){if(P=parseFloat(L[2]),I=parseFloat(L[3]),k=parseFloat(L[4]),D=L[1],T=parseInt(L[0]),z.set(T,p),M=D+T,L.length>6){let e=L.slice(6).find((e=>0===e.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else P=parseFloat(e.substr(0,10)),I=parseFloat(e.substr(10,10)),k=parseFloat(e.substr(20,10)),D=e.substr(31,3).trim(),M=D+(p-y+1);if(s){const e=3*c;if(a[e+0]=P,a[e+1]=I,a[e+2]=k,c+=1,l)continue}u.growIfFull(),u.atomTypeId[p]=h.add(M,D),u.x[p]=P,u.y[p]=I,u.z[p]=k,u.serial[p]=$?T:p,u.formalCharge[p]=t,i.addAtom(g,"","","HET",1,1),p+=1}else if(E||!$&&f>=S&&f0)continue;if(s&&g>0)continue;$?(d.index=z.get(parseInt(L[2])),m.index=z.get(parseInt(L[3])),B=parseInt(L[1])):(d.index=parseInt(e.substr(0,3))-1+y,m.index=parseInt(e.substr(3,3))-1+y,B=parseInt(e.substr(6,3))),t.bondStore.addBond(d,m,B)}else if("M CHG"===e.substr(0,6)){const t=parseInt(e.substr(6,3));for(let i=0,r=10;i"===e.charAt(0)&&(x=e.match(dd))?(R=x[1],O[R]=[]):!1!==R&&e&&O[R].push(e);++f}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),t.finalizeBonds(),Ho(t),e.Debug&&Be.timeEnd("SdfParser._parse "+this.name)}_postProcess(){Ho(this.structure)}}ze.add("sdf",md),ze.add("sd",md),ze.add("mol",md);function pd(e,t,i){return parseInt(e.substr(t,i).trim())}class fd extends Iu{get type(){return"prmtop"}_parse(){e.Debug&&Be.time("PrmtopParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=t.atomMap,s=t.atomStore;s.addField("partialCharge",1,"float32"),s.addField("radius",1,"float32");const n=[],o={},a=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let c,l,h,u,d;a.forEach((e=>{o[e]=0}));let m,p,f,g,y,b=new Uint8Array(0);this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r0)return void Be.error("dcd format with fixed atoms unsupported, aborting");const f=o.NATOM,g=4*f;for(let e=0,r=o.NSET;e=1&&(r.timeOffset=(o.ISTART-1)*r.deltaTime),e.Debug&&Be.timeEnd("DcdParser._parse "+this.name)}});const Sd={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Cd(e){switch(Number(e)){case Sd.BYTE:return"byte";case Sd.CHAR:return"char";case Sd.SHORT:return"short";case Sd.INT:return"int";case Sd.FLOAT:return"float";case Sd.DOUBLE:return"double";default:return"undefined"}}function Pd(e){switch(Number(e)){case Sd.BYTE:case Sd.CHAR:return 1;case Sd.SHORT:return 2;case Sd.INT:case Sd.FLOAT:return 4;case Sd.DOUBLE:return 8;default:return-1}}function Id(e){switch(String(e)){case"byte":return Sd.BYTE;case"char":return Sd.CHAR;case"short":return Sd.SHORT;case"int":return Sd.INT;case"float":return Sd.FLOAT;case"double":return Sd.DOUBLE;default:return-1}}function kd(e,t){if(1!==e){const i=new Array(e);for(let r=0;r6,"non valid type "+h);const u=e.readUint32();let d=e.readUint32();2===i&&(wd(d>0,"offsets larger than 4GB not supported"),d=e.readUint32()),c[0]===t&&(n+=u),s[r]={name:o,dimensions:c,attributes:l,type:Cd(h),size:u,offset:d,record:c[0]===t}}}return{variables:s,recordStep:n}}(e,r.recordId,t);return i.variables=s.variables,i.recordDimension.recordStep=s.recordStep,i}function $d(e){let t;const i=e.readUint32();if(i===Dd)return wd(e.readUint32()!==Dd,"wrong empty tag for list of attributes"),[];{wd(i!==Rd,"wrong tag for list of attributes");const r=e.readUint32();t=new Array(r);for(let i=0;i6,"non valid type "+s);const n=e.readUint32(),o=Md(e,s,n);Ad(e),t[i]={name:r,type:Cd(s),value:o}}}return t}class Fd{constructor(e){const t=new st(e);t.setBigEndian(),wd("CDF"!==t.readChars(3),"should start with CDF");const i=t.readByte();wd(i>2,"unknown version"),this.header=Od(t,i),this.buffer=t}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(e){return-1!==this.header.variables.findIndex((function(t){return t.name===e}))}getDataVariable(e){let t;return t="string"==typeof e?this.header.variables.find((function(t){return t.name===e})):e,wd(void 0===t,"variable not found"),this.buffer.seek(t.offset),t.record?function(e,t,i){const r=Id(t.type),s=t.size?t.size/Pd(r):1,n=i.length,o=new Array(n),a=i.recordStep;for(let t=0;t=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),e.Debug&&Be.timeEnd("NctrajParser._parse "+this.name)}}ze.add("nctraj",Ed),ze.add("ncdf",Ed),ze.add("nc",Ed);ze.add("trr",class extends vd{get type(){return"trr"}get isBinary(){return!0}_parse(){e.Debug&&Be.time("TrrParser._parse "+this.name);const t=_(this.streamer.data),i=new DataView(t),r=this.frames,s=r.coordinates,n=r.boxes,o=r.times;let a=0;for(;;){a+=8;const e=i.getInt32(a);a+=4,a+=e;const r=i.getInt32(a+8),c=i.getInt32(a+12),l=i.getInt32(a+16),h=i.getInt32(a+28),u=i.getInt32(a+32),d=i.getInt32(a+36),m=i.getInt32(a+40);a+=52;const p=r/9,f=3*m;if(8===p?o.push(i.getFloat64(a)):o.push(i.getFloat32(a)),a+=2*p,r){const e=new Float32Array(9);if(8===p)for(let t=0;t<9;++t)e[t]=10*i.getFloat64(a),a+=8;else for(let t=0;t<9;++t)e[t]=10*i.getFloat32(a),a+=4;n.push(e)}if(a+=c,a+=l,h){let e;if(8===p){e=new Float32Array(f);for(let t=0;t>8&65280|t>>24&255}e=new Float32Array(t,a,f);for(let t=0;t=t.byteLength)break}o.length>=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),e.Debug&&Be.timeEnd("TrrParser._parse "+this.name)}});const Ld=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function Nd(e){let t=1,i=0;for(;e>=t&&i<32;)i++,t<<=1;return i}const zd=new Uint8Array(32);function Vd(e,t){let i=1,r=0;zd[0]=1;for(let r=0;r>=8;for(;0!==s;)zd[e++]=255&s,s>>=8;i=e}let s=1;for(i--;zd[i]>=s;)r++,s*=2;return r+8*i}function Gd(e,t,i,r){const s=(1<=8;)o=o<<8|t[a++],c|=o>>n<0&&(n>n&(1<8;)Ud[a++]=Gd(e,t,8,o),r-=8;r>0&&(Ud[a++]=Gd(e,t,r,o));for(let e=i-1;e>0;e--){let t=0;for(let i=a-1;i>=0;i--){t=t<<8|Ud[i];const r=t/s[e]|0;Ud[i]=r,t-=r*s[e]}n[e]=t}n[0]=Ud[0]|Ud[1]<<8|Ud[2]<<16|Ud[3]<<24}ze.add("xtc",class extends vd{get type(){return"xtc"}get isBinary(){return!0}_parse(){e.Debug&&Be.time("XtcParser._parse "+this.name);const t=_(this.streamer.data),i=new DataView(t),r=this.frames,s=r.coordinates,n=r.boxes,o=r.times,a=new Int32Array(6),c=new Int32Array(3),l=new Int32Array(3),h=new Uint32Array(3),u=new Float32Array(3),d=new Float32Array(3);let m=0;const p=new Int32Array(3),f=new Uint32Array(p.buffer);for(;;){let e;const r=i.getInt32(m+4);m+=12;const g=3*r;o.push(i.getFloat32(m)),m+=4;const y=new Float32Array(9);for(let e=0;e<9;++e)y[e]=10*i.getFloat32(m),m+=4;if(n.push(y),r<=9){e=new Float32Array(r);for(let t=0;t16777215?(l[0]=Nd(c[0]),l[1]=Nd(c[1]),l[2]=Nd(c[2]),o=0):o=Vd(3,c);let y=i.getInt32(m);m+=4;let b=y-1;b=9>b?9:b;let x=Ld[b]/2|0,v=Ld[y]/2|0;h[0]=h[1]=h[2]=Ld[y];let w=4*Math.ceil(i.getInt32(m)/4);m+=4;const A=1/n;let _=0,S=0;const C=new Uint8Array(t,m);for(u[0]=u[1]=u[2]=0;S0){u[0]=u[1]=u[2]=0;for(let t=0;t<_;t+=3){if(jd(p,C,3,y,h,u,f),S++,u[0]+=d[0]-v,u[1]+=d[1]-v,u[2]+=d[2]-v,0===t){let t=u[0];u[0]=d[0],d[0]=t,t=u[1],u[1]=d[1],d[1]=t,t=u[2],u[2]=d[2],d[2]=t,e[r++]=d[0]*A,e[r++]=d[1]*A,e[r++]=d[2]*A}else d[0]=u[0],d[1]=u[1],d[2]=u[2];e[r++]=u[0]*A,e[r++]=u[1]*A,e[r++]=u[2]*A}}else e[r++]=u[0]*A,e[r++]=u[1]*A,e[r++]=u[2]*A;if(y+=t,t<0?(v=x,x=y>9?Ld[y-1]/2|0:0):t>0&&(x=v,v=Ld[y]/2|0),h[0]=h[1]=h[2]=Ld[y],0===h[0]||0===h[1]||0===h[2])return void console.error("(xdrfile error) Undefined error.")}m+=w}for(let t=0;t=t.byteLength)break}o.length>=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),e.Debug&&Be.timeEnd("XtcParser._parse "+this.name)}});class Hd extends Pu{constructor(e,t){const i=t||{};super(e,i),this.volume=new Cn(this.name,this.path),this.voxelSize=l(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new t.Matrix4}}const Wd=/\s+/,qd=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,Xd=.529177210859;class Yd extends Hd{get type(){return"cube"}_parse(){e.Debug&&Be.time("CubeParser._parse "+this.name);const i=this.volume,r=this.streamer.peekLines(6),s={},n=Xd*this.voxelSize;function o(e,t){var i=r[e].trim().split(Wd)[t];return parseFloat(i)}s.atomCount=Math.abs(o(2,0)),s.originX=o(2,1)*Xd,s.originY=o(2,2)*Xd,s.originZ=o(2,3)*Xd,s.NVX=o(3,0),s.NVY=o(4,0),s.NVZ=o(5,0),s.basisX=new t.Vector3(o(3,1),o(3,2),o(3,3)).multiplyScalar(n),s.basisY=new t.Vector3(o(4,1),o(4,2),o(4,3)).multiplyScalar(n),s.basisZ=new t.Vector3(o(5,1),o(5,2),o(5,3)).multiplyScalar(n);const a=new Float32Array(s.NVX*s.NVY*s.NVZ);let c=0,l=0;const h=o(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r=s.atomCount+6+h){const t=e.match(qd);for(let e=0,i=t.length;e>8&255}i.xStart=o[0],i.yStart=o[1],i.zStart=o[2],i.xExtent=o[3],i.yExtent=o[4],i.zExtent=o[5],i.xRate=o[6],i.yRate=o[7],i.zRate=o[8];const e=1/o[17],t=e*this.voxelSize;i.xlen=o[9]*t,i.ylen=o[10]*t,i.zlen=o[11]*t,i.alpha=o[12]*e,i.beta=o[13]*e,i.gamma=o[14]*e,r=o[15]/100,s=o[16],i.gamma=o[14]*e}t.header=i,e.Debug&&Be.log(i,r,s);const l=new Float32Array(i.xExtent*i.yExtent*i.zExtent);let h=512;const u=Math.ceil(i.xExtent/8),d=Math.ceil(i.yExtent/8),m=Math.ceil(i.zExtent/8);for(var p=0;pn){const e=i[r].trim();if(""!==e){const t=e.split(Zd);for(let e=0,i=t.length;e=n&&(f-n)%m!=0&&p=0?i-1:i+t/3)},parseNormalIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},addVertex:function(e,t,i){var r=this.vertices,s=this.object.geometry.vertices;s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addVertexLine:function(e){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[e+0]),i.push(t[e+1]),i.push(t[e+2])},addNormal:function(e,t,i){var r=this.normals,s=this.object.geometry.normals;s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addFace:function(e,t,i,r,s,n,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(e,l),u=this.parseVertexIndex(t,l),d=this.parseVertexIndex(i,l);if(void 0===r?this.addVertex(h,u,d):(c=this.parseVertexIndex(r,l),this.addVertex(h,u,c),this.addVertex(u,d,c)),void 0!==s){var m=this.normals.length;h=this.parseNormalIndex(s,m),u=s===n?h:this.parseNormalIndex(n,m),d=s===o?h:this.parseNormalIndex(o,m),void 0===r?this.addNormal(h,u,d):(c=this.parseNormalIndex(a,m),this.addNormal(h,u,c),this.addNormal(u,d,c))}},addLineGeometry:function(e){this.object.geometry.type="Line";for(var t=this.vertices.length,i=0,r=e.length;i0?v.setAttribute("normal",new t.BufferAttribute(new Float32Array(x.normals),3)):v.computeVertexNormals(),b.push(v)}}return b}};ze.add("obj",class extends fm{get type(){return"obj"}getLoader(){return new gm}});const ym=function(){this.propertyNameMapping={}};ym.prototype={constructor:ym,setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),i="",r=0;r=s.elements[a].count&&(a++,c=0);var u=this.parseASCIIElement(s.elements[a].properties,h);this.handleElement(r,s.elements[a].name,u),c++}}return this.postProcess(r)},postProcess:function(e){if(e.useColor){for(var t=0;t{const s=r.length;for(let n=0;n/g,""),{declaration:t(),root:i()};function t(){if(!s(/^<\?xml\s*/))return;const e={attributes:{}};for(;!n()&&!o("?>");){const t=r();if(!t)return e;e.attributes[t.name]=t.value}return s(/\?>\s*/),e}function i(){const e=s(vm);if(!e)return;const t={name:e[1],attributes:{},children:[]};for(;!(n()||o(">")||o("?>")||o("/>"));){const e=r();if(!e)return t;t.attributes[e.name]=e.value}if(s(/^\s*\/>\s*/))return t;let a;for(s(/\??>\s*/),t.content=function(){const e=s(wm);return e?e[1]:""}();a=i();)t.children.push(a);return s(/^<\/[\w-:.]+>\s*/),t}function r(){const e=s(Am);var t;if(e)return{name:e[1],value:(t=e[2],t.replace(xm,""))}}function s(t){const i=e.match(t);if(i)return e=e.slice(i[0].length),i}function n(){return 0===e.length}function o(t){return 0===e.indexOf(t)}}class Sm extends Pu{constructor(e,t){const i=t||{};super(e,i),this.useDomParser=l(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(e){return _m(e)}__domParser(e){return(new window.DOMParser).parseFromString(e,"text/xml")}_parse(){e.Debug&&Be.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),e.Debug&&Be.timeEnd("XmlParser._parse "+this.name)}}function Cm(e,t){const i=e.getNamedItem(t);return null!==i?i.value:""}function Pm(e,t,i=!1){const r=Cm(e,"icode").trim(),s=Cm(e,"chain").trim(),n=Cm(e,"altcode");let o=Cm(e,"resnum");return r&&(o+="^"+r),s&&(o+=":"+s),t&&(o+="."+t),i&&n.trim()&&(o+="%"+n),o+="/"+(parseInt(Cm(e,"model"))-1),o}function Im(e){const t=Cm(e,"chain").trim();let i=`[${Cm(e,"rescode")}]${Cm(e,"resnum")}`;return t&&(i+=`:${t}`),i}function km(e,t,i){void 0===e[t]?e[t]=i:e[t]|=i}function Mm(e,t){return null!==e&&e.value===t}function Dm(e,t,i){let r=0;const s=t.getElementsByTagName("clash");for(let t=0,i=s.length;t0&&(r+=1);t.getElementsByTagName("bond-outlier").length>0&&(r+=1);return t.getElementsByTagName("plane-outlier").length>0&&(r+=1),Mm(i.getNamedItem("rota"),"OUTLIER")&&(r+=1),Mm(i.getNamedItem("rama"),"OUTLIER")&&(r+=1),Mm(i.getNamedItem("RNApucker"),"outlier")&&(r+=1),r}ze.add("xml",Sm);class Tm{constructor(e,t){this.name=e,this.path=t,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){e.Debug&&Be.time("Validation.fromXml");const i=this.rsrzDict,r=this.rsccDict,s=this.rciDict,n=this.clashDict,o=this.clashArray,a=this.geoDict,c=this.geoAtomDict,l=this.atomDict,h=t.getElementsByTagName("Entry");if(1===h.length){const e=h[0].getElementsByTagName("chemical_shift_list");if(1===e.length){const t=e[0].getElementsByTagName("random_coil_index");for(let e=0,i=t.length;e0&&(a[r]=e)}else{const e=t.getElementsByTagName("clash"),i=t.getElementsByTagName("mog-bond-outlier"),s=t.getElementsByTagName("mog-angle-outlier");if(i.length>0||s.length>0||e.length>0){const t={};c[r]=t;for(let i=0,r=e.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(s=s+t[r++]|0)|0}while(--o);s%=65521,n%=65521}return s|n<<16|0}ze.add("validation",class extends Sm{constructor(e,t){super(e,t||{}),this.useDomParser=!0,this.validation=new Tm(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),e.Debug&&Be.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),e.Debug&&Be.timeEnd("ValidationParser._parse "+this.name)}});var $m=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();function Fm(e,t,i,r){var s=$m,n=r+i;e^=-1;for(var o=r;o>>8^s[255&(e^t[o])];return-1^e}var Em=30,Lm=12;function Nm(e,t){var i,r,s,n,o,a,c,l,h,u,d,m,p,f,g,y,b,x,v,w,A,_,S,C,P;i=e.state,r=e.next_in,C=e.input,s=r+(e.avail_in-5),n=e.next_out,P=e.output,o=n-(t-e.avail_out),a=n+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,u=i.wnext,d=i.window,m=i.hold,p=i.bits,f=i.lencode,g=i.distcode,y=(1<>>=v=x>>>24,p-=v,0===(v=x>>>16&255))P[n++]=65535&x;else{if(!(16&v)){if(0==(64&v)){x=f[(65535&x)+(m&(1<>>=v,p-=v),p<15&&(m+=C[r++]<>>=v=x>>>24,p-=v,!(16&(v=x>>>16&255))){if(0==(64&v)){x=g[(65535&x)+(m&(1<c){e.msg="invalid distance too far back",i.mode=Em;break e}if(m>>>=v,p-=v,A>(v=n-o)){if((v=A-v)>h&&i.sane){e.msg="invalid distance too far back",i.mode=Em;break e}if(_=0,S=d,0===u){if(_+=l-v,v2;)P[n++]=S[_++],P[n++]=S[_++],P[n++]=S[_++],w-=3;w&&(P[n++]=S[_++],w>1&&(P[n++]=S[_++]))}else{_=n-A;do{P[n++]=P[_++],P[n++]=P[_++],P[n++]=P[_++],w-=3}while(w>2);w&&(P[n++]=P[_++],w>1&&(P[n++]=P[_++]))}break}}break}}while(r>3,m&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=n,e.avail_in=r=1&&0===D[w];w--);if(A>w&&(A=w),0===w)return s[n++]=20971520,s[n++]=20971520,a.bits=1,0;for(v=1;v0&&(e===Um||1!==w))return-1;for(T[1]=0,b=1;bVm||e===Hm&&P>Gm)return 1;for(;;){p=b-S,o[x]m?(f=B[R+o[x]],g=k[M+o[x]]):(f=96,g=0),c=1<>S)+(l-=c)]=p<<24|f<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,x++,0==--D[b]){if(b===w)break;b=t[i+o[x]]}if(b>A&&(I&u)!==h){for(0===S&&(S=A),d+=v,C=1<<(_=b-S);_+SVm||e===Hm&&P>Gm)return 1;s[h=I&u]=A<<24|_<<16|d-n|0}}return 0!==I&&(s[d+I]=b-S<<24|64<<16|0),a.bits=A,0}var Zm=1,Qm=2,Jm=0,ep=-2,tp=1,ip=12,rp=30,sp=852,np=592;function op(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function ap(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function cp(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=tp,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(sp),t.distcode=t.distdyn=new Int32Array(np),t.sane=1,t.back=-1,Jm):ep}(e)):ep}function lp(e,t){var i,r;return e?(r=new ap,e.state=r,r.window=null,i=function(e,t){var i,r;return e&&e.state?(r=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ep:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,cp(e))):ep}(e,t),i!==Jm&&(e.state=null),i):ep}var hp,up,dp=!0;function mp(e){if(dp){var t;for(hp=new Int32Array(512),up=new Int32Array(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Km(Zm,e.lens,0,288,hp,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Km(Qm,e.lens,0,32,up,0,e.work,{bits:5}),dp=!1}e.lencode=hp,e.lenbits=9,e.distcode=up,e.distbits=5}function pp(e,t,i,r){var s,n=e.state;return null===n.window&&(n.wsize=1<=n.wsize?(Rm(n.window,t,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((s=n.wsize-n.wnext)>r&&(s=r),Rm(n.window,t,i-r,s,n.wnext),(r-=s)?(Rm(n.window,t,i-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=Fm(i.check,I,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=rp;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=rp;break}if(h-=4,A=8+(15&(l>>>=4)),0===i.wbits)i.wbits=A;else if(A>i.wbits){e.msg="invalid window size",i.mode=rp;break}i.dmax=1<>8&1),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Fm(i.check,I,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=r[n++]<>>8&255,I[2]=l>>>16&255,I[3]=l>>>24&255,i.check=Fm(i.check,I,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=r[n++]<>8),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Fm(i.check,I,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=r[n++]<>>8&255,i.check=Fm(i.check,I,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((m=i.length)>a&&(m=a),m&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Rm(i.head.extra,r,n,m,A)),512&i.flags&&(i.check=Fm(i.check,r,m,n)),a-=m,n+=m,i.length-=m),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;m=0;do{A=r[n+m++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&m>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=ip;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=r[n++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=r[n++]<>>=1)){case 0:i.mode=14;break;case 1:if(mp(i),i.mode=20,6===t){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=rp}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=r[n++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=rp;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(m=i.length){if(m>a&&(m=a),m>c&&(m=c),0===m)break e;Rm(s,r,n,m,o),a-=m,n+=m,c-=m,o+=m,i.length-=m;break}i.mode=ip;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=r[n++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=rp;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[k[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},_=Km(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,_){e.msg="invalid code lengths set",i.mode=rp;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=g,h-=g,i.lens[i.have++]=b;else{if(16===b){for(C=g+2;h>>=g,h-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=rp;break}A=i.lens[i.have-1],m=3+(3&l),l>>>=2,h-=2}else if(17===b){for(C=g+3;h>>=g)),l>>>=3,h-=3}else{for(C=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+m>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=rp;break}for(;m--;)i.lens[i.have++]=A}}if(i.mode===rp)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=rp;break}if(i.lenbits=9,S={bits:i.lenbits},_=Km(Zm,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,_){e.msg="invalid literal/lengths set",i.mode=rp;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},_=Km(Qm,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,_){e.msg="invalid distances set",i.mode=rp;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=n,e.avail_in=a,i.hold=l,i.bits=h,Nm(e,d),o=e.next_out,s=e.output,c=e.avail_out,n=e.next_in,r=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===ip&&(i.back=-1);break}for(i.back=0;y=(P=i.lencode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=b,0===y){i.mode=26;break}if(32&y){i.back=-1,i.mode=ip;break}if(64&y){e.msg="invalid literal/length code",i.mode=rp;break}i.extra=15&y,i.mode=22;case 22:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;y=(P=i.distcode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&y){e.msg="invalid distance code",i.mode=rp;break}i.offset=b,i.extra=15&y,i.mode=24;case 24:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=rp;break}i.mode=25;case 25:if(0===c)break e;if(m=d-c,i.offset>m){if((m=i.offset-m)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=rp;break}m>i.wnext?(m-=i.wnext,p=i.wsize-m):p=i.wnext-m,m>i.length&&(m=i.length),f=i.window}else f=s,p=o-i.offset,m=i.length;m>c&&(m=c),c-=m,i.length-=m;do{s[o++]=f[p++]}while(--m);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;s[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=r[n++]<=252?6:vp>=248?5:vp>=240?4:vp>=224?3:vp>=192?2:1;function wp(e){var t,i,r,s,n,o=e.length,a=0;for(s=0;s>>6,t[n++]=128|63&i):i<65536?(t[n++]=224|i>>>12,t[n++]=128|i>>>6&63,t[n++]=128|63&i):(t[n++]=240|i>>>18,t[n++]=128|i>>>12&63,t[n++]=128|i>>>6&63,t[n++]=128|63&i);return t}function Ap(e,t){var i,r,s,n,o=t||e.length,a=new Array(2*o);for(r=0,i=0;i4)a[r++]=65533,i+=n-1;else{for(s&=2===n?31:3===n?15:7;n>1&&i1?a[r++]=65533:s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|1023&s)}return function(e,t){if(t<65537&&(e.subarray&&bp||!e.subarray&&yp))return String.fromCharCode.apply(null,Bm(e,t));for(var i="",r=0;re.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+xp[e[i]]>t?i:t}xp[254]=xp[254]=1;var Sp=0,Cp={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Pp(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Ip(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var kp=Object.prototype.toString;function Mp(e){if(!(this instanceof Mp))return new Mp(e);this.options=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}}return e}({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Pp,this.strm.avail_out=0;var i,r,s,n=lp(this.strm,t.windowBits);if(n!==Sp)throw new Error(Cp[n]);this.header=new Ip,i=this.strm,r=this.header,i&&i.state&&(0==(2&(s=i.state).wrap)||(s.head=r,r.done=!1))}Mp.prototype.push=function(e,t){var i,r,s,n,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,u=!1;if(this.ended)return!1;r=t===~~t?t:!0===t?4:0,"string"==typeof e?c.input=function(e){for(var t=new Uint8Array(e.length),i=0,r=t.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(e){if(!e||!e.state)return ep;var t=e.state;return t.window&&(t.window=null),e.state=null,Jm}(this.strm),this.onEnd(i),this.ended=!0,i===Sp):2!==r||(this.onEnd(Sp),c.avail_out=0,!0)},Mp.prototype.onData=function(e){this.chunks.push(e)},Mp.prototype.onEnd=function(e){e===Sp&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(e){var t,i,r,s,n,o;for(r=0,t=0,i=e.length;tObject.assign(Object.assign({},e),{[t]:t})),{})}}const jp={backgroundColor:{type:"color"},quality:Up("auto","low","medium","high"),sampleLevel:Gp(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:Vp(1,10,0),zoomSpeed:Vp(1,10,0),panSpeed:Vp(1,10,0),clipNear:Gp(1,100,0),clipFar:Gp(1,100,0),clipDist:zp(200,0),clipMode:Up("scene","camera"),clipScale:Up("relative","absolute"),fogNear:Gp(1,100,0),fogFar:Gp(1,100,0),cameraType:Up("perspective","orthographic","stereo"),cameraEyeSep:Vp(3,1,.01),cameraFov:Gp(1,120,15),lightColor:{type:"color"},lightIntensity:Vp(2,10,0),ambientColor:{type:"color"},ambientIntensity:Vp(2,10,0),hoverTimeout:zp(1e4,-1),tooltip:{type:"boolean"},mousePreset:Up(...Object.keys(zn))};Object.defineProperty(e,"Box3",{enumerable:!0,get:function(){return t.Box3}}),Object.defineProperty(e,"Color",{enumerable:!0,get:function(){return t.Color}}),Object.defineProperty(e,"Euler",{enumerable:!0,get:function(){return t.Euler}}),Object.defineProperty(e,"Matrix3",{enumerable:!0,get:function(){return t.Matrix3}}),Object.defineProperty(e,"Matrix4",{enumerable:!0,get:function(){return t.Matrix4}}),Object.defineProperty(e,"Plane",{enumerable:!0,get:function(){return t.Plane}}),Object.defineProperty(e,"Quaternion",{enumerable:!0,get:function(){return t.Quaternion}}),Object.defineProperty(e,"Vector2",{enumerable:!0,get:function(){return t.Vector2}}),Object.defineProperty(e,"Vector3",{enumerable:!0,get:function(){return t.Vector3}}),Object.defineProperty(e,"Signal",{enumerable:!0,get:function(){return r.Signal}}),e.AngleRepresentation=kl,e.ArrowBuffer=Qh,e.Assembly=ko,e.AxesRepresentation=Ul,e.BackboneRepresentation=Hl,e.BallAndStickRepresentation=jl,e.BaseRepresentation=Wl,e.BoxBuffer=ru,e.BufferRepresentation=xa,e.CartoonRepresentation=Jl,e.Collection=Ja,e.Colormaker=U,e.ColormakerRegistry=Ee,e.Component=Qa,e.ComponentCollection=Ac,e.ConeBuffer=Yh,e.ContactRepresentation=eh,e.Counter=nt,e.CylinderBuffer=Gl,e.DatasourceRegistry=Le,e.DecompressorRegistry=Ge,e.DihedralHistogramRepresentation=sh,e.DihedralRepresentation=th,e.DistanceRepresentation=oh,e.EllipsoidBuffer=lu,e.Frames=rc,e.HelixorientRepresentation=hh,e.HyperballRepresentation=xh,e.Kdtree=_o,e.KeyActions=Un,e.LabelRepresentation=wh,e.LeftMouseButton=1,e.LicoriceRepresentation=uh,e.LineRepresentation=_h,e.MdsrvDatasource=class extends Dp{constructor(e=""){super(),this.baseUrl=e}getListing(e=""){let t=`${this.baseUrl}dir/${e}`;return"/"!==t[t.length-1]&&(t+="/"),tt(t,{ext:"json"}).then((t=>({path:e,data:t.data})))}getUrl(e){const t=Je(e);return`${this.baseUrl}file/${t.path}${t.query}`}getCountUrl(e){const t=Je(e);return`${this.baseUrl}traj/numframes/${t.path}${t.query}`}getFrameUrl(e,t){const i=Je(e);return`${this.baseUrl}traj/frame/${t}/${i.path}${i.query}`}getFrameParams(e,t){return`atomIndices=${t.join(";")}`}getPathUrl(e,t){const i=Je(e);return`${this.baseUrl}traj/path/${t}/${i.path}${i.query}`}getExt(e){return Je(e).ext}},e.MeasurementDefaultParams=Re,e.MeshBuffer=Bn,e.MiddleMouseButton=2,e.MolecularSurface=kh,e.MolecularSurfaceRepresentation=Mh,e.MouseActions=Nn,e.OctahedronBuffer=pu,e.ParserRegistry=ze,e.PdbWriter=class extends it{constructor(e,t){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";const i=Object.assign({},t);this.renumberSerial=l(i.renumberSerial,!0),this.remarks=function(e){return Array.isArray(e)?e:[e]}(l(i.remarks,[])),this.structure=e,this._records=[]}_writeRecords(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()}_writeTitle(){this._records.push(s.sprintf("TITLE %-74s",this.structure.name))}_writeRemarks(){this.remarks.forEach((e=>{this._records.push(s.sprintf("REMARK %-73s",e))})),this.structure.trajectory&&(this._records.push(s.sprintf("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(s.sprintf("REMARK %-73s",`Frame ${this.structure.trajectory.frame}`)))}_writeAtoms(){let e=1,t=1,i=" ",r=" ";const n=this.structure.modelStore.count>1;this.structure.eachModel((o=>{n&&this._records.push(s.sprintf("MODEL %4d%-66s",t++,"")),o.eachAtom((t=>{const n=t.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",o=this.renumberSerial?e:t.serial;let a=t.atomname;(1===a.length||a.length<4&&1===t.element.length&&a[0]===t.element)&&(a=" "+a),t.formalCharge?(i=Math.abs(t.formalCharge).toPrecision(1),r=t.formalCharge>0?"+":"-"):(i=" ",r=" "),this._records.push(s.sprintf(n,o,a,t.resname,l(t.chainname," "),t.resno,t.x,t.y,t.z,l(t.occupancy,1),l(t.bfactor,0),"",l(t.element,""),i,r)),e+=1}),this.structure.getSelection()),n&&this._records.push(s.sprintf("%-80s","ENDMDL"))})),this._records.push(s.sprintf("%-80s","END"))}getString(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()}getData(){return this._writeRecords(),this._records.join("\n")}},e.PickingProxy=ci,e.PointBuffer=$a,e.PointRepresentation=Dh,e.Queue=Mi,e.RepresentationCollection=ec,e.RepresentationElement=Xa,e.RepresentationRegistry=Ne,e.RibbonRepresentation=Oh,e.RightMouseButton=3,e.RocketRepresentation=$h,e.RopeRepresentation=Fh,e.ScriptExtensions=$e,e.SdfWriter=class extends it{constructor(e){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=e,this._records=[]}get idString(){return this.structure.id}get titleString(){return" "+this.structure.title}get countsString(){return s.sprintf("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)}get chargeLines(){const e=[];this.structure.eachAtom((t=>{null!=t.formalCharge&&0!==t.formalCharge&&e.push([t.index,t.formalCharge])}));const t=[];for(let i=0;i{this._records.push(this.formatAtom(e))})),this.structure.eachBond((e=>{this._records.push(this.formatBond(e))})),this.chargeLines.forEach((e=>{this._records.push(e)})),this._records.push("M END")}_writeFooter(){this._records.push("$$$$")}getData(){return this._writeRecords(),this._records.join("\n")}},e.Selection=ye,e.Shape=ba,e.ShapeComponent=Pc,e.SpacefillRepresentation=Eh,e.SpatialHash=vr,e.SphereBuffer=Ta,e.Stage=class{constructor(e,t={}){this.signals={parametersChanged:new r.Signal,fullscreenChanged:new r.Signal,componentAdded:new r.Signal,componentRemoved:new r.Signal,clicked:new r.Signal,hovered:new r.Signal},this.tasks=new nt,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Wt(e),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new Xt(this.viewer.renderer.domElement),this.viewerControls=new bi(this),this.trackballControls=new oi(this),this.pickingControls=new li(this),this.animationControls=new ki(this),this.mouseControls=new Gn(this),this.keyControls=new Hn(this),this.pickingBehavior=new Wn(this),this.mouseBehavior=new qn(this),this.animationBehavior=new Xn(this),this.keyBehavior=new Kn(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=h(t,Cc),this.setParameters(this.parameters),this.viewer.animate())}setParameters(e={}){u(this.parameters,e);const t=e,i=this.parameters,r=this.viewer,s=this.trackballControls;return void 0!==t.quality&&this.setQuality(i.quality),void 0!==t.impostor&&this.setImpostor(i.impostor),void 0!==t.rotateSpeed&&(s.rotateSpeed=i.rotateSpeed),void 0!==t.zoomSpeed&&(s.zoomSpeed=i.zoomSpeed),void 0!==t.panSpeed&&(s.panSpeed=i.panSpeed),void 0!==t.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),r.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),r.setFog(void 0,i.fogNear,i.fogFar),r.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),r.setSampling(i.sampleLevel),r.setBackground(i.backgroundColor),r.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(e){console.log("STAGE LOG",e),this.logList.push(e)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof xc){let i,r,s;t.setSelection("/0");const n=t.structure;if(n.biomolDict.BU1){const e=n.biomolDict.BU1;i=e.getAtomCount(n),r=e.getResidueCount(n),s=e.getInstanceCount(),t.setDefaultAssembly("BU1")}else i=n.getModelProxy(0).atomCount,r=n.getModelProxy(0).residueCount,s=1;let o=i;Ie&&(o*=4);const a=n.atomStore.count/n.residueStore.count<2;a&&(o*=10);let c="chainname",l="RdYlBu",h=!1;if(1===n.getChainnameCount(new ye("polymer and /0"))&&(c="residueindex",l="Spectral",h=!0),e.Debug&&console.log(o,i,s,a),r/s<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(s>5&&o>15e3||o>7e5){let e=Math.min(2,Math.max(.1,6e3/(o/s)));a&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:c,colorScale:l,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else o>25e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,lineOnly:!0}):o>1e5?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):o>8e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),o<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:l,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof vc||t instanceof wc)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(e,t={}){const i=Object.assign({},this.defaultFileParams,t),r=Je(e).name;this.tasks.increment(),this.log(`loading file '${r}'`);const s=l(i.ext,Je(e).ext);let n;return n=ze.isTrajectory(s)?Promise.reject(new Error(`loadFile: ext '${s}' is a trajectory and must be loaded into a structure component`)):tt(e,i),n.then((e=>{this.log(`loaded '${r}'`);const t=this.addComponentFromObject(e,i);return i.defaultRepresentation&&this.defaultFileRepresentation(t),this.tasks.decrement(),t}),(e=>{this.tasks.decrement();const t=`error loading file: '${e}'`;throw this.log(t),t}))}loadScript(e){const t=Je(e).name;return this.log(`loading script '${t}'`),tt(e).then((e=>{this.tasks.increment(),this.log(`running script '${t}'`),e.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${t}'`)})),this.log(`called script '${t}'`)}),(e=>{this.tasks.decrement();const i=`errored script '${t}' "${e}"`;throw this.log(i),i}))}addComponent(e){e?(this.compList.push(e),this.signals.componentAdded.dispatch(e)):Be.warn("Stage.addComponent: no component given")}addComponentFromObject(e,t={}){const i=Ue.get(e.type);if(i){const r=new i(this,e,t);return this.addComponent(r),r}Be.warn("no component for object type",e.type)}removeComponent(e){const t=this.compList.indexOf(e);-1!==t&&(this.compList.splice(t,1),e.dispose(),this.signals.componentRemoved.dispatch(e))}removeAllComponents(){this.compList.slice().forEach((e=>this.removeComponent(e)))}handleResize(){this.viewer.handleResize()}setSize(e,t){const i=this.viewer.container;i!==document.body&&(void 0!==e&&(i.style.width=e),void 0!==t&&(i.style.height=t),this.handleResize())}toggleFullscreen(e){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void Be.log("fullscreen mode (currently) not possible");const t=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&t.lastFullscreenElement){const e=t.lastFullscreenElement;e.style.width=e.dataset.normalWidth||"",e.style.height=e.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),t.handleResize(),t.signals.fullscreenChanged.dispatch(!1)}}e=e||this.viewer.container,this.lastFullscreenElement=e,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(e.dataset.normalWidth=e.style.width||"",e.dataset.normalHeight=e.style.height||"",e.style.width=window.screen.width+"px",e.style.height=window.screen.height+"px",e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){t.handleResize()}),100))}setSpin(e){e?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(e){e?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const e=this.parameters;if("scene"!==e.clipMode)return 0;let t=e.clipNear;return"absolute"===e.clipScale&&(t=this.viewer.absoluteToRelative(t)),2*t}setFocus(e){if("scene"!==this.parameters.clipMode)return;let t,i,r,s;"relative"===this.parameters.clipScale?(t=$(e/2,0,49.9),i=100-t,r=50,s=function(e){return $(e,0,100)}(2*i-50)):(t=this.viewer.relativeToAbsolute(e/2),i=t,r=0,s=2*i),this.setParameters({clipNear:t,clipFar:i,fogNear:r,fogFar:s})}getZoomForBox(e){const t=e.getSize(Sc),i=Math.max(t.x,t.y,t.z),r=Math.min(t.x,t.y,t.z);let s=i+Math.sqrt(r);const n=T(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(e).then((e=>{this.tasks.decrement(),t(e)})).catch((e=>{this.tasks.decrement(),i(e)}))}))}))}setImpostor(e){this.parameters.impostor=e;const t=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!t.includes(i.getType()))return;const r=i.getParameters();r.disableImpostor=!e,i.build(r)}))}setQuality(e){this.parameters.quality=e;const t=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(r){const s=r.getParameters();if(!t.includes(r.getType())){if(!i.includes(r.getType()))return;if(!s.disableImpostor)return void(r.repr.quality=e)}s.quality=e,r.build(s)}))}eachComponent(e,t){this.compList.slice().forEach((i=>{void 0!==t&&t!==i.type||e(i)}))}eachRepresentation(e,t){this.eachComponent((i=>{i.reprList.slice().forEach((r=>{void 0!==t&&t!==r.getType()||e(r,i)}))}))}getComponentsByName(e){const t=[];return this.eachComponent((i=>{(void 0===e||_c(e,i))&&t.push(i)})),new Ac(t)}getComponentsByObject(e){const t=[];return this.eachComponent((i=>{i.object===e&&t.push(i)})),new Ac(t)}getRepresentationsByName(e){const t=[];return this.eachRepresentation(((i,r)=>{(void 0===e||_c(e,i))&&t.push(i)})),new ec(t)}measureClear(){this.eachComponent((e=>e.measureClear()),"structure")}measureUpdate(){this.eachComponent((e=>e.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}},e.StaticDatasource=class extends Dp{constructor(e=""){super(),this.baseUrl=e}getUrl(e){const t=Je(e);let i=this.baseUrl+t.path;return Np.test(this.baseUrl)||(i=function(e){const t=window.location,i=t.pathname,r=i.substring(0,i.lastIndexOf("/")+1);return t.origin+r+e}(i)),i}getExt(e){return Je(e).ext}},e.StlWriter=class extends it{constructor(e){super(),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=e}getData(){const e=this.surface.index.length/3,i=new st(2*e+3*e*4*4+80+4);i.skip(80),i.writeUint32(e);const r=new t.Vector3,s=new t.Vector3,n=new t.Vector3,o=new t.Vector3;for(let t=0;t{e.eachAtom((e=>{n.growIfFull(),n.atomTypeId[c]=o.add(e.atomname,e.element),n.x[c]=e.x,n.y[c]=e.y,n.z[c]=e.z,n.serial[c]=e.serial,n.formalCharge[c]=e.formalCharge,n.partialCharge[c]=e.partialCharge,n.altloc[c]=e.altloc,n.occupancy[c]=e.occupancy,n.bfactor[c]=e.bfactor,s.addAtom(e.modelIndex+h,e.chainname,e.chainid,e.resname,e.resno,1===e.hetero,e.sstruc,e.inscode),a[e.index+l]=c,c+=1})),l+=e.atomStore.count,h+=e.modelStore.count}));const u=r.bondStore,d=r.getAtomProxy(),m=r.getAtomProxy();return l=0,i.forEach((e=>{e.eachBond((e=>{d.index=a[e.atomIndex1+l],m.index=a[e.atomIndex2+l],u.addBond(d,m,e.bondOrder)})),l+=e.atomStore.count})),s.finalize(),zo(r,!0),No(r,!0),r.finalizeAtoms(),r.finalizeBonds(),Ho(r),e.Debug&&Be.timeEnd("concatStructures"),r},e.download=f,e.flatten=function e(t,i){i=l(i,[]);for(let r=0;rt?(o&&(clearTimeout(o),o=null),a=l,n=e.apply(r,s),o||(r=s=null)):o||!1===i.trailing||(o=setTimeout(c,h)),n}},e.uniqueArray=x,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ngl.umd.js.map diff --git a/dist/ngl.umd.js.map b/dist/ngl.umd.js.map index 6c049633..101807c7 100644 --- a/dist/ngl.umd.js.map +++ b/dist/ngl.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"ngl.umd.js","sources":["../src/polyfills.js","../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/parser/parser-registry.ts","../src/worker/worker-utils.ts","../src/worker/worker-registry.ts","../src/globals.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../src/writer/writer.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/utils/io-buffer.ts","../src/writer/stl-writer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/stage/mouse-observer.ts","../src/constants.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/parser/dcd-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../src/parser/validation-parser.ts","../lib/pako_inflate.es6.js","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/datasource/mdsrv-datasource.ts","../src/ui/parameters.ts","../src/ngl.ts"],"sourcesContent":["/**\n * @file shims\n * @private\n * @author Alexander Rose \n */\n\n/// ///////////\n// Polyfills\n\nif (typeof window !== 'undefined') {\n (function () {\n 'use strict'\n // Console-polyfill. MIT license.\n // https://github.com/paulmillr/console-polyfill\n // Make it safe to do console.log() always.\n\n window.console = window.console || {}\n var con = window.console\n var prop, method\n var empty = {}\n var dummy = function () {}\n var properties = 'memory'.split(',')\n var methods = (\n 'assert,clear,count,debug,dir,dirxml,error,exception,group,' +\n 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +\n 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn'\n ).split(',')\n\n while ((prop = properties.pop())) if (!con[prop]) con[prop] = empty\n while ((method = methods.pop())) if (!con[method]) con[method] = dummy\n })()\n}\n\nif (typeof window !== 'undefined' && typeof window.HTMLCanvasElement !== 'undefined' && !window.HTMLCanvasElement.prototype.toBlob) {\n // http://code.google.com/p/chromium/issues/detail?id=67587#57\n Object.defineProperty(window.HTMLCanvasElement.prototype, 'toBlob', {\n\n value: function (callback, type, quality) {\n var bin = window.atob(this.toDataURL(type, quality).split(',')[ 1 ])\n var len = bin.length\n var len32 = len >> 2\n var a8 = new Uint8Array(len)\n var a32 = new Uint32Array(a8.buffer, 0, len32)\n\n for (var i = 0, j = 0; i < len32; i++) {\n a32[i] = (\n bin.charCodeAt(j++) |\n bin.charCodeAt(j++) << 8 |\n bin.charCodeAt(j++) << 16 |\n bin.charCodeAt(j++) << 24\n )\n }\n\n var tailLength = len & 3\n\n while (tailLength--) {\n a8[ j ] = bin.charCodeAt(j++)\n }\n\n callback(new window.Blob([ a8 ], { 'type': type || 'image/png' }))\n }\n\n })\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt\nMath.cbrt = Math.cbrt || function (x) {\n var y = Math.pow(Math.abs(x), 1 / 3)\n return x < 0 ? -y : y\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\nif (!Math.sign) {\n Math.sign = function (x) {\n // If x is NaN, the result is NaN.\n // If x is -0, the result is -0.\n // If x is +0, the result is +0.\n // If x is negative and not -0, the result is -1.\n // If x is positive and not +0, the result is +1.\n x = +x // convert to a number\n if (x === 0 || isNaN(x)) {\n return Number(x)\n }\n return x > 0 ? 1 : -1\n }\n}\n\nif (!Number.isInteger) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\n Number.isInteger = function isInteger (nVal) {\n return typeof nVal === 'number' && isFinite(nVal) && nVal > -9007199254740992 && nVal < 9007199254740992 && Math.floor(nVal) === nVal\n }\n}\n\nif (!Number.isNaN) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN\n Number.isNaN = function isNaN (value) {\n return value !== value // eslint-disable-line no-self-compare\n }\n}\n\nif (!Object.assign) {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n Object.defineProperty(Object, 'assign', {\n\n enumerable: false,\n configurable: true,\n writable: true,\n\n value: function (target/*, firstSource */) {\n 'use strict'\n if (target === undefined || target === null) { throw new TypeError('Cannot convert first argument to object') }\n\n var to = Object(target)\n\n var hasPendingException = false\n var pendingException\n\n for (var i = 1; i < arguments.length; i++) {\n var nextSource = arguments[i]\n if (nextSource === undefined || nextSource === null) { continue }\n\n var keysArray = Object.keys(Object(nextSource))\n for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {\n var nextKey = keysArray[nextIndex]\n try {\n var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey)\n if (desc !== undefined && desc.enumerable) { to[nextKey] = nextSource[nextKey] }\n } catch (e) {\n if (!hasPendingException) {\n hasPendingException = true\n pendingException = e\n }\n }\n }\n\n if (hasPendingException) { throw pendingException }\n }\n\n return to\n }\n\n })\n}\n\nif (!String.prototype.startsWith) {\n /*! https://mths.be/startswith v0.2.0 by @mathias */\n\n (function () {\n 'use strict' // needed to support `apply`/`call` with `undefined`/`null`\n var defineProperty = (function () {\n // IE 8 only supports `Object.defineProperty` on DOM elements\n var result\n try {\n var object = {}\n var $defineProperty = Object.defineProperty\n result = $defineProperty(object, object, object) && $defineProperty\n } catch (error) {} // eslint-disable-line no-empty\n return result\n }())\n var toString = {}.toString\n var startsWith = function (search) {\n if (this === null) {\n throw TypeError()\n }\n var string = String(this)\n if (search && toString.call(search) === '[object RegExp]') {\n throw TypeError()\n }\n var stringLength = string.length\n var searchString = String(search)\n var searchLength = searchString.length\n var position = arguments.length > 1 ? arguments[1] : undefined\n // `ToInteger`\n var pos = position ? Number(position) : 0\n if (Number.isNaN(pos)) {\n pos = 0\n }\n var start = Math.min(Math.max(pos, 0), stringLength)\n // Avoid the `indexOf` call if no match is possible\n if (searchLength + start > stringLength) {\n return false\n }\n var index = -1\n while (++index < searchLength) {\n if (string.charCodeAt(start + index) !== searchString.charCodeAt(index)) {\n return false\n }\n }\n return true\n }\n if (defineProperty) {\n defineProperty(String.prototype, 'startsWith', {\n 'value': startsWith,\n 'configurable': true,\n 'writable': true\n })\n } else {\n // eslint-disable-next-line no-extend-native\n String.prototype.startsWith = startsWith\n }\n }())\n}\n\nif (!String.prototype.endsWith) {\n // eslint-disable-next-line no-extend-native\n String.prototype.endsWith = function (searchString, position) {\n var subjectString = this.toString()\n if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {\n position = subjectString.length\n }\n position -= searchString.length\n var lastIndex = subjectString.indexOf(searchString, position)\n return lastIndex !== -1 && lastIndex === position\n }\n}\n\nif (!String.prototype.repeat) {\n // eslint-disable-next-line no-extend-native\n String.prototype.repeat = function (count) {\n 'use strict'\n if (this === null) {\n throw new TypeError('can\\'t convert ' + this + ' to object')\n }\n var str = '' + this\n count = +count\n if (Number.isNaN(count)) {\n count = 0\n }\n if (count < 0) {\n throw new RangeError('repeat count must be non-negative')\n }\n if (count === Infinity) {\n throw new RangeError('repeat count must be less than infinity')\n }\n count = Math.floor(count)\n if (str.length === 0 || count === 0) {\n return ''\n }\n // Ensuring count is a 31-bit integer allows us to heavily optimize the\n // main part. But anyway, most current (August 2014) browsers can't handle\n // strings 1 << 28 chars or longer, so:\n if (str.length * count >= 1 << 28) {\n throw new RangeError('repeat count must not overflow maximum string size')\n }\n var rpt = ''\n for (;;) {\n if ((count & 1) === 1) {\n rpt += str\n }\n count >>>= 1\n if (count === 0) {\n break\n }\n str += str\n }\n // Could we try:\n // return Array(count + 1).join(this);\n return rpt\n }\n}\n\nif (!String.prototype.includes) {\n // eslint-disable-next-line no-extend-native\n String.prototype.includes = function (search, start) {\n 'use strict'\n if (typeof start !== 'number') {\n start = 0\n }\n\n if (start + search.length > this.length) {\n return false\n } else {\n return this.indexOf(search, start) !== -1\n }\n }\n}\n\nif (!Array.prototype.includes) {\n // eslint-disable-next-line no-extend-native\n Array.prototype.includes = function (searchElement /*, fromIndex */) {\n 'use strict'\n if (this == null) {\n throw new TypeError('Array.prototype.includes called on null or undefined')\n }\n\n var O = Object(this)\n var len = parseInt(O.length, 10) || 0\n if (len === 0) {\n return false\n }\n var n = parseInt(arguments[1], 10) || 0\n var k\n if (n >= 0) {\n k = n\n } else {\n k = len + n\n if (k < 0) { k = 0 }\n }\n var currentElement\n while (k < len) {\n currentElement = O[k]\n if (searchElement === currentElement ||\n (Number.isNaN(searchElement) && Number.isNaN(currentElement))\n ) {\n return true\n }\n k++\n }\n return false\n }\n}\n\n// Production steps of ECMA-262, Edition 6, 22.1.2.1\n// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from\nif (!Array.from) {\n Array.from = (function () {\n var toStr = Object.prototype.toString\n var isCallable = function (fn) {\n return typeof fn === 'function' || toStr.call(fn) === '[object Function]'\n }\n var toInteger = function (value) {\n var number = Number(value)\n if (isNaN(number)) { return 0 }\n if (number === 0 || !isFinite(number)) { return number }\n return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number))\n }\n var maxSafeInteger = Math.pow(2, 53) - 1\n var toLength = function (value) {\n var len = toInteger(value)\n return Math.min(Math.max(len, 0), maxSafeInteger)\n }\n\n // The length property of the from method is 1.\n return function from (arrayLike/*, mapFn, thisArg */) {\n // 1. Let C be the this value.\n var C = this\n\n // 2. Let items be ToObject(arrayLike).\n var items = Object(arrayLike)\n\n // 3. ReturnIfAbrupt(items).\n if (arrayLike == null) {\n throw new TypeError('Array.from requires an array-like object - not null or undefined')\n }\n\n // 4. If mapfn is undefined, then let mapping be false.\n var mapFn = arguments.length > 1 ? arguments[1] : void undefined\n var T\n if (typeof mapFn !== 'undefined') {\n // 5. else\n // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.\n if (!isCallable(mapFn)) {\n throw new TypeError('Array.from: when provided, the second argument must be a function')\n }\n\n // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.\n if (arguments.length > 2) {\n T = arguments[2]\n }\n }\n\n // 10. Let lenValue be Get(items, \"length\").\n // 11. Let len be ToLength(lenValue).\n var len = toLength(items.length)\n\n // 13. If IsConstructor(C) is true, then\n // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.\n // 14. a. Else, Let A be ArrayCreate(len).\n var A = isCallable(C) ? Object(new C(len)) : new Array(len)\n\n // 16. Let k be 0.\n var k = 0\n // 17. Repeat, while k < len… (also steps a - h)\n var kValue\n while (k < len) {\n kValue = items[k]\n if (mapFn) {\n A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k)\n } else {\n A[k] = kValue\n }\n k += 1\n }\n // 18. Let putStatus be Put(A, \"length\", len, true).\n A.length = len\n // 20. Return A.\n return A\n }\n }())\n}\n\nif (typeof window !== 'undefined') {\n (function () {\n // http://paulirish.com/2011/requestanimationframe-for-smart-animating/\n // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating\n\n // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel\n\n // MIT license\n\n var lastTime = 0\n var vendors = [ 'ms', 'moz', 'webkit', 'o' ]\n\n for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {\n window.requestAnimationFrame = (\n window[ vendors[ x ] + 'RequestAnimationFrame' ]\n )\n\n window.cancelAnimationFrame = (\n window[ vendors[ x ] + 'CancelAnimationFrame' ] ||\n window[ vendors[ x ] + 'CancelRequestAnimationFrame' ]\n )\n }\n\n if (!window.requestAnimationFrame) {\n window.requestAnimationFrame = function (callback/*, element */) {\n var currTime = new Date().getTime()\n var timeToCall = Math.max(0, 16 - (currTime - lastTime))\n\n var id = window.setTimeout(function () {\n var time = currTime + timeToCall\n callback(time)\n }, timeToCall)\n\n lastTime = currTime + timeToCall\n\n return id\n }\n }\n\n if (!window.cancelAnimationFrame) {\n window.cancelAnimationFrame = function (id) {\n clearTimeout(id)\n }\n }\n }())\n}\n\nif (Function.prototype.name === undefined && Object.defineProperty !== undefined) {\n // Missing in IE9-11.\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name\n\n // eslint-disable-next-line no-extend-native\n Object.defineProperty(Function.prototype, 'name', {\n\n get: function () {\n return this.toString().match(/^\\s*function\\s*(\\S*)\\s*\\(/)[ 1 ]\n }\n\n })\n}\n\nif (typeof window !== 'undefined') {\n if (window.performance === undefined) {\n /* global self */\n self.performance = {}\n }\n\n if (window.performance.now === undefined) {\n (function () {\n var start = Date.now()\n\n window.performance.now = function () {\n return Date.now() - start\n }\n })()\n }\n}\n\nif (Object.defineProperty !== undefined) {\n // Missing in IE < 13\n // MIT license\n // Copyright (c) 2016 Financial Times\n // https://github.com/Financial-Times/polyfill-service\n if (Number.MAX_SAFE_INTEGER === undefined) {\n Object.defineProperty(Number, 'MAX_SAFE_INTEGER', {\n enumerable: false,\n configurable: false,\n writable: false,\n value: Math.pow(2, 53) - 1\n })\n }\n if (Number.MIN_SAFE_INTEGER === undefined) {\n Object.defineProperty(Number, 'MIN_SAFE_INTEGER', {\n enumerable: false,\n configurable: false,\n writable: false,\n value: -(Math.pow(2, 53) - 1)\n })\n }\n}\n","/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] === undefined) continue\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#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$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ',\n 'F 4/m -3 2/c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure) {\n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false) {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n const bonds = r.getBonds()\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const nn = atomIndices1.length\n\n for (let i = 0; i < nn; ++i) {\n const rai1 = atomIndices1[ i ]\n const rai2 = atomIndices2[ i ]\n const ai1 = rai1 + offset\n const ai2 = rai2 + offset\n const tmp = atomBondMap[ ai1 ]\n if (tmp !== undefined && tmp[ ai2 ] !== undefined) {\n bp.index = tmp[ ai2 ]\n const residueTypeBondIndex = r.residueType.getBondIndex(rai1, rai2)! // TODO\n // overwrite residueType bondOrder with value from existing bond\n bondOrders[ residueTypeBondIndex ] = bp.bondOrder\n } else {\n a1.index = ai1\n a2.index = ai2\n // only add bond if not already in bondStore\n bondStore.addBond(a1, a2, bondOrders[ i ])\n }\n }\n }\n\n // get RNA/DNA rung pseudo bonds\n const traceAtomIndex = r.residueType.traceAtomIndex\n const rungEndAtomIndex = r.residueType.rungEndAtomIndex\n if (traceAtomIndex !== -1 && rungEndAtomIndex !== -1) {\n a1.index = r.traceAtomIndex\n a2.index = r.rungEndAtomIndex\n rungBondStore.addBond(a1, a2)\n rungAtomSet.set(a1.index)\n rungAtomSet.set(a2.index)\n }\n })\n\n structure.atomSetDict.rung = rungAtomSet\n\n if (Debug) Log.timeEnd('calculateBondsWithin')\n}\n\nexport function calculateBondsBetween (structure: Structure, onlyAddBackbone = false, useExistingBonds = false) {\n if (Debug) Log.time('calculateBondsBetween')\n\n const bondStore = structure.bondStore\n const backboneBondStore = structure.backboneBondStore\n const backboneAtomSet = structure.getAtomSet(false)\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n if (backboneBondStore.count === 0) {\n backboneBondStore.resize(structure.residueStore.count)\n }\n\n function addBondIfConnected (rp1: ResidueProxy, rp2: ResidueProxy) {\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if ((useExistingBonds && ap1.hasBondTo(ap2)) || ap1.connectedTo(ap2)) {\n if (!onlyAddBackbone) {\n bondStore.addBond(ap1, ap2, 1) // assume single bond\n }\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n backboneBondStore.addBond(ap1, ap2)\n backboneAtomSet.set(ap1.index)\n backboneAtomSet.set(ap2.index)\n }\n }\n }\n\n structure.eachResidueN(2, addBondIfConnected)\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n\n // check for cyclic chains\n structure.eachChain(function (cp) {\n if (cp.residueCount === 0) return\n rp1.index = cp.residueOffset\n rp2.index = cp.residueOffset + cp.residueCount - 1\n addBondIfConnected(rp2, rp1)\n })\n\n structure.atomSetDict.backbone = backboneAtomSet\n\n if (!onlyAddBackbone) {\n if (Debug) Log.time('calculateBondsBetween inter')\n const spatialHash = structure.spatialHash\n structure.eachResidue(function (rp) {\n if (rp.backboneType === UnknownBackboneType && !rp.isWater()) {\n rp.eachAtom(function (ap) {\n if (ap.isMetal()) return\n spatialHash!.eachWithin(ap.x, ap.y, ap.z, 4, function (idx) { // TODO\n ap2.index = idx\n if (ap.modelIndex === ap2.modelIndex &&\n ap.residueIndex !== ap2.residueIndex &&\n !ap2.isMetal()\n ) {\n bondStore.addBondIfConnected(ap, ap2, 1) // assume single bond\n }\n })\n })\n }\n })\n if (Debug) Log.timeEnd('calculateBondsBetween inter')\n }\n\n if (Debug) Log.timeEnd('calculateBondsBetween')\n}\n\nexport function buildUnitcellAssembly (structure: Structure) {\n if (!structure.unitcell) return\n\n if (Debug) Log.time('buildUnitcellAssembly')\n\n const uc = structure.unitcell\n\n const structureCenterFrac = structure.center.clone().applyMatrix4(uc.cartToFrac)\n const centerFrac = structureCenterFrac.clone().floor()\n const symopDict: { [K: string]: Matrix4 } = getSymmetryOperations(uc.spacegroup)\n\n const centerFracSymop = new Vector3()\n const positionFracSymop = new Vector3()\n\n function getMatrixList (shift?: Vector3) {\n const matrixList: Matrix4[] = []\n\n Object.keys(symopDict).forEach(function (name) {\n const m = symopDict[ name ].clone()\n\n centerFracSymop.copy(structureCenterFrac).applyMatrix4(m).floor()\n positionFracSymop.setFromMatrixPosition(m)\n positionFracSymop.sub(centerFracSymop)\n positionFracSymop.add(centerFrac)\n\n if (shift) positionFracSymop.add(shift)\n\n m.setPosition(positionFracSymop)\n m.multiplyMatrices(uc.fracToCart, m)\n m.multiply(uc.cartToFrac)\n\n matrixList.push(m)\n })\n\n return matrixList\n }\n\n const unitcellAssembly = new Assembly('UNITCELL')\n const unitcellMatrixList = getMatrixList()\n const ncsMatrixList: Matrix4[] = []\n if (structure.biomolDict.NCS) {\n ncsMatrixList.push(\n new Matrix4(), ...structure.biomolDict.NCS.partList[ 0 ].matrixList\n )\n const ncsUnitcellMatrixList: Matrix4[] = []\n unitcellMatrixList.forEach(sm => {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n}\n\nclass PdbParser extends StructureParser {\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: number, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H') ? 1 : 0\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, 0, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, 1)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, 1)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file ngl\n * @private\n * @author Alexander Rose \n */\n\nimport './polyfills'\nimport _Promise from 'promise-polyfill'\n\n/**\n * The NGL module. These members are available in the `NGL` namespace when using the {@link https://github.com/umdjs/umd|UMD} build in the `ngl.js` file.\n * @module NGL\n */\n\nexport {\n Debug, setDebug,\n MeasurementDefaultParams, setMeasurementDefaultParams,\n ScriptExtensions, ColormakerRegistry,\n DatasourceRegistry, DecompressorRegistry,\n ParserRegistry, RepresentationRegistry,\n setListingDatasource, setTrajectoryDatasource,\n ListingDatasource, TrajectoryDatasource\n} from './globals'\nexport { autoLoad, getDataInfo, getFileInfo } from './loader/loader-utils'\nimport Selection from './selection/selection'\nimport PdbWriter from './writer/pdb-writer'\nimport SdfWriter from './writer/sdf-writer'\nimport StlWriter from './writer/stl-writer'\nimport Stage from './stage/stage'\nimport Viewer from './viewer/viewer'\nimport Collection from './component/collection'\nimport ComponentCollection from './component/component-collection'\nimport Component from './component/component'\nimport ShapeComponent from './component/shape-component'\nimport StructureComponent, {StructureRepresentationType} from './component/structure-component'\nimport SurfaceComponent from './component/surface-component'\nimport VolumeComponent, {VolumeRepresentationType} from './component/volume-component'\nimport RepresentationCollection from './component/representation-collection'\nimport RepresentationElement from './component/representation-element'\nimport Assembly from './symmetry/assembly'\nimport TrajectoryPlayer from './trajectory/trajectory-player'\nimport Superposition from './align/superposition'\nexport { superpose } from './align/align-utils'\nexport { guessElement, concatStructures } from './structure/structure-utils'\n\nexport { flatten, throttle, download, getQuery, uniqueArray } from './utils'\nimport Queue from './utils/queue'\nimport Counter from './utils/counter'\nimport Frames from './trajectory/frames'\n\n//\n\nimport Colormaker from './color/colormaker'\n\nimport './color/atomindex-colormaker'\nimport './color/bfactor-colormaker'\nimport './color/chainid-colormaker'\nimport './color/chainindex-colormaker'\nimport './color/chainname-colormaker'\nimport './color/densityfit-colormaker'\nimport './color/electrostatic-colormaker'\nimport './color/element-colormaker'\nimport './color/entityindex-colormaker'\nimport './color/entitytype-colormaker'\nimport './color/geoquality-colormaker'\nimport './color/hydrophobicity-colormaker'\nimport './color/modelindex-colormaker'\nimport './color/moleculetype-colormaker'\nimport './color/occupancy-colormaker'\nimport './color/partialcharge-colormaker'\nimport './color/random-colormaker'\nimport './color/randomcoilindex-colormaker'\nimport './color/residueindex-colormaker'\nimport './color/resname-colormaker'\nimport './color/sstruc-colormaker'\nimport './color/structuredata-colormaker'\nimport './color/uniform-colormaker'\nimport './color/value-colormaker'\nimport './color/volume-colormaker'\n\n//\n\nimport './component/shape-component'\nimport './component/structure-component'\nimport './component/surface-component'\nimport './component/volume-component'\n\n//\n\nimport AngleRepresentation, {AngleRepresentationParameters} from './representation/angle-representation'\nimport AxesRepresentation, {AxesRepresentationParameters} from './representation/axes-representation'\nimport BackboneRepresentation from './representation/backbone-representation'\nimport BallAndStickRepresentation, {BallAndStickRepresentationParameters} from './representation/ballandstick-representation'\nimport BaseRepresentation from './representation/base-representation'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './representation/cartoon-representation'\nimport ContactRepresentation, {ContactRepresentationParameters} from './representation/contact-representation'\nimport DihedralRepresentation, {DihedralRepresentationParameters} from './representation/dihedral-representation'\nimport DihedralHistogramRepresentation, {DihedralHistogramRepresentationParameters} from './representation/dihedral-histogram-representation'\nimport DistanceRepresentation, {DistanceRepresentationParameters} from './representation/distance-representation'\nimport HelixorientRepresentation from './representation/helixorient-representation'\nimport HyperballRepresentation, {HyperballRepresentationParameters} from './representation/hyperball-representation'\nimport LabelRepresentation, {LabelRepresentationParameters} from './representation/label-representation'\nimport LicoriceRepresentation from './representation/licorice-representation'\nimport LineRepresentation, {LineRepresentationParameters} from './representation/line-representation'\nimport MolecularSurfaceRepresentation, {MolecularSurfaceRepresentationParameters} from './representation/molecularsurface-representation'\nimport PointRepresentation, {PointRepresentationParameters} from './representation/point-representation'\nimport RibbonRepresentation, {RibbonRepresentationParameters} from './representation/ribbon-representation'\nimport RocketRepresentation, {RocketRepresentationParameters} from './representation/rocket-representation'\nimport RopeRepresentation from './representation/rope-representation'\nimport SpacefillRepresentation from './representation/spacefill-representation'\nimport StructureRepresentation, {StructureRepresentationParameters} from './representation/structure-representation'\nimport TraceRepresentation, {TraceRepresentationParameters} from './representation/trace-representation'\nimport TubeRepresentation from './representation/tube-representation'\nimport UnitcellRepresentation, {UnitcellRepresentationParameters} from './representation/unitcell-representation'\nimport ValidationRepresentation from './representation/validation-representation'\n\nimport BufferRepresentation from './representation/buffer-representation'\nimport ArrowBuffer from './buffer/arrow-buffer'\nimport BoxBuffer from './buffer/box-buffer'\nimport ConeBuffer from './buffer/cone-buffer'\nimport CylinderBuffer from './buffer/cylinder-buffer'\nimport EllipsoidBuffer from './buffer/ellipsoid-buffer'\nimport MeshBuffer from './buffer/mesh-buffer'\nimport OctahedronBuffer from './buffer/octahedron-buffer'\nimport PointBuffer from './buffer/point-buffer'\nimport SphereBuffer from './buffer/sphere-buffer'\nimport TetrahedronBuffer from './buffer/tetrahedron-buffer'\nimport TextBuffer from './buffer/text-buffer'\nimport TorusBuffer from './buffer/torus-buffer'\nimport WidelineBuffer from './buffer/wideline-buffer'\n\n//\n\nimport './parser/cif-parser'\nimport './parser/gro-parser'\nimport './parser/mmtf-parser'\nimport './parser/mol2-parser'\nimport './parser/pdb-parser'\nimport './parser/pdbqt-parser'\nimport './parser/pqr-parser'\nimport './parser/sdf-parser'\n\nimport './parser/prmtop-parser'\nimport './parser/psf-parser'\nimport './parser/top-parser'\n\nimport './parser/dcd-parser'\nimport './parser/nctraj-parser'\nimport './parser/trr-parser'\nimport './parser/xtc-parser'\n\nimport './parser/cube-parser'\nimport './parser/dsn6-parser'\nimport './parser/dx-parser'\nimport './parser/dxbin-parser'\nimport './parser/mrc-parser'\nimport './parser/xplor-parser'\n\nimport './parser/kin-parser'\nimport './parser/obj-parser'\nimport './parser/ply-parser'\n\nimport './parser/csv-parser'\nimport './parser/json-parser'\nimport './parser/msgpack-parser'\nimport './parser/netcdf-parser'\nimport './parser/text-parser'\nimport './parser/xml-parser'\n\nimport './parser/validation-parser'\n\n//\n\nimport Shape from './geometry/shape'\nimport Kdtree from './geometry/kdtree'\nimport SpatialHash from './geometry/spatial-hash'\nimport Structure from './structure/structure'\nimport MolecularSurface from './surface/molecular-surface'\nimport Volume from './surface/volume'\n\n//\n\nimport './utils/gzip-decompressor'\n\n//\n\nimport './datasource/rcsb-datasource'\nimport './datasource/pubchem-datasource'\nimport './datasource/passthrough-datasource'\nimport './datasource/alphafold-datasource'\nimport StaticDatasource from './datasource/static-datasource'\nimport MdsrvDatasource from './datasource/mdsrv-datasource'\n\n//\n\nexport {\n LeftMouseButton, MiddleMouseButton, RightMouseButton\n} from './constants'\nexport {MouseActionCallback} from './controls/mouse-actions'\nimport MouseActions from './controls/mouse-actions'\nimport KeyActions from './controls/key-actions'\nimport PickingProxy from './controls/picking-proxy'\n\n//\n\nexport { Signal } from 'signals'\nexport {\n Matrix3, Matrix4, Vector2, Vector3, Box3, Quaternion, Euler, Plane, Color\n} from 'three'\n\n//\n\nexport { UIStageParameters } from './ui/parameters'\nexport { StageParameters } from './stage/stage'\nexport { StructureComponentDefaultParameters } from './component/structure-component'\n\n//\n\nimport Version from './version'\n\nif (!(window as any).Promise) {\n (window as any).Promise = _Promise\n}\n\nexport {\n Version,\n StaticDatasource,\n MdsrvDatasource,\n Colormaker,\n Selection,\n PdbWriter,\n SdfWriter,\n StlWriter,\n Stage,\n Viewer,\n Collection,\n ComponentCollection,\n RepresentationCollection,\n RepresentationElement,\n Component,\n ShapeComponent,\n StructureComponent,\n SurfaceComponent,\n VolumeComponent,\n StructureRepresentationType,\n VolumeRepresentationType,\n\n Assembly,\n TrajectoryPlayer,\n Superposition,\n Frames,\n\n Queue,\n Counter,\n\n AngleRepresentation,\n AngleRepresentationParameters,\n AxesRepresentation,\n AxesRepresentationParameters,\n BackboneRepresentation,\n BallAndStickRepresentation,\n BallAndStickRepresentationParameters,\n BaseRepresentation,\n CartoonRepresentation,\n CartoonRepresentationParameters,\n ContactRepresentation,\n ContactRepresentationParameters,\n DihedralRepresentation,\n DihedralRepresentationParameters,\n DihedralHistogramRepresentation,\n DihedralHistogramRepresentationParameters,\n DistanceRepresentation,\n DistanceRepresentationParameters,\n HelixorientRepresentation,\n HyperballRepresentation,\n HyperballRepresentationParameters,\n LabelRepresentation,\n LabelRepresentationParameters,\n LicoriceRepresentation,\n LineRepresentation,\n LineRepresentationParameters,\n MolecularSurfaceRepresentation,\n MolecularSurfaceRepresentationParameters,\n PointRepresentation,\n PointRepresentationParameters,\n RibbonRepresentation,\n RibbonRepresentationParameters,\n RocketRepresentation,\n RocketRepresentationParameters,\n RopeRepresentation,\n SpacefillRepresentation,\n StructureRepresentation,\n StructureRepresentationParameters,\n TraceRepresentation,\n TraceRepresentationParameters,\n TubeRepresentation,\n UnitcellRepresentation,\n UnitcellRepresentationParameters,\n ValidationRepresentation,\n\n BufferRepresentation,\n ArrowBuffer,\n BoxBuffer,\n ConeBuffer,\n CylinderBuffer,\n EllipsoidBuffer,\n MeshBuffer,\n OctahedronBuffer,\n PointBuffer,\n SphereBuffer,\n TetrahedronBuffer,\n TextBuffer,\n TorusBuffer,\n WidelineBuffer,\n\n Shape,\n\n Structure,\n Kdtree,\n SpatialHash,\n MolecularSurface,\n Volume,\n\n MouseActions,\n KeyActions,\n PickingProxy\n}\n"],"names":["toStr","isCallable","maxSafeInteger","toLength","start","getQuery","id","window","const","m","RegExp","exec","location","search","decodeURIComponent","defaults","value","defaultValue","undefined","createParams","params","defaultParams","o","Object","assign","k","updateParams","newParams","getProtocol","protocol","match","getBrowser","ua","navigator","userAgent","test","openUrl","url","open","href","download","data","downloadName","isSafari","isChromeIos","a","document","createElement","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","result","readAsDataURL","let","objectUrlCreated","URL","createObjectURL","style","display","body","appendChild","target","click","removeChild","revokeObjectURL","str","replace","lexicographicCompare","elm1","elm2","binarySearchIndexOf","array","element","compareFunction","low","high","length","mid","cmp","rangeInSortedArray","min","max","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sort","filter","index","sorted","uint8ToString","u8a","chunkSize","c","i","push","String","fromCharCode","apply","subarray","join","getTypedArray","arrayType","arraySize","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Float32Array","Error","getUintArray","sizeOrArray","maxUint","ensureBuffer","buffer","ArrayBuffer","_ensureClassFromArray","constructor","Array","isArray","fromArray","ensureVector3","v","Vector3","ensureMatrix4","Matrix4","ensureQuaternion","q","Quaternion","ensureFloat32Array","arg","toLowerCaseString","toString","toLowerCase","console","prop","method","con","empty","dummy","properties","split","methods","pop","HTMLCanvasElement","prototype","toBlob","defineProperty","callback","type","quality","bin","atob","this","toDataURL","len","len32","a8","a32","j","charCodeAt","tailLength","Math","cbrt","x","y","pow","abs","sign","isNaN","Number","isInteger","nVal","isFinite","floor","enumerable","configurable","writable","TypeError","pendingException","to","hasPendingException","arguments","nextSource","keysArray","keys","nextIndex","nextKey","desc","getOwnPropertyDescriptor","e","startsWith","object","$defineProperty","error","string","call","stringLength","searchString","searchLength","position","pos","endsWith","subjectString","lastIndex","indexOf","repeat","count","RangeError","Infinity","rpt","includes","searchElement","O","parseInt","currentElement","n","from","fn","number","toInteger","arrayLike","C","items","T","mapFn","kValue","A","lastTime","vendors","requestAnimationFrame","cancelAnimationFrame","currTime","Date","getTime","timeToCall","setTimeout","clearTimeout","Function","name","get","performance","self","now","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","Registry","_dict","prototypeAccessors","names","degToRad","deg","add","key","chars","uuid","generateUUID","r","rnd","random","clamp","lerp","stop","alpha","spline","p0","p1","p2","p3","t","tension","v0","v1","t2","smoothstep","normalize","colorSpace","ScaleDefaultParameters","scale","mode","domain","reverse","tmpColor","Color","manageColor","_target","_name","descriptor","originalMethod","fromTo","bind","set","convertSRGBToLinear","getHex","kwd","Colormaker","parameters","structure","atomProxy","getAtomProxy","getScale","p","slice","chroma","out","colorToArray","color","offset","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","s","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","rules","negate","f","subTests","hasOwnProperty","and","operator","na","ret","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","signals","stringChanged","Signal","setString","prototypeAccessors$z","silent","retSelection","newSelection","oldSelection","selectionStack","trim","charAt","substr","chunks","createNewContext","getPrevContext","pushRule","rule","not","cu","toUpperCase","sele","substring","chain","negate2","resi","resiSingle","resiRange","map","resnameList","indexList","b","lastRule","parseSele","message","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","dispatch","isAllSelection","isNoneSelection","defineProperties","SelectionColormaker","super","colormakerList","selectionList","dataList","forEach","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set1","Set2","Set3","Dark2","Paired","Pastel1","Pastel2","Accent","rainbow","rwb","ColormakerModes","rgb","hsv","hsl","hsi","lab","hcl","schemes","userSchemes","getSchemes","types","getScales","getModes","ColormakerRegistry$1","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","MySelectionColormaker","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","getWorkerDeps","vars","deps","sym","__deps","makeWorkerString","onmessage","__name","postId","__postId","func","aMessage","transferList","postMessage","makeWorkerBlob","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","Browser","SupportsPassiveEventHandler","opts","addEventListener","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","log","info","warn","time","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","linewidth","opacity","labelUnit","arcVisible","planeVisible","Debug","ScriptExtensions","_WorkerRegistry","_ColormakerRegistry","DatasourceRegistry","RepresentationRegistry","_ParserRegistry","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","exports","ListingDatasource","TrajectoryDatasource","Streamer","src","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","then","decompressFn","_chunk","end","chunk","peekLines","chunkToLines","lines","chunkCount","asText","partialLine","isLast","idx","lastIndexOf","str2","concat","nextChunk","nextChunkOfLines","d","eachChunk","round","eachChunkOfLines","chunkNo","dispose","FileStreamer","Promise","resolve","reject","file","onload","event","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","status","response","statusText","responseType","send","Loader","ext","dir","path","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","load","parse","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","Writer","getBlob","getData","mimeType","defaultName","defaultExt","PdbWriter","renumberSerial","remarks","ensureArray","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","sprintf","trajectory","ia","im","charge","chargeSign","hasModels","modelStore","eachModel","eachAtom","formatString","hetero","serial","formalCharge","toPrecision","z","occupancy","bfactor","getSelection","getString","SdfWriter","idString","titleString","countsString","chargeLines","title","atomCount","bondCount","pairs","ap","nCharges","formatAtom","line","formatBond","bp","bondOrder","_writeHeader","_writeCTab","_writeFooter","eachBond","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","reset","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","toArray","StlWriter","surface","triangles","output","vector","vectorNorm1","vectorNorm2","vectorNorm3","indices","normal","addVectors","Counter","countChanged","signalsWrapper","clear","change","delta","increment","decrement","listen","counter","unlisten","has","remove","onZeroOnce","context","Stats","updated","maxDuration","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","update","startTime","currentTime","reInclude","shaderCache","getShader","defines","hash","definesText","getDefines","shaderText","ShaderChunk","WebGLRenderingContext","wrcp","_getShaderParameter","getShaderParameter","_getShaderInfoLog","getShaderInfoLog","_getProgramParameter","getProgramParameter","program","pname","LINK_STATUS","_getProgramInfoLog","getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","renderer","camera","viewer","canvas","_viewer","_factor","factor","_antialias","antialias","_onProgress","onProgress","_onFinish","onFinish","_n","_width","width","_height","height","_ctx","getContext","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","offsetX","offsetY","setViewOffset","render","w","h","drawImage","domElement","ceil","_finalize","view","renderAsync","TwoPI","PI","RAD2DEG","circularMean","stride","cosMean","sinMean","angle","cos","sin","atan2","calculateCenterArray","array1","array2","center","calculateDirectionArray","direction","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","copyArray","dst","srcOffset","dstOffset","copyWithin","arrayMax","il","arrayMin","arraySum","sum","arrayMean","ImageDefaultParameters","transparent","makeImage","ref","originalClearAlpha","getClearAlpha","backgroundColor","getClearColor","setLineWidthAndPixelSize","invert","scene","traverse","material","uniforms","size","__seen","trimCanvas","bg","g","doBreak","off","canvasHeight","canvasWidth","pixels","getImageData","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","blob","setClearAlpha","requestRender","vertex","matrix","modelViewProjectionMatrix","resolution","Vector2","projectionMatrixInverse","projectionMatrixTranspose","updateCameraUniforms","group","getInverse","projectionMatrix","copy","transpose","u","loadShader","gl","shaderSource","shaderType","shader","createShader","compileShader","COMPILE_STATUS","deleteShader","getExtension","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","createProgram","attachShader","attrib","bindAttribLocation","linkProgram","deleteProgram","useProgram","positionLocation","getAttribLocation","colorLoc","getUniformLocation","positionBuffer","createBuffer","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","enableVertexAttribArray","vertexAttribPointer","FLOAT","whiteTex","createTexture","whiteData","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","tex","texParameteri","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","uniform4fv","drawArrays","TRIANGLES","clearColor","COLOR_BUFFER_BIT","pixel","readPixels","floatPixel","getError","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","onBeforeRender","geometry","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","modelViewMatrix","multiplyMatrices","matrixWorldInverse","matrixWorld","materialProperties","pu","getUniforms","setValue","Viewer","idOrElement","boundingBox","Box3","boundingBoxSize","boundingBoxLength","memory","programs","geometries","textures","calls","vertices","faces","points","distVector","ticked","rendered","elm","getElementById","container","HTMLElement","innerWidth","innerHeight","box","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","cameraDistance","fogColor","fogNear","fogFar","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","LinearEncoding","lookAt","perspectiveCamera","PerspectiveCamera","orthographicCamera","OrthographicCamera","stereoCamera","StereoCamera","aspect","eyeSep","updateProjectionMatrix","stats","Scene","rotationGroup","Group","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","fog","Fog","spotLight","SpotLight","ambientLight","AmbientLight","dpr","devicePixelRatio","WebGLRenderer","preserveDrawingBuffer","innerHTML","setPixelRatio","setSize","autoClear","sortObjects","outputEncoding","capabilities","isWebGL2","extensions","supportsHalfFloat","dprWidth","dprHeight","JSON","stringify","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","WebGLRenderTarget","minFilter","NearestFilter","magFilter","stencilBuffer","format","RGBAFormat","FloatType","UnsignedByteType","texture","generateMipmaps","encoding","setRenderTarget","sampleTarget","LinearFilter","holdTarget","compositeUniforms","tForeground","Uniform","compositeMaterial","ShaderMaterial","vertexShader","fragmentShader","premultipliedAlpha","blending","AdditiveBlending","depthTest","depthWrite","compositeCamera","compositeScene","Mesh","PlaneGeometry","positions","bbGeometry","BufferGeometry","setIndex","BufferAttribute","setAttribute","bbMaterial","uColor","boundingBoxMesh","LineSegments","updateHelper","attributes","needsUpdate","isEmpty","computeBoundingSphere","instanceList","instance","addBuffer","wireframeGroup","background","pickable","setUserData","children","userData","mesh","getMesh","applyMatrix4","wireframeMesh","getWireframeMesh","quaternion","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","instanceMatrix","updateGeometry","computeBoundingBox","geoBoundingBox","clone","equals","expandByScalar","union","updateNode","node","makeEmpty","getSize","getPickingPixels","imgBuffer","readRenderTargetPixels","getImage","picking","imgBuffer2","ctx","imgData","putImageData","setLight","intensity","near","far","setClearColor","getStyle","level","setOutputEncoding","setColorWorkflow","sRGBEncoding","setCamera","fov","up","updateZoom","setClip","dist","left","right","top","bottom","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","pick","pid","picker","pixelBuffer","oid","getObjectById","tan","zoom","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","getWorldPosition","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","updateMatrix","updateMatrixWorld","pixelRatio","getPixelRatio","ortho","nearClip","updateMaterialUniforms","traverseVisible","Points","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","tmpTab","__zArray","__sortArray","__cmpFn","ai","bi","arr","tmp","stack","sp","swap","tmp2","quicksortCmp","attr","itemSize","sortProjectedPosition","__setVisibility","helper","visible","__updateLights","setLength","__renderPickingGroup","__renderModelGroup","renderTarget","__renderSuperSample","baseSampleWeight","sampleWeight","clearViewOffset","__renderStereo","_renderTarget","setScissorTest","setScissor","setViewport","cameraL","__render","cameraR","lastRenderedPicking","rendering","getTouchDistance","dx","touches","pageX","dy","pageY","sqrt","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","preventDefault","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","detail","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","distanceTo","lastTouchDistance","touchDistance","removeEventListener","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","multiplyScalar","_getRotateXY","_getCameraRotation","extractRotation","multiply","makeRotationY","_transformPanVector","transform","premultiply","pan","translate","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","rotate","setFromAxisAngle","makeRotationFromQuaternion","applyMatrix","zRotate","dz","makeRotationZ","rotateComponent","makeRotationAxis","setFromRotationMatrix","tmpVec","PickingProxy","pickingData","closestBondAtom","closeAtom","arrow","axes","cone","clash","contact","cylinder","distance","ellipsoid","octahedron","point","sphere","tetrahedron","torus","unitcell","unknown","volume","wideline","getComponentsByObject","list","getObject","getPosition","atom1","v2","atom2","acp1","getPositionOnCanvas","acp2","ca","acp","radius","getMaxRepresentationRadius","_objectIfType","getLabel","msg","qualifiedName","shape","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","rotation","project","getCameraDistance","getOrientation","setPosition","orient","decompose","setRotationFromQuaternion","spin","axis","rotateOnAxis","align","basis","setRotationFromMatrix","Animation","duration","args","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","toggle","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","lerpVectors","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","slerp","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","prototypeAccessors$1","every","animation","AnimationControls","animationList","finishedList","splice","rock","move","zoomMove","orientTo","timeout","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","next","shift","kill","Representation","lazy","step","clipRadius","precision","clipCenter","flatShaded","side","options","front","back","double","wireframe","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","roughness","metalness","diffuse","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","init","setColor","lazyProps","build","bufferParams","what","tp","sphereDetail","radialSegments","openEnded","disableImpostor","getColorParams","getBufferParams","val","prepare","cb","create","updateWhat","_make","manualAttach","disposed","attach","setVisibility","noRenderRequest","updateParameters","int","float","parseFloat","getParameters","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","calculateMeanVector3","projectPointOnVector","origin","sub","projectOnVector","minX","minY","minZ","maxX","maxY","maxZ","l","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","ax","ay","az","bx","by","bz","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","color2","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","col","rad","getFixedLengthWrappedDashData","remaining","drawing","k3","kprev","vl","inv","getNextWorker","nextWorker","minPending","Primitive","staticAccessors","Picker","Buffer","getShapeKey","expandBoundingBox","valueToShape","_primitiveData","fields","objectToShape","valueFromShape","objectFromShape","arrayFromShape","dataFromShape","bufferFromShape","SpherePrimitive","positionFromShape","expandByPoint","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","text","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","ix","iy","iz","dSq","Store","_fields","_defaultFields","prototypeAccessors$r","size$1","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","index1","index2","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","indexArray","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","state","addFeature","features","groups","centers","atomSets","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","intersection","intersects","getIntersectionSize","makeIntersection","wordsA","answer","toSeleString","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","HE","LI","BE","B","N","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","trace","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","Map","calcAngles","ap1","ap2","angles","d1","d2","subVectors","eachBondedAtom","angleTo","calcPlaneAngle","x1","v12","neighbours","ni","cross","ValenceModel","implicitH","totalH","idealGeometry","hydrogenCount","bondToElementCount","assignCharge","assignH","degree","valence","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","flag","a2","getOtherAtom","b2","atomicNumber2","isConjugated","multiBond","implicitHCount","geom","ba","oa","calculateHydrogensCharge","chg","implH","totH","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","addChargedContacts","contacts","maxIonicDist","ContactDefaultParams","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","masterIdx","masterModelIndex","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","spatialHash","contactStore","featureSet","atomStore","v3","n1","n2","getNormal","atoms","crossVectors","getOffset","projectOnPlane","ct","loop","invalidAtomContact","ti","tj","isIonicInteraction","atomSet1","atomSet2","maxDist","sn","sm","si","sj","areAtomSetsWithinDist","isPiStacking","isCationPi","isHistidineNitrogen","IonicTypeMetals","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","isMasterContact","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","addGroup","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","createContacts","maxHbondDistSq","donor","acceptor","isWeak","isWeakHydrogenBond","isHydrogenBond","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","c1","c2","lineOfSightDist","lineOfSightDistFactorSq","cx","cy","cz","as1","as2","vdw","distanceToSquared","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","setHex","contactColor","ContactPicker","prototypeAccessors$q","getIndex","_applyTransformations","_getPosition","ShapePicker","primitive","CylinderPicker","prototypeAccessors$2","ArrowPicker","prototypeAccessors$3","AtomPicker","prototypeAccessors$4","AxesPicker","prototypeAccessors$5","BondPicker","bondStore","prototypeAccessors$6","prototypeAccessors$7","center1","center2","ConePicker","prototypeAccessors$8","ClashPicker","validation","prototypeAccessors$9","clashArray","_getAtomProxyFromSele","getAtomIndices","sele1","sele2","DistancePicker","prototypeAccessors$10","EllipsoidPicker","prototypeAccessors$11","OctahedronPicker","prototypeAccessors$12","BoxPicker","prototypeAccessors$13","IgnorePicker","prototypeAccessors$14","MeshPicker","prototypeAccessors$15","__position","SpherePicker","prototypeAccessors$16","SurfacePicker","prototypeAccessors$17","TetrahedronPicker","prototypeAccessors$18","TorusPicker","prototypeAccessors$19","UnitcellPicker","prototypeAccessors$20","getCenter","VolumePicker","prototypeAccessors$22","vol","dp","SlicePicker","prototypeAccessors$23","PointPicker","prototypeAccessors$24","WidelinePicker","prototypeAccessors$25","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","wrap","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","qy","qz","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","bits","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","zOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_box","_contour","_wrap","vIndexLength","Matrix","cols","rows","At","nrows","ncols","Ai","Ati","pAt","ad","atd","multiplyABt","Ap","pA","pB","Cp","mrows","bd","cd","multiply3x3","Cd","Ad","Bd","m10","m11","m12","m13","m14","m15","m16","m17","m18","m20","m21","m22","m23","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","i0","i1","hypot","copyTo","svd","at","_m","amt","wmt","vmt","astep","_W","Vt","vstep","iter","maxIter","Aj","Vi","Vj","t0","t1","sd","beta","gamma","seed","val0","asum","Float64Array","EPSILON","JacobiSVDImpl","m4new","m4set","n11","n12","n13","n14","n21","n22","n23","n24","n31","n32","n33","n34","n41","n42","n43","n44","m4multiply","a11","a12","a13","a14","a21","a22","a23","a24","a31","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","m4makeScale","m4makeTranslation","m4makeRotationY","theta","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","jl","flagvert","tps","vertdeg","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","computeVertexNormals","nv3","ab","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","maxSize","tmpSize","tran","mroty","mscale","mtrans","Surface","Geometry","fromGeometry","setFromArray","VolumeSurface","mc","getSurface","smooth","normalMatrix","prototypeAccessors$p","geo","getColor","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","include","getAtomindex","volsurf","Volume","Matrix3","inverseMatrix","setData","rms","getThreeSide","FrontSide","BackSide","DoubleSide","prototypeAccessors$o","setAtomindex","_position","_min","_max","_mean","_rms","setStats","setMatrix","me","elements","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","setObjectMatrix","matrixWorldNeedsUpdate","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","property","uniform","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","isLine","dynamic","wireframeIndexCount","defaultParameters","UniformsUtils","merge","UniformsLib","common","emissive","lights","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","prototypeAccessors$n","nindex","setUsage","DYNAMIC_DRAW","makeMaterial","vertexColors","derivatives","fragDepth","wm","pm","NoBlending","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","setDrawRange","checkEdge","drawRange","updateWireframeIndex","updateRange","getRenderOrder","renderOrder","_getMesh","materialName","frustumCulled","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","attribute","wu","isVector3","toJSON","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","zoomScroll","trackballControls","clipNearScroll","focusScroll","focus","getFocus","almostIdentity","setFocus","zoomFocusScroll","eachRepresentation","reprElem","comp","repr","panDrag","rotateDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","panAtomDrag","rotateComponentDrag","movePick","pickingProxy","animationControls","tooltipPick","tt","tooltip","mp","innerText","MouseActionPresets","default","measurePick","measureClear","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleAnimations","toggleRock","KeyActionPresets","toggleSpin","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","padding","fontFamily","_clientRect","getVisibility","vp","cr","depth","zIndex","ComponentControls","RadiusFactoryTypes","covalent","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","va","vb","vc","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","makeBasis","determinant","getRotationQuaternion","inverse","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dot","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredAtomindex","filteredData","filteredPosition","BondHash","al","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","code","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","cache","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","diff","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","_center","a1","getAtomIndexByType","a3","a4","acos","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","_end","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","parentN","parent","elemScore","child1Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","pivotIndex","pivotValue","storeIndex","arrMedian","currentDim","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","Kdtree$1","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityIndex","chainIndex","residue","atomType","partialCharge","aromatic","euclideanDistSq","euclideanDist","entityList","residueTypeId","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","aa","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","connectedAtomIndex","connectedAtomIndices","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","noResname","toObject","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","L","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","prototypeAccessors$i","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","instanceCount","isIdentity","structureChainList","eachChain","getBoundingBox","partBox","prototypeAccessors$1$1","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","assignSecondaryStructure","secStruct","chainnames","chainnamesSorted","chainnamesIndex","helices","h1","h2","helix","helixRun","chainChange","sheets","s1","s2","strandCharCode","sheet","sheetRun","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","zhangSkolnickSS","isHelical","calculateSecondaryStructure","distances","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","rStart","rEnd","chainData","mIndex","rCount","eachResidueN","newChain","bbType1","bbType2","backboneEndAtomIndex","backboneStartAtomIndex","fill","rOffset","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","spacegroup","encodedSymopList","matrixDict","symopList","symop","denominator","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","unitcellAssembly","unitcellMatrixList","getMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","setFromMatrixPosition","fracToCart","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","rungEndIndex","bbEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","prevIndex","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","residueEnd","getModelProxy","_rp","rNextIndex","first","ModelProxy","chainEnd","_cp","Structure","refreshed","extraData","atomSetCache","boxes","bondSet","prototypeAccessors$c","finalizeAtoms","finalizeBonds","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getMaxScaleOnAxis","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","radius2","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","seq","getChainnameCount","Set","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","sizeAttenuation","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","buffers","prototypeAccessors$b","BufferRepresentation","GeometryBuffer","meshIndex","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","makeTranslation","applyPositionTransform","getNormalMatrix","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","IcosahedronBufferGeometry","_radius","MappedBuffer","mappingType","indexSize","mapping","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","PointBufferDefaultParameters","alphaTest","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","DataTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","flipY","pickingTex","pickingMap","mapSize","CUBIC_INTERPOLATION","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","NormalBlending","VolumeSlice","positionType","getPositionFromCoordinate","coord","vn","ms","setFromMatrixScale","dimLen","x0","y0","z0","setVec","tMin","tMax","pickingArray","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","prototypeAccessors$a","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","Euler","setFromEuler","setScale","setTransform","getCenterUntransformed","makeScale","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","invA","t4","t5","t8","t9","t11","t13","t14","t15","t17","t18","t20","t21","t23","t26","md","mean1","mean2","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","det","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","frame","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","resetCache","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","_s1","_s2","_i","_j","ali","calc","ali1","aliIdx1","aliIdx2","ali2","_atoms1","_atoms2","initMatrices","score","gap","makeScoreFn","Vi1","Si1","Hi","Si","gap0","scoreFn","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","pointer","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","item","pickDict","del","values","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","Stage","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","assembly","sizeScore","backboneOnly","radiusScale","surfaceType","probeRadius","lineOnly","loadFile","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","lastFullscreenElement","getFullscreenElement","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","dataset","normalWidth","normalHeight","screen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","resizeElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","setSpin","setRock","pclamp","bbSize","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","sc","ShapeComponent","__decorate","decorators","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","c0","StructureRepresentation","radiusSize","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","xOffset","attachment","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","order","selected","_break","calcArcPoint","edt","edt1d","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","placeholder","CanvasTexture","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","iChar","nChar","iCharAll","textAtlas","txt","xadvance","xShift","yShift","inputMapping","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","toFixed","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","eye","CylinderGeometryBufferDefaultParameters","getGeo","makeRotationX","CylinderBufferGeometry","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","d3","addScaledVector","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","directional","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","normals","getNormals","tangent","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","NaN","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","unit","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","p4","v34","inPlane1","inPlane2","improperStart","improperEnd","v3angle","nLines","nPlanes","line1","line2","sector","plane","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","obj","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","createWideLineBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","createMeshBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","Float32Concat","arrays","lengths","accumulatedOffset","linesList","startPoints","endPoints","startColors","endColors","triangleColors","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","opaqueCircleSectorAngleStep","sectionIndex","startOffset","setOneSideHistogram","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","scalingFactor","discHistogram","binBorders","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","res","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","positionN","sizeN","colorN","labelFactory","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tx","ty","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","ngTorus","lastClip","_probePositions","rExt","surfGrid","fillGridDim","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","dd","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","ConeBufferGeometry","_position1","_position2","GeometryGroup","geometryList","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vFrom","vTo","vSplit","fullLength","coneLength","BoxBuffer","BoxBufferGeometry","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","OctahedronBufferGeometry","TetrahedronBuffer","TetrahedronBufferGeometry","TorusBufferDefaultParameters","radiusRatio","tubularSegments","TorusBuffer","TorusBufferGeometry","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","divideScalar","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","hex","isLegacy","headerLine","headerId","legacyId","currentCoord","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","currentEntityData","currentEntityKey","chainIdx","currentChainname","currentSeqresChainname","isPqr","isPdbqt","sb","serialRadix","resnoRadix","doFrames","serialDict","unitcellDict","entityDataList","hetnameDict","modresDict","chainDict","seqresDict","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","ml","identityMatrix","covalentI","i$1","parseCore","begIcode","struct_conf","beg_auth_seq_id","pdbx_PDB_helix_class","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsName","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","experimentalMethods","GroParser","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","ctor","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","i2","decodeInt32","i4","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","MmtfParser","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","am","du","un","Mol2Parser","moleculeLineNo","modelAtomIdxStart","currentRecordType","PdbqtParser","PqrParser","reItem","SdfParser","headerLines","mItem","atomStart","bondStart","bondEnd","sdfData","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","atomNames","radii","pointersDict","pointers","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","PsfParser","lastSegid","segid","reField","TopParser","currentMoleculetype","molecules","moleculetypeDict","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","DcdParser","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","notNetcdf","statement","reason","readName","nameLength","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","version","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","TrrParser","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","num","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","mask","lastBB0","lastBB1","cnt","_tmpIntBytes","decodeInts","nums","XtcParser","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","zz","yy","xx","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","xmin","ymin","zmin","hx","hy","hz","DxbinParser","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","b1","b0","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","red","orange","gold","yellow","lime","green","sea","cyan","sky","blue","purple","magenta","hotpink","pink","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","white","gray","brown","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","lm","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","KinParser","currentGroupMasters","currentSubgroupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","ref$1","listMasters$1","listName$1","listColor$1","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","ref$2","listName$2","listColor$2","listMasters$2","radiusArray","ref$3","listMasters$3","listName$3","listColor$3","breakArray","ref$4","splitLine","ref$5","label$1","color$1","position$1","ref$6","label$2","color$2","position$2","ref$7","label$3","color$3","position$3","ref$8","dominant","ref$9","groupName$1","groupFlags$1","groupMasters$1","ref$10","groupName$2","groupFlags$2","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","objects","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","addFace","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","buffergeometry","ObjParser","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","colors","elementsNeedUpdate","elementName","setRGB","vertexIndices","vertex_indices","Face3","binaryRead","dataview","binaryReadElement","loc","PlyParser","CsvParser","table","reDelimiter","JsonParser","MsgpackParser","msgpack","NetcdfParser","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","child","re","prefix","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","ValidationParser","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","inflate_fast","strm","_in","last","_out","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","Z_STREAM_ERROR","TYPE","BAD","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","messages","ZStream","GZheader","Inflate","sources","source","raw","err","ended","_mode","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","RcsbDatasource","pdbid","baseUrl","suffixUrl","PubchemDatasource","PassThroughDatasource","suffixURL","AlphafoldDatasource","uniprotid","reProtocol","StaticDatasource","relativePath","pn","basePath","pathname","MdsrvDatasource","getListing","jsonData","frameIndex","getPathUrl","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","_Promise","atomIndexDict","modelCount","structures","flatten","wait","previous","later","leading","trailing"],"mappings":"k0BA6TQA,EACAC,EASAC,EACAC,EAqIEC,uBCrcJ,SAAUC,EAAUC,GACxB,GAAsB,oBAAXC,OAAX,CAEAC,IACMC,EADI,IAAIC,OAAUJ,EAAc,cAC1BK,KAAKJ,OAAOK,SAASC,QAEjC,OAAIJ,EACKK,mBAAmBL,EAAE,SAE5B,CARiD,CAUrD,CAcgB,SAAAM,EAAUC,EAAYC,GACpC,YAAiBC,IAAVF,EAAsBA,EAAQC,CACvC,CAEgB,SAAAE,EAAiBC,EAAgCC,GAC/Db,IAAMc,EAASC,OAAOC,OAAO,CAAE,EAAEJ,GACjC,IAAKZ,IAAMiB,KAAKJ,EAAe,MAEfH,IADAE,EAAOK,KACIH,EAAEG,GAAKJ,EAAcI,GAC/C,CACD,OAAOH,CACT,CAEgB,SAAAI,EAAiBN,EAAWO,GAC1C,IAAKnB,IAAMiB,KAAKE,EAAW,CACzBnB,IAAMQ,EAAQW,EAAUF,QACVP,IAAVF,IAAqBI,EAAOK,GAAKT,EACtC,CACD,OAAOI,CACT,UAsBgBQ,IACdpB,IAAMqB,EAAWtB,OAAOK,SAASiB,SACjC,OAAyC,OAAlCA,EAASC,MAAM,eAA0B,QAAUD,CAC5D,UAEgBE,IACd,GAAsB,oBAAXxB,OAAwB,OAAO,EAE1CC,IAAMwB,EAAKzB,OAAO0B,UAAUC,UAE5B,MAAI,YAAYC,KAAKH,GACZ,QACE,UAAUG,KAAKH,GACjB,SACE,WAAWG,KAAKH,GAClB,UACE,wBAAwBG,KAAKH,GAC/B,gBACE,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GAAKA,EAAYsuI,GAC5Bx3I,IACFl4C,aAAak4C,GACbA,EAAU,MAEZy3I,EAAWrvL,EACXrM,EAASogB,EAAKld,MAAM8vB,EAAS6tB,GACxBoD,IAASjxB,EAAU6tB,EAAO,OACrBoD,IAAgC,IAArBmB,EAAQy2I,WAC7B53I,EAAUn4C,WAAW6vL,EAAOxuI,IAGvBntD,CACT,CACF"} \ No newline at end of file +{"version":3,"file":"ngl.umd.js","sources":["../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../src/writer/writer.ts","../src/utils/io-buffer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/stage/mouse-observer.ts","../src/constants.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/ui/parameters.ts","../src/datasource/mdsrv-datasource.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/writer/stl-writer.ts"],"sourcesContent":["/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&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SQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ',\n 'F 4/m -3 2/c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure) {\n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false) {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n const bonds = r.getBonds()\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const nn = atomIndices1.length\n\n for (let i = 0; i < nn; ++i) {\n const rai1 = atomIndices1[ i ]\n const rai2 = atomIndices2[ i ]\n const ai1 = rai1 + offset\n const ai2 = rai2 + offset\n const tmp = atomBondMap[ ai1 ]\n if (tmp !== undefined && tmp[ ai2 ] !== undefined) {\n bp.index = tmp[ ai2 ]\n const residueTypeBondIndex = r.residueType.getBondIndex(rai1, rai2)! // TODO\n // overwrite residueType bondOrder with value from existing bond\n bondOrders[ residueTypeBondIndex ] = bp.bondOrder\n } else {\n a1.index = ai1\n a2.index = ai2\n // only add bond if not already in bondStore\n bondStore.addBond(a1, a2, bondOrders[ i ])\n }\n }\n }\n\n // get RNA/DNA rung pseudo bonds\n const traceAtomIndex = r.residueType.traceAtomIndex\n const rungEndAtomIndex = r.residueType.rungEndAtomIndex\n if (traceAtomIndex !== -1 && rungEndAtomIndex !== -1) {\n a1.index = r.traceAtomIndex\n a2.index = r.rungEndAtomIndex\n rungBondStore.addBond(a1, a2)\n rungAtomSet.set(a1.index)\n rungAtomSet.set(a2.index)\n }\n })\n\n structure.atomSetDict.rung = rungAtomSet\n\n if (Debug) Log.timeEnd('calculateBondsWithin')\n}\n\nexport function calculateBondsBetween (structure: Structure, onlyAddBackbone = false, useExistingBonds = false) {\n if (Debug) Log.time('calculateBondsBetween')\n\n const bondStore = structure.bondStore\n const backboneBondStore = structure.backboneBondStore\n const backboneAtomSet = structure.getAtomSet(false)\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n if (backboneBondStore.count === 0) {\n backboneBondStore.resize(structure.residueStore.count)\n }\n\n function addBondIfConnected (rp1: ResidueProxy, rp2: ResidueProxy) {\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if ((useExistingBonds && ap1.hasBondTo(ap2)) || ap1.connectedTo(ap2)) {\n if (!onlyAddBackbone) {\n bondStore.addBond(ap1, ap2, 1) // assume single bond\n }\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n backboneBondStore.addBond(ap1, ap2)\n backboneAtomSet.set(ap1.index)\n backboneAtomSet.set(ap2.index)\n }\n }\n }\n\n structure.eachResidueN(2, addBondIfConnected)\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n\n // check for cyclic chains\n structure.eachChain(function (cp) {\n if (cp.residueCount === 0) return\n rp1.index = cp.residueOffset\n rp2.index = cp.residueOffset + cp.residueCount - 1\n addBondIfConnected(rp2, rp1)\n })\n\n structure.atomSetDict.backbone = backboneAtomSet\n\n if (!onlyAddBackbone) {\n if (Debug) Log.time('calculateBondsBetween inter')\n const spatialHash = structure.spatialHash\n structure.eachResidue(function (rp) {\n if (rp.backboneType === UnknownBackboneType && !rp.isWater()) {\n rp.eachAtom(function (ap) {\n if (ap.isMetal()) return\n spatialHash!.eachWithin(ap.x, ap.y, ap.z, 4, function (idx) { // TODO\n ap2.index = idx\n if (ap.modelIndex === ap2.modelIndex &&\n ap.residueIndex !== ap2.residueIndex &&\n !ap2.isMetal()\n ) {\n bondStore.addBondIfConnected(ap, ap2, 1) // assume single bond\n }\n })\n })\n }\n })\n if (Debug) Log.timeEnd('calculateBondsBetween inter')\n }\n\n if (Debug) Log.timeEnd('calculateBondsBetween')\n}\n\nexport function buildUnitcellAssembly (structure: Structure) {\n if (!structure.unitcell) return\n\n if (Debug) Log.time('buildUnitcellAssembly')\n\n const uc = structure.unitcell\n\n const structureCenterFrac = structure.center.clone().applyMatrix4(uc.cartToFrac)\n const centerFrac = structureCenterFrac.clone().floor()\n const symopDict: { [K: string]: Matrix4 } = getSymmetryOperations(uc.spacegroup)\n\n const centerFracSymop = new Vector3()\n const positionFracSymop = new Vector3()\n\n function getMatrixList (shift?: Vector3) {\n const matrixList: Matrix4[] = []\n\n Object.keys(symopDict).forEach(function (name) {\n const m = symopDict[ name ].clone()\n\n centerFracSymop.copy(structureCenterFrac).applyMatrix4(m).floor()\n positionFracSymop.setFromMatrixPosition(m)\n positionFracSymop.sub(centerFracSymop)\n positionFracSymop.add(centerFrac)\n\n if (shift) positionFracSymop.add(shift)\n\n m.setPosition(positionFracSymop)\n m.multiplyMatrices(uc.fracToCart, m)\n m.multiply(uc.cartToFrac)\n\n matrixList.push(m)\n })\n\n return matrixList\n }\n\n const unitcellAssembly = new Assembly('UNITCELL')\n const unitcellMatrixList = getMatrixList()\n const ncsMatrixList: Matrix4[] = []\n if (structure.biomolDict.NCS) {\n ncsMatrixList.push(\n new Matrix4(), ...structure.biomolDict.NCS.partList[ 0 ].matrixList\n )\n const ncsUnitcellMatrixList: Matrix4[] = []\n unitcellMatrixList.forEach(sm => {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n}\n\nclass PdbParser extends StructureParser {\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: number, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H') ? 1 : 0\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H') ? 1 : 0\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, 0, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, 1)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, 1)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}"],"names":["getQuery","id","window","m","RegExp","exec","location","search","decodeURIComponent","defaults","value","defaultValue","undefined","createParams","params","defaultParams","o","Object","assign","k","updateParams","newParams","getProtocol","protocol","match","getBrowser","ua","navigator","userAgent","test","openUrl","url","open","href","download","data","downloadName","isSafari","isChromeIos","a","document","createElement","str","replace","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","result","readAsDataURL","objectUrlCreated","URL","createObjectURL","style","display","body","appendChild","target","click","removeChild","revokeObjectURL","lexicographicCompare","elm1","elm2","binarySearchIndexOf","array","element","compareFunction","low","high","length","mid","cmp","rangeInSortedArray","min","max","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sort","filter","index","sorted","uint8ToString","u8a","chunkSize","c","i","push","String","fromCharCode","apply","subarray","join","getTypedArray","arrayType","arraySize","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Float32Array","Error","getUintArray","sizeOrArray","maxUint","ensureBuffer","buffer","ArrayBuffer","_ensureClassFromArray","constructor","Array","isArray","fromArray","ensureVector3","v","Vector3","ensureMatrix4","Matrix4","ensureQuaternion","q","Quaternion","ensureFloat32Array","arg","toLowerCaseString","toString","toLowerCase","Registry","name","this","_dict","add","key","get","names","keys","degToRad","deg","chars","split","uuid","generateUUID","r","rnd","Math","random","clamp","lerp","start","stop","alpha","spline","p0","p1","p2","p3","t","tension","v0","v1","t2","smoothstep","x","normalize","colorSpace","ScaleDefaultParameters","scale","mode","domain","reverse","tmpColor","Color","manageColor","_target","_name","descriptor","originalMethod","fromTo","bind","set","convertSRGBToLinear","getHex","Colormaker","parameters","structure","atomProxy","getAtomProxy","getScale","p","slice","chroma","out","colorToArray","color","offset","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","s","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","error","rules","n","negate","f","subTests","hasOwnProperty","and","operator","na","ret","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","string","signals","stringChanged","Signal","setString","type","silent","retSelection","newSelection","oldSelection","selectionStack","trim","charAt","substr","chunks","createNewContext","getPrevContext","pop","pushRule","rule","not","cu","toUpperCase","lastRule","indexOf","indexList","map","parseInt","b","console","resnameList","isNaN","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","e","message","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","dispatch","isAllSelection","isNoneSelection","SelectionColormaker","super","colormakerList","selectionList","dataList","forEach","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set1","Set2","Set3","Dark2","Paired","Pastel1","Pastel2","Accent","rainbow","rwb","ColormakerModes","rgb","hsv","hsl","hsi","lab","hcl","getWorkerDeps","vars","deps","sym","__deps","prototype","makeWorkerString","onmessage","__name","postId","__postId","self","func","callback","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","defineProperty","addEventListener","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","log","Function","call","info","warn","time","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","linewidth","opacity","labelUnit","arcVisible","planeVisible","Debug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","exports","ListingDatasource","TrajectoryDatasource","Streamer","src","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","then","decompressFn","_chunk","end","chunk","peekLines","charCodeAt","count","chunkToLines","lines","chunkCount","floor","asText","partialLine","isLast","idx","lastIndexOf","str2","concat","nextChunk","nextChunkOfLines","d","eachChunk","round","eachChunkOfLines","chunkNo","dispose","FileStreamer","Promise","resolve","reject","file","onload","event","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","status","response","statusText","responseType","send","Loader","ext","dir","path","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","load","parse","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","Writer","getBlob","getData","mimeType","defaultName","defaultExt","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","reset","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","toArray","Counter","countChanged","signalsWrapper","clear","change","delta","increment","decrement","listen","counter","unlisten","has","remove","onZeroOnce","context","Stats","updated","maxDuration","Infinity","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","update","startTime","currentTime","performance","now","reInclude","shaderCache","getShader","defines","hash","definesText","getDefines","shaderText","ShaderChunk","WebGLRenderingContext","wrcp","_getShaderParameter","getShaderParameter","arguments","_getShaderInfoLog","getShaderInfoLog","_getProgramParameter","getProgramParameter","program","pname","LINK_STATUS","_getProgramInfoLog","getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","renderer","camera","viewer","canvas","_viewer","_factor","factor","_antialias","antialias","_onProgress","onProgress","_onFinish","onFinish","_n","_width","width","_height","height","_ctx","getContext","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","offsetX","offsetY","setViewOffset","render","w","h","drawImage","domElement","ceil","_finalize","view","renderAsync","setTimeout","TwoPI","PI","RAD2DEG","circularMean","stride","indices","cosMean","sinMean","angle","cos","sin","atan2","calculateCenterArray","array1","array2","center","calculateDirectionArray","direction","uniformArray","optionalTarget","uniformArray3","j","serialArray","serialBlockArray","replicateArrayEntries","repArr","copyArray","dst","srcOffset","dstOffset","copyWithin","arrayMax","il","arrayMin","arraySum","sum","arrayMean","ImageDefaultParameters","transparent","makeImage","originalClearAlpha","getClearAlpha","backgroundColor","getClearColor","setLineWidthAndPixelSize","invert","scene","traverse","material","uniforms","size","__seen","trimCanvas","bg","g","canvasHeight","canvasWidth","pixels","getImageData","y","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","setClearAlpha","requestRender","vertex","matrix","modelViewProjectionMatrix","resolution","Vector2","projectionMatrixInverse","projectionMatrixTranspose","updateCameraUniforms","group","getInverse","projectionMatrix","copy","transpose","u","loadShader","gl","shaderSource","shaderType","shader","createShader","compileShader","COMPILE_STATUS","deleteShader","getExtension","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","createProgram","attachShader","attrib","bindAttribLocation","linkProgram","deleteProgram","useProgram","positionLocation","getAttribLocation","colorLoc","getUniformLocation","positionBuffer","createBuffer","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","enableVertexAttribArray","vertexAttribPointer","FLOAT","whiteTex","createTexture","whiteData","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","tex","texParameteri","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","uniform4fv","drawArrays","TRIANGLES","clearColor","COLOR_BUFFER_BIT","pixel","readPixels","floatPixel","getError","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","onBeforeRender","geometry","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","modelViewMatrix","multiplyMatrices","matrixWorldInverse","matrixWorld","materialProperties","properties","pu","getUniforms","setValue","Viewer","idOrElement","boundingBox","Box3","boundingBoxSize","boundingBoxLength","memory","programs","geometries","textures","calls","vertices","faces","points","distVector","ticked","rendered","elm","getElementById","container","HTMLElement","innerWidth","innerHeight","box","getBoundingClientRect","overflow","wrapper","position","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","fogColor","fogNear","fogFar","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","LinearEncoding","lookAt","perspectiveCamera","PerspectiveCamera","z","orthographicCamera","OrthographicCamera","stereoCamera","StereoCamera","aspect","eyeSep","updateProjectionMatrix","stats","Scene","rotationGroup","Group","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","fog","Fog","spotLight","SpotLight","ambientLight","AmbientLight","dpr","devicePixelRatio","WebGLRenderer","preserveDrawingBuffer","innerHTML","setPixelRatio","setSize","autoClear","sortObjects","outputEncoding","capabilities","isWebGL2","extensions","supportsHalfFloat","dprWidth","dprHeight","JSON","stringify","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","WebGLRenderTarget","minFilter","NearestFilter","magFilter","stencilBuffer","format","RGBAFormat","FloatType","UnsignedByteType","texture","generateMipmaps","encoding","setRenderTarget","sampleTarget","LinearFilter","holdTarget","compositeUniforms","tForeground","Uniform","compositeMaterial","ShaderMaterial","vertexShader","fragmentShader","premultipliedAlpha","blending","AdditiveBlending","depthTest","depthWrite","compositeCamera","compositeScene","Mesh","PlaneGeometry","positions","bbGeometry","BufferGeometry","setIndex","BufferAttribute","setAttribute","bbMaterial","uColor","boundingBoxMesh","LineSegments","updateHelper","attributes","needsUpdate","isEmpty","computeBoundingSphere","cameraDistance","abs","instanceList","instance","addBuffer","wireframeGroup","background","pickable","setUserData","object","children","userData","mesh","getMesh","applyMatrix4","wireframeMesh","getWireframeMesh","quaternion","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","instanceMatrix","updateGeometry","computeBoundingBox","geoBoundingBox","clone","equals","expandByScalar","union","updateNode","node","makeEmpty","getSize","getPickingPixels","imgBuffer","readRenderTargetPixels","getImage","picking","imgBuffer2","ctx","imgData","putImageData","setLight","intensity","near","far","setClearColor","getStyle","level","setOutputEncoding","setColorWorkflow","sRGBEncoding","setCamera","fov","up","updateZoom","setClip","dist","left","right","top","bottom","handleResize","updateInfo","rInfo","rMemory","rRender","triangles","isStill","currentSampleLevel","renderPending","frameRequest","requestAnimationFrame","pick","pid","picker","pixelBuffer","oid","getObjectById","tan","zoom","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","getWorldPosition","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","updateMatrix","updateMatrixWorld","pixelRatio","getPixelRatio","ortho","nearClip","updateMaterialUniforms","traverseVisible","Points","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","ai","bi","arr","stack","tmp","sp","swap","tmp2","quicksortCmp","attr","itemSize","sortProjectedPosition","__setVisibility","helper","visible","__updateLights","setLength","__renderPickingGroup","__renderModelGroup","renderTarget","__renderSuperSample","baseSampleWeight","sampleWeight","clearViewOffset","__renderStereo","_renderTarget","setScissorTest","setScissor","setViewport","cameraL","__render","cameraR","lastRenderedPicking","rendering","cancelAnimationFrame","getTouchDistance","dx","touches","pageX","dy","pageY","sqrt","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","preventDefault","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","detail","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","distanceTo","lastTouchDistance","touchDistance","removeEventListener","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","multiplyScalar","_getRotateXY","_getCameraRotation","extractRotation","multiply","makeRotationY","_transformPanVector","transform","premultiply","pan","translate","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","rotate","setFromAxisAngle","makeRotationFromQuaternion","applyMatrix","zRotate","dz","makeRotationZ","rotateComponent","makeRotationAxis","setFromRotationMatrix","tmpVec","PickingProxy","pickingData","getComponentsByObject","list","getObject","getPosition","closestBondAtom","atom1","v2","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","radius","getMaxRepresentationRadius","arrow","_objectIfType","axes","cone","clash","contact","cylinder","distance","ellipsoid","octahedron","point","sphere","tetrahedron","torus","surface","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","serial","shape","toPrecision","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","rotation","project","getCameraDistance","getOrientation","setPosition","orient","decompose","setRotationFromQuaternion","vector","spin","axis","rotateOnAxis","align","basis","setRotationFromMatrix","Animation","duration","args","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","toggle","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","lerpVectors","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","slerp","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","animation","AnimationControls","animationList","finishedList","splice","rock","move","zoomMove","orientTo","timeout","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","next","shift","kill","Representation","lazy","step","clipRadius","precision","clipCenter","flatShaded","side","options","front","back","double","wireframe","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","roughness","metalness","diffuse","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","init","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","radialSegments","openEnded","disableImpostor","getColorParams","getBufferParams","val","prepare","cb","create","updateWhat","_make","manualAttach","disposed","attach","setVisibility","noRenderRequest","updateParameters","int","float","parseFloat","getParameters","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","origin","sub","projectOnVector","minX","minY","minZ","maxX","maxY","maxZ","l","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","ax","ay","az","bx","by","bz","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cx","cy","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","color2","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","col","rad","getFixedLengthWrappedDashData","remaining","drawing","k3","kprev","vl","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","expandByPoint","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","text","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","ix","iy","iz","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","index1","index2","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","intersection","intersects","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","indexArray","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","state","addFeature","features","groups","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","trace","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","A","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","Map","calcAngles","ap1","ap2","angles","d1","d2","subVectors","eachBondedAtom","number","angleTo","calcPlaneAngle","x1","v12","neighbours","ni","cross","ValenceModel","atomCount","charge","implicitH","totalH","idealGeometry","eachAtom","chg","implH","totH","geom","hydrogenCount","bondToElementCount","formalCharge","assignCharge","assignH","degree","bondCount","valence","eachBond","bondOrder","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","hetero","flag","a2","getOtherAtom","b2","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","ap","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","addGroup","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","v3","n1","n2","getNormal","atoms","normal","crossVectors","getOffset","projectOnPlane","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","c1","c2","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","distanceToSquared","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","setHex","contactColor","ContactPicker","getIndex","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","bp","center1","center2","addVectors","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","getCenter","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","wrap","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","qy","qz","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","bits","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","zOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_box","_contour","_wrap","vIndexLength","Matrix","cols","rows","copyTo","At","nrows","ncols","Ai","Ati","pAt","ad","atd","multiplyABt","Ap","pA","pB","Cp","mrows","bd","cd","multiply3x3","Cd","Ad","Bd","m10","m11","m12","m13","m14","m15","m16","m17","m18","m20","m21","m22","m23","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","i0","i1","hypot","EPSILON","FLT_MIN","svd","at","_m","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","t0","t1","sd","beta","gamma","seed","val0","asum","Float64Array","JacobiSVDImpl","m4new","m4set","n11","n12","n13","n14","n21","n22","n23","n24","n31","n32","n33","n34","n41","n42","n43","n44","m4multiply","a11","a12","a13","a14","a21","a22","a23","a24","a31","a32","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","m4makeScale","m4makeTranslation","m4makeRotationY","theta","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","jl","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","computeVertexNormals","nv3","ab","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","maxSize","pow","tmpSize","tran","mroty","mscale","mtrans","Surface","Geometry","fromGeometry","setFromArray","geo","getColor","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","include","getAtomindex","VolumeSurface","mc","getSurface","smooth","normalMatrix","volsurf","Volume","Matrix3","inverseMatrix","setData","setAtomindex","_position","_min","_max","_mean","_rms","setStats","rms","setMatrix","me","elements","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","FrontSide","BackSide","DoubleSide","setObjectMatrix","matrixWorldNeedsUpdate","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","property","uniform","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","isLine","dynamic","wireframeIndexCount","defaultParameters","UniformsUtils","merge","UniformsLib","common","emissive","lights","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","setUsage","DYNAMIC_DRAW","makeMaterial","vertexColors","derivatives","fragDepth","wm","pm","NoBlending","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","setDrawRange","checkEdge","drawRange","updateWireframeIndex","updateRange","getRenderOrder","renderOrder","_getMesh","materialName","frustumCulled","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","attribute","wu","isVector3","toJSON","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","focus","getFocus","sign","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","padding","fontFamily","_clientRect","getVisibility","vp","cr","depth","zIndex","ComponentControls","RadiusFactoryTypes","covalent","bfactor","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","va","vb","vc","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","makeBasis","determinant","getRotationQuaternion","inverse","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dot","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","al","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","code","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","cache","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","diff","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","_center","a1","getAtomIndexByType","a3","a4","acos","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","_end","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","len","parentN","parent","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","occupancy","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","aa","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","modelStore","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","L","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","instanceCount","isIdentity","structureChainList","eachChain","getBoundingBox","partBox","getSelection","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","eachModel","chainnamesSorted","chainnamesIndex","helices","h1","h2","helix","helixRun","chainChange","sheets","s1","s2","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","denominator","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","setFromMatrixPosition","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","prevIndex","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","first","ModelProxy","chainEnd","_cp","Structure","refreshed","title","extraData","atomSetCache","boxes","bondSet","finalizeAtoms","finalizeBonds","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getMaxScaleOnAxis","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","radius2","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","seq","getChainnameCount","Set","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","sizeAttenuation","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","buffers","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","makeTranslation","applyPositionTransform","getNormalMatrix","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","IcosahedronBufferGeometry","_radius","MappedBuffer","mappingType","indexSize","mapping","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","x0","y0","y1","PointBufferDefaultParameters","alphaTest","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","DataTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","flipY","pickingTex","pickingMap","mapSize","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","NormalBlending","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","setFromMatrixScale","vn","dimLen","z0","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","Euler","setFromEuler","setScale","setTransform","getCenterUntransformed","makeScale","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","trajectory","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t11","t13","t14","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","det","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","frame","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","resetCache","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","values","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","c0","StructureRepresentation","radiusSize","radiusScale","assembly","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","xOffset","attachment","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","order","selected","_break","Number","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","placeholder","CanvasTexture","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","toFixed","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","eye","CylinderGeometryBufferDefaultParameters","getGeo","makeRotationX","CylinderBufferGeometry","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","d3","addScaledVector","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","lineOnly","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","directional","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","normals","getNormals","tangent","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","NaN","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","unit","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","p4","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","nPlanes","line1","line2","sector","plane","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","obj","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","sprintf","res","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","probeRadius","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tx","ty","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","dd","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","ia","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","surfaceType","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","bbSize","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","ConeBufferGeometry","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vFrom","vTo","vSplit","fullLength","coneLength","BoxBuffer","BoxBufferGeometry","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","OctahedronBufferGeometry","TetrahedronBuffer","TetrahedronBufferGeometry","TorusBufferDefaultParameters","radiusRatio","tubularSegments","TorusBuffer","TorusBufferGeometry","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","divideScalar","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","hex","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","sb","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","line","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","ensureArray","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","ml","identityMatrix","covalentI","parseCore","begIcode","sc","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","method","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","ctor","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","output","i2","decodeInt32","i4","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","am","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","TypeError","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","version","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","num","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","mask","lastBB0","lastBB1","cnt","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","zz","yy","xx","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","xmin","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","b1","b0","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","red","orange","gold","yellow","lime","green","sea","cyan","sky","blue","purple","magenta","hotpink","pink","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","white","gray","brown","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","lm","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","objects","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","addFace","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","buffergeometry","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","colors","elementsNeedUpdate","elementName","setRGB","vertexIndices","vertex_indices","Face3","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","child","re","prefix","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","_out","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","source","raw","err","ended","_mode","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","getListing","jsonData","frameIndex","getPathUrl","renumberSerial","remarks","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","im","chargeSign","hasModels","formatString","getString","idString","titleString","countsString","chargeLines","pairs","nCharges","formatAtom","formatBond","_writeHeader","_writeCTab","_writeFooter","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","sizeScore","backboneOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","screen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","relativePath","pn","pathname","basePath","getAbsolutePath","vectorNorm1","vectorNorm2","vectorNorm3","structures","atomIndexDict","modelCount","flatten","wait","previous","later","leading","Date","clearTimeout","trailing"],"mappings":"4sBAQM,SAAUA,EAAUC,GACxB,GAAsB,oBAAXC,OAAwB,OAEnC,MACMC,EADI,IAAIC,OAAO,GAAGH,eACZI,KAAKH,OAAOI,SAASC,QAEjC,OAAIJ,EACKK,mBAAmBL,EAAE,SAE5B,CAEJ,CAcgB,SAAAM,EAAUC,EAAYC,GACpC,YAAiBC,IAAVF,EAAsBA,EAAQC,CACvC,CAEgB,SAAAE,EAAiBC,EAAgCC,GAC/D,MAAMC,EAASC,OAAOC,OAAO,CAAE,EAAEJ,GACjC,IAAK,MAAMK,KAAKJ,EAAe,MAEfH,IADAE,EAAOK,KACIH,EAAEG,GAAKJ,EAAcI,GAC/C,CACD,OAAOH,CACT,CAEgB,SAAAI,EAAiBN,EAAWO,GAC1C,IAAK,MAAMF,KAAKE,EAAW,CACzB,MAAMX,EAAQW,EAAUF,QACVP,IAAVF,IAAqBI,EAAOK,GAAKT,EACtC,CACD,OAAOI,CACT,UAsBgBQ,IACd,MAAMC,EAAWrB,OAAOI,SAASiB,SACjC,OAAyC,OAAlCA,EAASC,MAAM,eAA0B,QAAUD,CAC5D,UAEgBE,IACd,GAAsB,oBAAXvB,OAAwB,OAAO,EAE1C,MAAMwB,EAAKxB,OAAOyB,UAAUC,UAE5B,MAAI,YAAYC,KAAKH,GACZ,QACE,UAAUG,KAAKH,GACjB,SACE,WAAWG,KAAKH,GAClB,UACE,wBAAwBG,KAAKH,GAC/B,gBACE,QAAQG,KAAKH,GACf,sBACE,UAAUG,KAAKH,IACjB,QAIX,CAqEA,SAASI,EAASC,GACD7B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C,EAAK,SACLC,EAAK,SACLC,GAAM,QACNC,GAAM,QACNC,EAAK,QACLC,GAAM,QACNC,GAAM,SACNC,GAAM,SACNC,EAAK,SACLC,GAAM,QACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,QACNC,GAAM,SACNC,GAAM,QACNC,GAAM,SACNC,GAAM,QACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,QACNC,GAAM,QACNC,GAAM,MACNC,EAAK,QACLC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,OACNC,GAAM,MACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,QACNC,GAAM,SACNC,GAAM,SACNC,EAAK,QACLC,GAAM,QACNC,GAAM,QACNC,GAAM,MACNC,GAAM,QACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,MACNC,GAAM,MACNC,GAAM,MACNC,GAAM,MACNC,GAAM,MACNC,GAAM,QACNC,GAAM,QACNC,EAAK,QACLC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,QACNC,GAAM,SACNC,GAAM,SACNC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,KACNC,GAAM,QACNC,GAAM,MACNC,GAAM,MACNC,EAAK,MACLC,GAAM,MACNC,GAAM,MACNC,GAAM,QACNC,GAAM,QACNC,GAAM,QACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACNC,GAAM,SACN88D,IAAO,SACP58D,GAAM,SACN68D,IAAO,SACP38D,GAAM,SACN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D,CACT,CACF"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a80010ca..d3fb9add 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ngl", - "version": "2.1.1", + "version": "2.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ngl", - "version": "2.1.1", + "version": "2.2.0", "license": "MIT", "dependencies": { "chroma-js": "^1.3.7", diff --git a/package.json b/package.json index 7a4aa2ab..09a8d156 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngl", - "version": "2.1.1", + "version": "2.2.0", "description": "Scalable molecular graphics for the web", "main": "dist/ngl.umd.js", "module": "dist/ngl.esm.js",